Search by

vhosting / tools-sdk

Lukasss93

Tools API SDK

Package info

github.com/vhosting/tools-sdk

pkg:composer/vhosting/tools-sdk

Statistics

Installs: 93

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-04-23 13:30 UTC

This package is auto-updated.

Last update: 2026-11-23 14:12:51 UTC


README

The PHP SDK for interacting with the VHosting Tools API, developed using the Saloon library.

Installation

You can install the package via composer:

composer require vhosting/tools-sdk

The package automatically registers itself in Laravel through the Service Provider.

Configuration

You can publish the configuration file with the following command:

php artisan vendor:publish --provider="VHosting\ToolsSdk\ToolsSdkServiceProvider"

These are the supported environment variables:

TOOLS_TOKEN=your-api-token
TOOLS_URL=https://tools.vhosting-it.com
TOOLS_MOCK=false

The token can be generated by visiting https://tools.vhosting-it.com/token.

Usage

The SDK provides a Laravel Facade that makes it easy to access resources.

Workflow Management

All workflow operations are accessible via ToolsSdk::workflow().

Retrieve all workflows (Paginated)

use VHosting\ToolsSdk\Facades\ToolsSdk;

$paginator = ToolsSdk::workflow()->all();

foreach ($paginator as $workflow) {
    echo $workflow->id;
    echo $workflow->status;
}

Retrieve a single workflow

$workflow = ToolsSdk::workflow()->get(123);

echo $workflow->description;
echo $workflow->tasks_count;

Dispatch a new workflow

$workflow = ToolsSdk::workflow()->dispatch('workflow-type-name', [
    'parameter1' => 'value1',
    'parameter2' => 'value2',
]);

echo $workflow->id;

Retry a failed workflow

ToolsSdk::workflow()->retry(123);

Proxmox Firewall

$firewall = ToolsSdk::proxmox()->vm(123)->firewall();

$rules = $firewall->rules;
$ipset = $firewall->ipset;
$options = $firewall->options;

Rules and options are returned as FirewallRule and FirewallOption objects.

Use firewallRules() to create a rule or change an existing rule by its current pos.

$rules = ToolsSdk::proxmox()->vm(123)->firewallRules();
$rules->store(['type' => 'in', 'action' => 'ACCEPT', 'proto' => 'tcp', 'dport' => '443']);
$rules->update($pos, ['comment' => 'Allow HTTPS']);
$rules->destroy($pos);

Create or update an IP set with an optional comment or new name.

$vm = ToolsSdk::proxmox()->vm(123);
$vm->firewallUpsertIpset('allowed', ['comment' => 'Office networks']);
$vm->firewallUpsertIpset('allowed', ['rename' => 'trusted']);

Retrieve the content of an IP set as an array of FirewallIpset objects:

$entries = ToolsSdk::proxmox()->vm(123)->firewallIpset('allowed');

foreach ($entries as $entry) {
    echo $entry->cidr;
    echo $entry->comment;
}

Proxmox Kickstart

use VHosting\ToolsSdk\Types\Proxmox\KickstartType;

$kickstart = ToolsSdk::proxmox()->vm(123)->kickstart();

$configuration = $kickstart->show();

$configuration = $kickstart->upsert(
    enabled: true,
    type: KickstartType::UbuntuAutoInstall,
    content: "#cloud-config\nautoinstall:\n  version: 1\n",
);

$configuration = $kickstart->upsert(
    enabled: false,
    type: $configuration->type,
    content: $configuration->content,
);

$kickstart->destroy();

All three fields are required when creating or updating a configuration.

Mocking for Tests

The SDK integrates Saloon's faking system to facilitate testing:

use VHosting\ToolsSdk\Facades\ToolsSdk;
use Saloon\Http\Faking\MockResponse;

ToolsSdk::fake([
    '*' => MockResponse::make(['id' => 1, 'status' => 'completed'], 200),
]);

It is also possible to enable mocks globally via the TOOLS_MOCK=true environment variable, which will use the default data defined in the Mocks class.

License

MIT License (MIT). For more information, please see the LICENSE file.