client

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTransient

func IsTransient(err error) bool

IsTransient reports whether err is a transient failure worth retrying (server unavailability or a network-level error) rather than a client error (auth, validation, credits) that won't resolve on retry.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError represents a non-2xx response from the coordinator.

func (*APIError) Error

func (e *APIError) Error() string

type Board

type Board struct {
	ID               string  `json:"id"`
	PodID            *string `json:"pod_id,omitempty"`
	BoardType        string  `json:"board_type"`
	Device           string  `json:"device,omitempty"`
	Label            string  `json:"label"`
	State            string  `json:"state"`
	Disabled         bool    `json:"disabled"`
	SledVersion      string  `json:"sled_version"`
	CurrentSessionID *string `json:"current_session_id,omitempty"`
	CreatedAt        string  `json:"created_at"`
}

Board represents a siliconrig board as returned by the coordinator API.

type Client

type Client struct {
	BaseURL string
	APIKey  string
	HTTP    *http.Client
}

Client talks to the siliconrig coordinator API.

func New

func New(baseURL, apiKey string) *Client

New creates a client with sensible defaults.

func (*Client) CreateRunRecord added in v0.5.0

func (c *Client) CreateRunRecord(boardType, name, send string, runSeconds int, fileName string, data []byte) (*RunRecord, error)

CreateRunRecord uploads firmware and starts recording a run of it on a free board of boardType. The record comes back in state recording.

func (*Client) CreateSession

func (c *Client) CreateSession(boardType string) (*Session, error)

CreateSession starts a new session for the given board type.

func (*Client) DialSerialWS

func (c *Client) DialSerialWS(ctx context.Context, sessionID string) (*websocket.Conn, error)

DialSerialWS opens a WebSocket connection to the serial proxy for a session.

func (*Client) EndSession

func (c *Client) EndSession(id string) (*Session, error)

EndSession terminates a session by ID.

func (*Client) FindActiveSession

func (c *Client) FindActiveSession() (*Session, error)

FindActiveSession returns the first active/idle session, or an error.

func (*Client) FlashFirmware

func (c *Client) FlashFirmware(sessionID, filePath string) error

FlashFirmware uploads a firmware file to the given session.

func (*Client) FlashFirmwareBytes

func (c *Client) FlashFirmwareBytes(sessionID, name string, data []byte) error

FlashFirmwareBytes uploads in-memory firmware bytes to the given session.

func (*Client) GetConfig added in v0.4.1

func (c *Client) GetConfig() (*Config, error)

GetConfig returns the platform settings. Callers treat a failure as unknown rather than fatal: it only shapes what the CLI prints.

func (*Client) GetMe

func (c *Client) GetMe() (*User, error)

GetMe returns the authenticated user's profile.

func (*Client) GetRunRecord added in v0.5.0

func (c *Client) GetRunRecord(id string) (*RunRecord, error)

GetRunRecord returns a run record by ID.

func (*Client) GetSession

func (c *Client) GetSession(id string) (*Session, error)

GetSession returns a single session by ID.

func (*Client) ListBoards

func (c *Client) ListBoards() ([]Board, error)

ListBoards returns all boards (public, no auth required).

func (*Client) ListSessions

func (c *Client) ListSessions() (*SessionsPage, error)

ListSessions returns the authenticated user's sessions (active + recent ended).

func (*Client) PowerCycle

func (c *Client) PowerCycle(sessionID string) error

PowerCycle sends a power cycle command to the board in the given session.

type Config added in v0.4.1

type Config struct {
	IdleTimeoutSeconds int `json:"idle_timeout_seconds"`
}

Config is the subset of platform settings a client needs to behave correctly, from GET /v1/config.

type RunRecord added in v0.5.0

type RunRecord struct {
	ID                 string `json:"id"`
	Name               string `json:"name"`
	BoardType          string `json:"board_type"`
	FirmwareSHA256     string `json:"firmware_sha256"`
	FirmwareBytes      int    `json:"firmware_bytes"`
	Send               string `json:"send"`
	RunSeconds         int    `json:"run_seconds"`
	State              string `json:"state"`
	Error              string `json:"error,omitempty"`
	Truncated          bool   `json:"truncated"`
	BoardLabel         string `json:"board_label,omitempty"`
	PodVersion         string `json:"pod_version,omitempty"`
	CoordinatorVersion string `json:"coordinator_version,omitempty"`
	RecordedAt         string `json:"recorded_at,omitempty"`
	CreatedAt          string `json:"created_at"`
	URL                string `json:"url,omitempty"`
	BadgeMarkdown      string `json:"badge_markdown,omitempty"`
}

RunRecord is a recorded run of firmware on a real board. State is recording while the run is on the board, then ready or failed. URL and BadgeMarkdown come with the response that created the record.

type Session

type Session struct {
	ID          string  `json:"id"`
	UserID      string  `json:"user_id"`
	BoardID     *string `json:"board_id,omitempty"`
	BoardType   string  `json:"board_type"`
	State       string  `json:"state"`
	EndReason   *string `json:"end_reason,omitempty"`
	CreditsUsed int     `json:"credits_used"`
	StartedAt   *string `json:"started_at,omitempty"`
	EndedAt     *string `json:"ended_at,omitempty"`
	CreatedAt   string  `json:"created_at"`
}

Session represents a siliconrig session as returned by the coordinator API.

type SessionsPage

type SessionsPage struct {
	Active []Session `json:"active"`
	Ended  []Session `json:"ended"`
	Total  int       `json:"total"`
	Limit  int       `json:"limit"`
	Offset int       `json:"offset"`
}

SessionsPage is the paginated response from GET /v1/sessions.

type User

type User struct {
	ID             string `json:"id"`
	Email          string `json:"email"`
	BalanceCredits int    `json:"balance_credits"`
	IsActive       bool   `json:"is_active"`
	IsAdmin        bool   `json:"is_admin"`
	CreatedAt      string `json:"created_at"`
	LastActiveAt   string `json:"last_active_at"`
}

User represents the authenticated user profile.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL