Client
Constructor: v1.NewClient(config)
Client is the root entry point for SDK operations. It provides typed accessors
for each resource domain and manages the underlying gRPC connection. The
ClientInterface covers the stable core accessors; additive helpers such as
SandboxTemplates() are available on the concrete client.
Methods
Section titled “Methods”| Accessor | Returns | Description |
|---|---|---|
Sandboxes() |
SandboxInterface |
Sandbox lifecycle management |
SandboxTemplates() |
SandboxTemplateInterface |
Reusable sandbox template management |
Providers() |
ProviderInterface |
Provider CRUD and idempotent ensure |
Services() |
ServiceInterface |
Service exposure and management |
Exec() |
ExecInterface |
Command execution (run, stream, interactive) |
Files() |
FileInterface |
File upload and download |
Health() |
HealthInterface |
Gateway health checking |
SSH() |
SSHInterface |
SSH session and tunnel management |
TCP() |
TCPInterface |
TCP port forwarding |
Config() |
ConfigInterface |
Sandbox and gateway configuration |
Policy() |
PolicyInterface |
Draft policy review workflow |
Close() |
error |
Close the gRPC connection |
Sub-client hierarchy: Providers() has two nested accessors:
client.Providers().Profiles()returnsProfileInterfaceclient.Providers().Refresh()returnsRefreshInterface
Creating a Client
Section titled “Creating a Client”import v1 "github.com/ai-openshell/sdk-go/openshell/v1"
client, err := v1.NewClient(v1.Config{ Address: "gateway.example.com:443", Auth: v1.StaticToken("my-token"),})if err != nil { log.Fatal(err)}defer client.Close()Configuration
Section titled “Configuration”The Config struct controls connection behavior:
type Config struct { Address string // Gateway address (host:port) TLS *TLSConfig // TLS settings (nil uses system defaults) Auth AuthProvider // Authentication provider Timeout time.Duration // Default timeout for all operations (0 = no timeout) RetryPolicy *RetryPolicy // Retry configuration (nil = no automatic retries) Logger Logger // Custom logger (nil = no logging)}Authentication providers:
v1.StaticToken(token)provides a fixed bearer tokenv1.NoAuth()skips authentication (for local development)
Testing
Section titled “Testing”For unit tests, use the fake client instead of a real connection:
import "github.com/ai-openshell/sdk-go/openshell/v1/fake"
client := fake.NewClient()defer client.Close()The fake client implements the full ClientInterface with in-memory stores.
See Testing for details.
See also: Getting Started, Architecture
We are a Cloud Native Computing Foundation sandbox project.
Copyright OpenShell a Series of LF Projects, LLC
For website terms of use, trademark policy and other project policies please see lfprojects.org/policies/.