cluster
Manage cluster
Full_stats
Input parameters
No parameters.
Output parameters
| Parameter | Type | Description |
|---|---|---|
nodes_onlineNodes_online |
Integer | |
node_countNode_count |
Integer | |
vps_runningVps_running |
Integer | Number of running VPSes |
vps_stoppedVps_stopped |
Integer | Number of stopped VPSes |
vps_suspendedVps_suspended |
Integer | |
vps_deletedVps_deleted |
Integer | Number of lazily deleted VPSes |
vps_countVps_count |
Integer | |
user_activeUser_active |
Integer | |
user_suspendedUser_suspended |
Integer | |
user_deletedUser_deleted |
Integer | |
user_countUser_count |
Integer | |
ipv4_usedIpv4_used |
Integer | |
ipv4_countIpv4_count |
Integer |
Generate_migration_keys
Public_stats
Input parameters
No parameters.
Output parameters
| Parameter | Type | Description |
|---|---|---|
user_countNumber of users |
Integer | |
vps_countNumber of VPSes |
Integer | |
ipv4_leftNumber of free public IPv4 addresses |
Integer |
Examples
Examples use an initialized api client, authenticated when required. See initialization and authentication.
Example #0
Ruby · Simple
reply = api.cluster.public_stats
# reply is an instance of HaveAPI::Client::ResourceInstance
# reply.user_count = 1100
# reply.vps_count = 1560
# reply.ipv4_left = 256
Ruby · With error handling
begin
require 'haveapi/client'
api = HaveAPI::Client.new("https://api.vpsfree.cz/", version: "7.0")
api.setup
reply = api.cluster.public_stats
# reply is an instance of HaveAPI::Client::ResourceInstance
# reply.user_count = 1100
# reply.vps_count = 1560
# reply.ipv4_left = 256
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, ["cluster"]);
const action = CallbackClient.findAction(resource, "public_stats");
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, ["cluster"]);
const action = CallbackClient.findAction(resource, "public_stats");
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("cluster").action("public_stats")();
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("cluster").action("public_stats")();
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, ["cluster"]);
const action = CallbackClient.findAction(resource, "public_stats");
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, ["cluster"]);
const action = CallbackClient.findAction(resource, "public_stats");
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("cluster").action("public_stats")();
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("cluster").action("public_stats")();
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["cluster"].actions["public_stats"].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["cluster"].actions["public_stats"].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["cluster"].actions["public_stats"].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["cluster"].actions["public_stats"].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.Cluster.PublicStats.Prepare()
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.UserCount)
fmt.Println(response.Output.VpsCount)
fmt.Println(response.Output.Ipv4Left)
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.cluster().public_stats().send().await?;
println!("{:?}", &response.output.user_count);
println!("{:?}", &response.output.vps_count);
println!("{:?}", &response.output.ipv4_left);
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.cluster().public_stats().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.user_count);
println!("{:?}", &response.output.vps_count);
println!("{:?}", &response.output.ipv4_left);
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.cluster().public_stats().send()?;
println!("{:?}", &response.output.user_count);
println!("{:?}", &response.output.vps_count);
println!("{:?}", &response.output.ipv4_left);
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.cluster().public_stats().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.user_count);
println!("{:?}", &response.output.vps_count);
println!("{:?}", &response.output.ipv4_left);
Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.cluster.public_stats();
console.log(result.data.user_count);
console.log(result.data.vps_count);
console.log(result.data.ipv4_left);
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.cluster.public_stats();
void [result.data, result.meta, result.envelope, result.httpStatus];
const item = result.data;
const value0: unknown = item.user_count;
if (value0 !== null && value0 !== undefined) console.log(value0);
const value1: unknown = item.vps_count;
if (value1 !== null && value1 !== undefined) console.log(value1);
const value2: unknown = item.ipv4_left;
if (value2 !== null && value2 !== undefined) console.log(value2);
} 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->cluster->public_stats();
// $reply is an instance of \HaveAPI\Client\ResourceInstance
// $reply->user_count = 1100
// $reply->vps_count = 1560
// $reply->ipv4_left = 256
PHP · With error handling
try {
$api = new \HaveAPI\Client('https://api.vpsfree.cz/', '7.0');
$api->setup();
$reply = $api->cluster->public_stats();
// $reply is an instance of \HaveAPI\Client\ResourceInstance
// $reply->user_count = 1100
// $reply->vps_count = 1560
// $reply->ipv4_left = 256
} 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 cluster public_stats
# Number of users: 1100
# Number of VPSes: 1560
# Number of free public IPv4 addresses: 256
#
curl · Simple
$ curl --request GET \
--data-binary \{\"cluster\":null\} \
https://api.vpsfree.cz/v7.0/cluster/public_stats
# {
# "status": true,
# "message": null,
# "response": {
# "cluster": {
# "user_count": 1100,
# "vps_count": 1560,
# "ipv4_left": 256
# }
# },
# "errors": null
# }
HTTP · Simple
GET /v7.0/cluster/public_stats 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: 175
{
"status": true,
"message": null,
"response": {
"cluster": {
"user_count": 1100,
"vps_count": 1560,
"ipv4_left": 256
}
},
"errors": null
}
Search
Input parameters
| Parameter | Type | Required | Details | ||||
|---|---|---|---|---|---|---|---|
valueValue |
String | yes |
Value to be searched for Default:
|
Output parameters
| Parameter | Type | Description |
|---|---|---|
resourceResource |
String | Resource name of the located object |
idID |
Integer | Identifier of the located object |
attributeAttribute |
String | Name of the attribute containing the searched value |
valueValue |
String | Located value |
Set_maintenance
Input parameters
| Parameter | Type | Required | Details | ||||
|---|---|---|---|---|---|---|---|
lockLock |
Boolean | yes |
Default:
|
||||
reasonReason |
String | no |
Default: |
Output parameters
No parameters.