ByCloud Docs
GuidesCLIAPISDK

JavaScript SDK

Compute

Virtual machines, flavors, images, and keypairs

18 methods

GET

listFlavors()

List flavors

Parameters

limit

integer

- Maximum number of items to return

marker

string

- ID of the last item from the previous page (for pagination)

min_ram

integer

- Filter by minimum RAM (MB)

min_disk

integer

- Filter by minimum disk (GB)

min_vcpus

integer

- Filter by minimum vCPUs

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.listFlavors();
console.log(result);
GET

getFlavor()

Get flavor

Parameters

flavor_id

string

required

- Flavor ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.getFlavor({
flavor_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
GET

listImages()

List images

Parameters

limit

integer

- Maximum number of items to return

marker

string

- ID of the last item from the previous page (for pagination)

name

string

- Filter by name (exact match or prefix with *)

status

string

- Filter by status

tags

string

- Filter by tags (comma-separated)

visibility

string

- Filter by visibility

os_distro

string

- Filter by OS distribution

os_version

string

- Filter by OS version

architecture

string

- Filter by architecture

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.listImages();
console.log(result);
GET

getImage()

Get image

Parameters

image_id

string

required

- Image ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.getImage({
image_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
GET

listInstances()

List instances

Parameters

limit

integer

- Maximum number of items to return

marker

string

- ID of the last item from the previous page (for pagination)

name

string

- Filter by name (exact match or prefix with *)

status

string

- Filter by status

tags

string

- Filter by tags (comma-separated)

flavor_id

string

- Filter by flavor ID

image_id

string

- Filter by image ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.listInstances();
console.log(result);
POST

createInstance()

Create instance

Parameters

name

string

required
description

string

flavor_id

string

required

- Flavor ID

image_id

string

- Image ID (required if not booting from volume)

key_names

array

- SSH keypair names to authorize on the instance

security_groups

array

- Security group names or IDs

networks

array

- Networks to attach

assign_public_ip

boolean

- Assign a public IP address to the instance

volumes

array

- Volume attachments for boot from volume

metadata

object

tags

array

user_data

string

- Base64-encoded user data (cloud-init)

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.createInstance({
name: "web-server-01",
flavor_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
GET

getInstance()

Get instance

Parameters

instance_id

string

required

- Instance ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.getInstance({
instance_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
PATCH

updateInstance()

Update instance

Parameters

instance_id

string

required

- Instance ID

name

string

description

string

metadata

object

tags

array

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.updateInstance({
instance_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
DELETE

deleteInstance()

Delete instance

Parameters

instance_id

string

required

- Instance ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.deleteInstance({
instance_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
GET

getInstanceConsole()

Get instance console

Parameters

instance_id

string

required

- Instance ID

type

string

- Console type

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.getInstanceConsole({
instance_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
POST

rebootInstance()

Reboot instance

Parameters

instance_id

string

required

- Instance ID

type

string

- Reboot type

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.rebootInstance({
instance_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
POST

resizeInstance()

Resize instance

Parameters

instance_id

string

required

- Instance ID

flavor_id

string

required

- New flavor ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.resizeInstance({
instance_id: "550e8400-e29b-41d4-a716-446655440000",
flavor_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
POST

startInstance()

Start instance

Parameters

instance_id

string

required

- Instance ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.startInstance({
instance_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
POST

stopInstance()

Stop instance

Parameters

instance_id

string

required

- Instance ID

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.stopInstance({
instance_id: "550e8400-e29b-41d4-a716-446655440000"
});
console.log(result);
GET

listKeypairs()

List keypairs

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.listKeypairs();
console.log(result);
POST

createKeypair()

Create keypair

Parameters

name

string

required
public_key

string

- SSH public key (if not provided, a new keypair will be generated)

type

string

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.createKeypair({
name: "my-keypair"
});
console.log(result);
GET

getKeypair()

Get keypair

Parameters

keypair_name

string

required

- Keypair name

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.getKeypair({
keypair_name: "example"
});
console.log(result);
DELETE

deleteKeypair()

Delete keypair

Parameters

keypair_name

string

required

- Keypair name

Example

import { ByCloud } from "@bycoded/bycloud-sdk";
const client = new ByCloud({
token: "YOUR_ACCESS_TOKEN",
});
const result = await client.compute.deleteKeypair({
keypair_name: "example"
});
console.log(result);