node
Manage nodes
Create
Input parameters
| Parameter | Type | Required | Details | ||||||
|---|---|---|---|---|---|---|---|---|---|
idID |
Integer | no |
Node ID Default: |
||||||
nameName |
String | yes |
Node name Default:
|
||||||
typeRole |
String | yes |
node, storage or mailer Default:
|
||||||
hypervisor_typeHypervisor type |
String | no |
vpsadminos Default:
|
||||||
locationLocation |
Resource | yes |
Location node is placed in |
||||||
ip_addrIPv4 address |
String | yes |
Node's IP address Default:
|
||||||
max_txMax tx |
Integer | no |
Maximum output throughput Default: |
||||||
max_rxMax tx |
Integer | no |
Maximum input throughput Default: |
||||||
cpusCpus |
Integer | no |
Default: |
||||||
total_memoryTotal_memory |
Integer | no |
Default: |
||||||
total_swapTotal_swap |
Integer | no |
Default: |
||||||
max_vpsMax_vps |
Integer | no |
Default: |
||||||
maintenanceMaintenance |
Boolean | no |
Put the node into maintenance mode Default: |
Output parameters
| Parameter | Type | Description |
|---|---|---|
idID |
Integer | Node ID |
activeActive |
Boolean | |
nameName |
String | Node name |
domain_nameDomain name |
String | Node name including location domain |
fqdnFQDN |
String | |
typeRole |
String | node, storage or mailer |
hypervisor_typeHypervisor type |
String | vpsadminos |
locationLocation |
Resource | Location node is placed in |
ip_addrIPv4 address |
String | Node's IP address |
max_txMax tx |
Integer | Maximum output throughput |
max_rxMax tx |
Integer | Maximum input throughput |
cpusCpus |
Integer | |
total_memoryTotal_memory |
Integer | |
total_swapTotal_swap |
Integer | |
max_vpsMax_vps |
Integer | |
statusStatus |
Boolean | |
uptimeUptime |
Integer | |
loadavg1Loadavg1 |
Float | |
loadavg5Loadavg5 |
Float | |
loadavg15Loadavg15 |
Float | |
process_countProcess count |
Integer | |
cpu_userCpu_user |
Float | |
cpu_niceCpu_nice |
Float | |
cpu_systemCpu_system |
Float | |
cpu_idleCpu_idle |
Float | |
cpu_iowaitCpu_iowait |
Float | |
cpu_irqCpu_irq |
Float | |
cpu_softirqCpu_softirq |
Float | |
cpu_guestCpu_guest |
Float | |
used_memoryUsed memory |
Integer | in MB |
used_swapUsed swap |
Integer | in MB |
arc_c_maxArc_c_max |
Integer | |
arc_cArc_c |
Integer | |
arc_sizeArc_size |
Integer | |
arc_hitpercentArc_hitpercent |
Integer | |
versionVersion |
String | 4 or 6 |
kernelKernel |
String | |
cgroup_versionCgroup version |
String | |
pool_statePool_state |
String | |
pool_scanPool_scan |
String | |
pool_scan_percentPool_scan_percent |
Float | |
pool_checked_atPool_checked_at |
Datetime | |
pool_statusPool_status |
Boolean |
Evacuate
Input parameters
| Parameter | Type | Required | Details |
|---|---|---|---|
dst_nodeTarget node |
Resource | yes | |
stop_on_errorStop on error |
Boolean | no |
Default: |
maintenance_windowMaintenance_window |
Boolean | no |
Run migrations in every VPS's maintenance window Default: |
concurrencyConcurrency |
Integer | no |
How many migrations run concurrently Default: |
cleanup_dataCleanup_data |
Boolean | no |
Default: |
send_mailSend_mail |
Boolean | no |
Default: |
reasonReason |
String | no |
Default: |
Output parameters
| Parameter | Type | Description |
|---|---|---|
migration_plan_idMigration_plan_id |
Integer |
Index
Input parameters
| Parameter | Type | Required | Details | ||||
|---|---|---|---|---|---|---|---|
from_idFrom ID |
Integer | no |
List objects with IDs greater or lower than this value Default:
|
||||
limitLimit |
Integer | no |
Number of objects to retrieve Default:
|
||||
locationLocation |
Resource | no |
Location node is placed in |
||||
environmentEnvironment |
Resource | no | |||||
typeRole |
String | no |
node, storage or mailer Default:
|
||||
hypervisor_typeHypervisor type |
String | no |
vpsadminos Default:
|
||||
stateState |
String | no |
Default:
|
Output parameters
| Parameter | Type | Description |
|---|---|---|
idID |
Integer | Node ID |
activeActive |
Boolean | |
nameName |
String | Node name |
domain_nameDomain name |
String | Node name including location domain |
fqdnFQDN |
String | |
typeRole |
String | node, storage or mailer |
hypervisor_typeHypervisor type |
String | vpsadminos |
locationLocation |
Resource | Location node is placed in |
ip_addrIPv4 address |
String | Node's IP address |
max_txMax tx |
Integer | Maximum output throughput |
max_rxMax tx |
Integer | Maximum input throughput |
cpusCpus |
Integer | |
total_memoryTotal_memory |
Integer | |
total_swapTotal_swap |
Integer | |
max_vpsMax_vps |
Integer | |
statusStatus |
Boolean | |
uptimeUptime |
Integer | |
loadavg1Loadavg1 |
Float | |
loadavg5Loadavg5 |
Float | |
loadavg15Loadavg15 |
Float | |
process_countProcess count |
Integer | |
cpu_userCpu_user |
Float | |
cpu_niceCpu_nice |
Float | |
cpu_systemCpu_system |
Float | |
cpu_idleCpu_idle |
Float | |
cpu_iowaitCpu_iowait |
Float | |
cpu_irqCpu_irq |
Float | |
cpu_softirqCpu_softirq |
Float | |
cpu_guestCpu_guest |
Float | |
used_memoryUsed memory |
Integer | in MB |
used_swapUsed swap |
Integer | in MB |
arc_c_maxArc_c_max |
Integer | |
arc_cArc_c |
Integer | |
arc_sizeArc_size |
Integer | |
arc_hitpercentArc_hitpercent |
Integer | |
versionVersion |
String | 4 or 6 |
kernelKernel |
String | |
cgroup_versionCgroup version |
String | |
pool_statePool_state |
String | |
pool_scanPool_scan |
String | |
pool_scan_percentPool_scan_percent |
Float | |
pool_checked_atPool_checked_at |
Datetime | |
pool_statusPool_status |
Boolean | |
maintenance_lockMaintenance lock |
String | |
maintenance_lock_reasonMaintenance reason |
String |
Examples
Examples use an initialized api client, authenticated when required. See initialization and authentication.
Example #0
Ruby · Simple
reply = api.node.index
# reply is an instance of HaveAPI::Client::ResourceInstanceList,
# which is a subclass of Array
Ruby · With error handling
begin
require 'haveapi/client'
api = HaveAPI::Client.new("https://api.vpsfree.cz/", version: "7.0")
api.setup
api.authenticate(:token, token: 'example-token')
reply = api.node.index
# reply is an instance of HaveAPI::Client::ResourceInstanceList,
# which is a subclass of Array
rescue HaveAPI::Client::ValidationError => error
warn error.message
warn error.errors.inspect
rescue HaveAPI::Client::ActionFailed => error
warn error.message
warn error.response.errors.inspect if error.response.is_a?(HaveAPI::Client::Response)
rescue HaveAPI::Client::Authentication::AuthenticationFailed, HaveAPI::Client::ProtocolError,
RestClient::Exception, JSON::ParserError => error
warn error.message
end
JavaScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "index");
action.directInvoke({
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
JavaScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.authenticate("token", {token: "example-token"}, (api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "index");
action.directInvoke({
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
JavaScript (async) · Simple
const result = await api.resource("node").action("index")({params: {}});
console.log(result.value);
JavaScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main() {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.authenticate("token", {token: "example-token"});
const result = await api.resource("node").action("index")({params: {}});
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
TypeScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "index");
action.directInvoke({
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
TypeScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.authenticate("token", {token: "example-token"}, (api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "index");
action.directInvoke({
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
TypeScript (async) · Simple
const result = await api.resource("node").action("index")({params: {}});
console.log(result.value);
TypeScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main(): Promise<void> {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.authenticate("token", {token: "example-token"});
const result = await api.resource("node").action("index")({params: {}});
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
Python (sync) · Simple
response = api.resources["node"].actions["index"].call(params={})
print(response.data)
Python (sync) · With error handling
from haveapi_client import Client, ActionError, HaveAPIError, TokenAuth
try:
with Client("https://api.vpsfree.cz/", version="7.0", auth=TokenAuth("example-token")) as api:
response = api.resources["node"].actions["index"].call(params={})
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
Python (async) · Simple
# Run inside an async function after initializing api.
response = await api.resources["node"].actions["index"].call(params={})
print(response.data)
Python (async) · With error handling
import asyncio
from haveapi_client import AsyncClient, ActionError, HaveAPIError, TokenAuth
async def main() -> None:
try:
async with AsyncClient("https://api.vpsfree.cz/", version="7.0", auth=TokenAuth("example-token")) as api:
response = await api.resources["node"].actions["index"].call(params={})
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
asyncio.run(main())
Go API client · Simple
invocation := api.Node.Index.Prepare()
invocation.NewInput().SelectParameters()
response, err := invocation.Call()
if err != nil {
fmt.Println(err)
return
}
if !response.Status {
fmt.Println(response.Message, response.Errors)
return
}
for _, item := range response.Output {
if item != nil {
fmt.Println(item.Id)
fmt.Println(item.Name)
fmt.Println(item.Type)
if item.Location != nil {
fmt.Println(item.Location.Id)
fmt.Println(item.Location.Label)
}
fmt.Println(item.IpAddr)
fmt.Println(item.MaintenanceLock)
}
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().index().send().await?;
for item in &response.output {
println!("{:?}", &item.id);
println!("{:?}", &item.name);
println!("{:?}", &item.type_);
println!("{:?}", &item.location);
println!("{:?}", &item.ip_addr);
println!("{:?}", &item.maintenance_lock);
}
Rust API client (async) · With error handling
// cargo add vpsadmin-client
// cargo add tokio --features macros,rt-multi-thread
// cargo add serde_json
use vpsadmin_client::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.basic_auth("user", "secret")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().index().send().await {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
for item in &response.output {
println!("{:?}", &item.id);
println!("{:?}", &item.name);
println!("{:?}", &item.type_);
println!("{:?}", &item.location);
println!("{:?}", &item.ip_addr);
println!("{:?}", &item.maintenance_lock);
}
Ok(())
}
Rust API client (blocking) · Simple
// Use inside a synchronous function outside async runtime threads returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().index().send()?;
for item in &response.output {
println!("{:?}", &item.id);
println!("{:?}", &item.name);
println!("{:?}", &item.type_);
println!("{:?}", &item.location);
println!("{:?}", &item.ip_addr);
println!("{:?}", &item.maintenance_lock);
}
Rust API client (blocking) · With error handling
// cargo add vpsadmin-client --features blocking
// cargo add serde_json
// Construct, use and drop this blocking client outside async runtime threads.
use vpsadmin_client::blocking::Client;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.basic_auth("user", "secret")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().index().send() {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
for item in &response.output {
println!("{:?}", &item.id);
println!("{:?}", &item.name);
println!("{:?}", &item.type_);
println!("{:?}", &item.location);
println!("{:?}", &item.ip_addr);
println!("{:?}", &item.maintenance_lock);
}
Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.node.index();
for (const item of result.data) {
console.log(item.id);
console.log(item.name);
console.log(item.type);
console.log(item.location);
console.log(item.ip_addr);
console.log(item.maintenance_lock);
}
TypeScript API client · With error handling
// Configured API client: vpsadmin-typescript-client.
import { AsyncClient, AsyncError } from "haveapi-client";
import { createClient } from "vpsadmin-typescript-client";
async function main(): Promise<void> {
try {
const runtime = new AsyncClient("https://api.vpsfree.cz/v7.0");
await runtime.authenticate("basic", { user: "user", password: "secret" });
const api = createClient({ execute: spec => runtime.request(spec) });
const result = await api.node.index();
void [result.data, result.meta, result.envelope, result.httpStatus];
for (const item of result.data) {
const value0: unknown = item.id;
if (value0 !== null && value0 !== undefined) console.log(value0);
const value1: unknown = item.name;
if (value1 !== null && value1 !== undefined) console.log(value1);
const value2: unknown = item.type;
if (value2 !== null && value2 !== undefined) console.log(value2);
const value3: unknown = item.location;
if (value3 !== null && value3 !== undefined) console.log(value3);
const value4: unknown = item.ip_addr;
if (value4 !== null && value4 !== undefined) console.log(value4);
const value5: unknown = item.maintenance_lock;
if (value5 !== null && value5 !== undefined) console.log(value5);
}
} catch (error) {
if (!(error instanceof AsyncError)) throw error;
console.error(error.kind, error.httpStatus);
throw error;
}
}
main().catch(error => { throw error; });
PHP · Simple
$reply = $api->node->index();
// $reply is an instance of \HaveAPI\Client\ResourceInstanceList
PHP · With error handling
try {
$api = new \HaveAPI\Client('https://api.vpsfree.cz/', '7.0');
$api->setup();
$api->authenticate('token', ['token' => 'example-token']);
$reply = $api->node->index();
// $reply is an instance of \HaveAPI\Client\ResourceInstanceList
} catch (\HaveAPI\Client\Exception\ValidationError $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\ActionFailed $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\Base $error) {
echo $error->getMessage() . "\n";
} catch (\Exception $error) {
// Dependency failures still propagate to the application.
echo $error->getMessage() . "\n";
throw $error;
}
CLI · Simple
$ haveapi-cli -u https://api.vpsfree.cz/ --version 7.0 node index
# ID: 1
# Active: -
# Name: node1
# Domain name: -
# FQDN: -
# Role: node
# Hypervisor type: -
# Location: The Location (#1)
# IPv4 address: 192.168.0.10
# Max tx: -
# Max tx: -
# Cpus: -
# Total_memory: -
# Total_swap: -
# Max_vps: -
# Status: -
# Uptime: -
# Loadavg1: -
# Loadavg5: -
# Loadavg15: -
# Process count: -
# Cpu_user: -
# Cpu_nice: -
# Cpu_system: -
# Cpu_idle: -
# Cpu_iowait: -
# Cpu_irq: -
# Cpu_softirq: -
# Cpu_guest: -
# Used memory: -
# Used swap: -
# Arc_c_max: -
# Arc_c: -
# Arc_size: -
# Arc_hitpercent: -
# Version: -
# Kernel: -
# Cgroup version: -
# Pool_state: -
# Pool_scan: -
# Pool_scan_percent: -
# Pool_checked_at: -
# Pool_status: -
# Maintenance lock: no
# Maintenance reason: -
#
curl · Simple
$ curl --request GET \
--data-binary \{\"node\":\{\}\} \
https://api.vpsfree.cz/v7.0/nodes
# {
# "status": true,
# "message": null,
# "response": {
# "nodes": [
# {
# "id": 1,
# "name": "node1",
# "type": "node",
# "location": {
# "id": 1,
# "label": "The Location"
# },
# "ip_addr": "192.168.0.10",
# "maintenance_lock": "no"
# }
# ]
# },
# "errors": null
# }
HTTP · Simple
GET /v7.0/nodes HTTP/1.1
Host: api.vpsfree.cz
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 335
{
"status": true,
"message": null,
"response": {
"nodes": [
{
"id": 1,
"name": "node1",
"type": "node",
"location": {
"id": 1,
"label": "The Location"
},
"ip_addr": "192.168.0.10",
"maintenance_lock": "no"
}
]
},
"errors": null
}
Overview_list
Input parameters
No parameters.
Output parameters
| Parameter | Type | Description |
|---|---|---|
idID |
Integer | Node ID |
activeActive |
Boolean | |
nameName |
String | Node name |
domain_nameDomain name |
String | Node name including location domain |
fqdnFQDN |
String | |
typeRole |
String | node, storage or mailer |
hypervisor_typeHypervisor type |
String | vpsadminos |
locationLocation |
Resource | Location node is placed in |
ip_addrIPv4 address |
String | Node's IP address |
max_txMax tx |
Integer | Maximum output throughput |
max_rxMax tx |
Integer | Maximum input throughput |
cpusCpus |
Integer | |
total_memoryTotal_memory |
Integer | |
total_swapTotal_swap |
Integer | |
max_vpsMax_vps |
Integer | |
statusStatus |
Boolean | |
uptimeUptime |
Integer | |
loadavg1Loadavg1 |
Float | |
loadavg5Loadavg5 |
Float | |
loadavg15Loadavg15 |
Float | |
process_countProcess count |
Integer | |
cpu_userCpu_user |
Float | |
cpu_niceCpu_nice |
Float | |
cpu_systemCpu_system |
Float | |
cpu_idleCpu_idle |
Float | |
cpu_iowaitCpu_iowait |
Float | |
cpu_irqCpu_irq |
Float | |
cpu_softirqCpu_softirq |
Float | |
cpu_guestCpu_guest |
Float | |
used_memoryUsed memory |
Integer | in MB |
used_swapUsed swap |
Integer | in MB |
arc_c_maxArc_c_max |
Integer | |
arc_cArc_c |
Integer | |
arc_sizeArc_size |
Integer | |
arc_hitpercentArc_hitpercent |
Integer | |
versionVersion |
String | 4 or 6 |
kernelKernel |
String | |
cgroup_versionCgroup version |
String | |
pool_statePool_state |
String | |
pool_scanPool_scan |
String | |
pool_scan_percentPool_scan_percent |
Float | |
pool_checked_atPool_checked_at |
Datetime | |
pool_statusPool_status |
Boolean | |
last_reportLast report |
Datetime | |
vps_runningRunning VPS |
Integer | Number of running VPSes |
vps_stoppedStopped VPS |
Integer | Number of stopped VPSes |
vps_deletedDeleted VPS |
Integer | Number of lazily deleted VPSes |
vps_totalTotal VPS |
Integer | Total number of VPSes |
vps_freeFree VPS slots |
Integer | Number of free VPS slots |
vps_maxMax VPS slots |
Integer | Number of running VPSes |
maintenance_lockMaintenance lock |
String | |
maintenance_lock_reasonMaintenance reason |
String |
Public_status
Input parameters
No parameters.
Output parameters
| Parameter | Type | Description |
|---|---|---|
idId |
Integer | Node ID |
statusStatus |
Boolean | |
nameNode name |
String | Node name |
fqdnFQDN |
String | |
locationLocation |
Resource | Location node is placed in |
last_reportLast report |
Datetime | |
vps_countVPS count |
Integer | |
vps_freeFree VPS slots |
Integer | Number of free VPS slots |
kernelKernel |
String | |
typeRole |
String | node, storage or mailer |
hypervisor_typeHypervisor type |
String | vpsadminos |
cpu_idleCPU idle |
Float | |
cgroup_versionCgroup version |
String | |
pool_statePool_state |
String | |
pool_scanPool_scan |
String | |
pool_scan_percentPool_scan_percent |
Float | |
pool_checked_atPool_checked_at |
Datetime | |
pool_statusPool_status |
Boolean | |
maintenance_lockMaintenance lock |
String | |
maintenance_lock_reasonMaintenance reason |
String |
Examples
Examples use an initialized api client, authenticated when required. See initialization and authentication.
Example #0
Ruby · Simple
reply = api.node.public_status
# reply is an instance of HaveAPI::Client::ResourceInstanceList,
# which is a subclass of Array
Ruby · With error handling
begin
require 'haveapi/client'
api = HaveAPI::Client.new("https://api.vpsfree.cz/", version: "7.0")
api.setup
reply = api.node.public_status
# reply is an instance of HaveAPI::Client::ResourceInstanceList,
# which is a subclass of Array
rescue HaveAPI::Client::ValidationError => error
warn error.message
warn error.errors.inspect
rescue HaveAPI::Client::ActionFailed => error
warn error.message
warn error.response.errors.inspect if error.response.is_a?(HaveAPI::Client::Response)
rescue HaveAPI::Client::Authentication::AuthenticationFailed, HaveAPI::Client::ProtocolError,
RestClient::Exception, JSON::ParserError => error
warn error.message
end
JavaScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "public_status");
action.directInvoke({
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
JavaScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.setup((api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "public_status");
action.directInvoke({
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
JavaScript (async) · Simple
const result = await api.resource("node").action("public_status")();
console.log(result.value);
JavaScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main() {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.setup();
const result = await api.resource("node").action("public_status")();
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
TypeScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "public_status");
action.directInvoke({
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
TypeScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.setup((api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "public_status");
action.directInvoke({
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
TypeScript (async) · Simple
const result = await api.resource("node").action("public_status")();
console.log(result.value);
TypeScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main(): Promise<void> {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.setup();
const result = await api.resource("node").action("public_status")();
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
Python (sync) · Simple
response = api.resources["node"].actions["public_status"].call()
print(response.data)
Python (sync) · With error handling
from haveapi_client import Client, ActionError, HaveAPIError
try:
with Client("https://api.vpsfree.cz/", version="7.0") as api:
response = api.resources["node"].actions["public_status"].call()
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
Python (async) · Simple
# Run inside an async function after initializing api.
response = await api.resources["node"].actions["public_status"].call()
print(response.data)
Python (async) · With error handling
import asyncio
from haveapi_client import AsyncClient, ActionError, HaveAPIError
async def main() -> None:
try:
async with AsyncClient("https://api.vpsfree.cz/", version="7.0") as api:
response = await api.resources["node"].actions["public_status"].call()
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
asyncio.run(main())
Go API client · Simple
invocation := api.Node.PublicStatus.Prepare()
response, err := invocation.Call()
if err != nil {
fmt.Println(err)
return
}
if !response.Status {
fmt.Println(response.Message, response.Errors)
return
}
for _, item := range response.Output {
if item != nil {
fmt.Println(item.Status)
fmt.Println(item.Name)
if item.Location != nil {
fmt.Println(item.Location.Id)
fmt.Println(item.Location.Label)
}
fmt.Println(item.LastReport)
fmt.Println(item.VpsCount)
fmt.Println(item.VpsFree)
fmt.Println(item.Kernel)
fmt.Println(item.CpuIdle)
}
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().public_status().send().await?;
for item in &response.output {
println!("{:?}", &item.status);
println!("{:?}", &item.name);
println!("{:?}", &item.location);
println!("{:?}", &item.last_report);
println!("{:?}", &item.vps_count);
println!("{:?}", &item.vps_free);
println!("{:?}", &item.kernel);
println!("{:?}", &item.cpu_idle);
println!("{:?}", &item.maintenance_lock);
println!("{:?}", &item.maintenance_lock_reason);
}
Rust API client (async) · With error handling
// cargo add vpsadmin-client
// cargo add tokio --features macros,rt-multi-thread
// cargo add serde_json
use vpsadmin_client::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().public_status().send().await {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
for item in &response.output {
println!("{:?}", &item.status);
println!("{:?}", &item.name);
println!("{:?}", &item.location);
println!("{:?}", &item.last_report);
println!("{:?}", &item.vps_count);
println!("{:?}", &item.vps_free);
println!("{:?}", &item.kernel);
println!("{:?}", &item.cpu_idle);
println!("{:?}", &item.maintenance_lock);
println!("{:?}", &item.maintenance_lock_reason);
}
Ok(())
}
Rust API client (blocking) · Simple
// Use inside a synchronous function outside async runtime threads returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().public_status().send()?;
for item in &response.output {
println!("{:?}", &item.status);
println!("{:?}", &item.name);
println!("{:?}", &item.location);
println!("{:?}", &item.last_report);
println!("{:?}", &item.vps_count);
println!("{:?}", &item.vps_free);
println!("{:?}", &item.kernel);
println!("{:?}", &item.cpu_idle);
println!("{:?}", &item.maintenance_lock);
println!("{:?}", &item.maintenance_lock_reason);
}
Rust API client (blocking) · With error handling
// cargo add vpsadmin-client --features blocking
// cargo add serde_json
// Construct, use and drop this blocking client outside async runtime threads.
use vpsadmin_client::blocking::Client;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().public_status().send() {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
for item in &response.output {
println!("{:?}", &item.status);
println!("{:?}", &item.name);
println!("{:?}", &item.location);
println!("{:?}", &item.last_report);
println!("{:?}", &item.vps_count);
println!("{:?}", &item.vps_free);
println!("{:?}", &item.kernel);
println!("{:?}", &item.cpu_idle);
println!("{:?}", &item.maintenance_lock);
println!("{:?}", &item.maintenance_lock_reason);
}
Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.node.public_status();
for (const item of result.data) {
console.log(item.status);
console.log(item.name);
console.log(item.location);
console.log(item.last_report);
console.log(item.vps_count);
console.log(item.vps_free);
console.log(item.kernel);
console.log(item.cpu_idle);
console.log(item.maintenance_lock);
console.log(item.maintenance_lock_reason);
}
TypeScript API client · With error handling
// Configured API client: vpsadmin-typescript-client.
import { AsyncClient, AsyncError } from "haveapi-client";
import { createClient } from "vpsadmin-typescript-client";
async function main(): Promise<void> {
try {
const runtime = new AsyncClient("https://api.vpsfree.cz/v7.0");
const api = createClient({ execute: spec => runtime.request(spec) });
const result = await api.node.public_status();
void [result.data, result.meta, result.envelope, result.httpStatus];
for (const item of result.data) {
const value0: unknown = item.status;
if (value0 !== null && value0 !== undefined) console.log(value0);
const value1: unknown = item.name;
if (value1 !== null && value1 !== undefined) console.log(value1);
const value2: unknown = item.location;
if (value2 !== null && value2 !== undefined) console.log(value2);
const value3: unknown = item.last_report;
if (value3 !== null && value3 !== undefined) console.log(value3);
const value4: unknown = item.vps_count;
if (value4 !== null && value4 !== undefined) console.log(value4);
const value5: unknown = item.vps_free;
if (value5 !== null && value5 !== undefined) console.log(value5);
const value6: unknown = item.kernel;
if (value6 !== null && value6 !== undefined) console.log(value6);
const value7: unknown = item.cpu_idle;
if (value7 !== null && value7 !== undefined) console.log(value7);
const value8: unknown = item.maintenance_lock;
if (value8 !== null && value8 !== undefined) console.log(value8);
const value9: unknown = item.maintenance_lock_reason;
if (value9 !== null && value9 !== undefined) console.log(value9);
}
} catch (error) {
if (!(error instanceof AsyncError)) throw error;
console.error(error.kind, error.httpStatus);
throw error;
}
}
main().catch(error => { throw error; });
PHP · Simple
$reply = $api->node->public_status();
// $reply is an instance of \HaveAPI\Client\ResourceInstanceList
PHP · With error handling
try {
$api = new \HaveAPI\Client('https://api.vpsfree.cz/', '7.0');
$api->setup();
$reply = $api->node->public_status();
// $reply is an instance of \HaveAPI\Client\ResourceInstanceList
} catch (\HaveAPI\Client\Exception\ValidationError $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\ActionFailed $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\Base $error) {
echo $error->getMessage() . "\n";
} catch (\Exception $error) {
// Dependency failures still propagate to the application.
echo $error->getMessage() . "\n";
throw $error;
}
CLI · Simple
$ haveapi-cli -u https://api.vpsfree.cz/ --version 7.0 node public_status
# Id Status Node name FQDN Location Last report VPS count Free VPS slots Kernel Role Hypervisor type CPU idle Cgroup version Pool_state Pool_scan Pool_scan_percent Pool_checked_at Pool_status Maintenance lock Maintenance reason
# - true node1.prg - Prague (#1) 2016-11-20T08:30:50+01:00 68 12 2.6.32-042stab120.6 - - 65.3 - - - - - - - -
# - - node2.prg - Prague (#1) 2016-11-14T06:41:23+01:00 0 80 2.6.32-042stab120.6 - - 100.0 - - - - - - lock HW upgrade
# - true node3.prg - Prague (#1) 2016-11-20T08:30:46+01:00 65 15 2.6.32-042stab120.6 - - 72.6 - - - - - - - -
curl · Simple
$ curl --request GET \
--data-binary \{\"node\":null\} \
https://api.vpsfree.cz/v7.0/nodes/public_status
# {
# "status": true,
# "message": null,
# "response": {
# "nodes": [
# {
# "status": true,
# "name": "node1.prg",
# "location": {
# "id": 1,
# "label": "Prague"
# },
# "last_report": "2016-11-20T08:30:50+01:00",
# "vps_count": 68,
# "vps_free": 12,
# "kernel": "2.6.32-042stab120.6",
# "cpu_idle": 65.3
# },
# {
# "status": false,
# "name": "node2.prg",
# "location": {
# "id": 1,
# "label": "Prague"
# },
# "last_report": "2016-11-14T06:41:23+01:00",
# "vps_count": 0,
# "vps_free": 80,
# "kernel": "2.6.32-042stab120.6",
# "cpu_idle": 100.0,
# "maintenance_lock": "lock",
# "maintenance_lock_reason": "HW upgrade"
# },
# {
# "status": true,
# "name": "node3.prg",
# "location": {
# "id": 1,
# "label": "Prague"
# },
# "last_report": "2016-11-20T08:30:46+01:00",
# "vps_count": 65,
# "vps_free": 15,
# "kernel": "2.6.32-042stab120.6",
# "cpu_idle": 72.6
# }
# ]
# },
# "errors": null
# }
HTTP · Simple
GET /v7.0/nodes/public_status HTTP/1.1
Host: api.vpsfree.cz
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 1135
{
"status": true,
"message": null,
"response": {
"nodes": [
{
"status": true,
"name": "node1.prg",
"location": {
"id": 1,
"label": "Prague"
},
"last_report": "2016-11-20T08:30:50+01:00",
"vps_count": 68,
"vps_free": 12,
"kernel": "2.6.32-042stab120.6",
"cpu_idle": 65.3
},
{
"status": false,
"name": "node2.prg",
"location": {
"id": 1,
"label": "Prague"
},
"last_report": "2016-11-14T06:41:23+01:00",
"vps_count": 0,
"vps_free": 80,
"kernel": "2.6.32-042stab120.6",
"cpu_idle": 100.0,
"maintenance_lock": "lock",
"maintenance_lock_reason": "HW upgrade"
},
{
"status": true,
"name": "node3.prg",
"location": {
"id": 1,
"label": "Prague"
},
"last_report": "2016-11-20T08:30:46+01:00",
"vps_count": 65,
"vps_free": 15,
"kernel": "2.6.32-042stab120.6",
"cpu_idle": 72.6
}
]
},
"errors": null
}
Set_maintenance
Input parameters
| Parameter | Type | Required | Details | ||||
|---|---|---|---|---|---|---|---|
lockLock |
Boolean | yes |
Default:
|
||||
reasonReason |
String | no |
Default: |
Output parameters
No parameters.
Show
Input parameters
No parameters.
Output parameters
| Parameter | Type | Description |
|---|---|---|
idID |
Integer | Node ID |
activeActive |
Boolean | |
nameName |
String | Node name |
domain_nameDomain name |
String | Node name including location domain |
fqdnFQDN |
String | |
typeRole |
String | node, storage or mailer |
hypervisor_typeHypervisor type |
String | vpsadminos |
locationLocation |
Resource | Location node is placed in |
ip_addrIPv4 address |
String | Node's IP address |
max_txMax tx |
Integer | Maximum output throughput |
max_rxMax tx |
Integer | Maximum input throughput |
cpusCpus |
Integer | |
total_memoryTotal_memory |
Integer | |
total_swapTotal_swap |
Integer | |
max_vpsMax_vps |
Integer | |
statusStatus |
Boolean | |
uptimeUptime |
Integer | |
loadavg1Loadavg1 |
Float | |
loadavg5Loadavg5 |
Float | |
loadavg15Loadavg15 |
Float | |
process_countProcess count |
Integer | |
cpu_userCpu_user |
Float | |
cpu_niceCpu_nice |
Float | |
cpu_systemCpu_system |
Float | |
cpu_idleCpu_idle |
Float | |
cpu_iowaitCpu_iowait |
Float | |
cpu_irqCpu_irq |
Float | |
cpu_softirqCpu_softirq |
Float | |
cpu_guestCpu_guest |
Float | |
used_memoryUsed memory |
Integer | in MB |
used_swapUsed swap |
Integer | in MB |
arc_c_maxArc_c_max |
Integer | |
arc_cArc_c |
Integer | |
arc_sizeArc_size |
Integer | |
arc_hitpercentArc_hitpercent |
Integer | |
versionVersion |
String | 4 or 6 |
kernelKernel |
String | |
cgroup_versionCgroup version |
String | |
pool_statePool_state |
String | |
pool_scanPool_scan |
String | |
pool_scan_percentPool_scan_percent |
Float | |
pool_checked_atPool_checked_at |
Datetime | |
pool_statusPool_status |
Boolean | |
maintenance_lockMaintenance lock |
String | |
maintenance_lock_reasonMaintenance reason |
String |
Examples
Examples use an initialized api client, authenticated when required. See initialization and authentication.
Example #0
Ruby · Simple
reply = api.node.show(2)
# reply is an instance of HaveAPI::Client::ResourceInstance
# reply.id = 2
# reply.name = "node2"
# reply.type = "node"
# reply.location = HaveAPI::Client::ResourceInstance(resource: location, id: 1, label: "The Location")
# reply.ip_addr = "192.168.0.11"
# reply.maintenance_lock = "no"
Ruby · With error handling
begin
require 'haveapi/client'
api = HaveAPI::Client.new("https://api.vpsfree.cz/", version: "7.0")
api.setup
api.authenticate(:token, token: 'example-token')
reply = api.node.show(2)
# reply is an instance of HaveAPI::Client::ResourceInstance
# reply.id = 2
# reply.name = "node2"
# reply.type = "node"
# reply.location = HaveAPI::Client::ResourceInstance(resource: location, id: 1, label: "The Location")
# reply.ip_addr = "192.168.0.11"
# reply.maintenance_lock = "no"
rescue HaveAPI::Client::ValidationError => error
warn error.message
warn error.errors.inspect
rescue HaveAPI::Client::ActionFailed => error
warn error.message
warn error.response.errors.inspect if error.response.is_a?(HaveAPI::Client::Response)
rescue HaveAPI::Client::Authentication::AuthenticationFailed, HaveAPI::Client::ProtocolError,
RestClient::Exception, JSON::ParserError => error
warn error.message
end
JavaScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "show");
action.directInvoke(2, {
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
JavaScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.authenticate("token", {token: "example-token"}, (api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "show");
action.directInvoke(2, {
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
JavaScript (async) · Simple
const result = await api.resource("node").action("show")(2, {params: {}});
console.log(result.value);
JavaScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main() {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.authenticate("token", {token: "example-token"});
const result = await api.resource("node").action("show")(2, {params: {}});
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
TypeScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "show");
action.directInvoke(2, {
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
TypeScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.authenticate("token", {token: "example-token"}, (api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "show");
action.directInvoke(2, {
params: {},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
TypeScript (async) · Simple
const result = await api.resource("node").action("show")(2, {params: {}});
console.log(result.value);
TypeScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main(): Promise<void> {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.authenticate("token", {token: "example-token"});
const result = await api.resource("node").action("show")(2, {params: {}});
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
Python (sync) · Simple
response = api.resources["node"].actions["show"].call(path_params={"node_id": 2}, params={})
print(response.data)
Python (sync) · With error handling
from haveapi_client import Client, ActionError, HaveAPIError, TokenAuth
try:
with Client("https://api.vpsfree.cz/", version="7.0", auth=TokenAuth("example-token")) as api:
response = api.resources["node"].actions["show"].call(path_params={"node_id": 2}, params={})
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
Python (async) · Simple
# Run inside an async function after initializing api.
response = await api.resources["node"].actions["show"].call(path_params={"node_id": 2}, params={})
print(response.data)
Python (async) · With error handling
import asyncio
from haveapi_client import AsyncClient, ActionError, HaveAPIError, TokenAuth
async def main() -> None:
try:
async with AsyncClient("https://api.vpsfree.cz/", version="7.0", auth=TokenAuth("example-token")) as api:
response = await api.resources["node"].actions["show"].call(path_params={"node_id": 2}, params={})
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
asyncio.run(main())
Go API client · Simple
invocation := api.Node.Show.Prepare()
invocation.SetPathParamInt("node_id", 2)
response, err := invocation.Call()
if err != nil {
fmt.Println(err)
return
}
if !response.Status {
fmt.Println(response.Message, response.Errors)
return
}
if response.Output != nil {
fmt.Println(response.Output.Id)
fmt.Println(response.Output.Name)
fmt.Println(response.Output.Type)
if response.Output.Location != nil {
fmt.Println(response.Output.Location.Id)
fmt.Println(response.Output.Location.Label)
}
fmt.Println(response.Output.IpAddr)
fmt.Println(response.Output.MaintenanceLock)
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().show("2").send().await?;
println!("{:?}", &response.output.id);
println!("{:?}", &response.output.name);
println!("{:?}", &response.output.type_);
println!("{:?}", &response.output.location);
println!("{:?}", &response.output.ip_addr);
println!("{:?}", &response.output.maintenance_lock);
Rust API client (async) · With error handling
// cargo add vpsadmin-client
// cargo add tokio --features macros,rt-multi-thread
// cargo add serde_json
use vpsadmin_client::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.basic_auth("user", "secret")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().show("2").send().await {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
println!("{:?}", &response.output.id);
println!("{:?}", &response.output.name);
println!("{:?}", &response.output.type_);
println!("{:?}", &response.output.location);
println!("{:?}", &response.output.ip_addr);
println!("{:?}", &response.output.maintenance_lock);
Ok(())
}
Rust API client (blocking) · Simple
// Use inside a synchronous function outside async runtime threads returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().show("2").send()?;
println!("{:?}", &response.output.id);
println!("{:?}", &response.output.name);
println!("{:?}", &response.output.type_);
println!("{:?}", &response.output.location);
println!("{:?}", &response.output.ip_addr);
println!("{:?}", &response.output.maintenance_lock);
Rust API client (blocking) · With error handling
// cargo add vpsadmin-client --features blocking
// cargo add serde_json
// Construct, use and drop this blocking client outside async runtime threads.
use vpsadmin_client::blocking::Client;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.basic_auth("user", "secret")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().show("2").send() {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
println!("{:?}", &response.output.id);
println!("{:?}", &response.output.name);
println!("{:?}", &response.output.type_);
println!("{:?}", &response.output.location);
println!("{:?}", &response.output.ip_addr);
println!("{:?}", &response.output.maintenance_lock);
Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.node.show({ "path": { "node_id": 2 } });
console.log(result.data.id);
console.log(result.data.name);
console.log(result.data.type);
console.log(result.data.location);
console.log(result.data.ip_addr);
console.log(result.data.maintenance_lock);
TypeScript API client · With error handling
// Configured API client: vpsadmin-typescript-client.
import { AsyncClient, AsyncError } from "haveapi-client";
import { createClient } from "vpsadmin-typescript-client";
async function main(): Promise<void> {
try {
const runtime = new AsyncClient("https://api.vpsfree.cz/v7.0");
await runtime.authenticate("basic", { user: "user", password: "secret" });
const api = createClient({ execute: spec => runtime.request(spec) });
const result = await api.node.show({ "path": { "node_id": 2 } });
void [result.data, result.meta, result.envelope, result.httpStatus];
const item = result.data;
const value0: unknown = item.id;
if (value0 !== null && value0 !== undefined) console.log(value0);
const value1: unknown = item.name;
if (value1 !== null && value1 !== undefined) console.log(value1);
const value2: unknown = item.type;
if (value2 !== null && value2 !== undefined) console.log(value2);
const value3: unknown = item.location;
if (value3 !== null && value3 !== undefined) console.log(value3);
const value4: unknown = item.ip_addr;
if (value4 !== null && value4 !== undefined) console.log(value4);
const value5: unknown = item.maintenance_lock;
if (value5 !== null && value5 !== undefined) console.log(value5);
} catch (error) {
if (!(error instanceof AsyncError)) throw error;
console.error(error.kind, error.httpStatus);
throw error;
}
}
main().catch(error => { throw error; });
PHP · Simple
$reply = $api->node->show(2);
// $reply is an instance of \HaveAPI\Client\ResourceInstance
// $reply->id = 2
// $reply->name = "node2"
// $reply->type = "node"
// $reply->location = \HaveAPI\Client\ResourceInstance(resource: location, id: 1, label: "The Location")
// $reply->ip_addr = "192.168.0.11"
// $reply->maintenance_lock = "no"
PHP · With error handling
try {
$api = new \HaveAPI\Client('https://api.vpsfree.cz/', '7.0');
$api->setup();
$api->authenticate('token', ['token' => 'example-token']);
$reply = $api->node->show(2);
// $reply is an instance of \HaveAPI\Client\ResourceInstance
// $reply->id = 2
// $reply->name = "node2"
// $reply->type = "node"
// $reply->location = \HaveAPI\Client\ResourceInstance(resource: location, id: 1, label: "The Location")
// $reply->ip_addr = "192.168.0.11"
// $reply->maintenance_lock = "no"
} catch (\HaveAPI\Client\Exception\ValidationError $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\ActionFailed $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\Base $error) {
echo $error->getMessage() . "\n";
} catch (\Exception $error) {
// Dependency failures still propagate to the application.
echo $error->getMessage() . "\n";
throw $error;
}
CLI · Simple
$ haveapi-cli -u https://api.vpsfree.cz/ --version 7.0 node show 2
# ID: 2
# Active: -
# Name: node2
# Domain name: -
# FQDN: -
# Role: node
# Hypervisor type: -
# Location: The Location (#1)
# IPv4 address: 192.168.0.11
# Max tx: -
# Max tx: -
# Cpus: -
# Total_memory: -
# Total_swap: -
# Max_vps: -
# Status: -
# Uptime: -
# Loadavg1: -
# Loadavg5: -
# Loadavg15: -
# Process count: -
# Cpu_user: -
# Cpu_nice: -
# Cpu_system: -
# Cpu_idle: -
# Cpu_iowait: -
# Cpu_irq: -
# Cpu_softirq: -
# Cpu_guest: -
# Used memory: -
# Used swap: -
# Arc_c_max: -
# Arc_c: -
# Arc_size: -
# Arc_hitpercent: -
# Version: -
# Kernel: -
# Cgroup version: -
# Pool_state: -
# Pool_scan: -
# Pool_scan_percent: -
# Pool_checked_at: -
# Pool_status: -
# Maintenance lock: no
# Maintenance reason: -
#
curl · Simple
$ curl --request GET \
--data-binary \{\"node\":\{\}\} \
https://api.vpsfree.cz/v7.0/nodes/2
# {
# "status": true,
# "message": null,
# "response": {
# "node": {
# "id": 2,
# "name": "node2",
# "type": "node",
# "location": {
# "id": 1,
# "label": "The Location"
# },
# "ip_addr": "192.168.0.11",
# "maintenance_lock": "no"
# }
# },
# "errors": null
# }
HTTP · Simple
GET /v7.0/nodes/2 HTTP/1.1
Host: api.vpsfree.cz
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 300
{
"status": true,
"message": null,
"response": {
"node": {
"id": 2,
"name": "node2",
"type": "node",
"location": {
"id": 1,
"label": "The Location"
},
"ip_addr": "192.168.0.11",
"maintenance_lock": "no"
}
},
"errors": null
}
Update
Input parameters
| Parameter | Type | Required | Details | ||||
|---|---|---|---|---|---|---|---|
activeActive |
Boolean | no |
Default: |
||||
nameName |
String | no |
Node name Default:
|
||||
fqdnFQDN |
String | no |
Default: |
||||
typeRole |
String | no |
node, storage or mailer Default:
|
||||
hypervisor_typeHypervisor type |
String | no |
vpsadminos Default:
|
||||
locationLocation |
Resource | no |
Location node is placed in |
||||
ip_addrIPv4 address |
String | no |
Node's IP address Default:
|
||||
max_txMax tx |
Integer | no |
Maximum output throughput Default: |
||||
max_rxMax tx |
Integer | no |
Maximum input throughput Default: |
||||
max_vpsMax_vps |
Integer | no |
Default: |
Output parameters
No parameters.
Examples
Examples use an initialized api client, authenticated when required. See initialization and authentication.
Example #0
Ruby · Simple
reply = api.node.update(2, {name: "node2", type: "storage", location: 1, ip_addr: "192.168.0.11"})
# reply is an instance of HaveAPI::Client::ResourceInstance
Ruby · With error handling
begin
require 'haveapi/client'
api = HaveAPI::Client.new("https://api.vpsfree.cz/", version: "7.0")
api.setup
api.authenticate(:token, token: 'example-token')
reply = api.node.update(2, {name: "node2", type: "storage", location: 1, ip_addr: "192.168.0.11"})
# reply is an instance of HaveAPI::Client::ResourceInstance
rescue HaveAPI::Client::ValidationError => error
warn error.message
warn error.errors.inspect
rescue HaveAPI::Client::ActionFailed => error
warn error.message
warn error.response.errors.inspect if error.response.is_a?(HaveAPI::Client::Response)
rescue HaveAPI::Client::Authentication::AuthenticationFailed, HaveAPI::Client::ProtocolError,
RestClient::Exception, JSON::ParserError => error
warn error.message
end
JavaScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "update");
action.directInvoke(2, {
params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
JavaScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.authenticate("token", {token: "example-token"}, (api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "update");
action.directInvoke(2, {
params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
JavaScript (async) · Simple
const result = await api.resource("node").action("update")(2, {params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"}});
console.log(result.value);
JavaScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main() {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.authenticate("token", {token: "example-token"});
const result = await api.resource("node").action("update")(2, {params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"}});
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
TypeScript (callback) · Simple
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "update");
action.directInvoke(2, {
params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
}
});
TypeScript (callback) · With error handling
import { CallbackClient } from "haveapi-client";
const api = new CallbackClient("https://api.vpsfree.cz/", {version: "7.0"});
api.authenticate("token", {token: "example-token"}, (api, ready) => {
if (!ready) {
console.error("Discovery or authentication failed");
return;
}
try {
const resource = CallbackClient.findResource(api, ["node"]);
const action = CallbackClient.findAction(resource, "update");
action.directInvoke(2, {
params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"},
onReply: (owner, reply) => {
if (!reply.isOk()) {
console.error(reply.message(), reply.envelope.errors);
return;
}
console.log(reply.response());
console.log(reply.meta());
}
});
} catch (error) {
console.error(error);
}
});
TypeScript (async) · Simple
const result = await api.resource("node").action("update")(2, {params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"}});
console.log(result.value);
TypeScript (async) · With error handling
import { AsyncClient, AsyncError } from "haveapi-client";
async function main(): Promise<void> {
const api = new AsyncClient("https://api.vpsfree.cz/", {version: "7.0"});
try {
await api.authenticate("token", {token: "example-token"});
const result = await api.resource("node").action("update")(2, {params: {["name"]: "node2", ["type"]: "storage", ["location"]: 1, ["ip_addr"]: "192.168.0.11"}});
console.log(result.value);
console.log(result.response.meta);
} catch (error) {
if (error instanceof AsyncError) {
console.error(error.kind, error.message, error.errors);
} else {
throw error;
}
}
}
main().catch(error => console.error(error));
Python (sync) · Simple
response = api.resources["node"].actions["update"].call(path_params={"node_id": 2}, params={"name": "node2", "type": "storage", "location": 1, "ip_addr": "192.168.0.11"})
print(response.data)
Python (sync) · With error handling
from haveapi_client import Client, ActionError, HaveAPIError, TokenAuth
try:
with Client("https://api.vpsfree.cz/", version="7.0", auth=TokenAuth("example-token")) as api:
response = api.resources["node"].actions["update"].call(path_params={"node_id": 2}, params={"name": "node2", "type": "storage", "location": 1, "ip_addr": "192.168.0.11"})
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
Python (async) · Simple
# Run inside an async function after initializing api.
response = await api.resources["node"].actions["update"].call(path_params={"node_id": 2}, params={"name": "node2", "type": "storage", "location": 1, "ip_addr": "192.168.0.11"})
print(response.data)
Python (async) · With error handling
import asyncio
from haveapi_client import AsyncClient, ActionError, HaveAPIError, TokenAuth
async def main() -> None:
try:
async with AsyncClient("https://api.vpsfree.cz/", version="7.0", auth=TokenAuth("example-token")) as api:
response = await api.resources["node"].actions["update"].call(path_params={"node_id": 2}, params={"name": "node2", "type": "storage", "location": 1, "ip_addr": "192.168.0.11"})
print(response.data)
print(response.meta)
except ActionError as error:
print(error.message, error.errors)
except HaveAPIError as error:
print(error.message, error.status_code)
asyncio.run(main())
Go API client · Simple
invocation := api.Node.Update.Prepare()
invocation.SetPathParamInt("node_id", 2)
input := invocation.NewInput().SelectParameters()
input.SetName("node2")
input.SetType("storage")
input.SetLocation(1)
input.SetIpAddr("192.168.0.11")
response, err := invocation.Call()
if err != nil {
fmt.Println(err)
return
}
if !response.Status {
fmt.Println(response.Message, response.Errors)
return
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().update("2").name("node2".to_owned()).type_("storage".to_owned()).location(1_i64).ip_addr("192.168.0.11".to_owned()).send().await?;
Rust API client (async) · With error handling
// cargo add vpsadmin-client
// cargo add tokio --features macros,rt-multi-thread
// cargo add serde_json
use vpsadmin_client::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.basic_auth("user", "secret")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().update("2").name("node2".to_owned()).type_("storage".to_owned()).location(1_i64).ip_addr("192.168.0.11".to_owned()).send().await {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
Ok(())
}
Rust API client (blocking) · Simple
// Use inside a synchronous function outside async runtime threads returning Result<(), Box<dyn std::error::Error>>.
let response = api.node().update("2").name("node2".to_owned()).type_("storage".to_owned()).location(1_i64).ip_addr("192.168.0.11".to_owned()).send()?;
Rust API client (blocking) · With error handling
// cargo add vpsadmin-client --features blocking
// cargo add serde_json
// Construct, use and drop this blocking client outside async runtime threads.
use vpsadmin_client::blocking::Client;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = match Client::builder("https://api.vpsfree.cz/")
.basic_auth("user", "secret")
.build() {
Ok(api) => api,
Err(error) => {
eprintln!("Client configuration failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let response = match api.node().update("2").name("node2".to_owned()).type_("storage".to_owned()).location(1_i64).ip_addr("192.168.0.11".to_owned()).send() {
Ok(response) => response,
Err(error) => {
eprintln!("Request failed: {}", error);
eprintln!("HTTP status: {:?}; timeout: {}", error.http_status(), error.is_timeout());
return Err(error.into());
}
};
let _ = response.http_status;
let _ = &response.meta;
Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.node.update({ "path": { "node_id": 2 }, "params": { "name": "node2", "type": "storage", "location": 1, "ip_addr": "192.168.0.11" } });
TypeScript API client · With error handling
// Configured API client: vpsadmin-typescript-client.
import { AsyncClient, AsyncError } from "haveapi-client";
import { createClient } from "vpsadmin-typescript-client";
async function main(): Promise<void> {
try {
const runtime = new AsyncClient("https://api.vpsfree.cz/v7.0");
await runtime.authenticate("basic", { user: "user", password: "secret" });
const api = createClient({ execute: spec => runtime.request(spec) });
const result = await api.node.update({ "path": { "node_id": 2 }, "params": { "name": "node2", "type": "storage", "location": 1, "ip_addr": "192.168.0.11" } });
void [result.data, result.meta, result.envelope, result.httpStatus];
const item = result.data;
} catch (error) {
if (!(error instanceof AsyncError)) throw error;
console.error(error.kind, error.httpStatus);
throw error;
}
}
main().catch(error => { throw error; });
PHP · Simple
$reply = $api->node->update(2, [
'name' => 'node2',
'type' => 'storage',
'location' => 1,
'ip_addr' => '192.168.0.11'
]);
// $reply is an instance of \HaveAPI\Client\ResourceInstance
PHP · With error handling
try {
$api = new \HaveAPI\Client('https://api.vpsfree.cz/', '7.0');
$api->setup();
$api->authenticate('token', ['token' => 'example-token']);
$reply = $api->node->update(2, [
'name' => 'node2',
'type' => 'storage',
'location' => 1,
'ip_addr' => '192.168.0.11'
]);
// $reply is an instance of \HaveAPI\Client\ResourceInstance
} catch (\HaveAPI\Client\Exception\ValidationError $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\ActionFailed $error) {
echo $error->getMessage() . "\n";
print_r($error->getErrors());
} catch (\HaveAPI\Client\Exception\Base $error) {
echo $error->getMessage() . "\n";
} catch (\Exception $error) {
// Dependency failures still propagate to the application.
echo $error->getMessage() . "\n";
throw $error;
}
CLI · Simple
$ haveapi-cli -u https://api.vpsfree.cz/ --version 7.0 node update 2 -- \
--name node2 \
--type storage \
--location 1 \
--ip-addr 192.168.0.11
curl · Simple
$ curl --request PUT \
--data-binary \{\"node\":\{\"name\":\"node2\",\"type\":\"storage\",\"location\":1,\"ip_addr\":\"192.168.0.11\"\}\} \
https://api.vpsfree.cz/v7.0/nodes/2
# {
# "status": true,
# "message": null,
# "response": {
# "node": {}
# },
# "errors": null
# }
HTTP · Simple
PUT /v7.0/nodes/2 HTTP/1.1
Host: api.vpsfree.cz
Content-Type: application/json
{
"node": {
"name": "node2",
"type": "storage",
"location": 1,
"ip_addr": "192.168.0.11"
}
}
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 93
{
"status": true,
"message": null,
"response": {
"node": {}
},
"errors": null
}