Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

API Reference [experimental]

Felix edited this page Oct 26, 2020 · 17 revisions

Devices

/device/info

Returns public information about a device

Required parameters:

  • device_uuid: UUID of the device [string, UUID]

Responses:

  • Success:
{
  "uuid": "<UUID of the device [string, UUID]>",
  "name": "<Name of the device [string]>",
  "owner": "<Owner of the device [string]>",
  "powered_on": "<Device powered on [boolean]>",
  "starter_device": "<Device is the starter device [boolean]>",
  "hardware": [{
    "uuid": "<UUID of the hardware part [string, UUID]>",
    "device_uuid": "<UUID of the device the part belongs to, [string, UUID]>",
    "hardware_element": "<Name of the part [string]",
    "hardware_type": "<Type of the part (cpu, gpu, mainboard, disk or ram) [string]"
  }]
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}

/device/ping

Returns power state of a device

Required parameters:

  • device_uuid: UUID of the device [string, UUID]

Responses:

  • Device is online:
{"online": true}
  • Device is offline:
{"online": false}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}

/device/all

Returns all devices you own

No parameters

Responses:

  • Success:
{
  "devices": [{
    "uuid": "<UUID of the device [string, UUID]>",
    "name": "<Name of the device [string]>",
    "owner": "<Owner of the device [string, UUID]>",
    "powered_on": "<Device powered on [boolean]>",
    "starter_device": "<Device is the starter device [boolean]>"
  }]
}

/device/create

Creates a device

Required parameters:

  • gpu: The names of the graphics processing units [List[string]]
  • cpu: The names of the central processing units [List[string]]
  • mainboard: The name of the mainboard [string]
  • ram: The names of the memory units [List[string]]
  • disk: The names of the disks [List[string]]
  • processorCooler: The names of the cpu coolers [List[string]]
  • powerPack: The name of the power pack [string]
  • case: The name of the case [string]

Responses:

  • Success:
{
  "uuid": "<UUID of the device [string, UUID]>",
  "name": "<Name of the device [string]>",
  "owner": "<Owner of the device [string, UUID]>",
  "powered_on": "<Device powered on [boolean]>",
  "starter_device": false
}
  • You already reached the maximum number of devices a user can have:
{"error": "maximum_devices_reached", "origin": "user"}
  • A part does not exist in the game config (gpu, cpu, mainboard, ram, disk, processorCooler, powerPack or case):
{"error": "element_<part>_not_found"}
  • A part is missing from the inventory (gpu, cpu, mainboard, ram, disk, processorCooler, powerPack or case):
{"error": "<part>_not_in_inventory"}
  • No cpu was chosen:
{"error": "missing_cpu"}
  • No memory was chosen:
{"error": "missing_ram"}
  • No disk was chosen:
{"error": "missing_disk"}
  • The number of cpu coolers does not match the number of cpus:
{"error": "invalid_amount_of_cpu_coolers"}
  • The case is not compatible with the mainboard:
{"error": "incompatible_case"}
  • The mainboard does not have enough cpu slots:
{"error": "not_enough_cpu_slots"}
  • One of the cpu sockets is not compatible with the mainboard
{"error": "incompatible_cpu_socket"}
  • One of the cpu cooler sockets is not compatible with the mainboard
{"error": "incompatible_cooler_socket"}
  • An external gpu is required but not installed:
{"error": "missing_external_gpu"}
  • A gpu is not compatible with the motherboard:
{"error": "no_compatible_expansion_slot_for_gpu"}
  • A disk is not compatible with the motherboard:
{"error": "no_compatible_expansion_slot_for_disk"}
  • The mainboard does not have enough ram slots:
{"error": "not_enough_ram_slots"}
  • One of the ram units is not compatible with the mainboard because of the ram type:
{"error": "incompatible_ram_type"}
  • One of the ram units is not compatible with the mainboard because of the frequency:
{"error": "incompatible_ram_frequency"}
  • The total ram limit of the mainboard has been exceeded:
{"error": "ram_limit_exceeded"}
  • The power pack is insufficient:
{"error": "insufficient_power_pack"}

/device/starter_device

Creates a device to start from

No parameters

Responses:

  • Success:
{
  "uuid": "<UUID of the device [string, UUID]>",
  "name": "<Name of the device [string]>",
  "owner": "<Owner of the device [string, UUID]>",
  "powered_on": "<Device powered on [boolean]>",
  "starter_device": true
}
  • You already have a device:
{"error": "already_own_a_device"}

/device/power

Turns a device on or off

Required parameters:

  • device_uuid: UUID of the device [string, UUID]

Responses:

  • Success:
{
  "uuid": "<UUID of the device [string, UUID]>",
  "name": "<Name of the device [string]>",
  "owner": "<Owner of the device [string, UUID]>",
  "powered_on": "<Device powered on [boolean]>",
  "starter_device": "<Device is the starter device [boolean]>",
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}

/device/change_name

Changes the name of a device

Required parameters:

  • device_uuid: UUID of the device you want to rename [string, UUID]
  • name: The name you want to change to [string, 1-15 characters]

Responses:

  • Success:
{
  "uuid": "<UUID of the device>",
  "name": "<Name of the device>",
  "owner": "<Owner of the device>",
  "powered_on": "<Device powered on [boolean]>",
  "starter_device": "<Device is the starter device [boolean]>",
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • No permission to access the device
{"error": "permission_denied", "origin": "user"}
  • The device is powered off
{"error": "device_powered_off", "origin": "user"}

/device/delete

Deletes a device, including services

Required parameters:

  • device_uuid: UUID of the device you want to delete [string, UUID]

Responses:

  • Success:
{"ok": true}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}
  • The device cannot be deleted because it is the starter device:
{"error": "device_is_starter_device", "origin": "user"}

/device/spot

Returns a random device

No parameters

Responses:

  • Success:
{
  "uuid": "<UUID of the device [string, UUID]>",
  "name": "<Name of the device [string]>",
  "owner": "<Owner of the device [string, UUID]>",
  "powered_on": "<Device powered on [boolean]>",
  "starter_device": "<Device is the starter device [boolean]>",
}

/exist [MS]

Returns whether a device with a specific UUID exists

Required parameters:

  • device_uuid: UUID of the device you want to know whether it exists or not [string, UUID]

Responses:

  • The device exists:
{"exist": true}
  • The device does not exist:
{"exist": false}

/ping [MS]

Returns if the device is powered on

Required parameters:

  • device_uuid: UUID of the device [string, UUID]

Responses:

  • Device is powered on:
{"online": true}
  • Device is powered off:
{"online": false}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}

/owner [MS]

Returns the owner of a specific device

Required parameters:

  • device_uuid: UUID of the device you want to know the owner from [string, UUID]

Responses:

  • Success:
{"owner": "<UUID of the owner of the device [string, UUID]>"}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}

/delete_user [MS]

Deletes all devices of a user

Required parameters:

  • user_uuid UUID of the user to delete [string, UUID]

Responses:

  • Success:
{"ok": true}

Files

/file/all

Returns all files of a device

Required parameters:

  • device_uuid: UUID of the device you want to get all files from [string, UUID]
  • parent_dir_uuid: UUID of the parent directory you want to get all files from [string, UUID]

Responses:

  • Success:
{
  "files": [{
    "uuid": "<UUID of the file [string, UUID]>",
    "device": "<UUID of the device the file is on [string, UUID]>",
    "filename": "<Name of the file [string]>",
    "content": "<Content of the file [string]>",
    "parent_dir_uuid": "<UUID of the directory the file is in [string, UUID]>",
    "is_directory": "<If the file is a directory [boolean]>"
  }]
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}
  • The device is powered off
{"error": "device_powered_off", "origin": "user"}

/file/info

Returns information about a file

Required parameters:

  • device_uuid: UUID of the device the file you want to get information about is on [string, UUID]
  • file_uuid: UUID of the file you want to get information about [string, UUID]

Responses:

  • Success:
{
  "uuid": "<UUID of the file [string, UUID]>",
  "device": "<UUID of the device the file is on [string, UUID]>",
  "filename": "<Name of the file [string]>",
  "content": "<Content of the file [string]>",
  "parent_dir_uuid": "<UUID of the directory the file is in [string, UUID]>",
  "is_directory": "<If the file is a directory [boolean]>"
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • The file does not exist:
{"error": "file_not_found", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}
  • The device is powered off
{"error": "device_powered_off", "origin": "user"}

/file/move

Moves or renames a file to another location

Required parameters:

  • device_uuid: UUID of the device the file you want to move is on [string, UUID]
  • file_uuid: UUID of the file you want to move [string, UUID]
  • new_parent_dir_uuid: UUID of the directory you want to move the file to [string, UUID]
  • new_filename: New filename [string, 1-64 characters]

Responses:

  • Success:
{
  "uuid": "<UUID of the file [string, UUID]>",
  "device": "<UUID of the device the file is on [string, UUID]>",
  "filename": "<Name of the file [string]>",
  "content": "<Content of the file [string]>",
  "parent_dir_uuid": "<UUID of the directory the file is in [string, UUID]>",
  "is_directory": "<If the file is a directory [boolean]>"
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • The file does not exist:
{"error": "file_not_found", "origin": "user"}
  • A file with the specified filename already exists:
{"error": "file_already_exists", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}
  • The directory you want to move the file to does not exist:
{"error": "parent_directory_not_found", "origin": "user"}
  • You can not move the directory in itself or a subdirectory of itself:
{"error": "can_not_move_dir_into_itself", "origin": "user"}
  • The device is powered off
{"error": "device_powered_off", "origin": "user"}

/file/update

Changes the content of a file

Required parameters:

  • device_uuid: UUID of the device the file you want to change is on [string, UUID]
  • file_uuid: UUID of the file you want to change [string, UUID]
  • content: New content of the file [string, 0-255 characters]

Responses:

  • Success:
{
  "uuid": "<UUID of the file [string, UUID]>",
  "device": "<UUID of the device the file is on [string, UUID]>",
  "filename": "<Name of the file [string]>",
  "content": "<Content of the file [string]>",
  "parent_dir_uuid": "<UUID of the directory the file is in [string, UUID]>",
  "is_directory": "<If the file is a directory [boolean]>"
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • The file does not exist:
{"error": "file_not_found", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}
  • Directories can not be updated:
{"error": "directories_can_not_be_updated", "origin": "user"}
  • The device is powered off
{"error": "device_powered_off", "origin": "user"}

/file/delete

Deletes a file

Required parameters:

  • device_uuid: UUID of the device the file you want to delete is on [string, UUID]
  • file_uuid: UUID of the file you want to delete [string, UUID]

Responses:

  • Success:
{"ok":  true}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • The file does not exist:
{"error": "file_not_found", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}
  • The device is powered off
{"error": "device_powered_off", "origin": "user"}

/file/create

Creates a new file

Required parameters:

  • device_uuid: UUID of the device to create the file on [string, UUID]
  • filename: Name of the file you want to create [string, 1-64 characters]
  • content: Content of the new file [string, 0-255 characters]
  • parent_dir_uuid: UUID of the directory to create the file into [string, UUID]
  • is_directory: Boolean if the new file is a directory [boolean]

Responses:

  • Success:
{
  "uuid": "<UUID of the file [string, UUID]>",
  "device": "<UUID of the device the file is on [string, UUID]>",
  "filename": "<Name of the file [string]>",
  "content": "<Content of the file [string]>",
  "parent_dir_uuid": "<UUID of the directory the file is in [string, UUID]>",
  "is_directory": "<If the file is a directory [boolean]>"
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • No permission to access the device:
{"error": "permission_denied", "origin": "user"}
  • A file with the specified filename already exists:
{"error": "file_already_exists", "origin": "user"}
  • The parent directory for the new file does not exist:
{"error": "parent_directory_not_found", "origin": "user"}
  • If the new file is a directory, it can not have a another content value than "":
{"error": "directory_can_not_have_textcontent", "origin": "user"}
  • The device is powered off
{"error": "device_powered_off", "origin": "user"}

Hardware

/hardware/build

Checks if all parts of a device build are compatible and returns the performance of it

Required parameters: same as /device/create

Responses:

  • Success:
{
  "success": true,
  "performance": [
    "<CPU performance [number]>",
    "<RAM performance [number]>",
    "<GPU performance [number]>",
    "<Disk performance [number]>",
    "<Network speed [number]>"
  ]
}

/hardware/resources

Returns the current resource usage of the device

Required parameters:

  • device_uuid: UUID of the device you want to know the resource usage of [string, UUID]

Responses:

  • Success:
{
    "uuid": "<UUID of the device [string, UUID]>",
    "performance_cpu": "<CPU performance [number]>",
    "performance_ram": "<RAM performance [number]>",
    "performance_gpu": "<GPU performance [number]>",
    "performance_disk": "<Disk performance [number]>",
    "performance_network": "<Network performance [number]>",
    "usage_cpu": "<CPU usage [number]>",
    "usage_ram": "<RAM usage [number]>",
    "usage_gpu": "<GPU usage [number]>",
    "usage_disk": "<Disk usage [number]>",
    "usage_network": "<Network usage [number]>"
}
  • The device does not exist:
{"error": "device_not_found"}

/hardware/process

Returns the resource usage of a service

Required parameters:

  • service_uuid: UUID of the service [string, UUID]

Responses:

  • Success:
{
    "cpu": "<CPU usage [number]>",
    "ram": "<RAM usage [number]>",
    "gpu": "<GPU usage [number]>",
    "disk": "<Disk usage [number]>",
    "network": "<Network usage [number]>"
}
  • The service does not exist:
{"error": "service_not_found"}

/hardware/list

Returns the game configuration

No parameters.

Responses:

/hardware/register [MS]

Registers a new service and scales the other services on the device accordingly

Required parameters:

  • device_uuid: UUID of the device the new service is running on [string, UUID]
  • service_uuid: UUID of the new service [string, UUID]
  • user: UUID of the owner of the new service [string, UUID]
  • cpu: Requested cpu usage of the new service [number]
  • ram: Requested ram usage of the new service [number]
  • gpu: Requested gpu usage of the new service [number]
  • disk: Requested disk usage of the new service [number]
  • network: Requested network usage of the new service [number]

Responses:

  • Success:
{
    "service_uuid": "The UUID of the service [string, UUID]",
    "cpu": "<CPU usage [number, 0-1]>",
    "ram": "<RAM usage [number, 0-1]>",
    "gpu": "<GPU usage [number, 0-1]>",
    "disk": "<Disk usage [number, 0-1]>",
    "network": "<Network usage [number, 0-1]>"
}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • The service is already running:
{"error": "service_already_running", "origin": "service"}

/hardware/stop [MS]

Unregisters a service and scales all other services on the device accordingly

Required parameters:

  • device_uuid: UUID of the device the service is running on [string, UUID]
  • service_uuid: UUID of the service [string, UUID]
  • user: UUID of the owner of the service [string, UUID]

Responses:

  • Success:
{"ok": true}
  • The device does not exist:
{"error": "device_not_found", "origin": "user"}
  • The service is not running:
{"error": "service_not_running", "origin": "service"}

/hardware/scale [MS]

Updates the requested resources of a service and scales all other services accordingly

Required parameters:

  • device_uuid: [string, UUID]
  • service_uuid: [string, UUID]
  • user: [string, UUID]`
  • cpu: Requested cpu usage of the service [number]
  • ram: Requested ram usage of the service [number]
  • gpu: Requested gpu usage of the service [number]
  • disk: Requested disk usage of the service [number]
  • network: Requested network usage of the service [number]

Responses:

  • Success:
{
    "service_uuid": "The UUID of the service [string, UUID]",
    "cpu": "<CPU usage [number, 0-1]>",
    "ram": "<RAM usage [number, 0-1]>",
    "gpu": "<GPU usage [number, 0-1]>",
    "disk": "<Disk usage [number, 0-1]>",
    "network": "<Network usage [number, 0-1]>"
}
  • The service does not exist:
{"error": "service_not_found", "origin": "service"}
Clone this wiki locally