client

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package client provides a client for the opampcommander API server.

Index

Constants

View Source
const (
	// ListAgentURL is the path to list all agents.
	ListAgentURL = "/api/v1/agents"
	// GetAgentURL is the path to get an agent by ID.
	GetAgentURL = "/api/v1/agents/:id"
)
View Source
const (
	// ListConnectionsPath is the path to list all connections.
	ListConnectionsPath = "/api/v1/connections"
	// GetConnectionPath is the path to get a connection by ID.
	GetConnectionPath = "/api/v1/connections/:id"
)

API paths for connection resources.

Variables

View Source
var (
	// ErrEmptyResponse is an error that indicates that the response from the server is empty.
	ErrEmptyResponse = errors.New("empty response")
	// ErrUnexpectedBehavior is an error that indicates that the server behavior is not as expected.
	ErrUnexpectedBehavior = errors.New("unexpected behavior")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Endpoint string
	Client   *resty.Client
}

Client is a struct that contains the endpoint and the resty client.

func NewClient

func NewClient(endpoint string) *Client

NewClient creates a new client for opampcommander's apiserver.

func (*Client) GetAgent

func (c *Client) GetAgent(id uuid.UUID) (*agentv1.Agent, error)

GetAgent retrieves an agent by its ID.

func (*Client) GetConnection

func (c *Client) GetConnection(id uuid.UUID) (*connectionv1.Connection, error)

GetConnection retrieves a connection by its ID.

func (*Client) ListAgents

func (c *Client) ListAgents() ([]*agentv1.Agent, error)

ListAgents lists all agents.

func (*Client) ListConnections

func (c *Client) ListConnections() ([]*connectionv1.Connection, error)

ListConnections lists all connections.

type ResponseError

type ResponseError struct {
	StatusCode int
}

ResponseError represents an error that occurs when the response from the server is not as expected. It contains the status code of the response.

func (*ResponseError) Error

func (e *ResponseError) Error() string

Error implements the error interface for ResponseError.

Jump to

Keyboard shortcuts

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