lcherone/lxcpapi

LXC Web panel REST v1 API Client

v0.0.5 2016-01-02 18:28 UTC

This package is auto-updated.

Last update: 2021-04-28 20:51:48 UTC


README

About:

This php composer package provides a simple object orientated way to interact with the LXC Web Panel v1 REST API.

Author:

@lcherone

Setup:

Using composer add the package to your project:

composer require lcherone/lxcpapi

Initializing the client

<?php
require 'vendor/autoload.php';

/**
 * Initialize the API client class
 */
$api = new lcherone\lxcpapi\APIClient([
    'base_uri'   => 'http://lxcpanel.example.com:5000',
    'api_key'    => 'api-key-generated-in-panel'
]);
?>

Making calls:

To interact with the API its as simple as calling a class method or property, endpoints are dynamically loaded when traversed to.

Containers

Get

$containers = $api->containers->get();

Get (container)

$container = $api->containers->get('container_name');

Create

$container = $api->containers->create('my-container', 'sshd');

Update

$container = $api->containers->update('my-container', 'start');

Delete

$container = $api->containers->delete('my-container');

Clone/Copy

$container = $api->containers->copy('my-container');

Tokens

Create

$tokens = $api->tokens->create('some-fancy-api-key', 'API Token');

Delete

$tokens = $api->tokens->delete('some-fancy-api-key');