ExDaytona.Client (ex_daytona v0.4.0)

Copy Markdown View Source

Entry point for the high-level ExDaytona SDK facade.

Wraps the generated low-level connection with idiomatic defaults: the API key comes from the :api_key option or the DAYTONA_API_KEY environment variable, and every facade function returns {:ok, value} or {:error, %ExDaytona.Error{}} — never the raw openapi-generator response conventions.

{:ok, client} = ExDaytona.Client.new()
{:ok, sandbox} = ExDaytona.Sandbox.create(client, snapshot: "...")

The generated ExDaytona.Api.* modules remain available for the long tail of endpoints the facade doesn't cover — build a connection for them with conn/1.

Summary

Types

t()

A configured SDK client.

Functions

The platform base URL this client targets, resolved the same way ExDaytona.Connection.new/1 resolves it (explicit option, then the :base_url application env, then the production default).

The underlying Tesla client, for calling generated ExDaytona.Api.* functions the facade doesn't cover

Build a client for the Daytona platform API.

Same as new/1, but raises ArgumentError when no API key is available.

The configured transport implementation for key (:http_stream or :websocket) — see ExDaytona.Transport.

Types

t()

@type t() :: %ExDaytona.Client{
  api_key: String.t(),
  conn: Tesla.Env.client(),
  options: keyword(),
  transports: ExDaytona.Transport.t()
}

A configured SDK client.

  • conn — the underlying Tesla client for the main platform API
  • api_key — the Daytona API key (also used for toolbox connections)
  • options — the connection options the client was built with (minus base_url/bearer_token), reused when deriving toolbox connections

Functions

base_url(client)

@spec base_url(t()) :: String.t()

The platform base URL this client targets, resolved the same way ExDaytona.Connection.new/1 resolves it (explicit option, then the :base_url application env, then the production default).

conn(client)

@spec conn(t()) :: Tesla.Env.client()

The underlying Tesla client, for calling generated ExDaytona.Api.* functions the facade doesn't cover:

{:ok, client} = ExDaytona.Client.new()
ExDaytona.Api.Snapshots.get_all_snapshots(ExDaytona.Client.conn(client))

new(options \\ [])

@spec new(keyword()) :: {:ok, t()} | {:error, ExDaytona.Error.t()}

Build a client for the Daytona platform API.

Options

  • :api_key — Daytona API key (default: the DAYTONA_API_KEY environment variable)
  • all other options are passed through to ExDaytona.Connection.new/1 (:base_url, :retry, :timeout, :middleware, ...)

Returns {:error, %ExDaytona.Error{}} when no API key is available.

new!(options \\ [])

@spec new!(keyword()) :: t()

Same as new/1, but raises ArgumentError when no API key is available.

transport(client, key)

@spec transport(t(), :http_stream | :websocket) :: module()

The configured transport implementation for key (:http_stream or :websocket) — see ExDaytona.Transport.