Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14753666
D16594.id47192.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D16594.id47192.diff
View Options
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
@@ -1146,6 +1146,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',
@@ -6532,6 +6533,7 @@
'DrydockLease' => array(
'DrydockDAO',
'PhabricatorPolicyInterface',
+ 'PhabricatorConduitResultInterface',
),
'DrydockLeaseAcquiredLogType' => 'DrydockLogType',
'DrydockLeaseActivatedLogType' => 'DrydockLogType',
@@ -6552,6 +6554,7 @@
'DrydockLeaseReclaimLogType' => 'DrydockLogType',
'DrydockLeaseReleaseController' => 'DrydockLeaseController',
'DrydockLeaseReleasedLogType' => 'DrydockLogType',
+ 'DrydockLeaseSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'DrydockLeaseSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockLeaseStatus' => 'PhabricatorObjectStatus',
'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,11 @@
->setLabel(pht('Statuses'))
->setKey('statuses')
->setOptions(DrydockLeaseStatus::getStatusMap()),
+ id(new PhabricatorPHIDsSearchField())
+ ->setLabel(pht('Owners'))
+ ->setKey('ownerPHIDs')
+ ->setAliases(array('owner', 'owners', 'ownerPHID'))
+ ->setDescription(pht('Search leases by owner.')),
);
}
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;
@@ -106,6 +108,9 @@
'key_status' => array(
'columns' => array('status'),
),
+ 'key_owner' => array(
+ 'columns' => array('ownerPHID'),
+ ),
),
) + parent::getConfiguration();
}
@@ -535,4 +540,66 @@
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('status')
+ ->setType('map<string, wild>')
+ ->setDescription(pht(
+ "The string constant and name of this lease's status.")),
+ );
+ }
+
+ public function getFieldValuesForConduit() {
+ $status = $this->getStatus();
+
+ $until = $this->getUntil();
+ if ($until) {
+ $until = (int)$until;
+ } else {
+ $until = null;
+ }
+
+ return array(
+ 'resourcePHID' => $this->getResourcePHID(),
+ 'resourceType' => $this->getResourceType(),
+ 'until' => $until,
+ 'ownerPHID' => $this->getOwnerPHID(),
+ 'authorizingPHID' => $this->getAuthorizingPHID(),
+ 'status' => array(
+ 'value' => $status,
+ 'name' => DrydockLeaseStatus::getNameForStatus($status),
+ ),
+ );
+ }
+
+ public function getConduitSearchAttachments() {
+ return array();
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 22, 3:16 PM (10 h, 35 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7032897
Default Alt Text
D16594.id47192.diff (6 KB)
Attached To
Mode
D16594: Expose Drydock leases via Conduit
Attached
Detach File
Event Timeline
Log In to Comment