1. Go to this page and download the library: Download ftw-soft/rundeck-api-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ftw-soft / rundeck-api-client example snippets
FtwSoft\Rundeck\Authentication\PasswordAuthentication;
use FtwSoft\Rundeck\Authentication\TokenAuthentication;
use FtwSoft\Rundeck\Client;
use GuzzleHttp\Client as HttpClient;
use Http\Factory\Guzzle\RequestFactory;
use Http\Factory\Guzzle\StreamFactory;
$httpClient = new HttpClient();
// --- Setup authentication ---
# Password authentication
$authentication = new PasswordAuthentication(
'https://rundeck.local',
'username',
'password',
$httpClient,
new RequestFactory(),
new StreamFactory()
);
# OR Token based authentication
$authentication = new TokenAuthentication('secret-token');
// --- Initialize client ---
$client = new Client(
'https://rundeck.local',
$authentication,
$httpClient,
new RequestFactory(),
new StreamFactory(),
36 // optional API version
);
// Make a request
$response = $client->request('GET', 'projects');
var_dump($response->getBody()->getContents());