Skip to content

islo-labs/go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Islo Go SDK

fern shield

Official Go SDK for the Islo sandbox platform.

Install

go get github.com/islo-labs/go-sdk

Usage

Pass an Islo API key (or set ISLO_API_KEY) and client.NewIslo returns a client that automatically exchanges the key for a session JWT and refreshes it before expiry.

package main

import (
    "context"
    "fmt"

    api "github.com/islo-labs/go-sdk"
    "github.com/islo-labs/go-sdk/client"
    "github.com/islo-labs/go-sdk/option"
)

func main() {
    c := client.NewIslo(option.WithAPIKey("ak_..."))
    ctx := context.Background()

    sb, err := c.Sandboxes.CreateSandbox(ctx, &api.SandboxCreate{
        Name:  api.String("my-sandbox"),
        Image: api.String("python:3.12-slim"),
    })
    if err != nil {
        panic(err)
    }

    res, err := c.Sandboxes.ExecInSandbox(ctx, &api.ExecInSandboxRequest{
        SandboxName: sb.Name,
        Body: &api.ExecRequest{
            Command: []string{"echo", "Hello from sandbox"},
        },
    })
    if err != nil {
        panic(err)
    }
    fmt.Println("exec:", res.ExecID, "status:", res.Status)

    _, _ = c.Sandboxes.DeleteSandbox(ctx, &api.DeleteSandboxRequest{
        SandboxName: sb.Name,
    })
}

client.NewIslo is the recommended entry point. The plain generated client.NewClient is also available, but it expects a session JWT — use NewIslo if all you have is an API key.

Configuration

Option Description Default
option.WithAPIKey(key) Islo API key (ak_...). $ISLO_API_KEY
option.WithBaseURL(url) Control-plane API base URL. $ISLO_BASE_URL or https://api.islo.dev
option.WithComputeURL(url) Compute-plane API base URL. $ISLO_COMPUTE_URL or https://ca.compute.islo.dev
option.WithEnvironment(controlURL, computeURL) Set both control and compute URLs together. Production URLs
option.WithHTTPClient(c) Bring your own *http.Client. Its Transport is wrapped for auth; Timeout is preserved. &http.Client{}

For custom deployments, configure the control and compute planes independently:

c := client.NewIslo(
    option.WithAPIKey("ak_..."),
    option.WithBaseURL("https://api.customer.example.com"),
    option.WithComputeURL("https://compute.customer.example.com"),
)

The token cache is keyed on (controlURL, apiKey), so multiple NewIslo calls with the same key share one cached token.

Errors

API errors implement the standard errors.Is/errors.As interfaces:

import core "github.com/islo-labs/go-sdk/core"

_, err := c.Sandboxes.CreateSandbox(ctx, ...)
if err != nil {
    var apiError *core.APIError
    if errors.As(err, &apiError) {
        // inspect apiError.StatusCode, apiError.Body, etc.
    }
    return err
}

Advanced

Retries

Requests retry with exponential backoff on 408, 429, and 5xx (default: 2 attempts). Override per-client or per-call:

c := client.NewIslo(option.WithAPIKey("ak_..."))
_, err := c.Sandboxes.CreateSandbox(ctx, req, option.WithMaxAttempts(1))

Timeouts

Use a context-based timeout per request:

ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
_, err := c.Sandboxes.CreateSandbox(ctx, req)

Bypassing the API-key exchange

If you already hold a session JWT, skip NewIslo and use the raw generated client:

c := client.NewClient(option.WithAPIKey("<session-jwt>"))

Contributing

This SDK is generated by Fern from the OpenAPI spec in islo-labs/islo-web-api. Generated files carry a // Code generated by Fern. DO NOT EDIT. header and will be overwritten on the next regeneration; the hand-written wrapper (client/wrapper.go, customauth/) and this README are protected by .fernignore.

For API changes, edit the OpenAPI spec upstream. PRs to hand-written code here are welcome.

About

Islo Go SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages