2014-04-17 16:00:25 -07:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 10:54:15 +10:00
|
|
|
final class HarbormasterQueryBuildablesConduitAPIMethod
|
|
|
|
extends HarbormasterConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'harbormaster.querybuildables';
|
|
|
|
}
|
2014-04-17 16:00:25 -07:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
|
|
|
return pht('Query Harbormaster buildables.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
return array(
|
|
|
|
'ids' => 'optional list<id>',
|
|
|
|
'phids' => 'optional list<phid>',
|
|
|
|
'buildablePHIDs' => 'optional list<phid>',
|
|
|
|
'containerPHIDs' => 'optional list<phid>',
|
|
|
|
'manualBuildables' => 'optional bool',
|
|
|
|
) + self::getPagerParamTypes();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'wild';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
|
|
|
$query = id(new HarbormasterBuildableQuery())
|
|
|
|
->setViewer($viewer);
|
|
|
|
|
|
|
|
$ids = $request->getValue('ids');
|
|
|
|
if ($ids !== null) {
|
|
|
|
$query->withIDs($ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
$phids = $request->getValue('phids');
|
|
|
|
if ($phids !== null) {
|
|
|
|
$query->withPHIDs($phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
$buildable_phids = $request->getValue('buildablePHIDs');
|
|
|
|
if ($buildable_phids !== null) {
|
|
|
|
$query->withBuildablePHIDs($buildable_phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
$container_phids = $request->getValue('containerPHIDs');
|
|
|
|
if ($container_phids !== null) {
|
|
|
|
$query->withContainerPHIDs($container_phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
$manual = $request->getValue('manualBuildables');
|
|
|
|
if ($manual !== null) {
|
|
|
|
$query->withManualBuildables($manual);
|
|
|
|
}
|
|
|
|
|
|
|
|
$pager = $this->newPager($request);
|
|
|
|
|
|
|
|
$buildables = $query->executeWithCursorPager($pager);
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
foreach ($buildables as $buildable) {
|
|
|
|
$monogram = $buildable->getMonogram();
|
|
|
|
|
2014-04-17 16:01:16 -07:00
|
|
|
$status = $buildable->getBuildableStatus();
|
|
|
|
$status_name = HarbormasterBuildable::getBuildableStatusName($status);
|
|
|
|
|
2014-04-17 16:00:25 -07:00
|
|
|
$data[] = array(
|
|
|
|
'id' => $buildable->getID(),
|
|
|
|
'phid' => $buildable->getPHID(),
|
|
|
|
'monogram' => $monogram,
|
|
|
|
'uri' => PhabricatorEnv::getProductionURI('/'.$monogram),
|
2014-04-17 16:01:16 -07:00
|
|
|
'buildableStatus' => $status,
|
|
|
|
'buildableStatusName' => $status_name,
|
2014-04-17 16:00:25 -07:00
|
|
|
'buildablePHID' => $buildable->getBuildablePHID(),
|
|
|
|
'containerPHID' => $buildable->getContainerPHID(),
|
|
|
|
'isManualBuildable' => (bool)$buildable->getIsManualBuildable(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$results = array(
|
|
|
|
'data' => $data,
|
|
|
|
);
|
|
|
|
|
|
|
|
$results = $this->addPagerResults($results, $pager);
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|