client

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the Go client for the Den API.

func New

func New(baseURL string, opts ...Option) *Client

New creates a new Den client.

func (*Client) CreateSandbox

func (c *Client) CreateSandbox(ctx context.Context, cfg SandboxConfig) (*Sandbox, error)

CreateSandbox creates a new sandbox.

func (*Client) CreateSnapshot

func (c *Client) CreateSnapshot(ctx context.Context, id string, name string) (*SnapshotInfo, error)

CreateSnapshot creates a snapshot of a sandbox.

func (*Client) DestroySandbox

func (c *Client) DestroySandbox(ctx context.Context, id string) error

DestroySandbox removes a sandbox.

func (*Client) Exec

func (c *Client) Exec(ctx context.Context, id string, opts ExecOpts) (*ExecResult, error)

Exec runs a command in a sandbox.

func (*Client) GetSandbox

func (c *Client) GetSandbox(ctx context.Context, id string) (*Sandbox, error)

GetSandbox returns a sandbox by ID.

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health checks server health.

func (*Client) ListSandboxes

func (c *Client) ListSandboxes(ctx context.Context) ([]Sandbox, error)

ListSandboxes returns all sandboxes.

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, id string, path string) ([]byte, error)

ReadFile reads a file from a sandbox.

func (*Client) RestoreSnapshot

func (c *Client) RestoreSnapshot(ctx context.Context, snapshotID string) (*Sandbox, error)

RestoreSnapshot restores a sandbox from a snapshot.

func (*Client) StopSandbox

func (c *Client) StopSandbox(ctx context.Context, id string) error

StopSandbox stops a sandbox.

func (*Client) WriteFile

func (c *Client) WriteFile(ctx context.Context, id string, path string, content []byte) error

WriteFile writes a file to a sandbox.

type ExecOpts

type ExecOpts struct {
	Cmd     []string          `json:"cmd"`
	Env     map[string]string `json:"env,omitempty"`
	WorkDir string            `json:"workdir,omitempty"`
	Timeout int               `json:"timeout,omitempty"` // seconds
}

ExecOpts holds options for command execution.

type ExecResult

type ExecResult struct {
	ExitCode int    `json:"exit_code"`
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
}

ExecResult holds the result of command execution.

type Option

type Option func(*Client)

Option configures the Client.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key for authentication.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets a custom HTTP client.

type Sandbox

type Sandbox struct {
	ID        string    `json:"id"`
	Image     string    `json:"image"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
	ExpiresAt time.Time `json:"expires_at,omitempty"`
}

Sandbox represents a sandbox instance.

type SandboxConfig

type SandboxConfig struct {
	Image   string            `json:"image,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	WorkDir string            `json:"workdir,omitempty"`
	Timeout int               `json:"timeout,omitempty"`
	CPU     int64             `json:"cpu,omitempty"`
	Memory  int64             `json:"memory,omitempty"`
}

SandboxConfig holds sandbox creation options.

type SnapshotInfo

type SnapshotInfo struct {
	ID        string    `json:"id"`
	SandboxID string    `json:"sandbox_id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
}

SnapshotInfo holds snapshot metadata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL