Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15424270
D20723.id49406.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D20723.id49406.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
@@ -1222,6 +1222,7 @@
'DrydockResourceQuery' => 'applications/drydock/query/DrydockResourceQuery.php',
'DrydockResourceReclaimLogType' => 'applications/drydock/logtype/DrydockResourceReclaimLogType.php',
'DrydockResourceReleaseController' => 'applications/drydock/controller/DrydockResourceReleaseController.php',
+ 'DrydockResourceSearchConduitAPIMethod' => 'applications/drydock/conduit/DrydockResourceSearchConduitAPIMethod.php',
'DrydockResourceSearchEngine' => 'applications/drydock/query/DrydockResourceSearchEngine.php',
'DrydockResourceStatus' => 'applications/drydock/constants/DrydockResourceStatus.php',
'DrydockResourceUpdateWorker' => 'applications/drydock/worker/DrydockResourceUpdateWorker.php',
@@ -7021,6 +7022,7 @@
'DrydockResource' => array(
'DrydockDAO',
'PhabricatorPolicyInterface',
+ 'PhabricatorConduitResultInterface',
),
'DrydockResourceActivationFailureLogType' => 'DrydockLogType',
'DrydockResourceActivationYieldLogType' => 'DrydockLogType',
@@ -7034,6 +7036,7 @@
'DrydockResourceQuery' => 'DrydockQuery',
'DrydockResourceReclaimLogType' => 'DrydockLogType',
'DrydockResourceReleaseController' => 'DrydockResourceController',
+ 'DrydockResourceSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'DrydockResourceSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DrydockResourceStatus' => 'PhabricatorObjectStatus',
'DrydockResourceUpdateWorker' => 'DrydockWorker',
diff --git a/src/applications/drydock/conduit/DrydockResourceSearchConduitAPIMethod.php b/src/applications/drydock/conduit/DrydockResourceSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/drydock/conduit/DrydockResourceSearchConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class DrydockResourceSearchConduitAPIMethod
+ extends PhabricatorSearchEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'drydock.resource.search';
+ }
+
+ public function newSearchEngine() {
+ return new DrydockResourceSearchEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Retrieve information about Drydock resources.');
+ }
+
+}
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
@@ -44,6 +44,10 @@
$query->withOwnerPHIDs($map['ownerPHIDs']);
}
+ if ($map['resourcePHIDs']) {
+ $query->withResourcePHIDs($map['resourcePHIDs']);
+ }
+
return $query;
}
@@ -58,6 +62,11 @@
->setKey('ownerPHIDs')
->setAliases(array('owner', 'owners', 'ownerPHID'))
->setDescription(pht('Search leases by owner.')),
+ id(new PhabricatorPHIDsSearchField())
+ ->setLabel(pht('Resources'))
+ ->setKey('resourcePHIDs')
+ ->setAliases(array('resorucePHID', 'resource', 'resources'))
+ ->setDescription(pht('Search leases by resource.')),
);
}
diff --git a/src/applications/drydock/query/DrydockResourceQuery.php b/src/applications/drydock/query/DrydockResourceQuery.php
--- a/src/applications/drydock/query/DrydockResourceQuery.php
+++ b/src/applications/drydock/query/DrydockResourceQuery.php
@@ -100,46 +100,50 @@
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
- 'id IN (%Ld)',
+ 'resource.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
- 'phid IN (%Ls)',
+ 'resource.phid IN (%Ls)',
$this->phids);
}
if ($this->types !== null) {
$where[] = qsprintf(
$conn,
- 'type IN (%Ls)',
+ 'resource.type IN (%Ls)',
$this->types);
}
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
- 'status IN (%Ls)',
+ 'resource.status IN (%Ls)',
$this->statuses);
}
if ($this->blueprintPHIDs !== null) {
$where[] = qsprintf(
$conn,
- 'blueprintPHID IN (%Ls)',
+ 'resource.blueprintPHID IN (%Ls)',
$this->blueprintPHIDs);
}
if ($this->datasourceQuery !== null) {
$where[] = qsprintf(
$conn,
- 'name LIKE %>',
+ 'resource.name LIKE %>',
$this->datasourceQuery);
}
return $where;
}
+ protected function getPrimaryTableAlias() {
+ return 'resource';
+ }
+
}
diff --git a/src/applications/drydock/query/DrydockResourceSearchEngine.php b/src/applications/drydock/query/DrydockResourceSearchEngine.php
--- a/src/applications/drydock/query/DrydockResourceSearchEngine.php
+++ b/src/applications/drydock/query/DrydockResourceSearchEngine.php
@@ -40,6 +40,10 @@
$query->withStatuses($map['statuses']);
}
+ if ($map['blueprintPHIDs']) {
+ $query->withBlueprintPHIDs($map['blueprintPHIDs']);
+ }
+
return $query;
}
@@ -49,6 +53,12 @@
->setLabel(pht('Statuses'))
->setKey('statuses')
->setOptions(DrydockResourceStatus::getStatusMap()),
+ id(new PhabricatorPHIDsSearchField())
+ ->setLabel(pht('Buildables'))
+ ->setKey('blueprintPHIDs')
+ ->setAliases(array('blueprintPHID', 'blueprints', 'blueprint'))
+ ->setDescription(
+ pht('Search for resources generated by particular blueprints.')),
);
}
diff --git a/src/applications/drydock/storage/DrydockResource.php b/src/applications/drydock/storage/DrydockResource.php
--- a/src/applications/drydock/storage/DrydockResource.php
+++ b/src/applications/drydock/storage/DrydockResource.php
@@ -1,7 +1,9 @@
<?php
final class DrydockResource extends DrydockDAO
- implements PhabricatorPolicyInterface {
+ implements
+ PhabricatorPolicyInterface,
+ PhabricatorConduitResultInterface {
protected $id;
protected $phid;
@@ -340,4 +342,38 @@
public function describeAutomaticCapability($capability) {
return pht('Resources inherit the policies of their blueprints.');
}
+
+
+/* -( PhabricatorConduitResultInterface )---------------------------------- */
+
+
+ public function getFieldSpecificationsForConduit() {
+ return array(
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('blueprintPHID')
+ ->setType('phid')
+ ->setDescription(pht('The blueprint which generated this resource.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('status')
+ ->setType('map<string, wild>')
+ ->setDescription(pht('Information about resource status.')),
+ );
+ }
+
+ public function getFieldValuesForConduit() {
+ $status = $this->getStatus();
+
+ return array(
+ 'blueprintPHID' => $this->getBlueprintPHID(),
+ 'status' => array(
+ 'value' => $status,
+ 'name' => DrydockResourceStatus::getNameForStatus($status),
+ ),
+ );
+ }
+
+ public function getConduitSearchAttachments() {
+ return array();
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 23, 9:14 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7719045
Default Alt Text
D20723.id49406.diff (7 KB)
Attached To
Mode
D20723: Implement "drydock.resource.search"
Attached
Detach File
Event Timeline
Log In to Comment