From 14d35b817159ecb06b3eaae90959238957a10117 Mon Sep 17 00:00:00 2001 From: Ricky Elrod Date: Mon, 27 Jun 2011 04:00:28 -0400 Subject: [PATCH] Preliminary Conduit info method for Maniphest tasks. Summary: Provide a simple maniphest.info method for fetching info about a Maniphest task, given its ID. Test Plan: Tested via the web console, and it appeared to work fine. This is preliminary though, but I plan to use it for adding 'Txxx' to phabot. Reviewers: epriestley CC: Differential Revision: 540 --- src/__phutil_library_map__.php | 2 + .../info/ConduitAPI_maniphest_info_Method.php | 69 +++++++++++++++++++ .../method/maniphest/info/__init__.php | 18 +++++ 3 files changed, 89 insertions(+) create mode 100644 src/applications/conduit/method/maniphest/info/ConduitAPI_maniphest_info_Method.php create mode 100644 src/applications/conduit/method/maniphest/info/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ae0eba6fab..5bddbe16c0 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -105,6 +105,7 @@ phutil_register_library_map(array( 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/conduit/method/diffusion/getrecentcommitsbypath', 'ConduitAPI_file_download_Method' => 'applications/conduit/method/file/download', 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', + 'ConduitAPI_maniphest_info_Method' => 'applications/conduit/method/maniphest/info', 'ConduitAPI_paste_info_Method' => 'applications/conduit/method/paste/info', 'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners', 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', @@ -651,6 +652,7 @@ phutil_register_library_map(array( 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_download_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', + 'ConduitAPI_maniphest_info_Method' => 'ConduitAPIMethod', 'ConduitAPI_paste_info_Method' => 'ConduitAPIMethod', 'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod', 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/maniphest/info/ConduitAPI_maniphest_info_Method.php b/src/applications/conduit/method/maniphest/info/ConduitAPI_maniphest_info_Method.php new file mode 100644 index 0000000000..0abd32faa3 --- /dev/null +++ b/src/applications/conduit/method/maniphest/info/ConduitAPI_maniphest_info_Method.php @@ -0,0 +1,69 @@ + 'required id', + ); + } + + public function defineReturnType() { + return 'nonempty dict'; + } + + public function defineErrorTypes() { + return array( + 'ERR_BAD_TASK' => 'No such maniphest task exists', + ); + } + + protected function execute(ConduitAPIRequest $request) { + $task_id = $request->getValue('task_id'); + + $task = id(new ManiphestTask())->load($task_id); + if (!$task) { + throw new ConduitException('ERR_BAD_TASK'); + } + + $result = array( + 'id' => $task->getID(), + 'phid' => $task->getPHID(), + 'authorPHID' => $task->getAuthorPHID(), + 'ownerPHID' => $task->getAuthorPHID(), + 'ccPHIDs' => $task->getCCPHIDs(), + 'status' => $task->getStatus(), + 'priority' => ManiphestTaskPriority::getTaskPriorityName( + $task->getPriority()), + 'title' => $task->getTitle(), + 'description' => $task->getDescription(), + 'projectPHIDs' => $task->getProjectPHIDs(), + 'uri' => PhabricatorEnv::getProductionURI('/T'.$task->getID()), + + // Not sure what this is yet. + // 'attached' => array($task->getAttached()), + ); + return $result; + } + +} diff --git a/src/applications/conduit/method/maniphest/info/__init__.php b/src/applications/conduit/method/maniphest/info/__init__.php new file mode 100644 index 0000000000..f6d47f4ece --- /dev/null +++ b/src/applications/conduit/method/maniphest/info/__init__.php @@ -0,0 +1,18 @@ +