392 lines
12 KiB
YAML
392 lines
12 KiB
YAML
LabdHealthResponse:
|
|
type: object
|
|
additionalProperties: false
|
|
required:
|
|
- status
|
|
properties:
|
|
status:
|
|
type: string
|
|
enum:
|
|
- ok
|
|
LabdReadinessResponse:
|
|
type: object
|
|
additionalProperties: false
|
|
required:
|
|
- status
|
|
properties:
|
|
status:
|
|
type: string
|
|
enum:
|
|
- ready
|
|
- not_ready
|
|
TemplateId:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 48
|
|
pattern: ^[a-z0-9][a-z0-9-]{0,47}$
|
|
description: Identifier of a lab template known to the provisioner, such as `mikrotik-ospf-pair`. Templates are part of the provisioner build; the request never carries node images, commands, or configuration.
|
|
NodeName:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 15
|
|
pattern: ^[a-z][a-z0-9-]{0,14}$
|
|
description: Name of a node inside its template, such as `r1` or `srv`. It is the same in every lab of the template and is not an LXD instance name or a host name.
|
|
NodeKind:
|
|
type: string
|
|
description: 'Guest system of a node.
|
|
|
|
|
|
- mikrotik: a MikroTik Cloud Hosted Router VM; its console is RouterOS.
|
|
|
|
- ubuntu: a small Ubuntu VM; its console is a Linux login.
|
|
|
|
|
|
Adding a value is a contract change.'
|
|
enum:
|
|
- mikrotik
|
|
- ubuntu
|
|
LabCreateRequest:
|
|
type: object
|
|
description: A lab of one template variant. It has no field for a candidate, account, attempt, task, or company.
|
|
additionalProperties: false
|
|
required:
|
|
- template_id
|
|
- template_version
|
|
- seed
|
|
- ttl_seconds
|
|
properties:
|
|
template_id:
|
|
$ref: '#/TemplateId'
|
|
template_version:
|
|
type: integer
|
|
format: int32
|
|
minimum: 1
|
|
maximum: 10000
|
|
description: Version of the template. The provisioner refuses a version it does not hold, so a lab always matches the variant the backend served.
|
|
seed:
|
|
type: string
|
|
minLength: 64
|
|
maxLength: 64
|
|
pattern: ^[0-9a-f]{64}$
|
|
description: 'Variant seed: 32 random bytes in lowercase hex chosen by the backend for the item instance. The template renders the variant configuration of every node and the checker criteria from it. It is never returned by the provisioner.'
|
|
ttl_seconds:
|
|
type: integer
|
|
format: int32
|
|
minimum: 300
|
|
maximum: 14400
|
|
description: Lifetime of the lab from its creation. The provisioner refuses a value above its configured maximum.
|
|
LabState:
|
|
type: string
|
|
description: 'State of a lab.
|
|
|
|
|
|
- provisioning: capacity is reserved and the nodes are being cloned, connected, and booted.
|
|
|
|
- ready: every node answers on its management port; console tokens and checks are allowed.
|
|
|
|
- deleting: the timer ended, DeleteLab was called, or provisioning failed; the instances and bridges are being removed.
|
|
|
|
- deleted: every instance and bridge of the lab is gone and its capacity is free.
|
|
|
|
- failed: provisioning failed or timed out, or the provisioner restarted while provisioning; `failure_reason` says which. Its resources are removed as for `deleting` and the capacity returns once they are gone; create a new lab with a new ID.
|
|
|
|
|
|
Adding a value is a contract change.'
|
|
enum:
|
|
- provisioning
|
|
- ready
|
|
- deleting
|
|
- deleted
|
|
- failed
|
|
LabFailureReason:
|
|
type: string
|
|
description: 'Why a lab failed. None of the reasons depends on the person who uses the lab.
|
|
|
|
|
|
- provisioning_failed: LXD refused or failed an operation of the provisioning.
|
|
|
|
- provisioning_timed_out: a node did not answer on its management port within the provisioning timeout.
|
|
|
|
- interrupted: the provisioner process stopped while the lab was provisioning.'
|
|
enum:
|
|
- provisioning_failed
|
|
- provisioning_timed_out
|
|
- interrupted
|
|
LabNode:
|
|
type: object
|
|
description: A node of a lab by its template name and kind. It never carries an address, a MAC address, an instance name, or a credential.
|
|
additionalProperties: false
|
|
required:
|
|
- name
|
|
- kind
|
|
properties:
|
|
name:
|
|
$ref: '#/NodeName'
|
|
kind:
|
|
$ref: '#/NodeKind'
|
|
LabStatus:
|
|
type: object
|
|
description: State of a lab after one call. It never contains the seed, a node address, a key, a password, or an LXD object name.
|
|
additionalProperties: false
|
|
required:
|
|
- lab_id
|
|
- state
|
|
- template_id
|
|
- template_version
|
|
- created_at
|
|
- expires_at
|
|
- nodes
|
|
properties:
|
|
lab_id:
|
|
type: string
|
|
format: uuid
|
|
state:
|
|
$ref: '#/LabState'
|
|
template_id:
|
|
$ref: '#/TemplateId'
|
|
template_version:
|
|
type: integer
|
|
format: int32
|
|
minimum: 1
|
|
maximum: 10000
|
|
created_at:
|
|
type: string
|
|
format: date-time
|
|
ready_at:
|
|
type: string
|
|
format: date-time
|
|
description: Time the lab became `ready`; absent before.
|
|
expires_at:
|
|
type: string
|
|
format: date-time
|
|
description: Time the provisioner deletes the lab. It never moves, also not across restarts of the provisioner.
|
|
deleted_at:
|
|
type: string
|
|
format: date-time
|
|
description: Time the last resource of the lab was removed; absent before.
|
|
failure_reason:
|
|
$ref: '#/LabFailureReason'
|
|
nodes:
|
|
type: array
|
|
minItems: 1
|
|
maxItems: 8
|
|
description: Nodes of the template in template order.
|
|
items:
|
|
$ref: '#/LabNode'
|
|
ConsoleTokenRequest:
|
|
type: object
|
|
additionalProperties: false
|
|
required:
|
|
- node
|
|
properties:
|
|
node:
|
|
$ref: '#/NodeName'
|
|
ConsoleToken:
|
|
type: object
|
|
description: 'Single-use console token for one node. The token is a secret of the console gateway: it is never logged, stored by the backend, or passed to a browser.'
|
|
additionalProperties: false
|
|
required:
|
|
- token
|
|
- node
|
|
- expires_at
|
|
- attach_path
|
|
properties:
|
|
token:
|
|
type: string
|
|
minLength: 43
|
|
maxLength: 43
|
|
pattern: ^[A-Za-z0-9_-]{43}$
|
|
description: 32 random bytes in unpadded base64url.
|
|
node:
|
|
$ref: '#/NodeName'
|
|
expires_at:
|
|
type: string
|
|
format: date-time
|
|
attach_path:
|
|
type: string
|
|
maxLength: 128
|
|
pattern: ^/v1/labs/[0-9a-f-]{36}/console$
|
|
description: Path of the WebSocket attach on the provisioner origin.
|
|
CriterionId:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 32
|
|
pattern: ^[a-z0-9][a-z0-9_-]{0,31}$
|
|
description: Opaque identifier of a checker criterion of the template.
|
|
CriterionResult:
|
|
type: object
|
|
additionalProperties: false
|
|
required:
|
|
- id
|
|
- passed
|
|
properties:
|
|
id:
|
|
$ref: '#/CriterionId'
|
|
passed:
|
|
type: boolean
|
|
LabCheckResult:
|
|
type: object
|
|
description: 'Result of one check: whether each criterion of the variant holds on the nodes. It carries no node output, address, or configuration text.'
|
|
additionalProperties: false
|
|
required:
|
|
- lab_id
|
|
- checked_at
|
|
- score
|
|
- max_score
|
|
- criteria
|
|
properties:
|
|
lab_id:
|
|
type: string
|
|
format: uuid
|
|
checked_at:
|
|
type: string
|
|
format: date-time
|
|
score:
|
|
type: integer
|
|
format: int32
|
|
minimum: 0
|
|
maximum: 50
|
|
description: Number of passed criteria.
|
|
max_score:
|
|
type: integer
|
|
format: int32
|
|
minimum: 1
|
|
maximum: 50
|
|
description: Number of criteria.
|
|
criteria:
|
|
type: array
|
|
minItems: 1
|
|
maxItems: 50
|
|
items:
|
|
$ref: '#/CriterionResult'
|
|
Problem:
|
|
type: object
|
|
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. This is the lab provisioner copy of the public api/core Problem schema; keep both copies identical except for descriptions and the ProblemCode enum. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
|
additionalProperties: false
|
|
required:
|
|
- type
|
|
- title
|
|
- status
|
|
- code
|
|
properties:
|
|
type:
|
|
type: string
|
|
format: uri-reference
|
|
maxLength: 256
|
|
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
|
title:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 200
|
|
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
|
status:
|
|
type: integer
|
|
format: int32
|
|
minimum: 400
|
|
maximum: 599
|
|
description: HTTP status code generated by the origin server.
|
|
code:
|
|
$ref: '#/ProblemCode'
|
|
detail:
|
|
type: string
|
|
maxLength: 1000
|
|
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
|
instance:
|
|
type: string
|
|
format: uri-reference
|
|
maxLength: 2048
|
|
description: URI reference that identifies this occurrence, when one exists.
|
|
trace_id:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 128
|
|
pattern: ^[A-Za-z0-9._-]+$
|
|
description: Request identifier of the call when the caller propagated one; it is not a secret.
|
|
errors:
|
|
type: array
|
|
maxItems: 100
|
|
description: Field-level reasons for validation_failed. Other codes omit it.
|
|
items:
|
|
$ref: '#/ProblemFieldError'
|
|
ProblemCode:
|
|
type: string
|
|
description: 'Stable error code of the lab provisioner API. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
|
|
|
|
|
- validation_failed (400): parameters or body do not match the contract or a semantic rule, such as an unknown template or node; `errors` points at the fields.
|
|
|
|
- unauthenticated (401): the bearer token is missing or wrong.
|
|
|
|
- not_found (404): the route or the lab does not exist.
|
|
|
|
- method_not_allowed (405): the route does not support the method.
|
|
|
|
- state_conflict (409): the lab is not in a state that allows the operation, for example a console token or a check for a lab that is not ready.
|
|
|
|
- payload_too_large (413): the request body exceeds the limit.
|
|
|
|
- unsupported_media_type (415): the request Content-Type is not accepted.
|
|
|
|
- idempotency_key_reused (422): the lab ID was already used with a different payload.
|
|
|
|
- internal (500): unexpected server error.
|
|
|
|
- not_implemented (501): the route is described but not implemented yet, such as the console attach.
|
|
|
|
- lab_pool_busy (503): the lab does not fit the capacity or the provisioner is draining; see Retry-After.
|
|
|
|
- lab_unavailable (503): LXD or a node could not be reached, so nothing was done or evaluated. It is an infrastructure failure, never a failed check.
|
|
|
|
|
|
The Problem shape is the api/core shape; only this enum is specific to the lab provisioner.'
|
|
enum:
|
|
- validation_failed
|
|
- unauthenticated
|
|
- not_found
|
|
- method_not_allowed
|
|
- state_conflict
|
|
- payload_too_large
|
|
- unsupported_media_type
|
|
- idempotency_key_reused
|
|
- internal
|
|
- not_implemented
|
|
- lab_pool_busy
|
|
- lab_unavailable
|
|
ProblemFieldError:
|
|
type: object
|
|
description: One reason why a request field or parameter is invalid.
|
|
additionalProperties: false
|
|
required:
|
|
- in
|
|
- pointer
|
|
- code
|
|
- message
|
|
properties:
|
|
in:
|
|
$ref: '#/ProblemFieldLocation'
|
|
pointer:
|
|
type: string
|
|
maxLength: 1024
|
|
pattern: ^(/([^~/]|~[01])*)*$
|
|
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/ttl_seconds`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/lab_id`.
|
|
code:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 64
|
|
pattern: ^[a-z][a-z0-9_]*$
|
|
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
|
message:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 500
|
|
description: Fixed English message that never echoes the submitted value.
|
|
ProblemFieldLocation:
|
|
type: string
|
|
description: Part of the request that contains the invalid field.
|
|
enum:
|
|
- body
|
|
- query
|
|
- path
|
|
- header
|
|
- cookie
|