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
| Service | Description |
|---|---|
| Service | Service management (systemd) |
| Cron | Cron schedule management |
Software
| Service | Description |
|---|---|
| Package | Package management |
Config
| Service | Description |
|---|---|
| Hostname | Hostname query and update |
| Sysctl | Kernel parameter management |
| NTP | NTP server configuration |
| Timezone | System timezone |
Node
| Service | Description |
|---|---|
| Power | Power management (reboot, shutdown) |
| Process | Process management (list, get, signal) |
| Log | Log query (journal entries, by unit) |
| Status | Full node status |
| Load | Load averages |
| Uptime | System uptime |
| OS | Operating system info |
Networking
| Service | Description |
|---|---|
| DNS | DNS configuration query and update |
| Ping | Network ping |
| Interface | Network interface configuration |
| Route | Static route configuration |
Security
| Service | Description |
|---|---|
| User | User account management |
| Group | Group management |
| Certificate | CA certificate management |
Containers
| Service | Description |
|---|---|
| Docker | Container lifecycle |
Files
| Service | Description |
|---|---|
| File | File management (Object Store) |
| FileDeploy | File deployment to agents |
Command
| Service | Description |
|---|---|
| Command | Command execution (exec, shell) |
Hardware
| Service | Description |
|---|---|
| Disk | Disk usage |
| Memory | Memory statistics |
Audit
| Service | Description |
|---|---|
| Audit | Audit log operations |
Jobs
| Service | Description |
|---|---|
| Job | Async job queue operations |
Agent
| Service | Description |
|---|---|
| Agent | Agent discovery, lifecycle, enrollment |
Health
| Service | Description |
|---|---|
| Health | Health check operations |
Client Options
| Option | Description |
|---|---|
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:
| Target | Behavior |
|---|---|
_any | Send to any available agent (load balanced) |
_all | Broadcast to every agent |
hostname | Send to a specific host |
key:value | Send to agents matching a label |