mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
Provide an audit.query method for Conduit
Summary: Conduit access for open audits. Test Plan: Used test console to run some queries. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1792
This commit is contained in:
parent
a95c9873aa
commit
f0396b2f06
6 changed files with 141 additions and 2 deletions
|
@ -105,6 +105,8 @@ phutil_register_library_map(array(
|
|||
'ConduitAPIResponse' => 'applications/conduit/protocol/response',
|
||||
'ConduitAPI_arcanist_Method' => 'applications/conduit/method/arcanist/base',
|
||||
'ConduitAPI_arcanist_projectinfo_Method' => 'applications/conduit/method/arcanist/projectinfo',
|
||||
'ConduitAPI_audit_Method' => 'applications/conduit/method/audit/base',
|
||||
'ConduitAPI_audit_query_Method' => 'applications/conduit/method/audit/query',
|
||||
'ConduitAPI_chatlog_Method' => 'applications/conduit/method/chatlog/base',
|
||||
'ConduitAPI_chatlog_query_Method' => 'applications/conduit/method/chatlog/query',
|
||||
'ConduitAPI_chatlog_record_Method' => 'applications/conduit/method/chatlog/record',
|
||||
|
@ -979,6 +981,8 @@ phutil_register_library_map(array(
|
|||
'CelerityResourceGraph' => 'AbstractDirectedGraph',
|
||||
'ConduitAPI_arcanist_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_arcanist_projectinfo_Method' => 'ConduitAPI_arcanist_Method',
|
||||
'ConduitAPI_audit_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_audit_query_Method' => 'ConduitAPI_audit_Method',
|
||||
'ConduitAPI_chatlog_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_chatlog_query_Method' => 'ConduitAPI_chatlog_Method',
|
||||
'ConduitAPI_chatlog_record_Method' => 'ConduitAPI_chatlog_Method',
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
abstract class ConduitAPI_audit_Method extends ConduitAPIMethod {
|
||||
|
||||
|
||||
}
|
12
src/applications/conduit/method/audit/base/__init__.php
Normal file
12
src/applications/conduit/method/audit/base/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_audit_Method.php');
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_audit_query_Method extends ConduitAPI_audit_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Query audit requests.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'auditorPHIDs' => 'optional list<phid>',
|
||||
'commitPHIDs' => 'optional list<phid>',
|
||||
'status' => 'optional enum<"status-any", "status-open"> '.
|
||||
'(default = "status-any")',
|
||||
'offset' => 'optional int',
|
||||
'limit' => 'optional int (default = 100)',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'list<dict>';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
|
||||
$query = new PhabricatorAuditQuery();
|
||||
|
||||
$auditor_phids = $request->getValue('auditorPHIDs', array());
|
||||
if ($auditor_phids) {
|
||||
$query->withAuditorPHIDs($auditor_phids);
|
||||
}
|
||||
|
||||
$commit_phids = $request->getValue('commitPHIDs', array());
|
||||
if ($commit_phids) {
|
||||
$query->withCommitPHIDs($commit_phids);
|
||||
}
|
||||
|
||||
$status = $request->getValue('status', PhabricatorAuditQuery::STATUS_ANY);
|
||||
$query->withStatus($status);
|
||||
|
||||
$query->setOffset($request->getValue('offset', 0));
|
||||
$query->setLimit($request->getValue('limit', 100));
|
||||
|
||||
$requests = $query->execute();
|
||||
|
||||
$results = array();
|
||||
foreach ($requests as $request) {
|
||||
$results[] = array(
|
||||
'id' => $request->getID(),
|
||||
'commitPHID' => $request->getCommitPHID(),
|
||||
'auditorPHID' => $request->getAuditorPHID(),
|
||||
'reasons' => $request->getAuditReasons(),
|
||||
'status' => $request->getAuditStatus(),
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
}
|
13
src/applications/conduit/method/audit/query/__init__.php
Normal file
13
src/applications/conduit/method/audit/query/__init__.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/audit/query/audit');
|
||||
phutil_require_module('phabricator', 'applications/conduit/method/audit/base');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_audit_query_Method.php');
|
|
@ -28,8 +28,8 @@ class ConduitAPIRequest {
|
|||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function getValue($key) {
|
||||
return idx($this->params, $key);
|
||||
public function getValue($key, $default = null) {
|
||||
return coalesce(idx($this->params, $key), $default);
|
||||
}
|
||||
|
||||
public function getAllParameters() {
|
||||
|
|
Loading…
Reference in a new issue