A list of JobRouter archives, which users have access to, can be found via the GET route /application/users/:username/archives. Here the archive name, GUID, and database table name are displayed. The user is identified through the username (parameter :username). The return is made in JSON format:
{
"users": {
"archives": [
{
"name": "Archive name",
"guid": "GUID",
"table": "Database table"
},
... further archives ...
]
}
}
Example: List accessible archives
guzzlehttp
// user has been authenticated already
try {
$response = $client->request('GET', 'application/users/jdoe/archives');
$responseBody = json_decode($response->getBody(), true);
$archives = $body['users']['archives'];
foreach ($archives as $archive) {
echo "Name: " . $archive['name'] . ": " . $archive['table'] . "\n";
}
} catch (Exception $e) {
echo "Error during performance:" . $e->getMessage() . "\n";
}
cURL
// User has been authenticated already
curl_setopt($curlHandle, CURLOPT_URL,
'http://example.org/jobrouter/api/rest/v2/application/users/jdoe/archives');
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curlHandle, CURLOPT_COOKIEFILE, 'path/to/cooke/file.cookie');
$response = curl_exec($curlHandle);
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
curl_close();
if ($statusCode == 200) {
$userArchives = json_decode($response, true);
foreach ($userArchives['users']['archives'] as $archive) {
echo "Name: " . $archive['name'] . ": " . $archive['table'] . "\n";
}
} else {
"Error during performance: Code - " . $statusCode . ", ";
echo "Response: " . var_export($response, true);
}