Documentation
¶
Overview ¶
Package client provides a client for the opampcommander API server.
Index ¶
- Constants
- Variables
- type AgentGroupService
- func (s *AgentGroupService) CreateAgentGroup(ctx context.Context, createRequest *agentgroupv1.CreateRequest) (*agentgroupv1.AgentGroup, error)
- func (s *AgentGroupService) DeleteAgentGroup(ctx context.Context, name string) error
- func (s *AgentGroupService) GetAgentGroup(ctx context.Context, name string) (*agentgroupv1.AgentGroup, error)
- func (s *AgentGroupService) ListAgentGroups(ctx context.Context, opts ...ListOption) (*agentgroupv1.ListResponse, error)
- func (s *AgentGroupService) ListAgentsByAgentGroup(ctx context.Context, name string, opts ...ListOption) (*agentv1.ListResponse, error)
- func (s *AgentGroupService) UpdateAgentGroup(ctx context.Context, updateRequest *agentgroupv1.AgentGroup) (*agentgroupv1.AgentGroup, error)
- type AgentService
- func (s *AgentService) GetAgent(ctx context.Context, id uuid.UUID) (*agentv1.Agent, error)
- func (s *AgentService) ListAgents(ctx context.Context, opts ...ListOption) (*agentv1.ListResponse, error)
- func (s *AgentService) RestartAgent(ctx context.Context, id uuid.UUID) error
- func (s *AgentService) SearchAgents(ctx context.Context, query string, opts ...ListOption) (*agentv1.ListResponse, error)
- func (s *AgentService) SetAgentNewInstanceUID(ctx context.Context, id uuid.UUID, request agentv1.SetNewInstanceUIDRequest) (*agentv1.Agent, error)
- 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" // SearchAgentURL is the path to search agents. SearchAgentURL = "/api/v1/agents/search" // GetAgentURL is the path to get an agent by ID. GetAgentURL = "/api/v1/agents/{id}" // SetAgentNewInstanceUIDURL is the path to set a new instance UID for an agent. SetAgentNewInstanceUIDURL = "/api/v1/agents/{id}/new-instance-uid" // SetAgentConnectionSettingsURL is the path to set connection settings for an agent. SetAgentConnectionSettingsURL = "/api/v1/agents/{id}/connection-settings" // RestartAgentURL is the path to restart an agent. RestartAgentURL = "/api/v1/agents/{id}/restart" )
const ( // ListAgentGroupURL is the path to list all agent groups. ListAgentGroupURL = "/api/v1/agentgroups" // ListAgentsByAgentGroupURL is the path to list all agents in an agent group. ListAgentsByAgentGroupURL = "/api/v1/agentgroups/{name}/agents" // GetAgentGroupURL is the path to get an agent group by ID. GetAgentGroupURL = "/api/v1/agentgroups/{id}" // CreateAgentGroupURL is the path to create a new agent group. CreateAgentGroupURL = "/api/v1/agentgroups" // UpdateAgentGroupURL is the path to update an existing agent group. UpdateAgentGroupURL = "/api/v1/agentgroups/{id}" // DeleteAgentGroupURL is the path to delete an agent group. DeleteAgentGroupURL = "/api/v1/agentgroups/{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 AgentGroupService ¶ added in v0.1.20
type AgentGroupService struct {
// contains filtered or unexported fields
}
AgentGroupService provides methods to interact with agent groups.
func NewAgentGroupService ¶ added in v0.1.20
func NewAgentGroupService(service *service) *AgentGroupService
NewAgentGroupService creates a new AgentGroupService.
func (*AgentGroupService) CreateAgentGroup ¶ added in v0.1.20
func (s *AgentGroupService) CreateAgentGroup( ctx context.Context, createRequest *agentgroupv1.CreateRequest, ) (*agentgroupv1.AgentGroup, error)
CreateAgentGroup creates a new agent group.
func (*AgentGroupService) DeleteAgentGroup ¶ added in v0.1.20
func (s *AgentGroupService) DeleteAgentGroup(ctx context.Context, name string) error
DeleteAgentGroup deletes an agent group by its ID.
func (*AgentGroupService) GetAgentGroup ¶ added in v0.1.20
func (s *AgentGroupService) GetAgentGroup( ctx context.Context, name string, ) (*agentgroupv1.AgentGroup, error)
GetAgentGroup retrieves an agent group by its ID.
func (*AgentGroupService) ListAgentGroups ¶ added in v0.1.20
func (s *AgentGroupService) ListAgentGroups( ctx context.Context, opts ...ListOption, ) (*agentgroupv1.ListResponse, error)
ListAgentGroups lists all agent groups.
func (*AgentGroupService) ListAgentsByAgentGroup ¶ added in v0.1.22
func (s *AgentGroupService) ListAgentsByAgentGroup( ctx context.Context, name string, opts ...ListOption, ) (*agentv1.ListResponse, error)
ListAgentsByAgentGroup lists agents belonging to a specific agent group.
func (*AgentGroupService) UpdateAgentGroup ¶ added in v0.1.20
func (s *AgentGroupService) UpdateAgentGroup( ctx context.Context, updateRequest *agentgroupv1.AgentGroup, ) (*agentgroupv1.AgentGroup, error)
UpdateAgentGroup updates an existing agent group.
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.
func (*AgentService) RestartAgent ¶ added in v0.1.24
RestartAgent restarts an agent by its ID.
func (*AgentService) SearchAgents ¶ added in v0.1.25
func (s *AgentService) SearchAgents( ctx context.Context, query string, opts ...ListOption, ) (*agentv1.ListResponse, error)
SearchAgents searches agents by query.
func (*AgentService) SetAgentNewInstanceUID ¶ added in v0.1.24
func (s *AgentService) SetAgentNewInstanceUID( ctx context.Context, id uuid.UUID, request agentv1.SetNewInstanceUIDRequest, ) (*agentv1.Agent, error)
SetAgentNewInstanceUID sets a new instance UID for an agent.
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
AgentGroupService *AgentGroupService
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.