Last active
July 22, 2018 13:39
-
-
Save hobodave/5042006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'apiVersion' => '2', | |
'operations' => [ | |
'ListPriorities' => [ | |
'httpMethod' => 'GET', | |
'uri' => 'priority', | |
'summary' => 'Returns a list of all issue priorities.', | |
'responseClass' => 'ListPrioritiesResponse', | |
'responseType' => 'model', | |
], | |
'GetPriority' => [ | |
'httpMethod' => 'GET', | |
'uri' => 'priority/{id}', | |
'summary' => 'Returns an issue priority.', | |
'responseClass' => 'GetPriorityResponse', | |
'responseType' => 'model', | |
'parameters' => [ | |
'id' => [ | |
'required' => true, | |
'type' => 'string', | |
'location' => 'uri', | |
], | |
], | |
'command.expects' => [ | |
'static' => true, | |
'default' => 'application/json', | |
] | |
] | |
], | |
'models' => [ | |
'Priority' => [ | |
'type' => 'object', | |
'additionalProperties' => true, | |
'properties' => [ | |
'description' => [ | |
'location' => 'json', | |
'required' => true, | |
'type' => 'string', | |
], | |
'iconUrl' => [ | |
'location' => 'json', | |
'required' => true, | |
'type' => 'string', | |
], | |
'id' => [ | |
'location' => 'json', | |
'required' => true, | |
'type' => 'string', | |
], | |
'name' => [ | |
'location' => 'json', | |
'required' => true, | |
'type' => 'string', | |
], | |
'self' => [ | |
'location' => 'json', | |
'required' => true, | |
'type' => 'string', | |
], | |
'statusColor' => [ | |
'location' => 'json', | |
'required' => true, | |
'type' => 'string' | |
] | |
] | |
], | |
'ListPrioritiesResponse' => [ | |
'type' => 'array', | |
'items' => [ | |
'$ref' => 'Priority', | |
] | |
], | |
'GetPriorityResponse' => [ | |
'$ref' => 'Priority', | |
] | |
] | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"self":"http://jira1.snc1:8080/rest/api/2/priority/1","statusColor":"#cc0000","description":"Production site is down. Customers may be impacted.","iconUrl":"http://jira1.snc1:8080/images/icons/priority_blocker.gif","name":"Prod Issue","id":"1"},{"self":"http://jira1.snc1:8080/rest/api/2/priority/2","statusColor":"#ff0000","description":"Blocks development and/or testing work, production could not run.","iconUrl":"http://jira1.snc1:8080/images/icons/priority_critical.gif","name":"Blocker","id":"2"},{"self":"http://jira1.snc1:8080/rest/api/2/priority/7","statusColor":"#ff0000","description":"P0","iconUrl":"http://jira1.snc1:8080/images/icons/priority_major.gif","name":"P0","id":"7"},{"self":"http://jira1.snc1:8080/rest/api/2/priority/3","statusColor":"#009900","description":"High priority. Major loss of function.","iconUrl":"http://jira1.snc1:8080/images/icons/priority_major.gif","name":"P1","id":"3"},{"self":"http://jira1.snc1:8080/rest/api/2/priority/4","statusColor":"#009933","description":"Medium priority. Should be fixed in this iteration.","iconUrl":"http://jira1.snc1:8080/images/icons/priority_minor.gif","name":"P2","id":"4"},{"self":"http://jira1.snc1:8080/rest/api/2/priority/6","statusColor":"#006633","description":"Low priority. Minor loss of function, or other problem where easy workaround is present.","iconUrl":"http://jira1.snc1:8080/images/icons/priority_trivial.gif","name":"P3","id":"6"},{"self":"http://jira1.snc1:8080/rest/api/2/priority/8","statusColor":"#006633","description":"P4","iconUrl":"http://jira1.snc1:8080/images/icons/priority_trivial.gif","name":"P4","id":"8"},{"self":"http://jira1.snc1:8080/rest/api/2/priority/5","statusColor":"#0000cc","description":"Not scheduled to be resolved in the foreseeable future.","iconUrl":"http://jira1.snc1:8080/images/icons/priority_icebox.gif","name":"Icebox","id":"5"}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Guzzle\Service\Description\ServiceDescription; | |
require __DIR__ . '/vendor/autoload.php'; | |
$desc = ServiceDescription::factory(__DIR__ . '/jira-rest-api-2.php'); | |
$client = new \Guzzle\Service\Client(); | |
$client->addSubscriber(new \Guzzle\Plugin\CurlAuth\CurlAuthPlugin('davida', 'xxxxxx')); | |
$client->setBaseUrl('http://jira1.snc1:8080/rest/api/2'); | |
$client->setDescription($desc); | |
$command = $client->getCommand('ListPriorities'); | |
$response = $client->execute($command); | |
var_dump($response->toArray()); | |
/** | |
* Outputs: | |
* | |
array(0) { | |
} | |
*/ | |
$command = $client->getCommand('GetPriority', array('id' => 1)); | |
$response = $client->execute($command); | |
var_dump($response->toArray()); | |
/** | |
* Outputs: | |
* | |
array(6) { | |
'self' => | |
string(49) "http://jira1.snc1:8080/rest/api/2/priority/1" | |
'statusColor' => | |
string(7) "#cc0000" | |
'description' => | |
string(52) "Production site is down. Customers may be impacted." | |
'iconUrl' => | |
string(61) "http://jira1.snc1:8080/images/icons/priority_blocker.gif" | |
'name' => | |
string(10) "Prod Issue" | |
'id' => | |
string(1) "1" | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment