Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/superfly/sprites-go/llms.txt

Use this file to discover all available pages before exploring further.

Checkpoints capture the full state of a running sprite — memory, processes, filesystem — so you can restore it later to the exact same point. Creating and restoring checkpoints are streaming operations: CheckpointStream and RestoreStream deliver progress messages as the operation proceeds. This page also covers network policy management, which controls egress rules for a sprite.

Client methods

CreateCheckpoint

func (c *Client) CreateCheckpoint(ctx context.Context, spriteName string) (*CheckpointStream, error)
Initiates a checkpoint of the sprite with no comment. Returns a stream of progress messages.
ctx
context.Context
required
Context for the streaming request.
spriteName
string
required
Name of the sprite to checkpoint.
*CheckpointStream
*CheckpointStream
Stream of StreamMessage values describing checkpoint progress.
error
error
Non-nil if the API returns a non-200 status.
stream, err := client.CreateCheckpoint(ctx, "my-sprite")
if err != nil {
    log.Fatal(err)
}
stream.ProcessAll(func(msg *sprites.StreamMessage) error {
    fmt.Printf("[%s] %s\n", msg.Type, msg.Data)
    return nil
})

CreateCheckpointWithComment

func (c *Client) CreateCheckpointWithComment(ctx context.Context, spriteName string, comment string) (*CheckpointStream, error)
Creates a checkpoint with an optional human-readable comment attached, useful for identifying checkpoints in a list.
ctx
context.Context
required
Context for the streaming request.
spriteName
string
required
Name of the sprite to checkpoint.
comment
string
required
Descriptive comment. Pass an empty string for no comment.
*CheckpointStream
*CheckpointStream
Stream of progress messages.
error
error
Non-nil on API error.
stream, err := client.CreateCheckpointWithComment(ctx, "my-sprite", "before migration v2")
if err != nil {
    log.Fatal(err)
}
defer stream.Close()

ListCheckpoints

func (c *Client) ListCheckpoints(ctx context.Context, spriteName string, historyFilter string) ([]*Checkpoint, error)
Returns all non-auto checkpoints for the sprite. Pass an empty string for historyFilter to list all checkpoints without filtering.
ctx
context.Context
required
Request context.
spriteName
string
required
Name of the sprite.
historyFilter
string
required
Optional history branch filter. Pass "" to list all checkpoints.
[]*Checkpoint
[]*Checkpoint
Slice of checkpoints ordered by creation time.
error
error
Non-nil on API or parse errors.
checkpoints, err := client.ListCheckpoints(ctx, "my-sprite", "")
for _, cp := range checkpoints {
    fmt.Printf("%s  %s  %s\n", cp.ID, cp.CreateTime.Format(time.RFC3339), cp.Comment)
}

ListCheckpointsWithOptions

func (c *Client) ListCheckpointsWithOptions(ctx context.Context, spriteName string, opts ListCheckpointsOptions) ([]*Checkpoint, error)
Lists checkpoints with configurable options, including the ability to include auto-generated checkpoints.
ctx
context.Context
required
Request context.
spriteName
string
required
Name of the sprite.
opts
ListCheckpointsOptions
required
Listing options. See ListCheckpointsOptions.
[]*Checkpoint
[]*Checkpoint
Matching checkpoints.
error
error
Non-nil on API or parse errors.

GetCheckpoint

func (c *Client) GetCheckpoint(ctx context.Context, spriteName string, checkpointID string) (*Checkpoint, error)
Fetches metadata for a specific checkpoint by ID.
ctx
context.Context
required
Request context.
spriteName
string
required
Name of the sprite.
checkpointID
string
required
Checkpoint ID returned from ListCheckpoints or CreateCheckpoint.
*Checkpoint
*Checkpoint
Checkpoint metadata.
error
error
Non-nil if the checkpoint does not exist or the request fails.

RestoreCheckpoint

func (c *Client) RestoreCheckpoint(ctx context.Context, spriteName string, checkpointID string) (*RestoreStream, error)
Restores the sprite to the state captured in the specified checkpoint. Returns a stream of progress messages. The sprite restarts as part of the restore process.
ctx
context.Context
required
Context for the streaming request.
spriteName
string
required
Name of the sprite to restore.
checkpointID
string
required
ID of the checkpoint to restore from.
*RestoreStream
*RestoreStream
Stream of restore progress messages.
error
error
Non-nil if the checkpoint is not found or the restore cannot be initiated.
stream, err := client.RestoreCheckpoint(ctx, "my-sprite", checkpointID)
if err != nil {
    log.Fatal(err)
}
stream.ProcessAll(func(msg *sprites.StreamMessage) error {
    if msg.Error != "" {
        return fmt.Errorf("restore error: %s", msg.Error)
    }
    fmt.Println(msg.Data)
    return nil
})

Network policy

GetNetworkPolicy

func (c *Client) GetNetworkPolicy(ctx context.Context, spriteName string) (*NetworkPolicy, error)
Returns the current egress network policy for the sprite.
ctx
context.Context
required
Request context.
spriteName
string
required
Name of the sprite.
*NetworkPolicy
*NetworkPolicy
Current policy with its rules list.
error
error
Non-nil on network or API errors.
policy, err := client.GetNetworkPolicy(ctx, "my-sprite")
for _, rule := range policy.Rules {
    fmt.Printf("%s %s\n", rule.Action, rule.Domain)
}

UpdateNetworkPolicy

func (c *Client) UpdateNetworkPolicy(ctx context.Context, spriteName string, policy *NetworkPolicy) error
Replaces the sprite’s network policy with the provided one.
ctx
context.Context
required
Request context.
spriteName
string
required
Name of the sprite.
policy
*NetworkPolicy
required
New policy to apply. The existing policy is fully replaced.
error
error
Returns "invalid policy" on a 400 response, or a generic error for other failures.
err := client.UpdateNetworkPolicy(ctx, "my-sprite", &sprites.NetworkPolicy{
    Rules: []sprites.NetworkPolicyRule{
        {Domain: "api.example.com", Action: "allow"},
        {Action: "deny"},
    },
})

Stream types

CheckpointStream

type CheckpointStream struct {
    // unexported fields
}

Next

func (cs *CheckpointStream) Next() (*StreamMessage, error)
Returns the next StreamMessage from the checkpoint stream. Returns io.EOF when the stream is exhausted.

ProcessAll

func (cs *CheckpointStream) ProcessAll(handler func(*StreamMessage) error) error
Processes every message, calling handler for each. Closes the stream when complete.

Close

func (cs *CheckpointStream) Close() error
Closes the underlying HTTP response body.

RestoreStream

type RestoreStream struct {
    // unexported fields
}

Next

func (rs *RestoreStream) Next() (*StreamMessage, error)
Returns the next StreamMessage. Returns io.EOF at end of stream.

ProcessAll

func (rs *RestoreStream) ProcessAll(handler func(*StreamMessage) error) error
Processes all messages and closes the stream.

Close

func (rs *RestoreStream) Close() error
Closes the underlying HTTP response body.

Types

Checkpoint

type Checkpoint struct {
    ID         string    `json:"id"`
    CreateTime time.Time `json:"create_time"`
    History    []string  `json:"history,omitempty"`
    Comment    string    `json:"comment,omitempty"`
    IsAuto     bool      `json:"is_auto,omitempty"`
}
ID
string
Unique checkpoint identifier.
CreateTime
time.Time
When the checkpoint was created.
History
[]string
History branch identifiers associated with this checkpoint.
Comment
string
Human-readable label set at creation time.
IsAuto
bool
true if this checkpoint was created automatically by the platform.

ListCheckpointsOptions

type ListCheckpointsOptions struct {
    HistoryFilter string
    IncludeAuto   bool
}
HistoryFilter
string
Filter checkpoints by history branch. Empty string returns all branches.
IncludeAuto
bool
When true, includes automatically created checkpoints in the results.

StreamMessage

Returned by both CheckpointStream.Next() and RestoreStream.Next().
type StreamMessage struct {
    Type  string `json:"type"`
    Data  string `json:"data,omitempty"`
    Error string `json:"error,omitempty"`
}
Type
string
Message type: "info", "stdout", "stderr", or "error".
Data
string
Message payload for non-error events.
Error
string
Error message when Type is "error".

NetworkPolicy

type NetworkPolicy struct {
    Rules []NetworkPolicyRule `json:"rules"`
}
Rules
[]NetworkPolicyRule
Ordered list of network rules evaluated top to bottom.

NetworkPolicyRule

type NetworkPolicyRule struct {
    Domain  string `json:"domain,omitempty"`
    Action  string `json:"action,omitempty"`
    Include string `json:"include,omitempty"`
}
Domain
string
Domain or hostname pattern. Omit to create a catch-all rule.
Action
string
"allow" or "deny".
Include
string
Optional reference to a named policy to include inline.

Build docs developers (and LLMs) love