Doku durchsuchen
Menü
Geändert am Auf GitHub bearbeiten

Server-API: cdap

Als Markdown kopieren

Diese Routen liegen auf der Server-API, Port 21114 (21121 in Docker). Sie nehmen einen API-Schlüssel in X-API-Key oder ein Anmelde-Token; siehe Die HTTP-API. Die Beschreibungen stehen auf Englisch, wie in der OpenAPI-Beschreibung.

The CDAP gateway: devices that connect over the Connected Device Access Protocol, their widgets, alerts and commands, delegations, and the WebSockets of their terminal, desktop, media and files.

GET /api/cdap/alerts

List the CDAP alerts that are firing.

The list is not narrowed to the devices the caller sees.

On the server API, port 21114. Needs cdap.view.

Parameter In Type What it is
device_id query string Only the alerts of this device

200: The firing alerts (application/json)

Field Type
alerts array of CdapAlert
total integer
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
503 The CDAP gateway is off

POST /api/cdap/delegate

Give an account a higher CDAP role on one device for a while.

Super admins only. Delegations live in memory and end at a restart. While one is active, the grantee acts on the device (or on the listed widgets) with the delegated role when it is higher than their own.

On the server API, port 21114. Only for the role admin.

Request body, application/json:

Field Type Required What it is
grantee string yes The username of the account that gets the role
device_id string yes
widget_ids array of string The widgets it covers; empty means all
role string, one of operator, admin yes
duration_seconds integer yes How long it lasts, in seconds; at least 1, at most 86400
reason string

201: The delegation (application/json)

CdapDelegation.

Error When
400 The request is not valid
401 No credential, or one that is not valid
403 The caller is not a super admin
409 The delegation could not be added
503 The CDAP gateway is off

DELETE /api/cdap/delegate/{id}

End a CDAP delegation.

Super admins only.

On the server API, port 21114. Only for the role admin.

Parameter In Type Required What it is
id path string yes The delegation ID (dlg_...)

200: Ended (application/json)

Field Type
status "revoked"
id string
Error When
401 No credential, or one that is not valid
403 The caller is not a super admin
404 No such delegation, or it has expired
503 The CDAP gateway is off

GET /api/cdap/delegations

List the active CDAP delegations.

Super admins only.

On the server API, port 21114. Only for the role admin.

200: The delegations (application/json)

Field Type
delegations array of CdapDelegation
total integer
Error When
401 No credential, or one that is not valid
403 The caller is not a super admin
503 The CDAP gateway is off

GET /api/cdap/devices

List the connected CDAP devices.

Lists every connected device; the list is not narrowed to the devices the caller sees.

On the server API, port 21114. Needs cdap.view.

200: The connected devices (application/json)

Field Type
devices array of CdapDeviceInfo
total integer
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission
503 The CDAP gateway is off

GET /api/cdap/devices/{id}

Show one CDAP device with its manifest, widget values and connection.

A device that is not connected but has a saved manifest comes with connected false.

On the server API, port 21114. Needs cdap.view.

Parameter In Type Required What it is
id path string yes The CDAP device ID

200: The device (application/json)

CdapDeviceInfo.

Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 Not a CDAP device
503 The CDAP gateway is off

GET /api/cdap/devices/{id}/audio

Listen to or talk to a CDAP device's audio.

Opens a WebSocket (subprotocol cdap-audio). The first message is {"codec", "sample_rate", "channels", "direction"}; the server answers {"type": "ready", "session_id"}. Then send {"type": "audio_input", "codec", "data", "timestamp"} or {"type": "close"}. Needs the operator role or higher, or a delegation for the audio.

On the server API, port 21114. Needs device.connect.

Parameter In Type Required What it is
id path string yes The CDAP device ID

101: Switching to the WebSocket

Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The caller's role is below operator, or it does not see the device
503 The CDAP gateway is off
default The request was not a WebSocket upgrade the server could take (plain text)

POST /api/cdap/devices/{id}/command

Send a command to a widget of a CDAP device.

Answers once the gateway has passed the command on. The widget's permissions decide which roles may send which action (by default operator for set, trigger and reset, admin for execute); an active delegation can raise the caller's role. Unlike the console, this route does not ask cdap.terminal for a terminal widget.

On the server API, port 21114. Needs cdap.command.

Parameter In Type Required What it is
id path string yes The CDAP device ID

Request body, application/json:

Field Type Required What it is
widget_id string yes
action string, one of set, trigger, execute, reset, query yes
value The value for the widget, like true for a toggle or 50 for a slider
reason string Why, sent to the device with the command

202: The command went out to the device (application/json)

Field Type
status "sent"
command_id string
device_id string
Error When
400 The body, the action or the device ID is not valid
401 No credential, or one that is not valid
403 The caller does not see the device, or its role may not send this action to the widget (then required names the role the widget asks for and your_role the caller's)
404 The widget is not on the device
502 The device is not connected or the command failed
503 The CDAP gateway is off

GET /api/cdap/devices/{id}/desktop

Show and control a CDAP device's desktop.

Opens a WebSocket (subprotocol cdap-desktop). The first message asks for the stream (width, height, quality, fps, codecs); then input, resize, clipboard_set, monitor_select, quality and control messages go to the device, and frames come back. Needs a super admin, or a delegated admin role for the desktop.

On the server API, port 21114. Only for the role admin.

Parameter In Type Required What it is
id path string yes The CDAP device ID

101: Switching to the WebSocket

Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The caller is not a super admin and has no delegation for the desktop, or does not see the device
503 The CDAP gateway is off
default The request was not a WebSocket upgrade the server could take (plain text)

GET /api/cdap/devices/{id}/files

Browse a CDAP device's files.

Opens a WebSocket (subprotocol cdap-filebrowser). Send {"type": "file_list" | "file_read" | "file_write" | "file_delete", "data"} or {"type": "close"}. Needs a super admin, or a delegated admin role for the files.

On the server API, port 21114. Only for the role admin.

Parameter In Type Required What it is
id path string yes The CDAP device ID

101: Switching to the WebSocket

Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The caller is not a super admin and has no delegation for the files, or does not see the device
503 The CDAP gateway is off
default The request was not a WebSocket upgrade the server could take (plain text)

GET /api/cdap/devices/{id}/manifest

Show a CDAP device's manifest.

On the server API, port 21114. Needs cdap.view.

Parameter In Type Required What it is
id path string yes The CDAP device ID

200: The manifest as the device sent it (application/json)

CdapManifest.

Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 The device has no manifest
503 The CDAP gateway is off

GET /api/cdap/devices/{id}/state

Show a connected CDAP device's widget values.

On the server API, port 21114. Needs cdap.view.

Parameter In Type Required What it is
id path string yes The CDAP device ID

200: The widget values (application/json)

Field Type What it is
device_id string
widget_state object The current value of each widget, by widget ID
connected true
Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The credential's role lacks the permission
404 The device is not connected
503 The CDAP gateway is off

GET /api/cdap/devices/{id}/terminal

Open a terminal on a CDAP device.

Opens a WebSocket (subprotocol cdap-terminal). The first message is {"cols", "rows"} (80 by 24 when left out); the server answers {"type": "ready", "session_id"} or {"type": "error", "error"}. Then send {"type": "input", "data"}, {"type": "resize", "cols", "rows"} or {"type": "close"}. Needs a super admin, or a delegated admin role for the terminal.

On the server API, port 21114. Only for the role admin.

Parameter In Type Required What it is
id path string yes The CDAP device ID

101: Switching to the WebSocket

Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The caller is not a super admin and has no delegation for the terminal, or does not see the device
503 The CDAP gateway is off
default The request was not a WebSocket upgrade the server could take (plain text)

GET /api/cdap/devices/{id}/video

Watch a CDAP device's video stream.

Opens a WebSocket (subprotocol cdap-video). The first message is {"stream_id", "quality", "fps"}. Needs the operator role or higher, or a delegation for the video.

On the server API, port 21114. Needs device.connect.

Parameter In Type Required What it is
id path string yes The CDAP device ID

101: Switching to the WebSocket

Error When
400 The device ID is not valid
401 No credential, or one that is not valid
403 The caller's role is below operator, or it does not see the device
503 The CDAP gateway is off
default The request was not a WebSocket upgrade the server could take (plain text)

GET /api/cdap/status

Show whether the CDAP gateway runs, its port and how many devices are connected.

On the server API, port 21114. Needs cdap.view.

200: The gateway state (application/json)

Field Type What it is
enabled boolean
connected integer How many devices are connected
port integer The gateway port, 0 when it is off
tls boolean Whether the gateway port uses TLS; missing when the gateway is off
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

Durchsucht Seiten, Abschnitte, Befehle und Einstellungen.