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/retr0h/osapi/pkg/sdk/client"

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

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

Services

ServiceDescription
AgentAgent discovery and details
AuditAudit log operations
DockerContainer runtime operations
FileFile management (Object Store)
HealthHealth check operations
JobAsync job queue operations
MetricsPrometheus metrics access
NodeNode management, network, commands

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