Skip to content

Servers

OnCloud edited this page Jan 3, 2025 · 2 revisions

Important

Before making API calls, client must be initialized.

Build

Official documentation

const name = "my-server";  // Server name
const hostname = "my-server.example.com";  // FQDN
const operatingSystemId = 1;  // ID of the operating system template. Which can be found in Dashboard > Operating System Templates, the ending number of the URL.
const sshKeys = [1, 2, 3];  // IDs of the SSH keys

const serverBuild = await virtfusion.server.build(serverCreate.data.id, {
  name,
  hostname,
  operatingSystemId,
  sshKeys,
});

Create

Official documentation

const packageId = 1;  // ID of the package
const userId = 1;  // ID of the user
const hypervisorId = 1;  // ID of the hypervisor

const serverCreate = await virtfusion.server.create({
  packageId,
  userId,
  hypervisorId,
  ipv4: 1,  // Number of IPv4 address
});

Delete

Official documentation

const serverId = 1;  // ID of the server
const delay = 0;  // Delay in minutes

const serverDelete = await virtfusion.server.delete(serverId, 0);

List

Official documentation

const responseType = "simple";  // "full" or "simple"

const serverList = await virtfusion.server.list({
  responseType,
  page: 1,
  limit: 5,
});

Retrieve

Official documentation

const serverId = 1;  // ID of the server

const serverData = await virtfusion.server.retrieve(serverId);

Traffic Statistics

Official documentation

const serverId = 1;  // ID of the server

const serverTraffic = await virtfusion.server.traffic(serverId);
Clone this wiki locally