2017-25 © Pedro Peláez
 

library rundeck-api-client

Rundeck's API client

image

ftw-soft/rundeck-api-client

Rundeck's API client

  • Monday, June 18, 2018
  • by ftw-soft
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Rundeck API client

A php client to access the Rundeck API, based on the official documentation. Not all API functions are represented by default., (*1)

Requirements

  • PHP 7.2+ with enabled json extension
  • Rundeck 2.1+

This client is based on PSR-17 and PSR-18 and therefore you need a compatible HTTP client and request factories., (*2)

We suggest Guzzle 7+ and http-interop/http-factory-guzzle:, (*3)

composer require guzzlehttp/guzzle:^7.0 http-interop/http-factory-guzzle:^1.0

Installation

composer require ftw-soft/rundeck-api-client

Basic client usage

<?php
require_once __DIR__ . '/vendor/autoload.php';

use 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());

Supported default scenarios

This package includes common request scenarios which are called "resources". The following resources are currently supported: - Execution - Job - Project - Projects - System - Token - Tokens - User, (*4)

Each resource includes calls to the API and it's payload and/or response is represented by custom entity classes., (*5)

For example, (*6)

<?php
require_once __DIR__ . '/vendor/autoload.php';

use FtwSoft\Rundeck\Resource\Tokens as TokensResource;
use FtwSoft\Rundeck\Client;
use FtwSoft\Rundeck\Entity\TokenEntity;

/** @var Client $client */
$tokensResource = new TokensResource($client);

/** @var TokenEntity[] $tokens */
$tokens = $tokensResource->get();

foreach ($tokens as $token) {
    echo '====================================';
    echo 'id: ', $token->getId(), PHP_EOL;
    echo 'user:', $token->getUser(), PHP_EOL;
    echo 'token: ', $token->getToken(), PHP_EOL;
    echo 'creator: ', $token->getCreator(), PHP_EOL;
    echo 'expire at: ', $token->getExpiration()->format(\DATE_ATOM), PHP_EOL;
    echo 'roles: ', implode(', ', $token->getRoles()), PHP_EOL;
    echo 'is expired: ', $token->isExpired() ? 'yes' : 'no', PHP_EOL;
}

Feel free to add your own resources and entities to this package by creating a new pull request., (*7)

The Versions

18/06 2018

dev-master

9999999-dev

Rundeck's API client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Telesh

18/06 2018

1.0.1

1.0.1.0

Rundeck's API client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Telesh

18/05 2018

1.0.0

1.0.0.0

Rundeck's API client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Telesh