@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 leases via Conduit

Summary:
See T13212 for some context and discussion on this being revived.
See T11694 for original context.

Add a query constraint for lease owners and implement the conduit search method for Drydock leases.

Ref T11694. Fixes T13212.

Test Plan:
- Called the API method from conduit and browsed lease queries from the UI.
- Used the new "ownerPHIDs" constraint via API console.

{F5963044}

Reviewers: yelirekim, amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam, epriestley

Maniphest Tasks: T11694, T13212

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

authored by

Mike Riley and committed by
epriestley
5f3a7cb4 f6122547

+111 -1
+3
src/__phutil_library_map__.php
··· 1146 1146 'DrydockLeaseReclaimLogType' => 'applications/drydock/logtype/DrydockLeaseReclaimLogType.php', 1147 1147 'DrydockLeaseReleaseController' => 'applications/drydock/controller/DrydockLeaseReleaseController.php', 1148 1148 'DrydockLeaseReleasedLogType' => 'applications/drydock/logtype/DrydockLeaseReleasedLogType.php', 1149 + 'DrydockLeaseSearchConduitAPIMethod' => 'applications/drydock/conduit/DrydockLeaseSearchConduitAPIMethod.php', 1149 1150 'DrydockLeaseSearchEngine' => 'applications/drydock/query/DrydockLeaseSearchEngine.php', 1150 1151 'DrydockLeaseStatus' => 'applications/drydock/constants/DrydockLeaseStatus.php', 1151 1152 'DrydockLeaseUpdateWorker' => 'applications/drydock/worker/DrydockLeaseUpdateWorker.php', ··· 6532 6533 'DrydockLease' => array( 6533 6534 'DrydockDAO', 6534 6535 'PhabricatorPolicyInterface', 6536 + 'PhabricatorConduitResultInterface', 6535 6537 ), 6536 6538 'DrydockLeaseAcquiredLogType' => 'DrydockLogType', 6537 6539 'DrydockLeaseActivatedLogType' => 'DrydockLogType', ··· 6552 6554 'DrydockLeaseReclaimLogType' => 'DrydockLogType', 6553 6555 'DrydockLeaseReleaseController' => 'DrydockLeaseController', 6554 6556 'DrydockLeaseReleasedLogType' => 'DrydockLogType', 6557 + 'DrydockLeaseSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 6555 6558 'DrydockLeaseSearchEngine' => 'PhabricatorApplicationSearchEngine', 6556 6559 'DrydockLeaseStatus' => 'PhabricatorObjectStatus', 6557 6560 'DrydockLeaseUpdateWorker' => 'DrydockWorker',
+18
src/applications/drydock/conduit/DrydockLeaseSearchConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class DrydockLeaseSearchConduitAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'drydock.lease.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new DrydockLeaseSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Retrieve information about Drydock leases.'); 16 + } 17 + 18 + }
+13
src/applications/drydock/query/DrydockLeaseQuery.php
··· 5 5 private $ids; 6 6 private $phids; 7 7 private $resourcePHIDs; 8 + private $ownerPHIDs; 8 9 private $statuses; 9 10 private $datasourceQuery; 10 11 private $needUnconsumedCommands; ··· 21 22 22 23 public function withResourcePHIDs(array $phids) { 23 24 $this->resourcePHIDs = $phids; 25 + return $this; 26 + } 27 + 28 + public function withOwnerPHIDs(array $phids) { 29 + $this->ownerPHIDs = $phids; 24 30 return $this; 25 31 } 26 32 ··· 103 109 $conn, 104 110 'resourcePHID IN (%Ls)', 105 111 $this->resourcePHIDs); 112 + } 113 + 114 + if ($this->ownerPHIDs !== null) { 115 + $where[] = qsprintf( 116 + $conn, 117 + 'ownerPHID IN (%Ls)', 118 + $this->ownerPHIDs); 106 119 } 107 120 108 121 if ($this->ids !== null) {
+9
src/applications/drydock/query/DrydockLeaseSearchEngine.php
··· 40 40 $query->withStatuses($map['statuses']); 41 41 } 42 42 43 + if ($map['ownerPHIDs']) { 44 + $query->withOwnerPHIDs($map['ownerPHIDs']); 45 + } 46 + 43 47 return $query; 44 48 } 45 49 ··· 49 53 ->setLabel(pht('Statuses')) 50 54 ->setKey('statuses') 51 55 ->setOptions(DrydockLeaseStatus::getStatusMap()), 56 + id(new PhabricatorPHIDsSearchField()) 57 + ->setLabel(pht('Owners')) 58 + ->setKey('ownerPHIDs') 59 + ->setAliases(array('owner', 'owners', 'ownerPHID')) 60 + ->setDescription(pht('Search leases by owner.')), 52 61 ); 53 62 } 54 63
+68 -1
src/applications/drydock/storage/DrydockLease.php
··· 1 1 <?php 2 2 3 3 final class DrydockLease extends DrydockDAO 4 - implements PhabricatorPolicyInterface { 4 + implements 5 + PhabricatorPolicyInterface, 6 + PhabricatorConduitResultInterface { 5 7 6 8 protected $resourcePHID; 7 9 protected $resourceType; ··· 105 107 ), 106 108 'key_status' => array( 107 109 'columns' => array('status'), 110 + ), 111 + 'key_owner' => array( 112 + 'columns' => array('ownerPHID'), 108 113 ), 109 114 ), 110 115 ) + parent::getConfiguration(); ··· 533 538 534 539 public function describeAutomaticCapability($capability) { 535 540 return pht('Leases inherit policies from the resources they lease.'); 541 + } 542 + 543 + 544 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 545 + 546 + 547 + public function getFieldSpecificationsForConduit() { 548 + return array( 549 + id(new PhabricatorConduitSearchFieldSpecification()) 550 + ->setKey('resourcePHID') 551 + ->setType('phid?') 552 + ->setDescription(pht('PHID of the leased resource, if any.')), 553 + id(new PhabricatorConduitSearchFieldSpecification()) 554 + ->setKey('resourceType') 555 + ->setType('string') 556 + ->setDescription(pht('Type of resource being leased.')), 557 + id(new PhabricatorConduitSearchFieldSpecification()) 558 + ->setKey('until') 559 + ->setType('int?') 560 + ->setDescription(pht('Epoch at which this lease expires, if any.')), 561 + id(new PhabricatorConduitSearchFieldSpecification()) 562 + ->setKey('ownerPHID') 563 + ->setType('phid?') 564 + ->setDescription(pht('The PHID of the object that owns this lease.')), 565 + id(new PhabricatorConduitSearchFieldSpecification()) 566 + ->setKey('authorizingPHID') 567 + ->setType('phid') 568 + ->setDescription(pht( 569 + 'The PHID of the object that authorized this lease.')), 570 + id(new PhabricatorConduitSearchFieldSpecification()) 571 + ->setKey('status') 572 + ->setType('map<string, wild>') 573 + ->setDescription(pht( 574 + "The string constant and name of this lease's status.")), 575 + ); 576 + } 577 + 578 + public function getFieldValuesForConduit() { 579 + $status = $this->getStatus(); 580 + 581 + $until = $this->getUntil(); 582 + if ($until) { 583 + $until = (int)$until; 584 + } else { 585 + $until = null; 586 + } 587 + 588 + return array( 589 + 'resourcePHID' => $this->getResourcePHID(), 590 + 'resourceType' => $this->getResourceType(), 591 + 'until' => $until, 592 + 'ownerPHID' => $this->getOwnerPHID(), 593 + 'authorizingPHID' => $this->getAuthorizingPHID(), 594 + 'status' => array( 595 + 'value' => $status, 596 + 'name' => DrydockLeaseStatus::getNameForStatus($status), 597 + ), 598 + ); 599 + } 600 + 601 + public function getConduitSearchAttachments() { 602 + return array(); 536 603 } 537 604 538 605 }