Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
/ rest-client Public archive

A simple REST cient to interact with Jaeger REST API installations.

License

Notifications You must be signed in to change notification settings

jaeger-app/rest-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jaeger REST Client

Build Status Scrutinizer Code Quality Author GitHub license

A simple REST client to interact with Jaeger REST API installations.

Installation

Add jaeger-app/rest-client as a requirement to composer.json:

$ composer require jaeger-app/rest-client

Simple Example

use \JaegerApp\Rest\Client;

$client = new Client();
$backups = $client->setApiKey($api_key)
                 ->setApiSecret($api_secret)
                 ->setSiteUrl($api_endpoint_url)
                 ->get('/backups');

Authentication

Jaeger uses HMAC-SHA authentication which is a simple key / secret paradigm to create hashed signatures. You can get/set your api key and secret, as well as the API URL endpoint, from your individual Jaeger installations.

Error Handling

If anything goes wrong with a request the library will return an ApiProblem object. Here's an example:

use \JaegerApp\Rest\Client;
use \JaegerApp\Rest\ApiProblem;

$client = new Client();
$result = $client->setApiKey($api_key)
                 ->setApiSecret($api_secret)
                 ->setSiteUrl($api_endpoint_url)
                 ->get('/myendpoint');

if($result instanceof ApiProblem) 
{
    if($result->getStatus() == 403) {
        //authentication issue
    }

	$result->getTitle() //API problem response title
	$result->getDetail() //API problem response details
	
}

Hal Responses

For all successful responses from the Jaeger API, the library will return an instance of \JaegerApp\Rest\Client\Hal object which is a wrapper for \Nocarrier\Hal.

use \JaegerApp\Rest\Client;
use \JaegerApp\Rest\Hal;

$client = new Client();
$result = $client->setApiKey($api_key)
                 ->setApiSecret($api_secret)
                 ->setSiteUrl($api_endpoint_url)
                 ->get('/myendpoint');

if($result instanceof Hal) 
{
    $data = $result->getData();
    $resources = $result->getResources();
}

Examples

Since Jaeger follows the [Richardson Maturity Model](Richardson Maturity Model) there are helper methods available for each HTTP verb. Below are some simple use case examples and their implementations

Take a Backup

use \JaegerApp\Rest\Client;

$client = new Client();
$result = $client->setApiKey($api_key)
                 ->setApiSecret($api_secret)
                 ->setSiteUrl($api_endpoint_url)
                 ->post('/myendpoint');

Update Settings

use \JaegerApp\Rest\Client;

$client = new Client();
$settings = array('working_directory' => '/path/to/working_directory');
$update = $client->setApiKey($api_key)
                 ->setApiSecret($api_secret)
                 ->setSiteUrl($api_endpoint_url)
                 ->put('/settings', $settings);

Get Settings

use \JaegerApp\Rest\Client;

$client = new Client();
$settings = $client->setApiKey($api_key)
                 ->setApiSecret($api_secret)
                 ->setSiteUrl($api_endpoint_url)
                 ->get('/settings');

Get Storage Locations

use \JaegerApp\Rest\Client;

$client = new Client();
$storage_locations = $client->setApiKey($api_key)
                 ->setApiSecret($api_secret)
                 ->setSiteUrl($api_endpoint_url)
                 ->get('/storage');

About

A simple REST cient to interact with Jaeger REST API installations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages