client

package
v0.0.0-...-c52f179 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package client provides a Go SDK for the OSAPI REST API.

Create a client with New() and use the domain-specific services to interact with the API:

client := client.New("http://localhost:8080", "your-jwt-token")

// Get hostname
resp, err := client.Hostname.Get(ctx, "_any")

// Execute a command
resp, err := client.Command.Exec(ctx, client.ExecRequest{
    Command: "uptime",
    Target:  "_all",
})

Index

Constants

View Source
const (
	// TargetAny routes to any available agent (load-balanced).
	TargetAny = "_any"
	// TargetAll broadcasts to every agent.
	TargetAll = "_all"
)

Target constants for job routing.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError is the base error type for OSAPI API errors.

func (*APIError) Error

func (e *APIError) Error() string

Error returns a formatted error string.

type Agent

type Agent struct {
	Hostname         string             `json:"hostname"`
	MachineID        string             `json:"machine_id,omitempty"`
	Fingerprint      string             `json:"fingerprint,omitempty"`
	Status           string             `json:"status"`
	State            string             `json:"state,omitempty"`
	Labels           map[string]string  `json:"labels,omitempty"`
	Architecture     string             `json:"architecture,omitempty"`
	CPUCount         int                `json:"cpu_count"`
	Fqdn             string             `json:"fqdn,omitempty"`
	KernelVersion    string             `json:"kernel_version,omitempty"`
	PackageMgr       string             `json:"package_mgr,omitempty"`
	ServiceMgr       string             `json:"service_mgr,omitempty"`
	LoadAverage      *LoadAverage       `json:"load_average,omitempty"`
	Memory           *Memory            `json:"memory,omitempty"`
	OSInfo           *OSInfo            `json:"os_info,omitempty"`
	PrimaryInterface string             `json:"primary_interface,omitempty"`
	Interfaces       []NetworkInterface `json:"interfaces,omitempty"`
	Routes           []Route            `json:"routes,omitempty"`
	Conditions       []Condition        `json:"conditions,omitempty"`
	Timeline         []TimelineEvent    `json:"timeline,omitempty"`
	Uptime           string             `json:"uptime,omitempty"`
	StartedAt        time.Time          `json:"started_at"`
	RegisteredAt     time.Time          `json:"registered_at"`
	Facts            map[string]any     `json:"facts,omitempty"`
}

Agent represents a registered OSAPI agent.

type AgentJobResponse

type AgentJobResponse struct {
	Hostname string `json:"hostname,omitempty"`
	Status   string `json:"status,omitempty"`
	Error    string `json:"error,omitempty"`
	Changed  *bool  `json:"changed,omitempty"`
	Data     any    `json:"data,omitempty"`
}

AgentJobResponse represents an agent's response data for a broadcast job.

type AgentList

type AgentList struct {
	Agents []Agent `json:"agents"`
	Total  int     `json:"total"`
}

AgentList is a collection of agents.

type AgentSchedulingState

type AgentSchedulingState = string

AgentSchedulingState represents the scheduling state of an agent.

const (
	// AgentReady indicates the agent is accepting and processing jobs.
	AgentReady AgentSchedulingState = "Ready"
	// AgentDraining indicates the agent is finishing in-flight jobs
	// but not accepting new ones.
	AgentDraining AgentSchedulingState = "Draining"
	// AgentCordoned indicates the agent is blocked from receiving
	// new jobs until manually uncordoned.
	AgentCordoned AgentSchedulingState = "Cordoned"
	// AgentPending indicates the agent is awaiting PKI enrollment
	// acceptance and will not process jobs until accepted.
	AgentPending AgentSchedulingState = "Pending"
)

Agent scheduling state constants.

type AgentService

type AgentService struct {
	// contains filtered or unexported fields
}

AgentService provides agent discovery and details operations.

func (*AgentService) Accept

func (s *AgentService) Accept(
	ctx context.Context,
	hostname string,
	fingerprint string,
) (*Response[MessageResponse], error)

Accept accepts a pending agent enrollment. If fingerprint is provided, the agent is accepted by fingerprint; otherwise by hostname.

func (*AgentService) Drain

func (s *AgentService) Drain(
	ctx context.Context,
	hostname string,
) (*Response[MessageResponse], error)

Drain initiates draining of an agent, stopping it from accepting new jobs while allowing in-flight jobs to complete.

func (*AgentService) Get

func (s *AgentService) Get(
	ctx context.Context,
	hostname string,
) (*Response[Agent], error)

Get retrieves detailed information about a specific agent by hostname.

func (*AgentService) List

func (s *AgentService) List(
	ctx context.Context,
) (*Response[AgentList], error)

List retrieves all active agents.

func (*AgentService) ListPending

func (s *AgentService) ListPending(
	ctx context.Context,
) (*Response[PendingAgentList], error)

ListPending retrieves all agents awaiting enrollment acceptance.

func (*AgentService) Reject

func (s *AgentService) Reject(
	ctx context.Context,
	hostname string,
) (*Response[MessageResponse], error)

Reject rejects a pending agent enrollment.

func (*AgentService) Undrain

func (s *AgentService) Undrain(
	ctx context.Context,
	hostname string,
) (*Response[MessageResponse], error)

Undrain resumes job acceptance on a drained agent.

type AgentState

type AgentState struct {
	Status   string `json:"status,omitempty"`
	Duration string `json:"duration,omitempty"`
	Error    string `json:"error,omitempty"`
}

AgentState represents an agent's processing state for a broadcast job.

type AgentStats

type AgentStats struct {
	Total  int            `json:"total"`
	Ready  int            `json:"ready"`
	Agents []AgentSummary `json:"agents,omitempty"`
}

AgentStats represents agent statistics from the health endpoint.

type AgentSummary

type AgentSummary struct {
	Hostname   string `json:"hostname"`
	Labels     string `json:"labels,omitempty"`
	Registered string `json:"registered"`
}

AgentSummary represents a summary of an agent from the health endpoint.

type AuditEntry

type AuditEntry struct {
	ID           string    `json:"id"`
	Timestamp    time.Time `json:"timestamp"`
	User         string    `json:"user"`
	Roles        []string  `json:"roles,omitempty"`
	Method       string    `json:"method"`
	Path         string    `json:"path"`
	ResponseCode int       `json:"response_code"`
	DurationMs   int64     `json:"duration_ms"`
	SourceIP     string    `json:"source_ip"`
	OperationID  string    `json:"operation_id,omitempty"`
	TraceID      string    `json:"trace_id,omitempty"`
}

AuditEntry represents a single audit log entry.

type AuditList

type AuditList struct {
	Items      []AuditEntry `json:"items"`
	TotalItems int          `json:"total_items"`
}

AuditList is a paginated list of audit entries.

type AuditService

type AuditService struct {
	// contains filtered or unexported fields
}

AuditService provides audit log operations.

func (*AuditService) Export

func (s *AuditService) Export(
	ctx context.Context,
) (*Response[AuditList], error)

Export retrieves all audit log entries for export.

func (*AuditService) Get

func (s *AuditService) Get(
	ctx context.Context,
	id string,
) (*Response[AuditEntry], error)

Get retrieves a single audit log entry by ID.

func (*AuditService) List

func (s *AuditService) List(
	ctx context.Context,
	limit int,
	offset int,
) (*Response[AuditList], error)

List retrieves audit log entries with pagination.

type AuthError

type AuthError struct {
	APIError
}

AuthError represents authentication/authorization errors (401, 403).

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

Unwrap returns the underlying APIError.

type CertificateCA

type CertificateCA struct {
	Name   string `json:"name"`
	Source string `json:"source,omitempty"`
	Object string `json:"object,omitempty"`
}

CertificateCA represents a single CA certificate entry.

type CertificateCAMutationResult

type CertificateCAMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Name     string `json:"name"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

CertificateCAMutationResult represents the result of a CA certificate create, update, or delete operation.

type CertificateCAResult

type CertificateCAResult struct {
	Hostname     string          `json:"hostname"`
	Status       string          `json:"status"`
	Certificates []CertificateCA `json:"certificates,omitempty"`
	Error        string          `json:"error,omitempty"`
}

CertificateCAResult represents a CA certificate list result from a single agent.

type CertificateCreateOpts

type CertificateCreateOpts struct {
	// Name is the certificate name (required).
	Name string
	// Object is the object store reference for the PEM file (required).
	Object string
}

CertificateCreateOpts contains options for creating a CA certificate.

type CertificateService

type CertificateService struct {
	// contains filtered or unexported fields
}

CertificateService provides CA certificate management operations.

func (*CertificateService) Create

Create creates a new CA certificate on the target host.

func (*CertificateService) Delete

Delete deletes a CA certificate on the target host.

func (*CertificateService) List

List lists all CA certificates on the target host.

func (*CertificateService) Update

Update updates an existing CA certificate on the target host.

type CertificateUpdateOpts

type CertificateUpdateOpts struct {
	// Object is the new object store reference for the PEM file (required).
	Object string
}

CertificateUpdateOpts contains options for updating a CA certificate.

type Client

type Client struct {
	// Agent provides agent discovery and details operations.
	Agent *AgentService

	// Status provides full node status queries (OS, disk, memory, load).
	Status *StatusService

	// Hostname provides hostname query and update operations.
	Hostname *HostnameService

	// Disk provides disk usage query operations.
	Disk *DiskService

	// Memory provides memory usage query operations.
	Memory *MemoryService

	// Load provides load average query operations.
	Load *LoadService

	// Uptime provides uptime query operations.
	Uptime *UptimeService

	// OS provides operating system info query operations.
	OS *OSService

	// DNS provides DNS configuration query and update operations.
	DNS *DNSService

	// Ping provides network ping operations.
	Ping *PingService

	// Command provides command execution operations (exec, shell).
	Command *CommandService

	// FileDeploy provides file deployment operations on target hosts.
	FileDeploy *FileDeployService

	// Job provides job queue operations (create, get, list, delete, retry).
	Job *JobService

	// Health provides health check operations (liveness, readiness, status).
	Health *HealthService

	// Audit provides audit log operations (list, get, export).
	Audit *AuditService

	// File provides file management operations (upload, list, get, delete).
	File *FileService

	// Docker provides Docker container management operations (create, list,
	// inspect, start, stop, remove, exec, pull).
	Docker *DockerService

	// Cron provides cron schedule management operations (list, get,
	// create, update, delete).
	Cron *CronService

	// Sysctl provides sysctl parameter management operations (list, get,
	// set, delete).
	Sysctl *SysctlService

	// NTP provides NTP management operations (get, create, update, delete).
	NTP *NTPService

	// Timezone provides system timezone management operations (get, update).
	Timezone *TimezoneService

	// Process provides process management operations (list, get, signal).
	Process *ProcessService

	// Power provides power management operations (reboot, shutdown).
	Power *PowerService

	// User provides user account management operations (list, get,
	// create, update, delete, change password).
	User *UserService

	// Group provides group management operations (list, get, create,
	// update, delete).
	Group *GroupService

	// Package provides package management operations (list, get,
	// install, remove, update, list updates).
	Package *PackageService

	// Certificate provides CA certificate management operations
	// (list, create, update, delete).
	Certificate *CertificateService

	// Log provides log viewing operations (query journal entries).
	Log *LogService

	// Service provides systemd service management operations (list, get,
	// create, update, delete, start, stop, restart, enable, disable).
	Service *ServiceService

	// Interface provides network interface management operations (list, get,
	// create, update, delete).
	Interface *InterfaceService

	// Route provides network route management operations (list, get,
	// create, update, delete).
	Route *RouteService
	// contains filtered or unexported fields
}

Client is the top-level OSAPI SDK client. Use New() to create one.

func New

func New(
	baseURL string,
	bearerToken string,
	opts ...Option,
) *Client

New creates an OSAPI SDK client.

type Collection

type Collection[T any] struct {
	Results []T    `json:"results"`
	JobID   string `json:"job_id"`
}

Collection is a generic wrapper for collection responses from node queries.

func (Collection[T]) First

func (c Collection[T]) First() (T, bool)

First returns the first result and true, or the zero value and false if the collection is empty.

type CommandResult

type CommandResult struct {
	Hostname   string `json:"hostname"`
	Status     string `json:"status"`
	Stdout     string `json:"stdout,omitempty"`
	Stderr     string `json:"stderr,omitempty"`
	Error      string `json:"error,omitempty"`
	ExitCode   int    `json:"exit_code"`
	Changed    bool   `json:"changed"`
	DurationMs int64  `json:"duration_ms"`
}

CommandResult represents command execution result from a single agent.

type CommandService

type CommandService struct {
	// contains filtered or unexported fields
}

CommandService provides command execution operations.

func (*CommandService) Exec

Exec executes a command directly without a shell interpreter.

func (*CommandService) Shell

Shell executes a command through /bin/sh -c with shell features (pipes, redirects, variable expansion).

type ComponentHealth

type ComponentHealth struct {
	Status  string `json:"status"`
	Error   string `json:"error,omitempty"`
	Address string `json:"address,omitempty"`
}

ComponentHealth represents a component's health.

type Condition

type Condition struct {
	Type               string    `json:"type"`
	Status             bool      `json:"status"`
	Reason             string    `json:"reason,omitempty"`
	LastTransitionTime time.Time `json:"last_transition_time"`
}

Condition represents a node condition evaluated agent-side.

type ConditionType

type ConditionType = string

ConditionType represents a node or process condition evaluated agent-side.

const (
	ConditionMemoryPressure ConditionType = "MemoryPressure"
	ConditionHighLoad       ConditionType = "HighLoad"
	ConditionDiskPressure   ConditionType = "DiskPressure"
)

Condition type constants.

type ConflictError

type ConflictError struct {
	APIError
}

ConflictError represents conflict errors (409).

func (*ConflictError) Unwrap

func (e *ConflictError) Unwrap() error

Unwrap returns the underlying APIError.

type ConsumerDetail

type ConsumerDetail struct {
	Name        string `json:"name"`
	Pending     int    `json:"pending"`
	AckPending  int    `json:"ack_pending"`
	Redelivered int    `json:"redelivered"`
}

ConsumerDetail represents a single consumer's details.

type ConsumerStats

type ConsumerStats struct {
	Total     int              `json:"total"`
	Consumers []ConsumerDetail `json:"consumers,omitempty"`
}

ConsumerStats represents JetStream consumer statistics.

type CronCreateOpts

type CronCreateOpts struct {
	// Name is the cron drop-in entry name (required).
	Name string
	// Object is the name of the uploaded file in the object store (required).
	Object string
	// Schedule is the cron expression (mutually exclusive with Interval).
	Schedule string
	// Interval is the periodic interval: hourly, daily, weekly, monthly
	// (mutually exclusive with Schedule).
	Interval string
	// User is the user to run the command as (optional).
	User string
	// ContentType is "raw" or "template" (optional, defaults to raw).
	ContentType string
	// Vars contains template variables (optional).
	Vars map[string]any
}

CronCreateOpts contains options for creating a cron entry.

type CronEntryResult

type CronEntryResult struct {
	Hostname string `json:"hostname,omitempty"`
	Status   string `json:"status"`
	Name     string `json:"name"`
	Object   string `json:"object,omitempty"`
	Schedule string `json:"schedule,omitempty"`
	Interval string `json:"interval,omitempty"`
	Source   string `json:"source,omitempty"`
	User     string `json:"user,omitempty"`
	Error    string `json:"error,omitempty"`
}

CronEntryResult represents a cron entry from a single agent.

type CronMutationResult

type CronMutationResult struct {
	Hostname string `json:"hostname,omitempty"`
	Status   string `json:"status"`
	Name     string `json:"name"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

CronMutationResult represents the result of a cron create/update/delete operation.

type CronService

type CronService struct {
	// contains filtered or unexported fields
}

CronService provides cron schedule management operations.

func (*CronService) Create

Create creates a new cron entry on the target host.

func (*CronService) Delete

func (s *CronService) Delete(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[CronMutationResult]], error)

Delete deletes a cron entry on the target host.

func (*CronService) Get

func (s *CronService) Get(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[CronEntryResult]], error)

Get retrieves a single cron entry by name on the target host.

func (*CronService) List

func (s *CronService) List(
	ctx context.Context,
	hostname string,
) (*Response[Collection[CronEntryResult]], error)

List lists all cron entries on the target host.

func (*CronService) Update

func (s *CronService) Update(
	ctx context.Context,
	hostname string,
	name string,
	opts CronUpdateOpts,
) (*Response[Collection[CronMutationResult]], error)

Update updates an existing cron entry on the target host.

type CronUpdateOpts

type CronUpdateOpts struct {
	// Object is the new object to deploy (optional).
	Object string
	// Schedule is the cron expression (optional).
	Schedule string
	// User is the user to run the command as (optional).
	User string
	// ContentType is "raw" or "template" (optional).
	ContentType string
	// Vars contains template variables (optional).
	Vars map[string]any
}

CronUpdateOpts contains options for updating a cron entry.

type DNSConfig

type DNSConfig struct {
	Hostname      string   `json:"hostname"`
	Status        string   `json:"status"`
	Error         string   `json:"error,omitempty"`
	Changed       bool     `json:"changed"`
	Servers       []string `json:"servers,omitempty"`
	SearchDomains []string `json:"search_domains,omitempty"`
}

DNSConfig represents DNS configuration from a single agent.

type DNSDeleteResult

type DNSDeleteResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Error    string `json:"error,omitempty"`
	Changed  bool   `json:"changed"`
}

DNSDeleteResult represents DNS delete result from a single agent.

type DNSService

type DNSService struct {
	// contains filtered or unexported fields
}

DNSService provides DNS configuration query and update operations.

func (*DNSService) Delete

func (s *DNSService) Delete(
	ctx context.Context,
	target string,
	interfaceName string,
) (*Response[Collection[DNSDeleteResult]], error)

Delete removes DNS configuration for a network interface on the target host.

func (*DNSService) Get

func (s *DNSService) Get(
	ctx context.Context,
	target string,
	interfaceName string,
) (*Response[Collection[DNSConfig]], error)

Get retrieves DNS configuration for a network interface on the target host.

func (*DNSService) Update

func (s *DNSService) Update(
	ctx context.Context,
	target string,
	interfaceName string,
	servers []string,
	searchDomains []string,
	overrideDHCP bool,
) (*Response[Collection[DNSUpdateResult]], error)

Update updates DNS configuration for a network interface on the target host.

type DNSUpdateResult

type DNSUpdateResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Error    string `json:"error,omitempty"`
	Changed  bool   `json:"changed"`
}

DNSUpdateResult represents DNS update result from a single agent.

type Disk

type Disk struct {
	Name  string `json:"name"`
	Total int    `json:"total"`
	Used  int    `json:"used"`
	Free  int    `json:"free"`
}

Disk represents disk usage information.

type DiskResult

type DiskResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Error    string `json:"error,omitempty"`
	Changed  bool   `json:"changed"`
	Disks    []Disk `json:"disks,omitempty"`
}

DiskResult represents disk query result from a single agent.

type DiskService

type DiskService struct {
	// contains filtered or unexported fields
}

DiskService provides disk usage query operations.

func (*DiskService) Get

func (s *DiskService) Get(
	ctx context.Context,
	target string,
) (*Response[Collection[DiskResult]], error)

Get retrieves disk usage information from the target host.

type DockerActionResult

type DockerActionResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	ID       string `json:"id,omitempty"`
	Message  string `json:"message,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

DockerActionResult represents a docker container lifecycle action result from a single agent.

type DockerCreateOpts

type DockerCreateOpts struct {
	// Image is the container image reference (required).
	Image string
	// Name is an optional container name.
	Name string
	// Hostname sets the container hostname.
	Hostname string
	// DNS sets custom DNS servers for the container.
	DNS []string
	// Command overrides the image's default command.
	Command []string
	// Env is environment variables in KEY=VALUE format.
	Env []string
	// Ports is port mappings in host_port:container_port format.
	Ports []string
	// Volumes is volume mounts in host_path:container_path format.
	Volumes []string
	// AutoStart starts the container after creation (default true).
	AutoStart *bool
}

DockerCreateOpts contains options for creating a container.

type DockerDetailResult

type DockerDetailResult struct {
	Hostname        string            `json:"hostname"`
	Status          string            `json:"status"`
	ID              string            `json:"id,omitempty"`
	Name            string            `json:"name,omitempty"`
	Image           string            `json:"image,omitempty"`
	State           string            `json:"state,omitempty"`
	Created         string            `json:"created,omitempty"`
	Ports           []string          `json:"ports,omitempty"`
	Mounts          []string          `json:"mounts,omitempty"`
	Env             []string          `json:"env,omitempty"`
	NetworkSettings map[string]string `json:"network_settings,omitempty"`
	Health          string            `json:"health,omitempty"`
	Changed         bool              `json:"changed"`
	Error           string            `json:"error,omitempty"`
}

DockerDetailResult represents a docker container inspect result from a single agent.

type DockerExecOpts

type DockerExecOpts struct {
	// Command is the command and arguments to execute (required).
	Command []string
	// Env is additional environment variables in KEY=VALUE format.
	Env []string
	// WorkingDir is the working directory inside the container.
	WorkingDir string
}

DockerExecOpts contains options for executing a command in a container.

type DockerExecResult

type DockerExecResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Stdout   string `json:"stdout,omitempty"`
	Stderr   string `json:"stderr,omitempty"`
	ExitCode int    `json:"exit_code"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

DockerExecResult represents a docker container exec result from a single agent.

type DockerImageRemoveParams

type DockerImageRemoveParams struct {
	// Force forces removal even if the image is in use.
	Force bool
}

DockerImageRemoveParams contains parameters for removing an image.

type DockerListParams

type DockerListParams struct {
	// State filters by state: "running", "stopped", "all".
	State string
	// Limit caps the number of results.
	Limit int
}

DockerListParams contains parameters for listing containers.

type DockerListResult

type DockerListResult struct {
	Hostname   string              `json:"hostname"`
	Status     string              `json:"status"`
	Containers []DockerSummaryItem `json:"containers,omitempty"`
	Changed    bool                `json:"changed"`
	Error      string              `json:"error,omitempty"`
}

DockerListResult represents a docker container list result from a single agent.

type DockerPullOpts

type DockerPullOpts struct {
	// Image is the image reference to pull (required).
	Image string
}

DockerPullOpts contains options for pulling an image.

type DockerPullResult

type DockerPullResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	ImageID  string `json:"image_id,omitempty"`
	Tag      string `json:"tag,omitempty"`
	Size     int64  `json:"size"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

DockerPullResult represents a docker image pull result from a single agent.

type DockerRemoveParams

type DockerRemoveParams struct {
	// Force forces removal of a running container.
	Force bool
}

DockerRemoveParams contains parameters for removing a container.

type DockerResult

type DockerResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	ID       string `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	Image    string `json:"image,omitempty"`
	State    string `json:"state,omitempty"`
	Created  string `json:"created,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

DockerResult represents a docker container create result from a single agent.

type DockerService

type DockerService struct {
	// contains filtered or unexported fields
}

DockerService provides Docker container management operations.

func (*DockerService) Create

func (s *DockerService) Create(
	ctx context.Context,
	hostname string,
	opts DockerCreateOpts,
) (*Response[Collection[DockerResult]], error)

Create creates a new container on the target host.

func (*DockerService) Exec

Exec executes a command inside a running container on the target host.

func (*DockerService) ImageRemove

func (s *DockerService) ImageRemove(
	ctx context.Context,
	hostname string,
	imageName string,
	params *DockerImageRemoveParams,
) (*Response[Collection[DockerActionResult]], error)

ImageRemove removes a container image from the target host.

func (*DockerService) Inspect

func (s *DockerService) Inspect(
	ctx context.Context,
	hostname string,
	id string,
) (*Response[Collection[DockerDetailResult]], error)

Inspect retrieves detailed information about a specific container.

func (*DockerService) List

List lists containers on the target host, optionally filtered by state.

func (*DockerService) Pull

Pull pulls a container image on the target host.

func (*DockerService) Remove

Remove removes a container from the target host.

func (*DockerService) Start

func (s *DockerService) Start(
	ctx context.Context,
	hostname string,
	id string,
) (*Response[Collection[DockerActionResult]], error)

Start starts a stopped container on the target host.

func (*DockerService) Stop

Stop stops a running container on the target host.

type DockerStopOpts

type DockerStopOpts struct {
	// Timeout is seconds to wait before killing. Zero uses default.
	Timeout int
}

DockerStopOpts contains options for stopping a container.

type DockerSummaryItem

type DockerSummaryItem struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Image   string `json:"image"`
	State   string `json:"state"`
	Created string `json:"created"`
}

DockerSummaryItem represents a brief docker container summary.

type ExecRequest

type ExecRequest struct {
	// Command is the binary to execute (required).
	Command string

	// Args is the argument list passed to the command.
	Args []string

	// Cwd is the working directory. Empty uses the agent default.
	Cwd string

	// Timeout in seconds. Zero uses the server default (30s).
	Timeout int

	// Target specifies the host: "_any", "_all", hostname, or
	// label ("group:web").
	Target string
}

ExecRequest contains parameters for direct command execution.

type FileChanged

type FileChanged struct {
	Name    string `json:"name"`
	Changed bool   `json:"changed"`
	SHA256  string `json:"sha256"`
}

FileChanged represents the result of a change detection check.

type FileDelete

type FileDelete struct {
	Name    string `json:"name"`
	Deleted bool   `json:"deleted"`
}

FileDelete represents the result of a file deletion.

type FileDeployOpts

type FileDeployOpts struct {
	// ObjectName is the name of the file in the Object Store (required).
	ObjectName string

	// Path is the destination path on the target filesystem (required).
	Path string

	// ContentType is "raw" or "template" (required).
	ContentType string

	// Mode is the file permission mode (e.g., "0644"). Optional.
	Mode string

	// Owner is the file owner user. Optional.
	Owner string

	// Group is the file owner group. Optional.
	Group string

	// Vars are template variables when ContentType is "template". Optional.
	Vars map[string]any

	// Target specifies the host: "_any", "_all", hostname, or
	// label ("group:web").
	Target string
}

FileDeployOpts contains parameters for file deployment.

type FileDeployResult

type FileDeployResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

FileDeployResult represents the result of a file deploy operation for a single host in a collection response.

type FileDeployService

type FileDeployService struct {
	// contains filtered or unexported fields
}

FileDeployService provides file deployment operations on target hosts.

func (*FileDeployService) Deploy

Deploy deploys a file from the Object Store to the target host.

func (*FileDeployService) Status

func (s *FileDeployService) Status(
	ctx context.Context,
	target string,
	path string,
) (*Response[Collection[FileStatusResult]], error)

Status checks the deployment status of a file on the target host.

func (*FileDeployService) Undeploy

Undeploy removes a deployed file from the target host filesystem.

type FileItem

type FileItem struct {
	Name        string `json:"name"`
	SHA256      string `json:"sha256"`
	Size        int    `json:"size"`
	ContentType string `json:"content_type"`
	Source      string `json:"source"`
}

FileItem represents file metadata in a list.

type FileList

type FileList struct {
	Files []FileItem `json:"files"`
	Total int        `json:"total"`
}

FileList is a collection of files with total count.

type FileMetadata

type FileMetadata struct {
	Name        string `json:"name"`
	SHA256      string `json:"sha256"`
	Size        int    `json:"size"`
	ContentType string `json:"content_type"`
}

FileMetadata represents metadata for a single file.

type FileService

type FileService struct {
	// contains filtered or unexported fields
}

FileService provides file management operations for the Object Store.

func (*FileService) Changed

func (s *FileService) Changed(
	ctx context.Context,
	name string,
	file io.Reader,
) (*Response[FileChanged], error)

Changed computes the SHA-256 of the provided content and compares it against the stored hash in the Object Store. Returns true if the content differs or the file does not exist yet.

func (*FileService) Delete

func (s *FileService) Delete(
	ctx context.Context,
	name string,
) (*Response[FileDelete], error)

Delete removes a file from the Object Store.

func (*FileService) Get

func (s *FileService) Get(
	ctx context.Context,
	name string,
) (*Response[FileMetadata], error)

Get retrieves metadata for a specific file in the Object Store.

func (*FileService) List

func (s *FileService) List(
	ctx context.Context,
) (*Response[FileList], error)

List retrieves all files stored in the Object Store.

func (*FileService) Stale

func (s *FileService) Stale(
	ctx context.Context,
) (*Response[StaleList], error)

Stale lists deployments where the deployed file content no longer matches the current object store content.

func (*FileService) Upload

func (s *FileService) Upload(
	ctx context.Context,
	name string,
	contentType string,
	file io.Reader,
	opts ...UploadOption,
) (*Response[FileUpload], error)

Upload uploads a file to the Object Store via multipart/form-data. By default, it computes SHA-256 locally and compares against the stored hash to skip the upload when content is unchanged. Use WithForce to bypass this check.

type FileStatusResult

type FileStatusResult struct {
	Hostname string `json:"hostname"`
	Path     string `json:"path,omitempty"`
	Status   string `json:"status,omitempty"`
	SHA256   string `json:"sha256,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

FileStatusResult represents the result of a file status check for a single host in a collection response.

type FileUndeployOpts

type FileUndeployOpts struct {
	// Path is the filesystem path to remove from the target host (required).
	Path string

	// Target specifies the host: "_any", "_all", hostname, or
	// label ("group:web").
	Target string
}

FileUndeployOpts contains parameters for file undeployment.

type FileUndeployResult

type FileUndeployResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

FileUndeployResult represents the result of a file undeploy operation for a single host in a collection response.

type FileUpload

type FileUpload struct {
	Name        string `json:"name"`
	SHA256      string `json:"sha256"`
	Size        int    `json:"size"`
	Changed     bool   `json:"changed"`
	ContentType string `json:"content_type"`
}

FileUpload represents a successfully uploaded file.

type GroupCreateOpts

type GroupCreateOpts struct {
	// Name is the group name. Required.
	Name string
	// GID is the numeric group ID. If zero, the system assigns one.
	GID int
	// System creates a system group.
	System bool
}

GroupCreateOpts contains options for creating a group.

type GroupInfo

type GroupInfo struct {
	Name    string   `json:"name,omitempty"`
	GID     int      `json:"gid,omitempty"`
	Members []string `json:"members,omitempty"`
}

GroupInfo represents a group on the target node.

type GroupInfoResult

type GroupInfoResult struct {
	Hostname string      `json:"hostname"`
	Status   string      `json:"status"`
	Groups   []GroupInfo `json:"groups,omitempty"`
	Error    string      `json:"error,omitempty"`
}

GroupInfoResult represents a group listing result from a query operation.

type GroupMutationResult

type GroupMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Name     string `json:"name,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

GroupMutationResult represents the result of a group create, update, or delete operation.

type GroupService

type GroupService struct {
	// contains filtered or unexported fields
}

GroupService provides group management operations.

func (*GroupService) Create

Create creates a group on the target host.

func (*GroupService) Delete

func (s *GroupService) Delete(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[GroupMutationResult]], error)

Delete removes a group on the target host.

func (*GroupService) Get

func (s *GroupService) Get(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[GroupInfoResult]], error)

Get retrieves a single group by name on the target host.

func (*GroupService) List

func (s *GroupService) List(
	ctx context.Context,
	hostname string,
) (*Response[Collection[GroupInfoResult]], error)

List lists all groups on the target host.

func (*GroupService) Update

func (s *GroupService) Update(
	ctx context.Context,
	hostname string,
	name string,
	opts GroupUpdateOpts,
) (*Response[Collection[GroupMutationResult]], error)

Update updates a group on the target host.

type GroupUpdateOpts

type GroupUpdateOpts struct {
	// Members is the list of group member usernames (replaces existing).
	Members []string
}

GroupUpdateOpts contains options for updating a group.

type HealthService

type HealthService struct {
	// contains filtered or unexported fields
}

HealthService provides health check operations.

func (*HealthService) Liveness

func (s *HealthService) Liveness(
	ctx context.Context,
) (*Response[HealthStatus], error)

Liveness checks if the API server process is alive.

func (*HealthService) Ready

func (s *HealthService) Ready(
	ctx context.Context,
) (*Response[ReadyStatus], error)

Ready checks if the API server and its dependencies are ready to serve traffic. A 503 response is treated as success with the ServiceUnavailable flag set.

func (*HealthService) Status

func (s *HealthService) Status(
	ctx context.Context,
) (*Response[SystemStatus], error)

Status returns detailed system status including component health, NATS info, stream stats, and job queue counts. Requires authentication. A 503 response is treated as success with the ServiceUnavailable flag set.

type HealthStatus

type HealthStatus struct {
	Status string `json:"status"`
}

HealthStatus represents a liveness check response.

type HostnameResult

type HostnameResult struct {
	Hostname string            `json:"hostname"`
	Status   string            `json:"status"`
	Error    string            `json:"error,omitempty"`
	Changed  bool              `json:"changed"`
	Labels   map[string]string `json:"labels,omitempty"`
}

HostnameResult represents a hostname query result from a single agent.

type HostnameService

type HostnameService struct {
	// contains filtered or unexported fields
}

HostnameService provides hostname query and update operations.

func (*HostnameService) Get

Get retrieves the hostname from the target host.

func (*HostnameService) Update

Update updates the hostname on the target node.

type HostnameUpdateResult

type HostnameUpdateResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Error    string `json:"error,omitempty"`
	Changed  bool   `json:"changed"`
}

HostnameUpdateResult represents a hostname update result from a single agent.

type InterfaceConfigOpts

type InterfaceConfigOpts struct {
	// DHCP4 enables or disables DHCPv4.
	DHCP4 *bool
	// DHCP6 enables or disables DHCPv6.
	DHCP6 *bool
	// Addresses is the list of IP addresses in CIDR notation.
	Addresses []string
	// Gateway4 is the IPv4 gateway address.
	Gateway4 string
	// Gateway6 is the IPv6 gateway address.
	Gateway6 string
	// MTU is the maximum transmission unit.
	MTU *int
	// MACAddress is the hardware MAC address.
	MACAddress string
	// WakeOnLAN enables or disables Wake-on-LAN.
	WakeOnLAN *bool
}

InterfaceConfigOpts contains options for creating or updating a network interface.

type InterfaceGetResult

type InterfaceGetResult struct {
	Hostname  string         `json:"hostname"`
	Status    string         `json:"status"`
	Error     string         `json:"error,omitempty"`
	Interface *InterfaceInfo `json:"interface,omitempty"`
}

InterfaceGetResult represents an interface get result from a single agent.

type InterfaceInfo

type InterfaceInfo struct {
	Name       string   `json:"name,omitempty"`
	IPv4       string   `json:"ipv4,omitempty"`
	IPv6       string   `json:"ipv6,omitempty"`
	MAC        string   `json:"mac,omitempty"`
	Family     string   `json:"family,omitempty"`
	Primary    bool     `json:"primary"`
	DHCP4      bool     `json:"dhcp4"`
	DHCP6      bool     `json:"dhcp6"`
	Addresses  []string `json:"addresses,omitempty"`
	Gateway4   string   `json:"gateway4,omitempty"`
	Gateway6   string   `json:"gateway6,omitempty"`
	MTU        int      `json:"mtu,omitempty"`
	MACAddress string   `json:"mac_address,omitempty"`
	WakeOnLAN  bool     `json:"wakeonlan"`
	State      string   `json:"state,omitempty"`
}

InterfaceInfo represents a network interface's configuration.

type InterfaceListResult

type InterfaceListResult struct {
	Hostname   string          `json:"hostname"`
	Status     string          `json:"status"`
	Error      string          `json:"error,omitempty"`
	Interfaces []InterfaceInfo `json:"interfaces,omitempty"`
}

InterfaceListResult represents an interface list result from a single agent.

type InterfaceMutationResult

type InterfaceMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Name     string `json:"name,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

InterfaceMutationResult represents the result of an interface create, update, or delete.

type InterfaceService

type InterfaceService struct {
	// contains filtered or unexported fields
}

InterfaceService provides network interface management operations.

func (*InterfaceService) Create

Create creates a network interface configuration on the target host.

func (*InterfaceService) Delete

Delete removes a network interface configuration on the target host.

func (*InterfaceService) Get

Get retrieves a single network interface by name on the target host.

func (*InterfaceService) List

List lists all network interfaces on the target host.

func (*InterfaceService) Update

Update updates a network interface configuration on the target host.

type JobCreated

type JobCreated struct {
	JobID     string `json:"job_id"`
	Status    string `json:"status"`
	Revision  int64  `json:"revision"`
	Timestamp string `json:"timestamp,omitempty"`
}

JobCreated represents a newly created job response.

type JobDetail

type JobDetail struct {
	ID          string                      `json:"id,omitempty"`
	Status      string                      `json:"status,omitempty"`
	Hostname    string                      `json:"hostname,omitempty"`
	Created     string                      `json:"created,omitempty"`
	UpdatedAt   string                      `json:"updated_at,omitempty"`
	Error       string                      `json:"error,omitempty"`
	Changed     *bool                       `json:"changed,omitempty"`
	Operation   map[string]any              `json:"operation,omitempty"`
	Result      any                         `json:"result,omitempty"`
	AgentStates map[string]AgentState       `json:"agent_states,omitempty"`
	Responses   map[string]AgentJobResponse `json:"responses,omitempty"`
	Timeline    []TimelineEvent             `json:"timeline,omitempty"`
}

JobDetail represents a job's full details.

type JobList

type JobList struct {
	Items        []JobDetail    `json:"items,omitempty"`
	TotalItems   int            `json:"total_items"`
	StatusCounts map[string]int `json:"status_counts,omitempty"`
}

JobList is a paginated list of jobs.

type JobOperation

type JobOperation = string

JobOperation represents a specific operation using hierarchical dot notation. SDK consumers use these to avoid string typos when building orchestrator tasks. Defined as a type alias so it's interchangeable with string in assignments.

const (
	OpNodeHostnameGet    JobOperation = "node.hostname.get"
	OpNodeHostnameUpdate JobOperation = "node.hostname.update"
	OpNodeStatusGet      JobOperation = "node.status.get"
	OpNodeUptimeGet      JobOperation = "node.uptime.get"
	OpNodeLoadGet        JobOperation = "node.load.get"
	OpNodeMemoryGet      JobOperation = "node.memory.get"
	OpNodeDiskGet        JobOperation = "node.disk.get"
	OpNodeOSGet          JobOperation = "node.os.get"
)

Node operations — read-only operations that query node state.

const (
	OpNetworkDNSGet    JobOperation = "network.dns.get"
	OpNetworkDNSUpdate JobOperation = "network.dns.update"
	OpNetworkDNSDelete JobOperation = "network.dns.delete"
	OpNetworkPingDo    JobOperation = "network.ping.do"
)

Network operations.

const (
	OpCommandExec  JobOperation = "command.exec.execute"
	OpCommandShell JobOperation = "command.shell.execute"
)

Command operations — execute arbitrary commands on agents.

const (
	OpFileDeploy    JobOperation = "file.deploy.execute"
	OpFileUndeploy  JobOperation = "file.undeploy.execute"
	OpFileStatusGet JobOperation = "file.status.get"
)

File operations — manage file deployments and status.

const (
	OpDockerCreate      JobOperation = "docker.create.execute"
	OpDockerStart       JobOperation = "docker.start.execute"
	OpDockerStop        JobOperation = "docker.stop.execute"
	OpDockerRemove      JobOperation = "docker.remove.execute"
	OpDockerList        JobOperation = "docker.list.get"
	OpDockerInspect     JobOperation = "docker.inspect.get"
	OpDockerExec        JobOperation = "docker.exec.execute"
	OpDockerPull        JobOperation = "docker.pull.execute"
	OpDockerImageRemove JobOperation = "docker.image-remove.execute"
)

Docker operations.

const (
	OpCronList   JobOperation = "schedule.cron.list"
	OpCronGet    JobOperation = "schedule.cron.get"
	OpCronCreate JobOperation = "schedule.cron.create"
	OpCronUpdate JobOperation = "schedule.cron.update"
	OpCronDelete JobOperation = "schedule.cron.delete"
)

Schedule/Cron operations.

const (
	OpSysctlList   JobOperation = "node.sysctl.list"
	OpSysctlGet    JobOperation = "node.sysctl.get"
	OpSysctlCreate JobOperation = "node.sysctl.create"
	OpSysctlUpdate JobOperation = "node.sysctl.update"
	OpSysctlDelete JobOperation = "node.sysctl.delete"
)

Sysctl operations.

const (
	OpNtpGet    JobOperation = "node.ntp.get"
	OpNtpCreate JobOperation = "node.ntp.create"
	OpNtpUpdate JobOperation = "node.ntp.update"
	OpNtpDelete JobOperation = "node.ntp.delete"
)

NTP operations.

const (
	OpTimezoneGet    JobOperation = "node.timezone.get"
	OpTimezoneUpdate JobOperation = "node.timezone.update"
)

Timezone operations.

const (
	OpPowerReboot   JobOperation = "node.power.reboot"
	OpPowerShutdown JobOperation = "node.power.shutdown"
)

Power operations.

const (
	OpProcessList   JobOperation = "node.process.list"
	OpProcessGet    JobOperation = "node.process.get"
	OpProcessSignal JobOperation = "node.process.signal"
)

Process operations.

const (
	OpUserList           JobOperation = "node.user.list"
	OpUserGet            JobOperation = "node.user.get"
	OpUserCreate         JobOperation = "node.user.create"
	OpUserUpdate         JobOperation = "node.user.update"
	OpUserDelete         JobOperation = "node.user.delete"
	OpUserChangePassword JobOperation = "node.user.password"
)

User operations.

const (
	OpGroupList   JobOperation = "node.group.list"
	OpGroupGet    JobOperation = "node.group.get"
	OpGroupCreate JobOperation = "node.group.create"
	OpGroupUpdate JobOperation = "node.group.update"
	OpGroupDelete JobOperation = "node.group.delete"
)

Group operations.

const (
	OpSSHKeyList   JobOperation = "node.sshKey.list"
	OpSSHKeyAdd    JobOperation = "node.sshKey.add"
	OpSSHKeyRemove JobOperation = "node.sshKey.remove"
)

SSH Key operations.

const (
	OpPackageList        JobOperation = "node.package.list"
	OpPackageGet         JobOperation = "node.package.get"
	OpPackageInstall     JobOperation = "node.package.install"
	OpPackageRemove      JobOperation = "node.package.remove"
	OpPackageUpdate      JobOperation = "node.package.update"
	OpPackageListUpdates JobOperation = "node.package.listUpdates"
)

Package operations.

const (
	OpLogQuery     JobOperation = "node.log.query"
	OpLogQueryUnit JobOperation = "node.log.queryUnit"
	OpLogSources   JobOperation = "node.log.sources"
)

Log operations.

const (
	OpCertificateCAList   JobOperation = "certificate.ca.list"
	OpCertificateCACreate JobOperation = "certificate.ca.create"
	OpCertificateCAUpdate JobOperation = "certificate.ca.update"
	OpCertificateCADelete JobOperation = "certificate.ca.delete"
)

Certificate operations.

const (
	OpNetworkInterfaceList   JobOperation = "network.interface.list"
	OpNetworkInterfaceGet    JobOperation = "network.interface.get"
	OpNetworkInterfaceCreate JobOperation = "network.interface.create"
	OpNetworkInterfaceUpdate JobOperation = "network.interface.update"
	OpNetworkInterfaceDelete JobOperation = "network.interface.delete"
)

Network interface operations.

const (
	OpNetworkRouteList   JobOperation = "network.route.list"
	OpNetworkRouteGet    JobOperation = "network.route.get"
	OpNetworkRouteCreate JobOperation = "network.route.create"
	OpNetworkRouteUpdate JobOperation = "network.route.update"
	OpNetworkRouteDelete JobOperation = "network.route.delete"
)

Network route operations.

const (
	OpServiceList    JobOperation = "node.service.list"
	OpServiceGet     JobOperation = "node.service.get"
	OpServiceCreate  JobOperation = "node.service.create"
	OpServiceUpdate  JobOperation = "node.service.update"
	OpServiceDelete  JobOperation = "node.service.delete"
	OpServiceStart   JobOperation = "node.service.start"
	OpServiceStop    JobOperation = "node.service.stop"
	OpServiceRestart JobOperation = "node.service.restart"
	OpServiceEnable  JobOperation = "node.service.enable"
	OpServiceDisable JobOperation = "node.service.disable"
)

Service operations.

type JobService

type JobService struct {
	// contains filtered or unexported fields
}

JobService provides job queue operations.

func (*JobService) Delete

func (s *JobService) Delete(
	ctx context.Context,
	id string,
) error

Delete deletes a job by ID.

func (*JobService) Get

func (s *JobService) Get(
	ctx context.Context,
	id string,
) (*Response[JobDetail], error)

Get retrieves a job by ID.

func (*JobService) List

func (s *JobService) List(
	ctx context.Context,
	params ListParams,
) (*Response[JobList], error)

List retrieves jobs, optionally filtered by status.

func (*JobService) Retry

func (s *JobService) Retry(
	ctx context.Context,
	id string,
	target string,
) (*Response[JobCreated], error)

Retry retries a failed job by ID, optionally on a different target.

type JobStats

type JobStats struct {
	Total       int `json:"total"`
	Completed   int `json:"completed"`
	Failed      int `json:"failed"`
	Processing  int `json:"processing"`
	Unprocessed int `json:"unprocessed"`
	Dlq         int `json:"dlq"`
}

JobStats represents job queue statistics from the health endpoint.

type JobStatus

type JobStatus string

JobStatus represents the status of a job in the OSAPI system. These values match the status strings returned by the REST API.

const (
	// JobStatusSubmitted indicates the job is queued but no agent has
	// acknowledged it yet.
	JobStatusSubmitted JobStatus = "submitted"
	// JobStatusAcknowledged indicates an agent received the job.
	JobStatusAcknowledged JobStatus = "acknowledged"
	// JobStatusStarted indicates the agent has begun processing.
	JobStatusStarted JobStatus = "started"
	// JobStatusProcessing indicates the job is currently being processed.
	JobStatusProcessing JobStatus = "processing"
	// JobStatusCompleted indicates the job completed successfully.
	JobStatusCompleted JobStatus = "completed"
	// JobStatusFailed indicates the job failed during processing.
	JobStatusFailed JobStatus = "failed"
	// JobStatusSkipped indicates the job was skipped because the operation
	// is not supported on the target OS family.
	JobStatusSkipped JobStatus = "skipped"
	// JobStatusPartialFailure indicates some agents completed and some
	// failed in a broadcast operation.
	JobStatusPartialFailure JobStatus = "partial_failure"
	// JobStatusRetried indicates the job was retried after a failure.
	JobStatusRetried JobStatus = "retried"
	// JobStatusPending indicates the job is queued but not yet processed.
	JobStatusPending JobStatus = "pending"
)

type JobType

type JobType = string

JobType represents the type of job operation. Defined as a type alias so it's interchangeable with string in assignments.

const (
	// JobTypeQuery represents read operations that query system state.
	JobTypeQuery JobType = "query"
	// JobTypeModify represents write operations that modify system state.
	JobTypeModify JobType = "modify"
)

type KVBucketInfo

type KVBucketInfo struct {
	Name  string `json:"name"`
	Keys  int    `json:"keys"`
	Bytes int    `json:"bytes"`
}

KVBucketInfo represents a KV bucket's info.

type ListParams

type ListParams struct {
	// Status filters by job status (e.g., "pending", "completed").
	Status string

	// Limit is the maximum number of results. Zero uses server default.
	Limit int

	// Offset is the number of results to skip. Zero starts from the
	// beginning.
	Offset int
}

ListParams contains optional filters for listing jobs.

type LoadAverage

type LoadAverage struct {
	OneMin     float32 `json:"one_min"`
	FiveMin    float32 `json:"five_min"`
	FifteenMin float32 `json:"fifteen_min"`
}

LoadAverage represents system load averages.

type LoadResult

type LoadResult struct {
	Hostname    string       `json:"hostname"`
	Status      string       `json:"status"`
	Error       string       `json:"error,omitempty"`
	Changed     bool         `json:"changed"`
	LoadAverage *LoadAverage `json:"load_average,omitempty"`
}

LoadResult represents load average query result from a single agent.

type LoadService

type LoadService struct {
	// contains filtered or unexported fields
}

LoadService provides load average query operations.

func (*LoadService) Get

func (s *LoadService) Get(
	ctx context.Context,
	target string,
) (*Response[Collection[LoadResult]], error)

Get retrieves load average information from the target host.

type LogEntry

type LogEntry struct {
	Timestamp string `json:"timestamp,omitempty"`
	Unit      string `json:"unit,omitempty"`
	Priority  string `json:"priority,omitempty"`
	Message   string `json:"message,omitempty"`
	PID       int    `json:"pid,omitempty"`
	Hostname  string `json:"hostname,omitempty"`
}

LogEntry represents a single journal entry.

type LogEntryResult

type LogEntryResult struct {
	Hostname string     `json:"hostname"`
	Status   string     `json:"status"`
	Entries  []LogEntry `json:"entries,omitempty"`
	Error    string     `json:"error,omitempty"`
}

LogEntryResult represents the result of a log query for one host.

type LogQueryOpts

type LogQueryOpts struct {
	// Lines is the maximum number of log lines to return.
	Lines *int
	// Since filters entries since this time (e.g., "1h", "2026-01-01 00:00:00").
	Since *string
	// Priority filters by log priority level (e.g., "err", "warning", "info").
	Priority *string
}

LogQueryOpts contains options for log query operations.

type LogService

type LogService struct {
	// contains filtered or unexported fields
}

LogService provides log viewing operations.

func (*LogService) Query

func (s *LogService) Query(
	ctx context.Context,
	hostname string,
	opts LogQueryOpts,
) (*Response[Collection[LogEntryResult]], error)

Query returns journal log entries for the target host.

func (*LogService) QueryUnit

func (s *LogService) QueryUnit(
	ctx context.Context,
	hostname string,
	unit string,
	opts LogQueryOpts,
) (*Response[Collection[LogEntryResult]], error)

QueryUnit returns journal log entries for a specific systemd unit on the target host.

func (*LogService) Sources

func (s *LogService) Sources(
	ctx context.Context,
	hostname string,
) (*Response[Collection[LogSourceResult]], error)

Sources returns unique syslog identifiers available in the journal on the target host.

type LogSourceResult

type LogSourceResult struct {
	Hostname string   `json:"hostname"`
	Status   string   `json:"status"`
	Sources  []string `json:"sources,omitempty"`
	Error    string   `json:"error,omitempty"`
}

LogSourceResult represents the result of a log sources query for one host.

type Memory

type Memory struct {
	Total int `json:"total"`
	Used  int `json:"used"`
	Free  int `json:"free"`
}

Memory represents memory usage information.

type MemoryResult

type MemoryResult struct {
	Hostname string  `json:"hostname"`
	Status   string  `json:"status"`
	Error    string  `json:"error,omitempty"`
	Changed  bool    `json:"changed"`
	Memory   *Memory `json:"memory,omitempty"`
}

MemoryResult represents memory query result from a single agent.

type MemoryService

type MemoryService struct {
	// contains filtered or unexported fields
}

MemoryService provides memory usage query operations.

func (*MemoryService) Get

Get retrieves memory usage information from the target host.

type MessageResponse

type MessageResponse struct {
	Message string
}

MessageResponse represents a simple message response from the API.

type NATSInfo

type NATSInfo struct {
	URL     string `json:"url"`
	Version string `json:"version"`
}

NATSInfo represents NATS connection info.

type NTPService

type NTPService struct {
	// contains filtered or unexported fields
}

NTPService provides NTP management operations.

func (*NTPService) Create

func (s *NTPService) Create(
	ctx context.Context,
	hostname string,
	opts NtpCreateOpts,
) (*Response[Collection[NtpMutationResult]], error)

Create creates NTP configuration on the target host.

func (*NTPService) Delete

func (s *NTPService) Delete(
	ctx context.Context,
	hostname string,
) (*Response[Collection[NtpMutationResult]], error)

Delete removes NTP configuration from the target host.

func (*NTPService) Get

func (s *NTPService) Get(
	ctx context.Context,
	hostname string,
) (*Response[Collection[NtpStatusResult]], error)

Get retrieves NTP status from the target host.

func (*NTPService) Update

func (s *NTPService) Update(
	ctx context.Context,
	hostname string,
	opts NtpUpdateOpts,
) (*Response[Collection[NtpMutationResult]], error)

Update updates NTP configuration on the target host.

type NetworkInterface

type NetworkInterface struct {
	Name   string `json:"name"`
	Family string `json:"family,omitempty"`
	IPv4   string `json:"ipv4,omitempty"`
	IPv6   string `json:"ipv6,omitempty"`
	MAC    string `json:"mac,omitempty"`
}

NetworkInterface represents a network interface on an agent.

type NodeStatus

type NodeStatus struct {
	Hostname    string       `json:"hostname"`
	Status      string       `json:"status"`
	Uptime      string       `json:"uptime,omitempty"`
	Error       string       `json:"error,omitempty"`
	Changed     bool         `json:"changed"`
	Disks       []Disk       `json:"disks,omitempty"`
	LoadAverage *LoadAverage `json:"load_average,omitempty"`
	Memory      *Memory      `json:"memory,omitempty"`
	OSInfo      *OSInfo      `json:"os_info,omitempty"`
}

NodeStatus represents full node status from a single agent.

type NotFoundError

type NotFoundError struct {
	APIError
}

NotFoundError represents resource not found errors (404).

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

Unwrap returns the underlying APIError.

type NtpCreateOpts

type NtpCreateOpts struct {
	// Servers is the list of NTP server addresses to configure. Required.
	Servers []string
}

NtpCreateOpts contains options for creating NTP configuration.

type NtpMutationResult

type NtpMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

NtpMutationResult represents the result of an NTP create, update, or delete.

type NtpStatusResult

type NtpStatusResult struct {
	Hostname      string   `json:"hostname"`
	Status        string   `json:"status"`
	Synchronized  bool     `json:"synchronized,omitempty"`
	Stratum       int      `json:"stratum,omitempty"`
	Offset        string   `json:"offset,omitempty"`
	CurrentSource string   `json:"current_source,omitempty"`
	Servers       []string `json:"servers,omitempty"`
	Error         string   `json:"error,omitempty"`
}

NtpStatusResult represents NTP status from a query operation.

type NtpUpdateOpts

type NtpUpdateOpts struct {
	// Servers is the list of NTP server addresses to configure. Required.
	Servers []string
}

NtpUpdateOpts contains options for updating NTP configuration.

type OSInfo

type OSInfo struct {
	Distribution string `json:"distribution"`
	Version      string `json:"version"`
}

OSInfo represents operating system information.

type OSInfoResult

type OSInfoResult struct {
	Hostname string  `json:"hostname"`
	Status   string  `json:"status"`
	Error    string  `json:"error,omitempty"`
	Changed  bool    `json:"changed"`
	OSInfo   *OSInfo `json:"os_info,omitempty"`
}

OSInfoResult represents OS info query result from a single agent.

type OSService

type OSService struct {
	// contains filtered or unexported fields
}

OSService provides operating system info query operations.

func (*OSService) Get

func (s *OSService) Get(
	ctx context.Context,
	target string,
) (*Response[Collection[OSInfoResult]], error)

Get retrieves operating system information from the target host.

type ObjectStoreInfo

type ObjectStoreInfo struct {
	Name string `json:"name"`
	Size int    `json:"size"`
}

ObjectStoreInfo represents an Object Store bucket's info.

type Option

type Option func(*Client)

Option configures the Client.

func WithHTTPTransport

func WithHTTPTransport(
	transport http.RoundTripper,
) Option

WithHTTPTransport sets a custom base HTTP transport.

func WithLogger

func WithLogger(
	logger *slog.Logger,
) Option

WithLogger sets a custom logger. Defaults to slog.Default().

type PackageInfo

type PackageInfo struct {
	Name        string `json:"name,omitempty"`
	Version     string `json:"version,omitempty"`
	Description string `json:"description,omitempty"`
	Status      string `json:"status,omitempty"`
	Size        int64  `json:"size,omitempty"`
}

PackageInfo represents information about an installed package.

type PackageInfoResult

type PackageInfoResult struct {
	Hostname string        `json:"hostname"`
	Status   string        `json:"status"`
	Packages []PackageInfo `json:"packages,omitempty"`
	Error    string        `json:"error,omitempty"`
}

PackageInfoResult represents a package list result from a query operation.

type PackageMutationResult

type PackageMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Name     string `json:"name,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

PackageMutationResult represents the result of a package install, remove, or update operation.

type PackageService

type PackageService struct {
	// contains filtered or unexported fields
}

PackageService provides package management operations.

func (*PackageService) Get

func (s *PackageService) Get(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[PackageInfoResult]], error)

Get retrieves a single package by name on the target host.

func (*PackageService) Install

func (s *PackageService) Install(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[PackageMutationResult]], error)

Install installs a package on the target host.

func (*PackageService) List

List lists all installed packages on the target host.

func (*PackageService) ListUpdates

func (s *PackageService) ListUpdates(
	ctx context.Context,
	hostname string,
) (*Response[Collection[PackageUpdateResult]], error)

ListUpdates lists available package updates on the target host.

func (*PackageService) Remove

func (s *PackageService) Remove(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[PackageMutationResult]], error)

Remove removes a package from the target host.

func (*PackageService) Update

Update updates all packages on the target host.

type PackageUpdateResult

type PackageUpdateResult struct {
	Hostname string       `json:"hostname"`
	Status   string       `json:"status"`
	Updates  []UpdateInfo `json:"updates,omitempty"`
	Error    string       `json:"error,omitempty"`
}

PackageUpdateResult represents an update list result for one host.

type PendingAgent

type PendingAgent struct {
	MachineID   string    `json:"machine_id"`
	Hostname    string    `json:"hostname"`
	Fingerprint string    `json:"fingerprint"`
	RequestedAt time.Time `json:"requested_at"`
}

PendingAgent represents an agent awaiting enrollment acceptance.

type PendingAgentList

type PendingAgentList struct {
	Agents []PendingAgent `json:"agents"`
	Total  int            `json:"total"`
}

PendingAgentList is a collection of pending agents.

type Permission

type Permission = string

Permission represents a fine-grained resource:verb permission. Permissions use the format "resource:verb" (e.g., "node:read", "docker:execute").

const (
	PermAgentRead        Permission = "agent:read"
	PermAgentWrite       Permission = "agent:write"
	PermNodeRead         Permission = "node:read"
	PermNodeWrite        Permission = "node:write"
	PermNetworkRead      Permission = "network:read"
	PermNetworkWrite     Permission = "network:write"
	PermJobRead          Permission = "job:read"
	PermJobWrite         Permission = "job:write"
	PermHealthRead       Permission = "health:read"
	PermAuditRead        Permission = "audit:read"
	PermCommandExecute   Permission = "command:execute"
	PermFileRead         Permission = "file:read"
	PermFileWrite        Permission = "file:write"
	PermDockerRead       Permission = "docker:read"
	PermDockerWrite      Permission = "docker:write"
	PermDockerExecute    Permission = "docker:execute"
	PermCronRead         Permission = "cron:read"
	PermCronWrite        Permission = "cron:write"
	PermSysctlRead       Permission = "sysctl:read"
	PermSysctlWrite      Permission = "sysctl:write"
	PermNtpRead          Permission = "ntp:read"
	PermNtpWrite         Permission = "ntp:write"
	PermTimezoneRead     Permission = "timezone:read"
	PermTimezoneWrite    Permission = "timezone:write"
	PermPowerExecute     Permission = "power:execute"
	PermProcessRead      Permission = "process:read"
	PermProcessExecute   Permission = "process:execute"
	PermUserRead         Permission = "user:read"
	PermUserWrite        Permission = "user:write"
	PermPackageRead      Permission = "package:read"
	PermPackageWrite     Permission = "package:write"
	PermLogRead          Permission = "log:read"
	PermCertificateRead  Permission = "certificate:read"
	PermCertificateWrite Permission = "certificate:write"
	PermServiceRead      Permission = "service:read"
	PermServiceWrite     Permission = "service:write"
)

Permission constants.

type PingResult

type PingResult struct {
	Hostname        string  `json:"hostname"`
	Status          string  `json:"status"`
	Error           string  `json:"error,omitempty"`
	Changed         bool    `json:"changed"`
	PacketsSent     int     `json:"packets_sent"`
	PacketsReceived int     `json:"packets_received"`
	PacketLoss      float64 `json:"packet_loss"`
	MinRtt          string  `json:"min_rtt,omitempty"`
	AvgRtt          string  `json:"avg_rtt,omitempty"`
	MaxRtt          string  `json:"max_rtt,omitempty"`
}

PingResult represents ping result from a single agent.

type PingService

type PingService struct {
	// contains filtered or unexported fields
}

PingService provides network ping operations.

func (*PingService) Do

func (s *PingService) Do(
	ctx context.Context,
	target string,
	address string,
) (*Response[Collection[PingResult]], error)

Do sends an ICMP ping to the specified address from the target host.

type PowerOpts

type PowerOpts struct {
	// Delay is the number of seconds to wait before executing the operation.
	Delay int
	// Message is an optional message to broadcast before the operation.
	Message string
}

PowerOpts contains options for power operations (reboot, shutdown).

type PowerResult

type PowerResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Action   string `json:"action,omitempty"`
	Delay    int    `json:"delay,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

PowerResult represents the result of a power operation for one host.

type PowerService

type PowerService struct {
	// contains filtered or unexported fields
}

PowerService provides power management operations.

func (*PowerService) Reboot

func (s *PowerService) Reboot(
	ctx context.Context,
	hostname string,
	opts PowerOpts,
) (*Response[Collection[PowerResult]], error)

Reboot initiates a reboot on the target host.

func (*PowerService) Shutdown

func (s *PowerService) Shutdown(
	ctx context.Context,
	hostname string,
	opts PowerOpts,
) (*Response[Collection[PowerResult]], error)

Shutdown initiates a shutdown on the target host.

type ProcessInfo

type ProcessInfo struct {
	PID        int     `json:"pid"`
	Name       string  `json:"name,omitempty"`
	User       string  `json:"user,omitempty"`
	State      string  `json:"state,omitempty"`
	CPUPercent float64 `json:"cpu_percent,omitempty"`
	MemPercent float32 `json:"mem_percent,omitempty"`
	MemRSS     int64   `json:"mem_rss,omitempty"`
	Command    string  `json:"command,omitempty"`
	StartTime  string  `json:"start_time,omitempty"`
}

ProcessInfo represents information about a single running process.

type ProcessInfoResult

type ProcessInfoResult struct {
	Hostname  string        `json:"hostname"`
	Status    string        `json:"status"`
	Processes []ProcessInfo `json:"processes,omitempty"`
	Error     string        `json:"error,omitempty"`
}

ProcessInfoResult represents the result of a process list/get operation for one host.

type ProcessService

type ProcessService struct {
	// contains filtered or unexported fields
}

ProcessService provides process management operations.

func (*ProcessService) Get

func (s *ProcessService) Get(
	ctx context.Context,
	hostname string,
	pid int,
) (*Response[Collection[ProcessInfoResult]], error)

Get returns information about a specific process by PID on the target host.

func (*ProcessService) List

List returns all running processes on the target host.

func (*ProcessService) Signal

Signal sends a signal to a specific process by PID on the target host.

type ProcessSignalOpts

type ProcessSignalOpts struct {
	// Signal is the signal name to send (e.g., TERM, KILL, HUP).
	Signal string
}

ProcessSignalOpts contains options for the process signal operation.

type ProcessSignalResult

type ProcessSignalResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	PID      int    `json:"pid,omitempty"`
	Signal   string `json:"signal,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

ProcessSignalResult represents the result of sending a signal to a process for one host.

type ReadyStatus

type ReadyStatus struct {
	Status             string `json:"status"`
	Error              string `json:"error,omitempty"`
	ServiceUnavailable bool   `json:"service_unavailable"`
}

ReadyStatus represents a readiness check response.

type RegistryEntry

type RegistryEntry struct {
	Type       string   `json:"type"`
	Hostname   string   `json:"hostname"`
	Status     string   `json:"status"`
	Conditions []string `json:"conditions,omitempty"`
	Age        string   `json:"age"`
	CPUPercent float64  `json:"cpu_percent"`
	MemBytes   int64    `json:"mem_bytes"`
}

RegistryEntry represents a unified component registration in the health registry.

type Response

type Response[T any] struct {
	Data T
	// contains filtered or unexported fields
}

Response wraps a domain type with raw JSON for CLI --json mode.

func NewResponse

func NewResponse[T any](
	data T,
	rawJSON []byte,
) *Response[T]

NewResponse creates a Response with the given data and raw JSON body.

func (*Response[T]) RawJSON

func (r *Response[T]) RawJSON() []byte

RawJSON returns the raw HTTP response body.

type Role

type Role = string

Role represents a built-in RBAC role name.

const (
	RoleAdmin Role = "admin"
	RoleWrite Role = "write"
	RoleRead  Role = "read"
)

Built-in role constants.

type Route

type Route struct {
	Destination string `json:"destination"`
	Gateway     string `json:"gateway"`
	Interface   string `json:"interface"`
	Mask        string `json:"mask,omitempty"`
	Flags       string `json:"flags,omitempty"`
	Metric      int    `json:"metric"`
}

Route represents a network routing table entry.

type RouteConfigOpts

type RouteConfigOpts struct {
	// Routes is the list of route entries. Required.
	Routes []RouteItem
}

RouteConfigOpts contains options for creating or updating routes.

type RouteGetResult

type RouteGetResult struct {
	Hostname string      `json:"hostname"`
	Status   string      `json:"status"`
	Error    string      `json:"error,omitempty"`
	Routes   []RouteInfo `json:"routes,omitempty"`
}

RouteGetResult represents a route get result from a single agent.

type RouteInfo

type RouteInfo struct {
	Destination string `json:"destination,omitempty"`
	Gateway     string `json:"gateway,omitempty"`
	Interface   string `json:"interface,omitempty"`
	Metric      int    `json:"metric,omitempty"`
	Scope       string `json:"scope,omitempty"`
}

RouteInfo represents a network route entry.

type RouteItem

type RouteItem struct {
	// To is the destination in CIDR notation. Required.
	To string
	// Via is the gateway IP address. Required.
	Via string
	// Metric is the route metric (priority). Optional.
	Metric *int
}

RouteItem represents a single route entry for create/update operations.

type RouteListResult

type RouteListResult struct {
	Hostname string      `json:"hostname"`
	Status   string      `json:"status"`
	Error    string      `json:"error,omitempty"`
	Routes   []RouteInfo `json:"routes,omitempty"`
}

RouteListResult represents a route list result from a single agent.

type RouteMutationResult

type RouteMutationResult struct {
	Hostname  string `json:"hostname"`
	Status    string `json:"status"`
	Interface string `json:"interface,omitempty"`
	Changed   bool   `json:"changed"`
	Error     string `json:"error,omitempty"`
}

RouteMutationResult represents the result of a route create, update, or delete.

type RouteService

type RouteService struct {
	// contains filtered or unexported fields
}

RouteService provides network route management operations.

func (*RouteService) Create

func (s *RouteService) Create(
	ctx context.Context,
	target string,
	interfaceName string,
	opts RouteConfigOpts,
) (*Response[Collection[RouteMutationResult]], error)

Create creates route configuration for an interface on the target host.

func (*RouteService) Delete

func (s *RouteService) Delete(
	ctx context.Context,
	target string,
	interfaceName string,
) (*Response[Collection[RouteMutationResult]], error)

Delete removes route configuration for an interface on the target host.

func (*RouteService) Get

func (s *RouteService) Get(
	ctx context.Context,
	target string,
	interfaceName string,
) (*Response[Collection[RouteGetResult]], error)

Get retrieves routes for a specific interface on the target host.

func (*RouteService) List

List lists all network routes on the target host.

func (*RouteService) Update

func (s *RouteService) Update(
	ctx context.Context,
	target string,
	interfaceName string,
	opts RouteConfigOpts,
) (*Response[Collection[RouteMutationResult]], error)

Update updates route configuration for an interface on the target host.

type SSHKeyAddOpts

type SSHKeyAddOpts struct {
	// Key is the full SSH public key line (e.g., "ssh-ed25519 AAAA... user@host").
	Key string
}

SSHKeyAddOpts contains options for adding an SSH key.

type SSHKeyInfo

type SSHKeyInfo struct {
	Type        string `json:"type,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
	Comment     string `json:"comment,omitempty"`
}

SSHKeyInfo represents a single SSH authorized key.

type SSHKeyInfoResult

type SSHKeyInfoResult struct {
	Hostname string       `json:"hostname"`
	Status   string       `json:"status"`
	Keys     []SSHKeyInfo `json:"keys,omitempty"`
	Error    string       `json:"error,omitempty"`
}

SSHKeyInfoResult represents SSH key list result for one host.

type SSHKeyMutationResult

type SSHKeyMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

SSHKeyMutationResult represents SSH key add/remove result for one host.

type ServerError

type ServerError struct {
	APIError
}

ServerError represents internal server errors (500).

func (*ServerError) Unwrap

func (e *ServerError) Unwrap() error

Unwrap returns the underlying APIError.

type ServiceCreateOpts

type ServiceCreateOpts struct {
	// Name is the service unit name (required).
	Name string
	// Object is the object store reference for the unit file (required).
	Object string
}

ServiceCreateOpts contains options for creating a service unit file.

type ServiceGetResult

type ServiceGetResult struct {
	Hostname string       `json:"hostname"`
	Status   string       `json:"status"`
	Service  *ServiceInfo `json:"service,omitempty"`
	Error    string       `json:"error,omitempty"`
}

ServiceGetResult represents a service get result from a single agent.

type ServiceInfo

type ServiceInfo struct {
	Name        string `json:"name,omitempty"`
	Status      string `json:"status,omitempty"`
	Enabled     bool   `json:"enabled"`
	Description string `json:"description,omitempty"`
	PID         int    `json:"pid,omitempty"`
}

ServiceInfo represents a single systemd service entry.

type ServiceInfoResult

type ServiceInfoResult struct {
	Hostname string        `json:"hostname"`
	Status   string        `json:"status"`
	Services []ServiceInfo `json:"services,omitempty"`
	Error    string        `json:"error,omitempty"`
}

ServiceInfoResult represents a service list result from a single agent.

type ServiceMutationResult

type ServiceMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Name     string `json:"name"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

ServiceMutationResult represents the result of a service mutation or action operation.

type ServiceService

type ServiceService struct {
	// contains filtered or unexported fields
}

ServiceService provides systemd service management operations.

func (*ServiceService) Create

Create creates a new service unit file on the target host.

func (*ServiceService) Delete

func (s *ServiceService) Delete(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[ServiceMutationResult]], error)

Delete deletes a service unit file on the target host.

func (*ServiceService) Disable

func (s *ServiceService) Disable(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[ServiceMutationResult]], error)

Disable disables a service from starting on boot on the target host.

func (*ServiceService) Enable

func (s *ServiceService) Enable(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[ServiceMutationResult]], error)

Enable enables a service to start on boot on the target host.

func (*ServiceService) Get

func (s *ServiceService) Get(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[ServiceGetResult]], error)

Get returns information about a specific service on the target host.

func (*ServiceService) List

List returns all services on the target host.

func (*ServiceService) Restart

func (s *ServiceService) Restart(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[ServiceMutationResult]], error)

Restart restarts a service on the target host.

func (*ServiceService) Start

func (s *ServiceService) Start(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[ServiceMutationResult]], error)

Start starts a service on the target host.

func (*ServiceService) Stop

Stop stops a service on the target host.

func (*ServiceService) Update

Update updates an existing service unit file on the target host.

type ServiceUpdateOpts

type ServiceUpdateOpts struct {
	// Object is the new object store reference for the unit file (required).
	Object string
}

ServiceUpdateOpts contains options for updating a service unit file.

type ShellRequest

type ShellRequest struct {
	// Command is the shell command string passed to /bin/sh -c (required).
	Command string

	// Cwd is the working directory. Empty uses the agent default.
	Cwd string

	// Timeout in seconds. Zero uses the server default (30s).
	Timeout int

	// Target specifies the host: "_any", "_all", hostname, or
	// label ("group:web").
	Target string
}

ShellRequest contains parameters for shell command execution.

type StaleDeployment

type StaleDeployment struct {
	ObjectName  string `json:"object_name"`
	Hostname    string `json:"hostname"`
	Provider    string `json:"provider"`
	Path        string `json:"path"`
	DeployedSHA string `json:"deployed_sha"`
	CurrentSHA  string `json:"current_sha"`
	DeployedAt  string `json:"deployed_at"`
}

StaleDeployment represents a deployment that is out of sync with the current object store content.

type StaleList

type StaleList struct {
	Stale []StaleDeployment `json:"stale"`
	Total int               `json:"total"`
}

StaleList is a list of stale deployments.

type StatusService

type StatusService struct {
	// contains filtered or unexported fields
}

StatusService provides node status operations.

func (*StatusService) Get

func (s *StatusService) Get(
	ctx context.Context,
	target string,
) (*Response[Collection[NodeStatus]], error)

Get retrieves node status (OS info, disk, memory, load) from the target host.

type StreamInfo

type StreamInfo struct {
	Name      string `json:"name"`
	Messages  int    `json:"messages"`
	Bytes     int    `json:"bytes"`
	Consumers int    `json:"consumers"`
}

StreamInfo represents a JetStream stream's info.

type SysctlCreateOpts

type SysctlCreateOpts struct {
	// Key is the sysctl parameter name (e.g., "net.ipv4.ip_forward"). Required.
	Key string
	// Value is the parameter value. Required.
	Value string
}

SysctlCreateOpts contains options for creating a sysctl parameter.

type SysctlEntryResult

type SysctlEntryResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Key      string `json:"key,omitempty"`
	Value    string `json:"value,omitempty"`
	Error    string `json:"error,omitempty"`
}

SysctlEntryResult represents a sysctl entry from a query operation.

type SysctlMutationResult

type SysctlMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Key      string `json:"key,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

SysctlMutationResult represents the result of a sysctl create, update, or delete.

type SysctlService

type SysctlService struct {
	// contains filtered or unexported fields
}

SysctlService provides sysctl management operations.

func (*SysctlService) Create

Create creates a sysctl parameter on the target host.

func (*SysctlService) Delete

func (s *SysctlService) Delete(
	ctx context.Context,
	hostname string,
	key string,
) (*Response[Collection[SysctlMutationResult]], error)

Delete removes a sysctl parameter on the target host.

func (*SysctlService) Get

func (s *SysctlService) Get(
	ctx context.Context,
	hostname string,
	key string,
) (*Response[Collection[SysctlEntryResult]], error)

Get retrieves a single sysctl parameter by key on the target host.

func (*SysctlService) List

List lists all sysctl parameters on the target host.

func (*SysctlService) Update

Update updates an existing sysctl parameter on the target host.

type SysctlUpdateOpts

type SysctlUpdateOpts struct {
	// Value is the new parameter value. Required.
	Value string
}

SysctlUpdateOpts contains options for updating a sysctl parameter.

type SystemStatus

type SystemStatus struct {
	Status             string                     `json:"status"`
	Version            string                     `json:"version"`
	Uptime             string                     `json:"uptime"`
	ServiceUnavailable bool                       `json:"service_unavailable"`
	Components         map[string]ComponentHealth `json:"components,omitempty"`
	NATS               *NATSInfo                  `json:"nats,omitempty"`
	Agents             *AgentStats                `json:"agents,omitempty"`
	Jobs               *JobStats                  `json:"jobs,omitempty"`
	Consumers          *ConsumerStats             `json:"consumers,omitempty"`
	Streams            []StreamInfo               `json:"streams,omitempty"`
	KVBuckets          []KVBucketInfo             `json:"kv_buckets,omitempty"`
	ObjectStores       []ObjectStoreInfo          `json:"object_stores,omitempty"`
	Registry           []RegistryEntry            `json:"registry,omitempty"`
}

SystemStatus represents detailed system status.

type TimelineEvent

type TimelineEvent struct {
	Timestamp string `json:"timestamp"`
	Event     string `json:"event"`
	Hostname  string `json:"hostname,omitempty"`
	Message   string `json:"message,omitempty"`
	Error     string `json:"error,omitempty"`
}

TimelineEvent represents a lifecycle event. Used by both job timelines and agent state transition history.

type TimezoneMutationResult

type TimezoneMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Timezone string `json:"timezone,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

TimezoneMutationResult represents the result of a timezone update.

type TimezoneResult

type TimezoneResult struct {
	Hostname  string `json:"hostname"`
	Status    string `json:"status"`
	Timezone  string `json:"timezone,omitempty"`
	UTCOffset string `json:"utc_offset,omitempty"`
	Error     string `json:"error,omitempty"`
}

TimezoneResult represents timezone information from a query operation.

type TimezoneService

type TimezoneService struct {
	// contains filtered or unexported fields
}

TimezoneService provides timezone management operations.

func (*TimezoneService) Get

Get retrieves the system timezone from the target host.

func (*TimezoneService) Update

Update sets the system timezone on the target host.

type TimezoneUpdateOpts

type TimezoneUpdateOpts struct {
	// Timezone is the IANA timezone name (e.g., "America/New_York"). Required.
	Timezone string
}

TimezoneUpdateOpts contains options for updating the system timezone.

type UnexpectedStatusError

type UnexpectedStatusError struct {
	APIError
}

UnexpectedStatusError represents unexpected HTTP status codes.

func (*UnexpectedStatusError) Unwrap

func (e *UnexpectedStatusError) Unwrap() error

Unwrap returns the underlying APIError.

type UpdateInfo

type UpdateInfo struct {
	Name           string `json:"name,omitempty"`
	CurrentVersion string `json:"current_version,omitempty"`
	NewVersion     string `json:"new_version,omitempty"`
}

UpdateInfo represents information about an available package update.

type UploadOption

type UploadOption func(*uploadOptions)

UploadOption configures Upload behavior.

func WithForce

func WithForce() UploadOption

WithForce bypasses both SDK-side pre-check and server-side digest check. The file is always uploaded and changed is always true.

type UptimeResult

type UptimeResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Uptime   string `json:"uptime,omitempty"`
	Error    string `json:"error,omitempty"`
	Changed  bool   `json:"changed"`
}

UptimeResult represents uptime query result from a single agent.

type UptimeService

type UptimeService struct {
	// contains filtered or unexported fields
}

UptimeService provides uptime query operations.

func (*UptimeService) Get

Get retrieves uptime information from the target host.

type UserCreateOpts

type UserCreateOpts struct {
	// Name is the username. Required.
	Name string
	// UID is the numeric user ID. If zero, the system assigns one.
	UID int
	// GID is the primary group ID. If zero, a group matching the username is created.
	GID int
	// Home is the home directory path.
	Home string
	// Shell is the login shell path.
	Shell string
	// Groups is the list of supplementary group names.
	Groups []string
	// Password is the initial password (plaintext, hashed by the agent).
	Password string
	// System creates a system account.
	System bool
}

UserCreateOpts contains options for creating a user account.

type UserInfo

type UserInfo struct {
	Name   string   `json:"name,omitempty"`
	UID    int      `json:"uid,omitempty"`
	GID    int      `json:"gid,omitempty"`
	Home   string   `json:"home,omitempty"`
	Shell  string   `json:"shell,omitempty"`
	Groups []string `json:"groups,omitempty"`
	Locked bool     `json:"locked,omitempty"`
}

UserInfo represents a user account on the target node.

type UserInfoResult

type UserInfoResult struct {
	Hostname string     `json:"hostname"`
	Status   string     `json:"status"`
	Users    []UserInfo `json:"users,omitempty"`
	Error    string     `json:"error,omitempty"`
}

UserInfoResult represents a user listing result from a query operation.

type UserMutationResult

type UserMutationResult struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
	Name     string `json:"name,omitempty"`
	Changed  bool   `json:"changed"`
	Error    string `json:"error,omitempty"`
}

UserMutationResult represents the result of a user create, update, delete, or password operation.

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService provides user account management operations.

func (*UserService) AddKey

func (s *UserService) AddKey(
	ctx context.Context,
	hostname string,
	username string,
	opts SSHKeyAddOpts,
) (*Response[Collection[SSHKeyMutationResult]], error)

AddKey adds an SSH authorized key for a user on the target host.

func (*UserService) ChangePassword

func (s *UserService) ChangePassword(
	ctx context.Context,
	hostname string,
	name string,
	password string,
) (*Response[Collection[UserMutationResult]], error)

ChangePassword changes a user's password on the target host.

func (*UserService) Create

Create creates a user account on the target host.

func (*UserService) Delete

func (s *UserService) Delete(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[UserMutationResult]], error)

Delete removes a user account on the target host.

func (*UserService) Get

func (s *UserService) Get(
	ctx context.Context,
	hostname string,
	name string,
) (*Response[Collection[UserInfoResult]], error)

Get retrieves a single user account by name on the target host.

func (*UserService) List

func (s *UserService) List(
	ctx context.Context,
	hostname string,
) (*Response[Collection[UserInfoResult]], error)

List lists all user accounts on the target host.

func (*UserService) ListKeys

func (s *UserService) ListKeys(
	ctx context.Context,
	hostname string,
	username string,
) (*Response[Collection[SSHKeyInfoResult]], error)

ListKeys returns SSH authorized keys for a user on the target host.

func (*UserService) RemoveKey

func (s *UserService) RemoveKey(
	ctx context.Context,
	hostname string,
	username string,
	fingerprint string,
) (*Response[Collection[SSHKeyMutationResult]], error)

RemoveKey removes an SSH authorized key by fingerprint for a user on the target host.

func (*UserService) Update

func (s *UserService) Update(
	ctx context.Context,
	hostname string,
	name string,
	opts UserUpdateOpts,
) (*Response[Collection[UserMutationResult]], error)

Update updates a user account on the target host.

type UserUpdateOpts

type UserUpdateOpts struct {
	// Shell is the new login shell path.
	Shell string
	// Home is the new home directory path.
	Home string
	// Groups is the list of supplementary group names (replaces existing).
	Groups []string
	// Lock locks or unlocks the account.
	Lock *bool
}

UserUpdateOpts contains options for updating a user account.

type ValidationError

type ValidationError struct {
	APIError
}

ValidationError represents validation errors (400).

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap returns the underlying APIError.

Directories

Path Synopsis
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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