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 ListOption
- type ListOptionFunc
- type ListSettings
- 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(ctx context.Context, opts ...ListOption) (*agentv1.ListResponse, 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) GetServerVersion ¶ added in v0.1.18
GetServerVersion retrieves the server version information.
func (*Client) SetAuthToken ¶ added in v0.1.1
SetAuthToken sets the authentication token for the client.
func (*Client) SetVerbose ¶ added in v0.1.10
SetVerbose enables verbose logging 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(ctx context.Context, 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( ctx context.Context, opts ...ListOption, ) (*connectionv1.ListResponse, error)
ListConnections lists all connections.
type ListOption ¶ added in v0.1.18
type ListOption interface {
Apply(settings *ListSettings)
}
ListOption is an interface for options that can be applied to list operations.
func WithContinueToken ¶ added in v0.1.18
func WithContinueToken(token string) ListOption
WithContinueToken sets the continue token for pagination.
func WithLimit ¶ added in v0.1.18
func WithLimit(limit int) ListOption
WithLimit sets the limit for the number of items to return.
type ListOptionFunc ¶ added in v0.1.18
type ListOptionFunc func(*ListSettings)
ListOptionFunc is a function type that implements the ListOption interface.
func (ListOptionFunc) Apply ¶ added in v0.1.18
func (f ListOptionFunc) Apply(opt *ListSettings)
Apply applies the ListOptionFunc to the ListSettings.
type ListSettings ¶ added in v0.1.18
type ListSettings struct {
// contains filtered or unexported fields
}
ListSettings holds the settings for listing resources.
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 WithBearerToken ¶ added in v0.1.13
func WithBearerToken(bearerToken string) OptionFunc
WithBearerToken sets the Bearer token for the client.
func WithLogger ¶ added in v0.1.10
func WithLogger(logger *slog.Logger) OptionFunc
WithLogger sets the logger for the client.
func WithVerbose ¶ added in v0.1.10
func WithVerbose(verbose bool) OptionFunc
WithVerbose enables verbose logging 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 ¶
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.