콘텐츠로 이동

기기 만들기·연결

POST
/api/v1/stations/{station_id}/devices
curl --request POST \
--url https://dev.api.endueos.com/api/v1/stations/stn_01J9ZK3Q8M4XW7D2N5R6T0V1BC/devices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "type": "virtual", "kind": "linux", "name": "research-box", "size": "small", "storage_gb": 10, "start": true, "pin_to_dock": true }'

Device 를 만든다.

type: actual — 기기를 등록한다. 에이전트 하나와 연결 토큰 하나가 함께 생기고 토큰(enrollment)은 이 응답에만 나온다. Dock 1단 끝에 붙는다.

type: virtual — VM·Storage·에이전트가 함께 생긴다. 사용자 JWT 로만 (API 키면 403 FORBIDDEN — 비용이 생긴다). 201 의 Device 는 compute_status 가 provisioning·starting·stopped(start: false) 중 하나다 — 에이전트가 붙으면 running 이 된다 (이벤트 device.status_changed). 컴퓨트 공급자에 닿지 못하면 failed(status_reason: compute_unavailable)로 만들어진다 — 다시 시작하거나 지운다. 402 INSUFFICIENT_CREDITS(계정 잔액 ≤ 0), 409 VIRTUAL_DEVICE_LIMIT_REACHED·VOLUME_QUOTA_EXCEEDED, 422 DEVICE_KIND_NOT_HOSTABLE.

공통 — 409 DEVICE_LIMIT_REACHED(OS max_resources)·OS_HALTED, 422 DEVICE_KIND_NOT_ALLOWED(OS allowed_kinds).

가이드 — 기기

station_id
필수
string
/^stn_[0-9A-HJKMNP-TV-Z]{26}$/
예시
stn_01J9ZK3Q8M4XW7D2N5R6T0V1BC
Media typeapplication/json
One of: discriminator: type

Actual Device 를 등록한다. 에이전트 하나와 연결 토큰 하나가 함께 생긴다.

object
type
필수
string
허용 값: actual
kind
필수
string
허용 값: chrome mac android linux windows
name
필수
string
>= 1 characters <= 100 characters
description
string
<= 500 characters
labels

20개까지. 키 1~63자, 값 255자까지.

object
예시
{
"type": "virtual",
"kind": "linux",
"name": "research-box",
"size": "small",
"storage_gb": 10,
"start": true,
"pin_to_dock": true
}

비밀값이 든 응답 — 캐시하지 않는다.

Media typeapplication/json
object
data
필수
object
device
필수

OS 가 관리하는 기기. actual(사용자의 기기)과 virtual(플랫폼이 띄운 VM) 둘이다. id 는 Resource 와 같은 res_ 다 — /resources/{resource_id} 는 같은 기기를 v0.1.0 의 Resource 모양으로 보여 준다.

object
device_id
필수

Device 의 id — Resource 와 같은 res_ 다 (v0.1.0 이 이미 냈다).

string
/^res_[0-9A-HJKMNP-TV-Z]{26}$/
station_id
필수
string
/^stn_[0-9A-HJKMNP-TV-Z]{26}$/
type
필수
string
허용 값: actual virtual
kind
필수
string
허용 값: chrome mac android linux windows
name
필수
string
description
필수
Any of:
string
labels
필수
object
status
필수

등록 상태 (Resource 의 status 와 같다).

string
허용 값: pending active disabled
online
필수

에이전트가 접속해 있고 핸드셰이크를 마쳤다. Resource 의 online 과 같은 규칙.

boolean
compute_status
필수
Any of:

Virtual Device 의 컴퓨트 상태. actual 이면 compute_status 가 null 이다.

string
허용 값: provisioning starting running stopping stopped failed deleting
status_reason
필수
Any of:
string
size
필수
Any of:

컴퓨트 크기. small 1 vCPU·1 GiB, medium 2 vCPU·4 GiB, large 4 vCPU·8 GiB — 공급자가 가장 가까운 사양으로 맞춘다.

string
허용 값: small medium large
workloads
필수

Actual 은 agent 하나, virtual 은 vm·storage(없을 수 있다)·agent.

Array<object>
One of: discriminator: type

Virtual Device 의 컴퓨트 한 대.

object
type
필수
string
허용 값: vm
workload_id
필수
string
/^wkl_[0-9A-HJKMNP-TV-Z]{26}$/
status
필수
string
허용 값: pending starting running stopping stopped failed destroyed
provider
필수

컴퓨트 공급자 — local(로컬 컨테이너)·fly·aws·vultr 등.

string
region
필수
Any of:
string
cpus
필수
integer format: int32
memory_mb
필수
integer format: int32
started_at
필수
Any of:
string format: date-time
stopped_at
필수
Any of:
string format: date-time
agent_version
필수
Any of:
string
os
필수
Any of:
string
arch
필수
Any of:
string
facts
필수

에이전트가 알려 준 기기 정보. 끊겨도 지워지지 않는다.

object
tool_count
필수
integer format: int32
last_connected_at
필수
Any of:
string format: date-time
last_seen_at
필수
Any of:
string format: date-time
last_disconnected_at
필수
Any of:
string format: date-time
started_at
필수
Any of:
string format: date-time
stopped_at
필수
Any of:
string format: date-time
created_at
필수
string format: date-time
updated_at
필수
string format: date-time
enrollment

Actual 일 때만 — 에이전트를 기기에 붙일 때 넣는 값. 이 응답에서만 볼 수 있다. virtual 은 OS 가 토큰을 관리하므로 없다.

object
token
필수

osat_{agent_id}_{hex 64}. 이 응답에서만 볼 수 있다. 에이전트는 불투명한 문자열로 다룬다.

string
endpoint
필수

wss://{host}/api/v1/relay/socket

string
meta
필수
object
request_id
필수
string
timestamp
필수
string format: date-time
duration

서버 처리 시간(ms).

integer format: int32
예시
{
"data": {
"device": {
"device_id": "res_01J9ZK3Q8M4XW7D2N5R6T0V1BC",
"station_id": "stn_01J9ZK3Q8M4XW7D2N5R6T0V1BC",
"type": "actual",
"kind": "chrome",
"status": "pending",
"compute_status": "provisioning",
"size": "small",
"workloads": [
{
"type": "vm",
"workload_id": "wkl_01J9ZK3Q8M4XW7D2N5R6T0V1BC",
"status": "pending"
}
]
}
}
}
Cache-Control
필수
string
허용 값: no-store

요청 형식이 틀렸다 — VALIDATION_ERROR(details.errors[]) 또는 BAD_REQUEST. 본문은 오류 봉투.

인증이 없거나 무효다 — UNAUTHORIZED. 본문은 오류 봉투.

크레딧이 없다 — INSUFFICIENT_CREDITS (충전하면 다시 된다). 본문은 오류 봉투.

이 인증 수단으로는 못 하는 일이다 — FORBIDDEN (예: API 키로 클라우드 기기 만들기). 본문은 오류 봉투.

없거나 내 것이 아니다 — *_NOT_FOUND. 본문은 오류 봉투.

지금 상태와 충돌한다 — 코드는 위 설명을 본다. 본문은 오류 봉투.

형식은 맞지만 할 수 없다 — 코드는 위 설명을 본다. 본문은 오류 봉투.

한도를 넘었다 — Retry-After 초 뒤에 다시. 본문은 오류 봉투.

서버 오류 — INTERNAL_ERROR. 본문은 오류 봉투.

의존 서비스에 닿지 못했다 — 잠시 뒤 다시. 본문은 오류 봉투.