Documentation
¶
Overview ¶
Package client provides a client for the opampcommander API server.
Index ¶
- Constants
- Variables
- type AgentService
- type AuthService
- func (s *AuthService) ExchangeDeviceAuthToken(deviceCode string, expiry time.Time) (*v1auth.AuthnTokenResponse, error)
- func (s *AuthService) GetAuthTokenByBasicAuth(username, password string) (*v1auth.AuthnTokenResponse, error)
- func (s *AuthService) GetDeviceAuthToken() (*v1auth.DeviceAuthnTokenResponse, error)
- func (s *AuthService) GetInfo() (*v1auth.InfoResponse, error)
- type Client
- type ConnectionService
- type Option
- type OptionFunc
- type ResponseError
Constants ¶
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" )
const ( // GithubAuthDeviceAuthAPIURL is the API URL for GitHub device authentication. GithubAuthDeviceAuthAPIURL = "/api/v1/auth/github/device" // GithubAuthExchangeDeviceAuthAPIURL is the API URL for exchanging GitHub device authentication tokens. GithubAuthExchangeDeviceAuthAPIURL = "/api/v1/auth/github/device/exchange" // BasicAuthAPIURL is the API URL for basic authentication. BasicAuthAPIURL = "/api/v1/auth/basic" // InfoAPIURL is the API URL to fetch auth info. InfoAPIURL = "/api/v1/auth/info" )
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 ¶
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 AgentService ¶ added in v0.1.1
type AgentService struct {
// contains filtered or unexported fields
}
AgentService provides methods to interact with agents.
func NewAgentService ¶ added in v0.1.1
func NewAgentService(service *service) *AgentService
NewAgentService creates a new AgentService.
func (*AgentService) ListAgents ¶ added in v0.1.1
func (s *AgentService) ListAgents() ([]*agentv1.Agent, error)
ListAgents lists all agents.
type AuthService ¶ added in v0.1.1
type AuthService struct {
// contains filtered or unexported fields
}
AuthService provides methods to interact with authentication resources.
func NewAuthService ¶ added in v0.1.1
func NewAuthService(service *service) *AuthService
NewAuthService creates a new AuthService.
func (*AuthService) ExchangeDeviceAuthToken ¶ added in v0.1.1
func (s *AuthService) ExchangeDeviceAuthToken(deviceCode string, expiry time.Time) (*v1auth.AuthnTokenResponse, error)
ExchangeDeviceAuthToken exchanges a device code for an authentication token.
func (*AuthService) GetAuthTokenByBasicAuth ¶ added in v0.1.1
func (s *AuthService) GetAuthTokenByBasicAuth(username, password string) (*v1auth.AuthnTokenResponse, error)
GetAuthTokenByBasicAuth retrieves an authentication token using basic authentication.
func (*AuthService) GetDeviceAuthToken ¶ added in v0.1.1
func (s *AuthService) GetDeviceAuthToken() (*v1auth.DeviceAuthnTokenResponse, error)
GetDeviceAuthToken retrieves a device authentication token from GitHub.
func (*AuthService) GetInfo ¶ added in v0.1.1
func (s *AuthService) GetInfo() (*v1auth.InfoResponse, error)
GetInfo retrieves authentication information from the server.
type Client ¶
type Client struct {
Endpoint string
AgentService *AgentService
ConnectionService *ConnectionService
AuthService *AuthService
// contains filtered or unexported fields
}
Client is a struct that contains the endpoint and the resty client.
func (*Client) SetAuthToken ¶ added in v0.1.1
SetAuthToken sets the authentication token for the client.
type ConnectionService ¶ added in v0.1.1
type ConnectionService struct {
// contains filtered or unexported fields
}
ConnectionService provides methods to interact with connection resources.
func NewConnectionService ¶ added in v0.1.1
func NewConnectionService(service *service) *ConnectionService
NewConnectionService creates a new ConnectionService.
func (*ConnectionService) GetConnection ¶ added in v0.1.1
func (s *ConnectionService) GetConnection(id uuid.UUID) (*connectionv1.Connection, error)
GetConnection retrieves a connection by its ID.
func (*ConnectionService) ListConnections ¶ added in v0.1.1
func (s *ConnectionService) ListConnections() ([]*connectionv1.Connection, error)
ListConnections lists all connections.
type Option ¶ added in v0.1.1
type Option interface {
Apply(client *Client)
}
Option provides a way to configure the opampcommander API client.
type OptionFunc ¶ added in v0.1.1
type OptionFunc func(*Client)
OptionFunc is a function that applies an option to the Client.
func WithBarearToken ¶ added in v0.1.1
func WithBarearToken(barearToken string) OptionFunc
WithBarearToken sets the Bearer token for the client.
func (OptionFunc) Apply ¶ added in v0.1.1
func (f OptionFunc) Apply(c *Client)
Apply applies the option to the Client.
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.