agentclient

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package agentclient is a typed HTTP client over the agent's actual API (agent/internal/api/handlers.go: PUT/GET/DELETE /interfaces). It takes an arbitrary *http.Client so the caller decides the transport — an SSH tunnel (internal/sshclient.TunnelClient) or a direct mTLS client — the client itself doesn't care which.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to a single agent's HTTP API.

func New

func New(httpClient *http.Client, baseURL string) *Client

New returns a Client that issues requests through httpClient against baseURL (e.g. "http://127.0.0.1:8080" for a tunnelled agent, or "https://<agent-addr>" for direct mTLS).

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, name string) error

Delete removes the named interface from the agent (DELETE /interfaces/{name}).

func (*Client) Get

Get fetches the current config of the named interface (GET /interfaces/{name}).

func (*Client) Info

func (c *Client) Info(ctx context.Context) (*agentmodels.HostInfo, error)

Info fetches the host facts the agent discovered at startup — its backend and creatable interface kinds, whether Docker is available on the host, whether the agent itself runs in a container, kernel-module presence (GET /info).

func (*Client) List

List fetches every interface configured on the agent (GET /interfaces/).

func (*Client) Metrics

func (c *Client) Metrics(ctx context.Context) (*agentmodels.MetricsSnapshot, error)

Metrics fetches the agent's latest CPU/RAM/load/network/peer snapshot (GET /metrics).

func (*Client) MetricsHistory

func (c *Client) MetricsHistory(ctx context.Context) (*agentmodels.SystemHistory, error)

MetricsHistory fetches every host-level sample plus every per-peer sample still retained in the agent's in-memory ring buffers (GET /metrics/history) — up to 48h, oldest first — for charting instead of just the latest value (see Metrics). Per-peer series arrive in SystemHistory.Interfaces; history is served only through this one endpoint.

func (*Client) Profile

func (c *Client) Profile(ctx context.Context, name string, seconds int) ([]byte, error)

Profile fetches a Go runtime profiling dump from the agent (GET /debug/pprof/<name>). For the CPU "profile" and "trace" kinds, seconds sets the sampling window (appended as ?seconds=N); it's ignored for the instantaneous kinds (heap/goroutine/allocs/…). The agent answers 403 unless profiling is enabled (SetProfilingEnabled). Returns the raw dump bytes.

func (*Client) Set

Set applies cfg to the agent's interface of the same name, creating it if it doesn't already exist (PUT /interfaces).

func (*Client) SetMetricsEnabled

func (c *Client) SetMetricsEnabled(ctx context.Context, enabled bool) error

SetMetricsEnabled turns the agent's metrics collection on/off at runtime (PATCH /metrics). Not persisted by the agent across restarts — callers that want the setting to survive a redeploy re-apply it via SyncServer, same as interface config.

func (*Client) SetProfilingEnabled

func (c *Client) SetProfilingEnabled(ctx context.Context, enabled bool) error

SetProfilingEnabled turns the agent's Go runtime profiling (the /debug/pprof endpoints) on/off at runtime (PATCH /profiling). Like metrics, not persisted by the agent across restarts — re-applied via SyncServer.

type NotFoundError

type NotFoundError struct {
	Interface string
}

NotFoundError is returned by Get/Delete when the agent has no interface with the given name (agent storage.NotFound, mapped to HTTP 404 by the agent's handlers).

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Jump to

Keyboard shortcuts

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