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 ¶
- type Client
- func (c *Client) Delete(ctx context.Context, name string) error
- func (c *Client) Get(ctx context.Context, name string) (*agentmodels.InterfaceConfig, error)
- func (c *Client) Info(ctx context.Context) (*agentmodels.HostInfo, error)
- func (c *Client) List(ctx context.Context) ([]agentmodels.InterfaceConfig, error)
- func (c *Client) Metrics(ctx context.Context) (*agentmodels.MetricsSnapshot, error)
- func (c *Client) MetricsHistory(ctx context.Context) (*agentmodels.SystemHistory, error)
- func (c *Client) Profile(ctx context.Context, name string, seconds int) ([]byte, error)
- func (c *Client) Set(ctx context.Context, cfg agentmodels.InterfaceConfig) error
- func (c *Client) SetMetricsEnabled(ctx context.Context, enabled bool) error
- func (c *Client) SetProfilingEnabled(ctx context.Context, enabled bool) error
- type NotFoundError
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 ¶
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 ¶
Delete removes the named interface from the agent (DELETE /interfaces/{name}).
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, name string) (*agentmodels.InterfaceConfig, error)
Get fetches the current config of the named interface (GET /interfaces/{name}).
func (*Client) Info ¶
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 ¶
func (c *Client) List(ctx context.Context) ([]agentmodels.InterfaceConfig, error)
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 ¶
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 ¶
func (c *Client) Set(ctx context.Context, cfg agentmodels.InterfaceConfig) error
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 ¶
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 ¶
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