Documentation
¶
Index ¶
- type Client
- func (c *Client) CreateSandbox(ctx context.Context, cfg SandboxConfig) (*Sandbox, error)
- func (c *Client) CreateSnapshot(ctx context.Context, id string, name string) (*SnapshotInfo, error)
- func (c *Client) DestroySandbox(ctx context.Context, id string) error
- func (c *Client) Exec(ctx context.Context, id string, opts ExecOpts) (*ExecResult, error)
- func (c *Client) GetSandbox(ctx context.Context, id string) (*Sandbox, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListSandboxes(ctx context.Context) ([]Sandbox, error)
- func (c *Client) ReadFile(ctx context.Context, id string, path string) ([]byte, error)
- func (c *Client) RestoreSnapshot(ctx context.Context, snapshotID string) (*Sandbox, error)
- func (c *Client) StopSandbox(ctx context.Context, id string) error
- func (c *Client) WriteFile(ctx context.Context, id string, path string, content []byte) error
- type ExecOpts
- type ExecResult
- type Option
- type Sandbox
- type SandboxConfig
- type SnapshotInfo
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 (*Client) CreateSandbox ¶
CreateSandbox creates a new sandbox.
func (*Client) CreateSnapshot ¶
CreateSnapshot creates a snapshot of a sandbox.
func (*Client) DestroySandbox ¶
DestroySandbox removes a sandbox.
func (*Client) GetSandbox ¶
GetSandbox returns a sandbox by ID.
func (*Client) ListSandboxes ¶
ListSandboxes returns all sandboxes.
func (*Client) RestoreSnapshot ¶
RestoreSnapshot restores a sandbox from a snapshot.
func (*Client) StopSandbox ¶
StopSandbox stops 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 ¶
WithAPIKey sets the API key for authentication.
func WithHTTPClient ¶
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.
Click to show internal directories.
Click to hide internal directories.