Skip to content

location

Manage locations

Create

Input parameters

ParameterTypeRequiredDetails
label
Label
String no

Location label

Default: null

description
Description
String no

Location description

Default: null

has_ipv6
Has IPv6
Boolean no

True if location has IPv6 addresses

Default: null

Validation rules
RuleDetails
Include

Allowed values:

  • true
  • false

Validation error message: %{value} cannot be used

remote_console_server
Remote console server
String no

URL to HTTP remote console server

Default: null

Validation rules
RuleDetails
Format

Must match this regular expression:

\A(https?://.+)?\z

null

Validation error message: invalid format

domain
Domain
String no

Location domain, subdomain at environment domain

Default: null

Validation rules
RuleDetails
Format

Must match this regular expression:

\A[0-9a-zA-Z\-.]{3,255}\z

null

Validation error message: invalid format

environment
Environment
Resource no

Filter locations by environment

Output parameters

ParameterTypeDescription
id
ID
Integer Location ID
label
Label
String Location label
description
Description
String Location description
has_ipv6
Has IPv6
Boolean True if location has IPv6 addresses
remote_console_server
Remote console server
String URL to HTTP remote console server
domain
Domain
String Location domain, subdomain at environment domain
environment
Environment
Resource Filter locations by environment

Examples

Examples use an initialized api client, authenticated when required. See initialization and authentication.

Example #0

Ruby · Simple
reply = api.location.create({label: "Brno", has_ipv6: true, remote_console_server: "", domain: "brq"})

# reply is an instance of HaveAPI::Client::ResourceInstance
# reply.id = 2
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.location.create({label: "Brno", has_ipv6: true, remote_console_server: "", domain: "brq"})

  # reply is an instance of HaveAPI::Client::ResourceInstance
  # reply.id = 2
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, ["location"]);
const action = CallbackClient.findAction(resource, "create");
action.directInvoke({
  params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"},
  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, ["location"]);
    const action = CallbackClient.findAction(resource, "create");
    action.directInvoke({
      params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"},
      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("location").action("create")({params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"}});
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("location").action("create")({params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"}});
    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, ["location"]);
const action = CallbackClient.findAction(resource, "create");
action.directInvoke({
  params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"},
  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, ["location"]);
    const action = CallbackClient.findAction(resource, "create");
    action.directInvoke({
      params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"},
      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("location").action("create")({params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"}});
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("location").action("create")({params: {["label"]: "Brno", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "brq"}});
    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["location"].actions["create"].call(params={"label": "Brno", "has_ipv6": True, "remote_console_server": "", "domain": "brq"})
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["location"].actions["create"].call(params={"label": "Brno", "has_ipv6": True, "remote_console_server": "", "domain": "brq"})
        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["location"].actions["create"].call(params={"label": "Brno", "has_ipv6": True, "remote_console_server": "", "domain": "brq"})
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["location"].actions["create"].call(params={"label": "Brno", "has_ipv6": True, "remote_console_server": "", "domain": "brq"})
            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.Location.Create.Prepare()
input := invocation.NewInput().SelectParameters()
input.SetLabel("Brno")
input.SetHasIpv6(true)
input.SetRemoteConsoleServer("")
input.SetDomain("brq")
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)
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.location().create().label("Brno".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("brq".to_owned()).send().await?;
println!("{:?}", &response.output.id);
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.location().create().label("Brno".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("brq".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;
    println!("{:?}", &response.output.id);
    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.location().create().label("Brno".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("brq".to_owned()).send()?;
println!("{:?}", &response.output.id);
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.location().create().label("Brno".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("brq".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;
    println!("{:?}", &response.output.id);
    Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.location.create({ "params": { "label": "Brno", "has_ipv6": true, "remote_console_server": "", "domain": "brq" } });
console.log(result.data.id);
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.location.create({ "params": { "label": "Brno", "has_ipv6": true, "remote_console_server": "", "domain": "brq" } });
    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);
  } 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->location->create([
    'label' => 'Brno',
    'has_ipv6' => true,
    'remote_console_server' => '',
    'domain' => 'brq'
]);

// $reply is an instance of \HaveAPI\Client\ResourceInstance
// $reply->id = 2
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->location->create([
        'label' => 'Brno',
        'has_ipv6' => true,
        'remote_console_server' => '',
        'domain' => 'brq'
    ]);

    // $reply is an instance of \HaveAPI\Client\ResourceInstance
    // $reply->id = 2
} 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 location create -- \
              --label Brno \
              --has-ipv6 \
              --remote-console-server '' \
              --domain brq
#                     ID:  2
#                  Label:  -
#            Description:  -
#               Has IPv6:  -
#  Remote console server:  -
#                 Domain:  -
#            Environment:  -
# 
curl · Simple
$ curl --request POST \
       --data-binary \{\"location\":\{\"label\":\"Brno\",\"has_ipv6\":true,\"remote_console_server\":\"\",\"domain\":\"brq\"\}\} \
       https://api.vpsfree.cz/v7.0/locations

# {
#   "status": true,
#   "message": null,
#   "response": {
#     "location": {
#       "id": 2
#     }
#   },
#   "errors": null
# }
HTTP · Simple
POST /v7.0/locations HTTP/1.1
Host: api.vpsfree.cz
Content-Type: application/json

{
  "location": {
    "label": "Brno",
    "has_ipv6": true,
    "remote_console_server": "",
    "domain": "brq"
  }
}

HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 116

{
  "status": true,
  "message": null,
  "response": {
    "location": {
      "id": 2
    }
  },
  "errors": null
}

Index

Input parameters

ParameterTypeRequiredDetails
from_id
From ID
Integer no

List objects with IDs greater or lower than this value

Default: null

Validation rules
RuleDetails
Number
  • Must be a number after parameter type conversion.
  • Minimum: 0 (inclusive).

Validation error message: must be at least 0

limit
Limit
Integer no

Number of objects to retrieve

Default: null

Validation rules
RuleDetails
Number
  • Must be a number after parameter type conversion.
  • Minimum: 0 (inclusive).
  • Maximum: 1000 (inclusive).

Validation error message: must be between 0 and 1000

environment
Environment
Resource no

Filter locations by environment

has_hypervisor
Has hypervisor
Boolean no

List only locations having at least one hypervisor node

Default: null

has_storage
Has storage
Boolean no

List only locations having at least one storage node

Default: null

hypervisor_type
Hypervisor type
String no

List only locations having at least one node of this type

Default: null

Validation rules
RuleDetails
Include

Allowed values:

  • vpsadminos

Validation error message: %{value} cannot be used

shares_v4_networks_with
Shares IPv4 networks with location
Resource no
shares_v6_networks_with
Shares IPv4 networks with location
Resource no
shares_any_networks_with
Shares IPv4 networks with location
Resource no
shares_networks_primary
Shared network primary
Boolean no

Filter locations with shared networks that are primary in the other location

Default: null

Output parameters

ParameterTypeDescription
id
ID
Integer Location ID
label
Label
String Location label
description
Description
String Location description
has_ipv6
Has IPv6
Boolean True if location has IPv6 addresses
remote_console_server
Remote console server
String URL to HTTP remote console server
domain
Domain
String Location domain, subdomain at environment domain
environment
Environment
Resource Filter locations by environment
maintenance_lock
Maintenance lock
String
maintenance_lock_reason
Maintenance reason
String

Examples

Examples use an initialized api client, authenticated when required. See initialization and authentication.

Example #0

Ruby · Simple
reply = api.location.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

  reply = api.location.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, ["location"]);
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.setup((api, ready) => {
  if (!ready) {
    console.error("Discovery or authentication failed");
    return;
  }
  try {
    const resource = CallbackClient.findResource(api, ["location"]);
    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("location").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.setup();
    const result = await api.resource("location").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, ["location"]);
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.setup((api, ready) => {
  if (!ready) {
    console.error("Discovery or authentication failed");
    return;
  }
  try {
    const resource = CallbackClient.findResource(api, ["location"]);
    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("location").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.setup();
    const result = await api.resource("location").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["location"].actions["index"].call(params={})
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["location"].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["location"].actions["index"].call(params={})
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["location"].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.Location.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.Label)
		fmt.Println(item.HasIpv6)
		fmt.Println(item.RemoteConsoleServer)
		fmt.Println(item.Domain)
	}
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.location().index().send().await?;
for item in &response.output {
    println!("{:?}", &item.label);
    println!("{:?}", &item.has_ipv6);
    println!("{:?}", &item.remote_console_server);
    println!("{:?}", &item.domain);
}
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.location().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.label);
        println!("{:?}", &item.has_ipv6);
        println!("{:?}", &item.remote_console_server);
        println!("{:?}", &item.domain);
    }
    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.location().index().send()?;
for item in &response.output {
    println!("{:?}", &item.label);
    println!("{:?}", &item.has_ipv6);
    println!("{:?}", &item.remote_console_server);
    println!("{:?}", &item.domain);
}
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.location().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.label);
        println!("{:?}", &item.has_ipv6);
        println!("{:?}", &item.remote_console_server);
        println!("{:?}", &item.domain);
    }
    Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.location.index();
for (const item of result.data) {
  console.log(item.label);
  console.log(item.has_ipv6);
  console.log(item.remote_console_server);
  console.log(item.domain);
}
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.location.index();
    void [result.data, result.meta, result.envelope, result.httpStatus];
    for (const item of result.data) {
      const value0: unknown = item.label;
      if (value0 !== null && value0 !== undefined) console.log(value0);
      const value1: unknown = item.has_ipv6;
      if (value1 !== null && value1 !== undefined) console.log(value1);
      const value2: unknown = item.remote_console_server;
      if (value2 !== null && value2 !== undefined) console.log(value2);
      const value3: unknown = item.domain;
      if (value3 !== null && value3 !== undefined) console.log(value3);
    }
  } 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->location->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();

    $reply = $api->location->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 location index
#                     ID:  -
#                  Label:  Prague
#            Description:  -
#               Has IPv6:  true
#  Remote console server:  https://console.vpsadmin.mydomain.com
#                 Domain:  prg
#            Environment:  -
#       Maintenance lock:  -
#     Maintenance reason:  -
# 
curl · Simple
$ curl --request GET \
       --data-binary \{\"location\":\{\}\} \
       https://api.vpsfree.cz/v7.0/locations

# {
#   "status": true,
#   "message": null,
#   "response": {
#     "locations": [
#       {
#         "label": "Prague",
#         "has_ipv6": true,
#         "remote_console_server": "https://console.vpsadmin.mydomain.com",
#         "domain": "prg"
#       }
#     ]
#   },
#   "errors": null
# }
HTTP · Simple
GET /v7.0/locations 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: 270

{
  "status": true,
  "message": null,
  "response": {
    "locations": [
      {
        "label": "Prague",
        "has_ipv6": true,
        "remote_console_server": "https://console.vpsadmin.mydomain.com",
        "domain": "prg"
      }
    ]
  },
  "errors": null
}

Set_maintenance

Input parameters

ParameterTypeRequiredDetails
lock
Lock
Boolean yes

Default: null

Validation rules
RuleDetails
Present

Must be supplied and cannot be null. Must not be empty; strings must contain a non-whitespace character.

Validation error message: must be present and non-empty

reason
Reason
String no

Default: ""

Output parameters

No parameters.

Show

Input parameters

No parameters.

Output parameters

ParameterTypeDescription
id
ID
Integer Location ID
label
Label
String Location label
description
Description
String Location description
has_ipv6
Has IPv6
Boolean True if location has IPv6 addresses
remote_console_server
Remote console server
String URL to HTTP remote console server
domain
Domain
String Location domain, subdomain at environment domain
environment
Environment
Resource Filter locations by environment
maintenance_lock
Maintenance lock
String
maintenance_lock_reason
Maintenance reason
String

Examples

Examples use an initialized api client, authenticated when required. See initialization and authentication.

Example #0

Ruby · Simple
reply = api.location.show(2)

# reply is an instance of HaveAPI::Client::ResourceInstance
# reply.id = 2
# reply.label = "Brno"
# reply.has_ipv6 = true
# reply.remote_console_server = ""
# reply.domain = "brq"
Ruby · With error handling
begin
  require 'haveapi/client'

  api = HaveAPI::Client.new("https://api.vpsfree.cz/", version: "7.0")
  api.setup

  reply = api.location.show(2)

  # reply is an instance of HaveAPI::Client::ResourceInstance
  # reply.id = 2
  # reply.label = "Brno"
  # reply.has_ipv6 = true
  # reply.remote_console_server = ""
  # reply.domain = "brq"
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, ["location"]);
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.setup((api, ready) => {
  if (!ready) {
    console.error("Discovery or authentication failed");
    return;
  }
  try {
    const resource = CallbackClient.findResource(api, ["location"]);
    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("location").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.setup();
    const result = await api.resource("location").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, ["location"]);
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.setup((api, ready) => {
  if (!ready) {
    console.error("Discovery or authentication failed");
    return;
  }
  try {
    const resource = CallbackClient.findResource(api, ["location"]);
    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("location").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.setup();
    const result = await api.resource("location").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["location"].actions["show"].call(path_params={"location_id": 2}, params={})
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["location"].actions["show"].call(path_params={"location_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["location"].actions["show"].call(path_params={"location_id": 2}, params={})
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["location"].actions["show"].call(path_params={"location_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.Location.Show.Prepare()
invocation.SetPathParamInt("location_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.Label)
	fmt.Println(response.Output.HasIpv6)
	fmt.Println(response.Output.RemoteConsoleServer)
	fmt.Println(response.Output.Domain)
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.location().show("2").send().await?;
println!("{:?}", &response.output.id);
println!("{:?}", &response.output.label);
println!("{:?}", &response.output.has_ipv6);
println!("{:?}", &response.output.remote_console_server);
println!("{:?}", &response.output.domain);
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.location().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.label);
    println!("{:?}", &response.output.has_ipv6);
    println!("{:?}", &response.output.remote_console_server);
    println!("{:?}", &response.output.domain);
    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.location().show("2").send()?;
println!("{:?}", &response.output.id);
println!("{:?}", &response.output.label);
println!("{:?}", &response.output.has_ipv6);
println!("{:?}", &response.output.remote_console_server);
println!("{:?}", &response.output.domain);
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.location().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.label);
    println!("{:?}", &response.output.has_ipv6);
    println!("{:?}", &response.output.remote_console_server);
    println!("{:?}", &response.output.domain);
    Ok(())
}
TypeScript API client · Simple
// Requires an initialized api and an async context.
const result = await api.location.show({ "path": { "location_id": 2 } });
console.log(result.data.id);
console.log(result.data.label);
console.log(result.data.has_ipv6);
console.log(result.data.remote_console_server);
console.log(result.data.domain);
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.location.show({ "path": { "location_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.label;
    if (value1 !== null && value1 !== undefined) console.log(value1);
    const value2: unknown = item.has_ipv6;
    if (value2 !== null && value2 !== undefined) console.log(value2);
    const value3: unknown = item.remote_console_server;
    if (value3 !== null && value3 !== undefined) console.log(value3);
    const value4: unknown = item.domain;
    if (value4 !== null && value4 !== undefined) console.log(value4);
  } 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->location->show(2);

// $reply is an instance of \HaveAPI\Client\ResourceInstance
// $reply->id = 2
// $reply->label = "Brno"
// $reply->has_ipv6 = true
// $reply->remote_console_server = ""
// $reply->domain = "brq"
PHP · With error handling
try {
    $api = new \HaveAPI\Client('https://api.vpsfree.cz/', '7.0');
    $api->setup();

    $reply = $api->location->show(2);

    // $reply is an instance of \HaveAPI\Client\ResourceInstance
    // $reply->id = 2
    // $reply->label = "Brno"
    // $reply->has_ipv6 = true
    // $reply->remote_console_server = ""
    // $reply->domain = "brq"
} 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 location show 2
#                     ID:  2
#                  Label:  Brno
#            Description:  -
#               Has IPv6:  true
#  Remote console server:  -
#                 Domain:  brq
#            Environment:  -
#       Maintenance lock:  -
#     Maintenance reason:  -
# 
curl · Simple
$ curl --request GET \
       --data-binary \{\"location\":\{\}\} \
       https://api.vpsfree.cz/v7.0/locations/2

# {
#   "status": true,
#   "message": null,
#   "response": {
#     "location": {
#       "id": 2,
#       "label": "Brno",
#       "has_ipv6": true,
#       "remote_console_server": "",
#       "domain": "brq"
#     }
#   },
#   "errors": null
# }
HTTP · Simple
GET /v7.0/locations/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: 221

{
  "status": true,
  "message": null,
  "response": {
    "location": {
      "id": 2,
      "label": "Brno",
      "has_ipv6": true,
      "remote_console_server": "",
      "domain": "brq"
    }
  },
  "errors": null
}

Update

Input parameters

ParameterTypeRequiredDetails
label
Label
String no

Location label

Default: null

description
Description
String no

Location description

Default: null

has_ipv6
Has IPv6
Boolean no

True if location has IPv6 addresses

Default: null

Validation rules
RuleDetails
Include

Allowed values:

  • true
  • false

Validation error message: %{value} cannot be used

remote_console_server
Remote console server
String no

URL to HTTP remote console server

Default: null

Validation rules
RuleDetails
Format

Must match this regular expression:

\A(https?://.+)?\z

null

Validation error message: invalid format

domain
Domain
String no

Location domain, subdomain at environment domain

Default: null

Validation rules
RuleDetails
Format

Must match this regular expression:

\A[0-9a-zA-Z\-.]{3,255}\z

null

Validation error message: invalid format

environment
Environment
Resource no

Filter locations by environment

Output parameters

ParameterTypeDescription
id
ID
Integer Location ID
label
Label
String Location label
description
Description
String Location description
has_ipv6
Has IPv6
Boolean True if location has IPv6 addresses
remote_console_server
Remote console server
String URL to HTTP remote console server
domain
Domain
String Location domain, subdomain at environment domain
environment
Environment
Resource Filter locations by environment

Examples

Examples use an initialized api client, authenticated when required. See initialization and authentication.

Example #0

Ruby · Simple
reply = api.location.update(2, {label: "Ostrava",
 has_ipv6: true,
 remote_console_server: "",
 domain: "ova",
 environment: 1})

# 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.location.update(2, {label: "Ostrava",
   has_ipv6: true,
   remote_console_server: "",
   domain: "ova",
   environment: 1})

  # 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, ["location"]);
const action = CallbackClient.findAction(resource, "update");
action.directInvoke(2, {
  params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1},
  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, ["location"]);
    const action = CallbackClient.findAction(resource, "update");
    action.directInvoke(2, {
      params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1},
      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("location").action("update")(2, {params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1}});
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("location").action("update")(2, {params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1}});
    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, ["location"]);
const action = CallbackClient.findAction(resource, "update");
action.directInvoke(2, {
  params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1},
  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, ["location"]);
    const action = CallbackClient.findAction(resource, "update");
    action.directInvoke(2, {
      params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1},
      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("location").action("update")(2, {params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1}});
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("location").action("update")(2, {params: {["label"]: "Ostrava", ["has_ipv6"]: true, ["remote_console_server"]: "", ["domain"]: "ova", ["environment"]: 1}});
    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["location"].actions["update"].call(path_params={"location_id": 2}, params={"label": "Ostrava", "has_ipv6": True, "remote_console_server": "", "domain": "ova", "environment": 1})
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["location"].actions["update"].call(path_params={"location_id": 2}, params={"label": "Ostrava", "has_ipv6": True, "remote_console_server": "", "domain": "ova", "environment": 1})
        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["location"].actions["update"].call(path_params={"location_id": 2}, params={"label": "Ostrava", "has_ipv6": True, "remote_console_server": "", "domain": "ova", "environment": 1})
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["location"].actions["update"].call(path_params={"location_id": 2}, params={"label": "Ostrava", "has_ipv6": True, "remote_console_server": "", "domain": "ova", "environment": 1})
            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.Location.Update.Prepare()
invocation.SetPathParamInt("location_id", 2)
input := invocation.NewInput().SelectParameters()
input.SetLabel("Ostrava")
input.SetHasIpv6(true)
input.SetRemoteConsoleServer("")
input.SetDomain("ova")
input.SetEnvironment(1)
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 {
}
Rust API client (async) · Simple
// Use inside an async function returning Result<(), Box<dyn std::error::Error>>.
let response = api.location().update("2").label("Ostrava".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("ova".to_owned()).environment(1_i64).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.location().update("2").label("Ostrava".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("ova".to_owned()).environment(1_i64).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.location().update("2").label("Ostrava".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("ova".to_owned()).environment(1_i64).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.location().update("2").label("Ostrava".to_owned()).has_ipv6(true).remote_console_server("".to_owned()).domain("ova".to_owned()).environment(1_i64).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.location.update({ "path": { "location_id": 2 }, "params": { "label": "Ostrava", "has_ipv6": true, "remote_console_server": "", "domain": "ova", "environment": 1 } });
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.location.update({ "path": { "location_id": 2 }, "params": { "label": "Ostrava", "has_ipv6": true, "remote_console_server": "", "domain": "ova", "environment": 1 } });
    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->location->update(2, [
    'label' => 'Ostrava',
    'has_ipv6' => true,
    'remote_console_server' => '',
    'domain' => 'ova',
    'environment' => 1
]);

// $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->location->update(2, [
        'label' => 'Ostrava',
        'has_ipv6' => true,
        'remote_console_server' => '',
        'domain' => 'ova',
        'environment' => 1
    ]);

    // $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 location update 2 -- \
              --label Ostrava \
              --has-ipv6 \
              --remote-console-server '' \
              --domain ova \
              --environment 1
curl · Simple
$ curl --request PUT \
       --data-binary \{\"location\":\{\"label\":\"Ostrava\",\"has_ipv6\":true,\"remote_console_server\":\"\",\"domain\":\"ova\",\"environment\":1\}\} \
       https://api.vpsfree.cz/v7.0/locations/2

# {
#   "status": true,
#   "message": null,
#   "response": {
#     "location": {}
#   },
#   "errors": null
# }
HTTP · Simple
PUT /v7.0/locations/2 HTTP/1.1
Host: api.vpsfree.cz
Content-Type: application/json

{
  "location": {
    "label": "Ostrava",
    "has_ipv6": true,
    "remote_console_server": "",
    "domain": "ova",
    "environment": 1
  }
}

HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 97

{
  "status": true,
  "message": null,
  "response": {
    "location": {}
  },
  "errors": null
}