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

API Reference [experimental]

MaxiHuHe04 edited this page Sep 9, 2019 · 17 revisions

Devices

/device/info

Returns public information about a device

Required parameters:

  • device_uuid: 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]>",
  "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]"
  }]
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/device/ping

Returns power state of a device

Required parameters:

  • device_uuid: The device to ping [string, UUID]

Responses:

  • Device is online:
{"online": true}
  • Device is offline:
{"online": false}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/device/get_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]>"
  }]
}

/device/create

Creates a device

Required parameters:

  • gpu: The name of the graphics processing unit [string]
  • cpu: The name of the central processing unit [string]
  • motherboard: The name of the motherboard [string]
  • ram: The name of the memory [string]
  • disk: The name of the disk [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]>"
}
  • A part does not exist (gpu, cpu, motherboard, ram or disk):
{"error": "element_<part>_not_found"}
  • A part is missing from the inventory (gpu, cpu, motherboard, ram or disk):
{"error": "<part>_not_in_inventory"}
  • The motherboard socket is not compatible with the cpu:
{"error": "incompatible_cpu_socket"}
  • The motherboard has not enough ram slots:
{"error": "not_enough_ram_slots"}
  • A ram type is incompatible with the motherboard:
{"error": "incompatible_ram_types"}
  • The drive interface is not compatible with the motherboard:
{"error": "incompatible_drive_interface"}
  • No memory was chosen:
{"error": "missing_ram"}
  • No hard drive was chosen:
{"error": "missing_hard_drive"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/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]>"
}
  • 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]>"
}
  • No permission to turn on/off the device
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/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]>"
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • No permission to rename the device
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/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}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • No permission to delete the device:
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/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]>"
}

/exist [MS]

Returns whether a device with a certain UUID exists

Required parameters:

  • device_uuid: The 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}

/owner [MS]

Returns the owner UUID of a certain device

Required parameters:

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

Responses:

  • Success:
{"owner": "<The UUID of the owner of the device [string, UUID]>"}
  • device_uuid missing or invalid:
{"error": "device_not_found", "origin": "user"}

Files

/file/all

Returns all files of a device

Required parameters:

  • device_uuid: The device 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]>"
  }]
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • No permission to see the files on the device:
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/file/info

Returns information about a file

Required parameters:

  • device_uuid: The device the file you want to get information about is on [string, UUID]
  • file_uuid: The 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]>"
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • File not found:
{"error": "file_not_found", "origin": "user"}
  • No permission to see the files on the device:
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/file/move

Moves a file to another location

Required parameters:

  • device_uuid: The device the file you want to move is on [string, UUID]
  • file_uuid: The UUID of the file you want to move [string, UUID]
  • filename: The 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]>"
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • File not found:
{"error": "file_not_found", "origin": "user"}
  • A file with the specified filename already exists:
{"error": "file_already_exists", "origin": "user"}
  • No permission to move files on the device:
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/file/update

Changes the content of a file

Required parameters:

  • device_uuid: The device the file you want to change is on [string, UUID]
  • file_uuid: The UUID of the file you want to change [string, UUID]
  • content: The 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]>"
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • File not found:
{"error": "file_not_found", "origin": "user"}
  • No permission to change files on the device:
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/file/delete

Deletes a file

Required parameters:

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

Responses:

  • Success:
{"ok":  true}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • File not found:
{"error": "file_not_found", "origin": "user"}
  • No permission to delete files on the device:
{"error": "permission_denied", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/file/create

Creates a new file

Required parameters:

  • device_uuid: The UUID of the device to create the file on [string, UUID]
  • filename: The name of the file you want to create [string, 1-15 characters]
  • content: The content of the new 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]>"
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • No permission to create files on the device:
{"error": "permission_denied", "origin": "user"}
  • A file with the specified filename already exists:
{"error": "file_already_exists", "origin": "user"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

Hardware

/hardware/build

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

Required parameters:

  • gpu: The name of the graphics processing unit [string]
  • cpu: The name of the central processing unit [string]
  • motherboard: The name of the motherboard [string]
  • ram: The name of the memory [string]
  • disk: The name of the disk [string]

Responses:

  • Success:
{
  "success": true,
  "performance": [
    "<CPU performance [number]>",
    "<RAM performance [number]>",
    "<GPU performance [number]>",
    "<Disk performance [number]>",
    "<Network speed [number]>"
  ]
}
  • A part does not exist (gpu, cpu, motherboard, ram or disk):
{"error": "element_<part>_not_found"}
  • The motherboard socket is not compatible with the cpu:
{"error": "incompatible_cpu_socket"}
  • The motherboard has not enough ram slots:
{"error": "not_enough_ram_slots"}
  • A ram type is incompatible with the motherboard:
{"error": "incompatible_ram_types"}
  • The drive interface is not compatible with the motherboard:
{"error": "incompatible_drive_interface"}
  • No memory was chosen:
{"error": "missing_ram"}
  • No hard drive was chosen:
{"error": "missing_hard_drive"}
  • Missing or invalid parameters:
{"error": "invalid_input_data"}

/hardware/resources

Returns the current resource usage of the device

Required parameters:

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

Responses:

  • Success:
{
    "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]>"
}
  • Device not found:
{"error": "device_not_found"}

/hardware/register [MS]

Required parameters:

  • device_uuid: [string, UUID]
  • service_uuid: [string, UUID]
  • user: [string, UUID]

Responses:

  • Success:
{
    "service_uuid": "The UUID of the service [string, UUID]",
    "cpu": "<[number]>",
    "ram": "<[number]>",
    "gpu": "<[number]>",
    "disk": "<[number]>",
    "network": "<[number]>"
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • The service is already running:
{"error": "service_already_running", "origin": "service"}

/hardware/stop [MS]

Required parameters:

  • device_uuid: [string, UUID]
  • service_uuid: [string, UUID]
  • user: [string, UUID]

Responses:

  • Success:
{"success": true}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • The service is not running:
{"error": "service_not_running", "origin": "service"}

/hardware/scale [MS]

Required parameters:

  • device_uuid: [string, UUID]
  • service_uuid: [string, UUID]
  • user: [string, UUID]`

Responses:

  • Success:
{
    "service_uuid": "The UUID of the service [string, UUID]",
    "cpu": "<[number]>",
    "ram": "<[number]>",
    "gpu": "<[number]>",
    "disk": "<[number]>",
    "network": "<[number]>"
}
  • Device not found:
{"error": "device_not_found", "origin": "user"}
  • The service was not found:
{"error": "service_not_found", "origin": "service"}

Clone this wiki locally