From 8759f7e6ec62515fbefa53dde772eff7a477904a Mon Sep 17 00:00:00 2001 From: Mike Riley <mikeriley@yelirekim.com> Date: Thu, 13 Oct 2016 20:48:24 +0000 Subject: [PATCH] Expose Drydock blueprints via Conduit Summary: This search engine ports cleanly to Conduit out of the box. Ref T11694 Test Plan: called the API method from the console, browsed blueprints in the ui Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T11694 Differential Revision: https://secure.phabricator.com/D16593 --- src/__phutil_library_map__.php | 3 ++ ...DrydockBlueprintSearchConduitAPIMethod.php | 18 +++++++++++ .../drydock/storage/DrydockBlueprint.php | 32 ++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/applications/drydock/conduit/DrydockBlueprintSearchConduitAPIMethod.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index fbae5beb97..5fee27238f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -940,6 +940,7 @@ phutil_register_library_map(array( 'DrydockBlueprintNameNgrams' => 'applications/drydock/storage/DrydockBlueprintNameNgrams.php', 'DrydockBlueprintPHIDType' => 'applications/drydock/phid/DrydockBlueprintPHIDType.php', 'DrydockBlueprintQuery' => 'applications/drydock/query/DrydockBlueprintQuery.php', + 'DrydockBlueprintSearchConduitAPIMethod' => 'applications/drydock/conduit/DrydockBlueprintSearchConduitAPIMethod.php', 'DrydockBlueprintSearchEngine' => 'applications/drydock/query/DrydockBlueprintSearchEngine.php', 'DrydockBlueprintTransaction' => 'applications/drydock/storage/DrydockBlueprintTransaction.php', 'DrydockBlueprintTransactionQuery' => 'applications/drydock/query/DrydockBlueprintTransactionQuery.php', @@ -5512,6 +5513,7 @@ phutil_register_library_map(array( 'PhabricatorCustomFieldInterface', 'PhabricatorNgramsInterface', 'PhabricatorProjectInterface', + 'PhabricatorConduitResultInterface', ), 'DrydockBlueprintController' => 'DrydockController', 'DrydockBlueprintCoreCustomField' => array( @@ -5530,6 +5532,7 @@ phutil_register_library_map(array( 'DrydockBlueprintNameNgrams' => 'PhabricatorSearchNgrams', 'DrydockBlueprintPHIDType' => 'PhabricatorPHIDType', 'DrydockBlueprintQuery' => 'DrydockQuery', + 'DrydockBlueprintSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'DrydockBlueprintSearchEngine' => 'PhabricatorApplicationSearchEngine', 'DrydockBlueprintTransaction' => 'PhabricatorApplicationTransaction', 'DrydockBlueprintTransactionQuery' => 'PhabricatorApplicationTransactionQuery', diff --git a/src/applications/drydock/conduit/DrydockBlueprintSearchConduitAPIMethod.php b/src/applications/drydock/conduit/DrydockBlueprintSearchConduitAPIMethod.php new file mode 100644 index 0000000000..80f5019414 --- /dev/null +++ b/src/applications/drydock/conduit/DrydockBlueprintSearchConduitAPIMethod.php @@ -0,0 +1,18 @@ +<?php + +final class DrydockBlueprintSearchConduitAPIMethod + extends PhabricatorSearchEngineAPIMethod { + + public function getAPIMethodName() { + return 'drydock.blueprint.search'; + } + + public function newSearchEngine() { + return new DrydockBlueprintSearchEngine(); + } + + public function getMethodSummary() { + return pht('Retrieve information about Drydock blueprints.'); + } + +} diff --git a/src/applications/drydock/storage/DrydockBlueprint.php b/src/applications/drydock/storage/DrydockBlueprint.php index 87ea777f72..afd3b771ca 100644 --- a/src/applications/drydock/storage/DrydockBlueprint.php +++ b/src/applications/drydock/storage/DrydockBlueprint.php @@ -10,7 +10,8 @@ final class DrydockBlueprint extends DrydockDAO PhabricatorPolicyInterface, PhabricatorCustomFieldInterface, PhabricatorNgramsInterface, - PhabricatorProjectInterface { + PhabricatorProjectInterface, + PhabricatorConduitResultInterface { protected $className; protected $blueprintName; @@ -360,4 +361,33 @@ final class DrydockBlueprint extends DrydockDAO ); } + +/* -( PhabricatorConduitResultInterface )---------------------------------- */ + + + public function getFieldSpecificationsForConduit() { + return array( + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('name') + ->setType('string') + ->setDescription(pht('The name of this blueprint.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('type') + ->setType('string') + ->setDescription(pht('The type of resource this blueprint provides.')), + ); + } + + public function getFieldValuesForConduit() { + return array( + 'name' => $this->getBlueprintName(), + 'type' => $this->getImplementation()->getType(), + ); + } + + public function getConduitSearchAttachments() { + return array( + ); + } + }