Page MenuHomePhabricator

D16594.id39946.diff
No OneTemporary

D16594.id39946.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -973,6 +973,7 @@
'DrydockLeaseReclaimLogType' => 'applications/drydock/logtype/DrydockLeaseReclaimLogType.php',
'DrydockLeaseReleaseController' => 'applications/drydock/controller/DrydockLeaseReleaseController.php',
'DrydockLeaseReleasedLogType' => 'applications/drydock/logtype/DrydockLeaseReleasedLogType.php',
+ 'DrydockLeaseSearchConduitAPIMethod' => 'applications/drydock/conduit/DrydockLeaseSearchConduitAPIMethod.php',
'DrydockLeaseSearchEngine' => 'applications/drydock/query/DrydockLeaseSearchEngine.php',
'DrydockLeaseStatus' => 'applications/drydock/constants/DrydockLeaseStatus.php',
'DrydockLeaseUpdateWorker' => 'applications/drydock/worker/DrydockLeaseUpdateWorker.php',
@@ -5502,6 +5503,7 @@
'DrydockLease' => array(
'DrydockDAO',
'PhabricatorPolicyInterface',
+ 'PhabricatorConduitResultInterface',
),
'DrydockLeaseAcquiredLogType' => 'DrydockLogType',
'DrydockLeaseActivatedLogType' => 'DrydockLogType',
@@ -5520,6 +5522,7 @@
'DrydockLeaseReclaimLogType' => 'DrydockLogType',
'DrydockLeaseReleaseController' => 'DrydockLeaseController',
'DrydockLeaseReleasedLogType' => 'DrydockLogType',
+ 'DrydockLeaseSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'DrydockLeaseSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockLeaseStatus' => 'DrydockConstants',
'DrydockLeaseUpdateWorker' => 'DrydockWorker',
diff --git a/src/applications/drydock/conduit/DrydockLeaseSearchConduitAPIMethod.php b/src/applications/drydock/conduit/DrydockLeaseSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/drydock/conduit/DrydockLeaseSearchConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class DrydockLeaseSearchConduitAPIMethod
+ extends PhabricatorSearchEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'drydock.lease.search';
+ }
+
+ public function newSearchEngine() {
+ return new DrydockLeaseSearchEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Retrieve information about Drydock leases.');
+ }
+
+}
diff --git a/src/applications/drydock/query/DrydockLeaseQuery.php b/src/applications/drydock/query/DrydockLeaseQuery.php
--- a/src/applications/drydock/query/DrydockLeaseQuery.php
+++ b/src/applications/drydock/query/DrydockLeaseQuery.php
@@ -5,6 +5,7 @@
private $ids;
private $phids;
private $resourcePHIDs;
+ private $ownerPHIDs;
private $statuses;
private $datasourceQuery;
private $needUnconsumedCommands;
@@ -24,6 +25,11 @@
return $this;
}
+ public function withOwnerPHIDs(array $phids) {
+ $this->ownerPHIDs = $phids;
+ return $this;
+ }
+
public function withStatuses(array $statuses) {
$this->statuses = $statuses;
return $this;
@@ -105,6 +111,13 @@
$this->resourcePHIDs);
}
+ if ($this->ownerPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'ownerPHID IN (%Ls)',
+ $this->ownerPHIDs);
+ }
+
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
diff --git a/src/applications/drydock/query/DrydockLeaseSearchEngine.php b/src/applications/drydock/query/DrydockLeaseSearchEngine.php
--- a/src/applications/drydock/query/DrydockLeaseSearchEngine.php
+++ b/src/applications/drydock/query/DrydockLeaseSearchEngine.php
@@ -40,6 +40,10 @@
$query->withStatuses($map['statuses']);
}
+ if ($map['ownerPHIDs']) {
+ $query->withOwnerPHIDs($map['ownerPHIDs']);
+ }
+
return $query;
}
@@ -49,6 +53,17 @@
->setLabel(pht('Statuses'))
->setKey('statuses')
->setOptions(DrydockLeaseStatus::getStatusMap()),
+ id(new PhabricatorPHIDsSearchField())
+ ->setLabel(pht('Owners'))
+ ->setKey('ownerPHIDs')
+ ->setDescription(pht('Search leases by owner.'))
+ ->setAliases(array('owner', 'owners')),
+ );
+ }
+
+ protected function getHiddenFields() {
+ return array(
+ 'ownerPHIDs',
);
}
diff --git a/src/applications/drydock/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php
--- a/src/applications/drydock/storage/DrydockLease.php
+++ b/src/applications/drydock/storage/DrydockLease.php
@@ -1,7 +1,9 @@
<?php
final class DrydockLease extends DrydockDAO
- implements PhabricatorPolicyInterface {
+ implements
+ PhabricatorPolicyInterface,
+ PhabricatorConduitResultInterface {
protected $resourcePHID;
protected $resourceType;
@@ -83,6 +85,9 @@
'key_resource' => array(
'columns' => array('resourcePHID', 'status'),
),
+ 'key_owner' => array(
+ 'columns' => array('ownerPHID'),
+ ),
),
) + parent::getConfiguration();
}
@@ -497,4 +502,65 @@
return pht('Leases inherit policies from the resources they lease.');
}
+
+/* -( PhabricatorConduitResultInterface )---------------------------------- */
+
+
+ public function getFieldSpecificationsForConduit() {
+ return array(
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('resourcePHID')
+ ->setType('phid?')
+ ->setDescription(pht('PHID of the leased resource, if any.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('resourceType')
+ ->setType('string')
+ ->setDescription(pht('Type of resource being leased.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('until')
+ ->setType('int?')
+ ->setDescription(pht('Epoch at which this lease expires, if any.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('ownerPHID')
+ ->setType('phid?')
+ ->setDescription(pht('The PHID of the object that owns this lease.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('authorizingPHID')
+ ->setType('phid')
+ ->setDescription(pht(
+ 'The PHID of the object that authorized this lease.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('attributes')
+ ->setType('map<string, wild>')
+ ->setDescription(pht(
+ 'Implementation specific attributes for this lease.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('status')
+ ->setType('map<string, wild>')
+ ->setDescription(pht(
+ "The string constant and name of this lease's status.")),
+ );
+ }
+
+ public function getFieldValuesForConduit() {
+ $status = $this->getStatus();
+ return array(
+ 'resourcePHID' => $this->getResourcePHID(),
+ 'resourceType' => $this->getResourceType(),
+ 'until' => $this->getUntil(),
+ 'ownerPHID' => $this->getOwnerPHID(),
+ 'authorizingPHID' => $this->getAuthorizingPHID(),
+ 'attributes' => $this->getAttributes(),
+ 'status' => array(
+ 'value' => $status,
+ 'name' => DrydockLeaseStatus::getNameForStatus($status),
+ ),
+ );
+ }
+
+ public function getConduitSearchAttachments() {
+ return array(
+ );
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Thu, May 9, 8:25 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6274452
Default Alt Text
D16594.id39946.diff (7 KB)

Event Timeline