@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Expose Drydock authorizations via Conduit

Summary:
`DrydockAuthorizationSearchEngine` was being used solely to display authorizations for a specific blueprint from the web UI and consequently expected that callers set a specific blueprint before performing a query. Here we check to see if a blueprint has been set in cases where the engine could be operating from either Conduit or the web.

Ref T11694

Test Plan:
- called the API method from the console
- approved an authorization
- followed the "view all" link from a blueprint page

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T11694

Differential Revision: https://secure.phabricator.com/D16592

authored by

Mike Riley and committed by
yelirekim
fa90f8be eec2d953

+106 -3
+3
src/__phutil_library_map__.php
··· 919 919 'DrydockAuthorizationListView' => 'applications/drydock/view/DrydockAuthorizationListView.php', 920 920 'DrydockAuthorizationPHIDType' => 'applications/drydock/phid/DrydockAuthorizationPHIDType.php', 921 921 'DrydockAuthorizationQuery' => 'applications/drydock/query/DrydockAuthorizationQuery.php', 922 + 'DrydockAuthorizationSearchConduitAPIMethod' => 'applications/drydock/conduit/DrydockAuthorizationSearchConduitAPIMethod.php', 922 923 'DrydockAuthorizationSearchEngine' => 'applications/drydock/query/DrydockAuthorizationSearchEngine.php', 923 924 'DrydockAuthorizationViewController' => 'applications/drydock/controller/DrydockAuthorizationViewController.php', 924 925 'DrydockBlueprint' => 'applications/drydock/storage/DrydockBlueprint.php', ··· 5468 5469 'DrydockAuthorization' => array( 5469 5470 'DrydockDAO', 5470 5471 'PhabricatorPolicyInterface', 5472 + 'PhabricatorConduitResultInterface', 5471 5473 ), 5472 5474 'DrydockAuthorizationAuthorizeController' => 'DrydockController', 5473 5475 'DrydockAuthorizationListController' => 'DrydockController', 5474 5476 'DrydockAuthorizationListView' => 'AphrontView', 5475 5477 'DrydockAuthorizationPHIDType' => 'PhabricatorPHIDType', 5476 5478 'DrydockAuthorizationQuery' => 'DrydockQuery', 5479 + 'DrydockAuthorizationSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 5477 5480 'DrydockAuthorizationSearchEngine' => 'PhabricatorApplicationSearchEngine', 5478 5481 'DrydockAuthorizationViewController' => 'DrydockController', 5479 5482 'DrydockBlueprint' => array(
+18
src/applications/drydock/conduit/DrydockAuthorizationSearchConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class DrydockAuthorizationSearchConduitAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'drydock.authorization.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new DrydockAuthorizationSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Retrieve information about Drydock authorizations.'); 16 + } 17 + 18 + }
+35 -2
src/applications/drydock/query/DrydockAuthorizationSearchEngine.php
··· 30 30 $query = new DrydockAuthorizationQuery(); 31 31 32 32 $blueprint = $this->getBlueprint(); 33 - $query->withBlueprintPHIDs(array($blueprint->getPHID())); 33 + if ($blueprint) { 34 + $query->withBlueprintPHIDs(array($blueprint->getPHID())); 35 + } 34 36 35 37 return $query; 36 38 } ··· 38 40 protected function buildQueryFromParameters(array $map) { 39 41 $query = $this->newQuery(); 40 42 43 + if ($map['blueprintPHIDs']) { 44 + $query->withBlueprintPHIDs($map['blueprintPHIDs']); 45 + } 46 + 47 + if ($map['objectPHIDs']) { 48 + $query->withObjectPHIDs($map['objectPHIDs']); 49 + } 50 + 41 51 return $query; 42 52 } 43 53 44 54 protected function buildCustomSearchFields() { 45 - return array(); 55 + return array( 56 + id(new PhabricatorSearchDatasourceField()) 57 + ->setLabel(pht('Blueprints')) 58 + ->setKey('blueprintPHIDs') 59 + ->setConduitParameterType(new ConduitPHIDListParameterType()) 60 + ->setDescription(pht('Search authorizations for specific blueprints.')) 61 + ->setAliases(array('blueprint', 'blueprints')) 62 + ->setDatasource(new DrydockBlueprintDatasource()), 63 + id(new PhabricatorPHIDsSearchField()) 64 + ->setLabel(pht('Objects')) 65 + ->setKey('objectPHIDs') 66 + ->setDescription(pht('Search authorizations from specific objects.')) 67 + ->setAliases(array('object', 'objects')), 68 + ); 69 + } 70 + 71 + protected function getHiddenFields() { 72 + return array( 73 + 'blueprintPHIDs', 74 + 'objectPHIDs', 75 + ); 46 76 } 47 77 48 78 protected function getURI($path) { 49 79 $blueprint = $this->getBlueprint(); 80 + if (!$blueprint) { 81 + throw new PhutilInvalidStateException('setBlueprint'); 82 + } 50 83 $id = $blueprint->getID(); 51 84 return "/drydock/blueprint/{$id}/authorizations/".$path; 52 85 }
+50 -1
src/applications/drydock/storage/DrydockAuthorization.php
··· 2 2 3 3 final class DrydockAuthorization extends DrydockDAO 4 4 implements 5 - PhabricatorPolicyInterface { 5 + PhabricatorPolicyInterface, 6 + PhabricatorConduitResultInterface { 6 7 7 8 const OBJECTAUTH_ACTIVE = 'active'; 8 9 const OBJECTAUTH_INACTIVE = 'inactive'; ··· 203 204 'authorizes access to.'); 204 205 } 205 206 207 + 208 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 209 + 210 + 211 + public function getFieldSpecificationsForConduit() { 212 + return array( 213 + id(new PhabricatorConduitSearchFieldSpecification()) 214 + ->setKey('blueprintPHID') 215 + ->setType('phid') 216 + ->setDescription(pht( 217 + 'PHID of the blueprint this request was made for.')), 218 + id(new PhabricatorConduitSearchFieldSpecification()) 219 + ->setKey('blueprintAuthorizationState') 220 + ->setType('map<string, wild>') 221 + ->setDescription(pht('Authorization state of this request.')), 222 + id(new PhabricatorConduitSearchFieldSpecification()) 223 + ->setKey('objectPHID') 224 + ->setType('phid') 225 + ->setDescription(pht( 226 + 'PHID of the object which requested authorization.')), 227 + id(new PhabricatorConduitSearchFieldSpecification()) 228 + ->setKey('objectAuthorizationState') 229 + ->setType('map<string, wild>') 230 + ->setDescription(pht('Authorization state of the requesting object.')), 231 + ); 232 + } 233 + 234 + public function getFieldValuesForConduit() { 235 + $blueprint_state = $this->getBlueprintAuthorizationState(); 236 + $object_state = $this->getObjectAuthorizationState(); 237 + return array( 238 + 'blueprintPHID' => $this->getBlueprintPHID(), 239 + 'blueprintAuthorizationState' => array( 240 + 'value' => $blueprint_state, 241 + 'name' => self::getBlueprintStateName($blueprint_state), 242 + ), 243 + 'objectPHID' => $this->getObjectPHID(), 244 + 'objectAuthorizationState' => array( 245 + 'value' => $object_state, 246 + 'name' => self::getObjectStateName($object_state), 247 + ), 248 + ); 249 + } 250 + 251 + public function getConduitSearchAttachments() { 252 + return array( 253 + ); 254 + } 206 255 207 256 }