From 9bea00c159b6a2bc98a29bcec5cce89b0e4a3442 Mon Sep 17 00:00:00 2001 From: Tim Hirsh Date: Fri, 2 Nov 2018 02:56:34 +0000 Subject: [PATCH] Add harbormaster.buildplan.search api method Summary: This revision adds a conduit search method for build plans. Other api methods (eg: `harbormaster.build.search`) support build plan phid's as a constraint, but they weren't exposed anywhere, so this provides a way to fetch them. Test Plan: Used the api console to run some searches. Output: ``` { "data": [ { "id": 1, "type": "HMCP", "phid": "PHID-HMCP-q2c25wvegzdkxs7gzor6", "fields": { "name": "my build plan", "planStatus": "active", "dateCreated": 1538085249, "dateModified": 1538085249, "policy": { "view": "users", "edit": "admin" } }, { "id": 1, "type": "HMCP", "phid": "PHID-HMCP-q2c25wvegzdkxs7gzor6", "fields": { "name": "my build plan", "status": { "value": "active" }, "dateCreated": 1538085249, "dateModified": 1538085249, "policy": { "view": "users", "edit": "admin" } }, "attachments": {} }, ... ], "maps": {}, "query": { "queryKey": null }, "cursor": { "limit": 100, "after": null, "before": null, "order": null } } ``` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, yelirekim Differential Revision: https://secure.phabricator.com/D19769 --- src/__phutil_library_map__.php | 3 ++ .../HarbormasterBuildPlanSearchAPIMethod.php | 18 +++++++++++ .../configuration/HarbormasterBuildPlan.php | 31 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/applications/harbormaster/conduit/HarbormasterBuildPlanSearchAPIMethod.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a472b66411..7a9ea1df70 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1326,6 +1326,7 @@ phutil_register_library_map(array( 'HarbormasterBuildPlanNameNgrams' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php', 'HarbormasterBuildPlanPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildPlanPHIDType.php', 'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php', + 'HarbormasterBuildPlanSearchAPIMethod' => 'applications/harbormaster/conduit/HarbormasterBuildPlanSearchAPIMethod.php', 'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php', 'HarbormasterBuildPlanTransaction' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanTransaction.php', 'HarbormasterBuildPlanTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanTransactionQuery.php', @@ -6775,6 +6776,7 @@ phutil_register_library_map(array( 'PhabricatorPolicyInterface', 'PhabricatorSubscribableInterface', 'PhabricatorNgramsInterface', + 'PhabricatorConduitResultInterface', 'PhabricatorProjectInterface', ), 'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource', @@ -6785,6 +6787,7 @@ phutil_register_library_map(array( 'HarbormasterBuildPlanNameNgrams' => 'PhabricatorSearchNgrams', 'HarbormasterBuildPlanPHIDType' => 'PhabricatorPHIDType', 'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', + 'HarbormasterBuildPlanSearchAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine', 'HarbormasterBuildPlanTransaction' => 'PhabricatorApplicationTransaction', 'HarbormasterBuildPlanTransactionQuery' => 'PhabricatorApplicationTransactionQuery', diff --git a/src/applications/harbormaster/conduit/HarbormasterBuildPlanSearchAPIMethod.php b/src/applications/harbormaster/conduit/HarbormasterBuildPlanSearchAPIMethod.php new file mode 100644 index 0000000000..b5e03b3071 --- /dev/null +++ b/src/applications/harbormaster/conduit/HarbormasterBuildPlanSearchAPIMethod.php @@ -0,0 +1,18 @@ +setKey('name') + ->setType('string') + ->setDescription(pht('The name of this build plan.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('status') + ->setType('map') + ->setDescription(pht('The current status of this build plan.')), + ); + } + + public function getFieldValuesForConduit() { + return array( + 'name' => $this->getName(), + 'status' => array( + 'value' => $this->getPlanStatus(), + ), + ); + } + + public function getConduitSearchAttachments() { + return array(); + } + }