PHP code example of cyberfusion / cluster-api-client
1. Go to this page and download the library: Download cyberfusion/cluster-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/ */
cyberfusion / cluster-api-client example snippets
use Cyberfusion\ClusterApi\Client;
use Cyberfusion\ClusterApi\Configuration;
use Cyberfusion\ClusterApi\ClusterApi;
// Create the configuration with your username/password
$configuration = Configuration::withCredentials('username', 'password');
// Start the client once and authorize
$client = new Client($configuration);
// Initialize the API
$api = new ClusterApi($client);
// Perform the request
$result = $api->virtualHosts()->list();
// Access the virtual host models
$virtualHosts = $result->getData('virtualHosts');
use Cyberfusion\ClusterApi\Enums\Sort;
use Cyberfusion\ClusterApi\Models\VirtualHost;
use Cyberfusion\ClusterApi\Support\FilterEntry;
use Cyberfusion\ClusterApi\Support\SortEntry;
$listFilter = VirtualHost::listFilter()
->filter(new FilterEntry('server_software_name', 'Apache'))
->filter(new FilterEntry('domain', 'cyberfusion.nl'))
->sort(new SortEntry('domain', Sort::DESC));
$listFilter = (new ListFilter())
->setFilters([
new FilterEntry('server_software_name', 'Apache'),
new FilterEntry('domain', 'cyberfusion.nl'),
])
->setSort([
new SortEntry('domain', Sort::DESC)
]);
);
use Cyberfusion\ClusterApi\Client;
use Cyberfusion\ClusterApi\ClusterApi;
use Cyberfusion\ClusterApi\Configuration;
use Cyberfusion\ClusterApi\Models\Login;
// Initialize the configuration without any credentials or access token
$configuration = new Configuration();
// Start the client with manual authentication
$client = new Client($configuration, true);
// Initialize the API
$api = new ClusterApi($client);
// Create the request
$login = (new Login())
->setUsername('username')
->setPassword('password');
// Perform the request
$response = $api
->authentication()
->login($login);
// Store the access token in the configuration
if ($response->isSuccess()) {
$configuration->setAccessToken($response->getData('access_token'));
}