Documentation
¶
Overview ¶
Package rexec provides a Go SDK for interacting with Rexec - Terminal as a Service.
The SDK allows you to programmatically create, manage, and interact with sandboxed Linux environments through the Rexec API.
Basic usage:
client := rexec.NewClient("https://rexec.sh", "your-api-token")
// Create a sandbox (preferred)
sandbox, err := client.Sandboxes.Create(ctx, &rexec.CreateSandboxRequest{
Image: "ubuntu",
Name: "my-sandbox",
})
// Legacy: client.Containers is the same service
term, err := client.Terminal.Connect(ctx, sandbox.ID)
term.Write([]byte("echo hello\n"))
Index ¶
- type APIError
- type Client
- type Container
- type ContainerService
- type CreateContainerRequest
- type CreateSandboxRequest
- type ErrorResponse
- type FileInfo
- type FileService
- type Sandbox
- type SandboxService
- func (s *SandboxService) Create(ctx context.Context, req *CreateSandboxRequest) (*Sandbox, error)
- func (s *SandboxService) Delete(ctx context.Context, id string) error
- func (s *SandboxService) Get(ctx context.Context, id string) (*Sandbox, error)
- func (s *SandboxService) List(ctx context.Context) ([]Sandbox, error)
- func (s *SandboxService) Start(ctx context.Context, id string) error
- func (s *SandboxService) Stop(ctx context.Context, id string) error
- type Terminal
- type TerminalService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Sandboxes is the preferred accessor for sandbox lifecycle APIs.
Sandboxes *SandboxService
// Containers is a deprecated alias for Sandboxes (same pointer). Prefer Sandboxes.
Containers *SandboxService
Files *FileService
Terminal *TerminalService
// contains filtered or unexported fields
}
Client is the main Rexec API client.
func (*Client) SetHTTPClient ¶
SetHTTPClient sets a custom HTTP client.
type Container ¶
type Container = Sandbox
Container is a deprecated alias for Sandbox. Deprecated: use Sandbox.
type ContainerService ¶
type ContainerService = SandboxService
ContainerService is a deprecated alias for SandboxService. Deprecated: use SandboxService.
type CreateContainerRequest ¶
type CreateContainerRequest = CreateSandboxRequest
CreateContainerRequest is a deprecated alias for CreateSandboxRequest. Deprecated: use CreateSandboxRequest.
type CreateSandboxRequest ¶ added in v1.1.0
type CreateSandboxRequest struct {
Name string `json:"name,omitempty"`
Image string `json:"image"`
Environment map[string]string `json:"environment,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
CreateSandboxRequest represents a request to create a sandbox. Prefer image aliases such as "ubuntu".
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse represents an API error response.
type FileInfo ¶
type FileInfo struct {
Name string `json:"name"`
Path string `json:"path"`
Size int64 `json:"size"`
Mode string `json:"mode"`
ModTime time.Time `json:"mod_time"`
IsDir bool `json:"is_dir"`
}
FileInfo represents file metadata.
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
FileService handles file operations.
type Sandbox ¶ added in v1.1.0
type Sandbox struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
}
Sandbox represents a Rexec sandbox (isolated Linux environment). Wire protocol still uses the /api/containers resource.
type SandboxService ¶ added in v1.1.0
type SandboxService struct {
// contains filtered or unexported fields
}
SandboxService handles sandbox lifecycle operations. HTTP paths remain /api/containers for backend compatibility.
func (*SandboxService) Create ¶ added in v1.1.0
func (s *SandboxService) Create(ctx context.Context, req *CreateSandboxRequest) (*Sandbox, error)
Create creates a new sandbox.
func (*SandboxService) Delete ¶ added in v1.1.0
func (s *SandboxService) Delete(ctx context.Context, id string) error
Delete deletes a sandbox.
func (*SandboxService) List ¶ added in v1.1.0
func (s *SandboxService) List(ctx context.Context) ([]Sandbox, error)
List returns all sandboxes for the authenticated user.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal represents a WebSocket terminal connection.
type TerminalService ¶
type TerminalService struct {
// contains filtered or unexported fields
}
TerminalService handles terminal connections.