Documentation
¶
Index ¶
- Constants
- func ParseSSE(reader io.Reader) <-chan SSEEvent
- func ParseSSEData(event SSEEvent, v any) error
- type APIError
- type AuthenticationError
- type Box
- type BoxConfig
- type BoxHandle
- func (h *BoxHandle) Close(ctx context.Context) error
- func (h *BoxHandle) ExposePort(ctx context.Context, targetPort int) (*ExposedPort, error)
- func (h *BoxHandle) GetPublicURL(port int) (string, error)
- func (h *BoxHandle) ID() string
- func (h *BoxHandle) Metadata() map[string]string
- func (h *BoxHandle) Pause(ctx context.Context) error
- func (h *BoxHandle) Refresh(ctx context.Context) error
- func (h *BoxHandle) Resume(ctx context.Context) error
- func (h *BoxHandle) Run(ctx context.Context, command string, opts *CommandOptions) (*CommandResult, error)
- func (h *BoxHandle) Status() BoxStatus
- func (h *BoxHandle) Stop(ctx context.Context) error
- func (h *BoxHandle) WaitUntilReady(ctx context.Context) error
- type BoxNotFoundError
- type BoxStatus
- type BoxTimeoutError
- type Client
- func (c *Client) CreateBox(ctx context.Context, config *BoxConfig) (*BoxHandle, error)
- func (c *Client) GetBox(ctx context.Context, boxID string) (*BoxHandle, error)
- func (c *Client) ListBoxes(ctx context.Context) ([]*Box, error)
- func (c *Client) WithSandbox(ctx context.Context, fn func(context.Context, *BoxHandle) error, ...) error
- type ClientOption
- type Command
- type CommandOptions
- type CommandResult
- type CommandStatus
- type CommandTimeoutError
- type ExposedPort
- type InsufficientCreditsError
- type Organization
- type RateLimitError
- type SSEEndData
- type SSEErrorData
- type SSEEvent
- type SSEOutputData
- type SSEStartData
- type SSEStatusData
- type TavorError
- type ValidationError
Constants ¶
const Version = "1.4.0"
Variables ¶
This section is empty.
Functions ¶
func ParseSSEData ¶ added in v1.2.0
Types ¶
type AuthenticationError ¶
type AuthenticationError struct {
TavorError
}
func NewAuthenticationError ¶
func NewAuthenticationError(message string) *AuthenticationError
type Box ¶
type Box struct { ID string `json:"id"` Status BoxStatus `json:"status"` Metadata map[string]string `json:"metadata,omitempty"` StartedAt *time.Time `json:"started_at,omitempty"` TerminatedAt *time.Time `json:"terminated_at,omitempty"` Details string `json:"details,omitempty"` InsertedAt time.Time `json:"created_at"` Hostname string `json:"hostname,omitempty"` }
type BoxHandle ¶
type BoxHandle struct {
// contains filtered or unexported fields
}
func (*BoxHandle) ExposePort ¶ added in v1.3.0
ExposePort exposes a port from inside the sandbox to a random external port. This allows external access to services running inside the sandbox.
targetPort is the port number inside the sandbox to expose. Returns an ExposedPort containing the proxy_port (external), target_port, and expires_at. Returns an error if the box is not in a running state or if no ports are available.
func (*BoxHandle) GetPublicURL ¶ added in v1.1.0
GetPublicURL returns the public web URL for accessing a specific port on the box
func (*BoxHandle) Pause ¶ added in v1.4.0
Pause pauses the execution of the sandbox. This temporarily stops the sandbox from running while preserving its state. Returns an error if the box cannot be paused.
func (*BoxHandle) Resume ¶ added in v1.4.0
Resume resumes the execution of a paused sandbox. This continues the sandbox execution from where it was paused. Returns an error if the box cannot be resumed.
func (*BoxHandle) Run ¶
func (h *BoxHandle) Run(ctx context.Context, command string, opts *CommandOptions) (*CommandResult, error)
type BoxNotFoundError ¶
type BoxNotFoundError struct { TavorError BoxID string }
func NewBoxNotFoundError ¶
func NewBoxNotFoundError(boxID string) *BoxNotFoundError
type BoxTimeoutError ¶
type BoxTimeoutError struct { TavorError BoxID string Timeout int // seconds }
func NewBoxTimeoutError ¶
func NewBoxTimeoutError(boxID string, timeout int) *BoxTimeoutError
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type ClientOption ¶
type ClientOption func(*Client)
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
func WithDebug ¶
func WithDebug(debug bool) ClientOption
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
func WithLogger ¶
func WithLogger(logger *slog.Logger) ClientOption
type Command ¶
type Command struct { ID string `json:"id"` BoxID string `json:"box_id"` Cmd string `json:"cmd"` Status CommandStatus `json:"status"` Stdout string `json:"stdout,omitempty"` Stderr string `json:"stderr,omitempty"` ExitCode *int `json:"exit_code,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
type CommandOptions ¶
type CommandResult ¶
type CommandStatus ¶
type CommandStatus string
const ( CommandStatusQueued CommandStatus = "queued" CommandStatusRunning CommandStatus = "running" CommandStatusDone CommandStatus = "done" CommandStatusFailed CommandStatus = "failed" CommandStatusError CommandStatus = "error" )
type CommandTimeoutError ¶
type CommandTimeoutError struct { TavorError CommandID string Timeout int // milliseconds }
func NewCommandTimeoutError ¶
func NewCommandTimeoutError(commandID string, timeout int) *CommandTimeoutError
type ExposedPort ¶ added in v1.3.0
type InsufficientCreditsError ¶
type InsufficientCreditsError struct { TavorError Required float64 Available float64 }
func NewInsufficientCreditsError ¶
func NewInsufficientCreditsError(required, available float64) *InsufficientCreditsError
type Organization ¶
type RateLimitError ¶
type RateLimitError struct { TavorError RetryAfter int // seconds }
func NewRateLimitError ¶
func NewRateLimitError(retryAfter int) *RateLimitError
type SSEEndData ¶ added in v1.2.0
type SSEEndData struct {
Status string `json:"status"`
}
type SSEErrorData ¶ added in v1.2.0
type SSEErrorData struct {
Error string `json:"error"`
}
type SSEOutputData ¶ added in v1.2.0
type SSEStartData ¶ added in v1.2.0
type SSEStatusData ¶ added in v1.2.0
type TavorError ¶
func (*TavorError) Error ¶
func (e *TavorError) Error() string
type ValidationError ¶
type ValidationError struct { TavorError Field string }
func NewValidationError ¶
func NewValidationError(field, message string) *ValidationError