mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-22 11:39:03 +01:00
Summary: Ref T7803. Ref T5873. I want to drive Conduit through more shared infrastructure, but can't currently add parameters automatically. Put a `getX()` around the `defineX()` methods so the parent can provide default behaviors. Also like 60% of methods don't define any special error types; don't require them to implement this method. I want to move away from this in general. Test Plan: - Ran `arc unit --everything`. - Called `conduit.query`. - Browsed Conduit UI. Reviewers: btrahan Reviewed By: btrahan Subscribers: hach-que, epriestley Maniphest Tasks: T5873, T7803 Differential Revision: https://secure.phabricator.com/D12380
63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class AlmanacQueryDevicesConduitAPIMethod
|
|
extends AlmanacConduitAPIMethod {
|
|
|
|
public function getAPIMethodName() {
|
|
return 'almanac.querydevices';
|
|
}
|
|
|
|
public function getMethodDescription() {
|
|
return pht('Query Almanac devices.');
|
|
}
|
|
|
|
protected function defineParamTypes() {
|
|
return array(
|
|
'ids' => 'optional list<id>',
|
|
'phids' => 'optional list<phid>',
|
|
'names' => 'optional list<phid>',
|
|
) + self::getPagerParamTypes();
|
|
}
|
|
|
|
protected function defineReturnType() {
|
|
return 'list<wild>';
|
|
}
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
$viewer = $request->getUser();
|
|
|
|
$query = id(new AlmanacDeviceQuery())
|
|
->setViewer($viewer);
|
|
|
|
$ids = $request->getValue('ids');
|
|
if ($ids !== null) {
|
|
$query->withIDs($ids);
|
|
}
|
|
|
|
$phids = $request->getValue('phids');
|
|
if ($phids !== null) {
|
|
$query->withPHIDs($phids);
|
|
}
|
|
|
|
$names = $request->getValue('names');
|
|
if ($names !== null) {
|
|
$query->withNames($names);
|
|
}
|
|
|
|
$pager = $this->newPager($request);
|
|
|
|
$devices = $query->executeWithCursorPager($pager);
|
|
|
|
$data = array();
|
|
foreach ($devices as $device) {
|
|
$data[] = $this->getDeviceDictionary($device);
|
|
}
|
|
|
|
$results = array(
|
|
'data' => $data,
|
|
);
|
|
|
|
return $this->addPagerResults($results, $pager);
|
|
}
|
|
|
|
}
|