Skip to main content

Client Library

The osapi package provides a typed Go client for the OSAPI REST API. Create a client with New() and use domain-specific services to interact with the API.

Quick Start​

import "github.com/osapi-io/osapi/pkg/sdk/client"

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

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

Services​

ServiceDescription
ServiceService management (systemd)
ScheduleScheduled entry management

Software​

ServiceDescription
PackagePackage management

Config​

ServiceDescription
HostnameHostname query and update
SysctlKernel parameter management
NTPNTP server configuration
TimezoneSystem timezone

Node​

ServiceDescription
PowerPower management (reboot, shutdown)
ProcessProcess management (list, get, signal)
LogLog query (journal entries, by unit)
StatusFull node status
LoadLoad averages
UptimeSystem uptime
OSOperating system info

Networking​

ServiceDescription
DNSDNS configuration query and update
PingNetwork ping
InterfaceNetwork interface configuration
RouteStatic route configuration

Security​

ServiceDescription
UserUser account management
GroupGroup management
CertificateCA certificate management

Containers​

ServiceDescription
DockerContainer lifecycle

Files​

ServiceDescription
FileFile management (Object Store)
FileDeployFile deployment to agents

Command​

ServiceDescription
CommandCommand execution (exec, shell)

Hardware​

ServiceDescription
DiskDisk usage
MemoryMemory statistics

Audit​

ServiceDescription
AuditAudit log operations

Jobs​

ServiceDescription
JobAsync job queue operations

Agent​

ServiceDescription
AgentAgent discovery, lifecycle, enrollment

Health​

ServiceDescription
HealthHealth check operations

Client Options​

OptionDescription
WithLogger(logger)Set custom slog.Logger
WithHTTPTransport(transport)Set custom http.RoundTripper

WithLogger defaults to slog.Default(). WithHTTPTransport sets the base transport for HTTP requests.

Targeting​

Most operations accept a target parameter:

TargetBehavior
_anySend to any available agent (load balanced)
_allBroadcast to every agent
hostnameSend to a specific host
key:valueSend to agents matching a label