Skip to content

Latest commit

 

History

History
660 lines (512 loc) · 17.7 KB

api.md

File metadata and controls

660 lines (512 loc) · 17.7 KB

Dedalus Python API

Complete reference of every operation, grouped by resource. See the README for usage and configuration.

Contents

Setup

import os

from dedalus_sdk import Dedalus

client = Dedalus(
    browser_token=os.environ.get("DEDALUS_BROWSER_TOKEN"),
)

Machines

List machines

Direction Type
Request MachineListParams
page = client.machines.list()

Create machine

Direction Type
Request MachineCreateParams
Response Machine
machine = client.machines.create(
    autosleep="300s",
    memory_mib=4096,
    storage_gib=10,
    vcpu=1,
    idempotency_key="",
)

Get machine

Direction Type
Response MachineRetrieveResponse
machine = client.machines.retrieve(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
)

Update machine

Changes settings such as autosleep.

Direction Type
Request MachineUpdateParams
Response Machine
machine = client.machines.update(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    idempotency_key="",
)

Destroy machine

Direction Type
Request MachineDeleteParams
Response Machine
machine = client.machines.delete(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    idempotency_key="",
)

Sleep a running machine

Direction Type
Response Machine
machine = client.machines.sleep(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    idempotency_key="",
)

Wake a sleeping machine

Direction Type
Response Machine
machine = client.machines.wake(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    idempotency_key="",
)

Reboot a machine with fresh memory

Checkpoints files and replaces the runtime. The machine ID and filesystem are preserved. RAM, processes, and temporary mounts are cleared. Poll the machine until its phase is running. Retry the same Idempotency-Key after a lost response.

Direction Type
Request MachineRebootParams
Response Machine
machine = client.machines.reboot(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    idempotency_key="",
)

Resize machine

Wakes a sleeping Machine, then waits up to 30 seconds for the host to confirm CPU and RAM. Returns the Machine with its confirmed size. After RESIZE_TIMEOUT, repeat the same request and Idempotency-Key to wait again.

Direction Type
Request MachineResizeParams
Response MachineResizeResponse
machine = client.machines.resize(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    idempotency_key="",
)

Machines Ssh

List SSH sessions

Direction Type
Request SSHListParams
page = client.machines.ssh.list(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
)

Create SSH session

Direction Type
Request SSHCreateParams
Response SSHSession
ssh = client.machines.ssh.create(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    public_key="",
    idempotency_key="",
)

Get SSH session

Direction Type
Response SSHSession
ssh = client.machines.ssh.retrieve(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    session_id="sessionID",
)

Delete SSH session

Direction Type
Response SSHSession
ssh = client.machines.ssh.delete(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    session_id="sessionID",
    idempotency_key="",
)

Machines Executions

List executions

Direction Type
Request ExecutionListParams
page = client.machines.executions.list(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
)

Create execution

Direction Type
Request ExecutionCreateParams
Response Execution
execution = client.machines.executions.create(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    command=[""],
    idempotency_key="",
)

Get execution

Direction Type
Response Execution
execution = client.machines.executions.retrieve(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    execution_id="executionID",
)

Delete execution

Direction Type
Response Execution
execution = client.machines.executions.delete(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    execution_id="executionID",
    idempotency_key="",
)

Get execution output

Direction Type
Response ExecutionOutput
execution = client.machines.executions.output(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    execution_id="executionID",
)

List execution events

Direction Type
Request ExecutionEventsParams
page = client.machines.executions.events(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    execution_id="executionID",
)

Machines Executions Logs

Get execution log status
Direction Type
Response Status
log = client.machines.executions.logs.retrieve(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    execution_id="executionID",
)
Create execution log read token
Direction Type
Response ReadToken
log = client.machines.executions.logs.create_token(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    execution_id="executionID",
    idempotency_key="",
)

Machines Autoresizing

Read this machine's autoresizing settings

Direction Type
Response Policy
autoresizing = client.machines.autoresizing.retrieve(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
)

Set this machine's autoresizing settings

Changes RAM, CPU or both for this machine. An absent resource keeps its setting.

Direction Type
Request AutoresizingUpdateParams
Response Policy
autoresizing = client.machines.autoresizing.update(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    idempotency_key="",
)

Machines Ports

List ports

Direction Type
Request PortListParams
page = client.machines.ports.list(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
)

Create port

Direction Type
Request PortCreateParams
Response Port
port = client.machines.ports.create(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port=0,
    protocol="http",
    visibility="private",
    idempotency_key="",
)

Get port

Direction Type
Response Port
port = client.machines.ports.retrieve(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port_id="portID",
)

Update port

Direction Type
Request PortUpdateParams
Response Port
port = client.machines.ports.update(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port_id="portID",
    visibility="public",
    idempotency_key="",
)

Delete port

Direction Type
Response Port
port = client.machines.ports.delete(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port_id="portID",
    idempotency_key="",
)

Machines Ports AccessKeys

List port access keys
Direction Type
Request AccessKeyListParams
Response AccessKeyListResponse
access_key = client.machines.ports.access_keys.list(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port_id="portID",
)
Mint port access key
Direction Type
Request AccessKeyMintParams
Response AccessKeyMintResponse
access_key = client.machines.ports.access_keys.mint(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port_id="portID",
    expires_in=1,
    idempotency_key="",
)
Revoke port access key
Direction Type
Response AccessKeyRevokeResponse
access_key = client.machines.ports.access_keys.revoke(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port_id="portID",
    access_key_id="accessKeyID",
    idempotency_key="",
)
Rotate port access key
Direction Type
Request AccessKeyRotateParams
Response AccessKeyRotateResponse
access_key = client.machines.ports.access_keys.rotate(
    machine_id="017f22e2-79b0-7cc3-98c4-dc0c0c07398f",
    port_id="portID",
    access_key_id="accessKeyID",
    expires_in=1,
    idempotency_key="",
)

Organization

Organization Autoresizing

Read organization autoresizing policy

Direction Type
Response Policy
autoresizing = client.organization.autoresizing.retrieve()

Set organization autoresizing policy

Changes defaults copied to new Machines. Existing Machines retain their own policy.

Direction Type
Request AutoresizingUpdateParams
Response Policy
autoresizing = client.organization.autoresizing.update(
    idempotency_key="",
)

Images

List images owned by the authenticated organization

Pages through the organization's images in ID order. Each item has the same shape as a single image read. A deleted image is left out; it still reads by ID.

Direction Type
Request ImageListParams
Response ImageList
images = client.images.list(
    limit=100,
)

Register an immutable OCI image for preparation

Requires an entitled organization and linux/amd64 on the current fleet. Acceptance queues preparation; only a ready image can launch a machine. Private registry credentials are not yet supported.

Direction Type
Request ImageCreateParams
Response Image
image = client.images.create(
    platform="linux/amd64",
    source={"kind": ""},
    idempotency_key="",
)

Read preparation status for an organization-owned image

A preparing image reports its stage, the worker's last step and an estimated percent of the whole preparation. A failed image names the cause: IMAGE_OS_UNSUPPORTED, IMAGE_SOURCE_INVALID, IMAGE_SOURCE_NOT_FOUND and IMAGE_SOURCE_UNAUTHORIZED describe the image or its reference and are final; IMAGE_SOURCE_UNAVAILABLE, IMAGE_REGISTRY_UNREACHABLE, IMAGE_REGISTRY_RATE_LIMITED, IMAGE_ARCHIVE_UNAVAILABLE and IMAGE_EXECUTION_FAILED describe this attempt and are retryable with a new idempotency key.

Direction Type
Response Image
image = client.images.retrieve(
    image_id="imageID",
)

Rename an organization-owned image

Changes only the name. The image's source, platform and state are immutable.

Direction Type
Request ImageUpdateParams
Response Image
image = client.images.update(
    image_id="imageID",
    name="",
    idempotency_key="",
)

Delete an organization-owned image

The image can create no new Machine and no longer counts against the organization's image limit. Machines already running from it keep working. The image stays readable, and deleting it again returns the same image.

Direction Type
Response Image
image = client.images.delete(
    image_id="imageID",
    idempotency_key="",
)

Images Uploads

Reserve an immutable Docker image archive upload

Direction Type
Request UploadCreateParams
Response Reservation
upload = client.images.uploads.create(
    platform="",
    sha256="",
    size_bytes=0,
    idempotency_key="",
)