From c4f7a05034625a34d9224aaa39baf824d3d2c48b Mon Sep 17 00:00:00 2001 From: Ricky Elrod Date: Tue, 14 Jun 2011 01:21:30 -0400 Subject: [PATCH] Conduit paste.info method for the pastebin. Summary: This implements a paste.info conduit method, for retrieving info about a paste. Imagine that. Test Plan: [ricky@rhelpad01 method]$ echo '{"paste_id":1}' | arc call-conduit --conduit-uri=http://phabricator.local/api/ paste.info {"error":null,"errorMessage":null,"response":{"id":"1","phid":"PHID-PSTE-10934f3df8ed33c06555","authorPHID":"PHID-USER-9d03e8fa47516d37dc92","filePHID":"PHID-FILE-e85f6a72c773d24f4981","title":"test.php","dateCreated":"1307731614"}} Reviewers: epriestley CC: Differential Revision: 458 --- src/__phutil_library_map__.php | 2 + .../info/ConduitAPI_paste_info_Method.php | 60 +++++++++++++++++++ .../conduit/method/paste/info/__init__.php | 16 +++++ 3 files changed, 78 insertions(+) create mode 100644 src/applications/conduit/method/paste/info/ConduitAPI_paste_info_Method.php create mode 100644 src/applications/conduit/method/paste/info/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ca916ce23d..a9898fe78c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -104,6 +104,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_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', 'ConduitAPI_user_whoami_Method' => 'applications/conduit/method/user/whoami', @@ -636,6 +637,7 @@ phutil_register_library_map(array( 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_download_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', + 'ConduitAPI_paste_info_Method' => 'ConduitAPIMethod', 'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod', 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', 'ConduitAPI_user_whoami_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/paste/info/ConduitAPI_paste_info_Method.php b/src/applications/conduit/method/paste/info/ConduitAPI_paste_info_Method.php new file mode 100644 index 0000000000..51da551c36 --- /dev/null +++ b/src/applications/conduit/method/paste/info/ConduitAPI_paste_info_Method.php @@ -0,0 +1,60 @@ + 'required id', + ); + } + + public function defineReturnType() { + return 'nonempty dict'; + } + + public function defineErrorTypes() { + return array( + 'ERR_BAD_PASTE' => 'No such paste exists' + ); + } + + protected function execute(ConduitAPIRequest $request) { + $paste_id = $request->getValue('paste_id'); + $paste = id(new PhabricatorPaste())->load($paste_id); + if (!$paste) { + throw new ConduitException('ERR_BAD_PASTE'); + } + + $result = array( + 'id' => $paste->getID(), + 'phid' => $paste->getPHID(), + 'authorPHID' => $paste->getAuthorPHID(), + 'filePHID' => $paste->getFilePHID(), + 'title' => $paste->getTitle(), + 'dateCreated' => $paste->getDateCreated(), + ); + + return $result; + } + +} diff --git a/src/applications/conduit/method/paste/info/__init__.php b/src/applications/conduit/method/paste/info/__init__.php new file mode 100644 index 0000000000..1a92ec47f0 --- /dev/null +++ b/src/applications/conduit/method/paste/info/__init__.php @@ -0,0 +1,16 @@ +