client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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) 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 binary to the given session.

func (*Client) GetMe

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

GetMe returns the authenticated user's profile.

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 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