1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

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
This commit is contained in:
Ricky Elrod 2011-06-14 01:21:30 -04:00
parent 555464c4a7
commit c4f7a05034
3 changed files with 78 additions and 0 deletions

View file

@ -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',

View file

@ -0,0 +1,60 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class ConduitAPI_paste_info_Method extends ConduitAPIMethod {
public function getMethodDescription() {
return "Retrieve an array of information about a paste.";
}
public function defineParamTypes() {
return array(
'paste_id' => '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;
}
}

View file

@ -0,0 +1,16 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/conduit/method/base');
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
phutil_require_module('phabricator', 'applications/paste/storage/paste');
phutil_require_module('phutil', 'utils');
phutil_require_source('ConduitAPI_paste_info_Method.php');