client

package
v0.1.41 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 16 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 in a namespace.
	ListAgentURL = "/api/v1/namespaces/{namespace}/agents"
	// SearchAgentURL is the path to search agents in a namespace.
	SearchAgentURL = "/api/v1/namespaces/{namespace}/agents/search"
	// GetAgentURL is the path to get an agent by ID in a namespace.
	GetAgentURL = agentByIDURL
	// UpdateAgentURL is the path to update an agent in a namespace.
	UpdateAgentURL = agentByIDURL
	// DeleteAgentURL is the path to delete an agent by ID in a namespace.
	DeleteAgentURL = agentByIDURL
)
View Source
const (
	// ListAgentGroupURL is the path to list all agent groups within a namespace.
	ListAgentGroupURL = "/api/v1/namespaces/{namespace}/agentgroups"
	// ListAgentsByAgentGroupURL is the path to list all agents in an agent group.
	ListAgentsByAgentGroupURL = "/api/v1/namespaces/{namespace}/agentgroups/{name}/agents"
	// GetAgentGroupURL is the path to get an agent group by namespace and name.
	GetAgentGroupURL = "/api/v1/namespaces/{namespace}/agentgroups/{id}"
	// CreateAgentGroupURL is the path to create a new agent group.
	CreateAgentGroupURL = "/api/v1/namespaces/{namespace}/agentgroups"
	// UpdateAgentGroupURL is the path to update an existing agent group.
	UpdateAgentGroupURL = "/api/v1/namespaces/{namespace}/agentgroups/{id}"
	// DeleteAgentGroupURL is the path to delete an agent group.
	DeleteAgentGroupURL = "/api/v1/namespaces/{namespace}/agentgroups/{id}"
)
View Source
const (
	// ListAgentPackageURL is the path to list all agent packages.
	ListAgentPackageURL = "/api/v1/namespaces/{namespace}/agentpackages"
	// GetAgentPackageURL is the path to get an agent package by name.
	GetAgentPackageURL = "/api/v1/namespaces/{namespace}/agentpackages/{id}"
	// CreateAgentPackageURL is the path to create a new agent package.
	CreateAgentPackageURL = "/api/v1/namespaces/{namespace}/agentpackages"
	// UpdateAgentPackageURL is the path to update an existing agent package.
	UpdateAgentPackageURL = "/api/v1/namespaces/{namespace}/agentpackages/{id}"
	// DeleteAgentPackageURL is the path to delete an agent package.
	DeleteAgentPackageURL = "/api/v1/namespaces/{namespace}/agentpackages/{id}"
)
View Source
const (
	// ListAgentRemoteConfigURL is the path to list all agent remote configs.
	ListAgentRemoteConfigURL = "/api/v1/namespaces/{namespace}/agentremoteconfigs"
	// GetAgentRemoteConfigURL is the path to get an agent remote config by name.
	GetAgentRemoteConfigURL = "/api/v1/namespaces/{namespace}/agentremoteconfigs/{id}"
	// CreateAgentRemoteConfigURL is the path to create a new agent remote config.
	CreateAgentRemoteConfigURL = "/api/v1/namespaces/{namespace}/agentremoteconfigs"
	// UpdateAgentRemoteConfigURL is the path to update an existing agent remote config.
	UpdateAgentRemoteConfigURL = "/api/v1/namespaces/{namespace}/agentremoteconfigs/{id}"
	// DeleteAgentRemoteConfigURL is the path to delete an agent remote config.
	DeleteAgentRemoteConfigURL = "/api/v1/namespaces/{namespace}/agentremoteconfigs/{id}"
)
View Source
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"
	// GithubAuthCodeURLAPIURL is the API URL to obtain an auth-code URL bound to a CLI loopback redirect.
	GithubAuthCodeURLAPIURL = "/api/v1/auth/github/authcode"
	// 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"
	// RefreshAPIURL is the API URL for refreshing an access token.
	RefreshAPIURL = "/api/v1/auth/refresh"
)
View Source
const (
	// ListCertificateURL is the path to list all certificates.
	ListCertificateURL = "/api/v1/namespaces/{namespace}/certificates"
	// GetCertificateURL is the path to get a certificate by name.
	GetCertificateURL = "/api/v1/namespaces/{namespace}/certificates/{id}"
	// CreateCertificateURL is the path to create a new certificate.
	CreateCertificateURL = "/api/v1/namespaces/{namespace}/certificates"
	// UpdateCertificateURL is the path to update an existing certificate.
	UpdateCertificateURL = "/api/v1/namespaces/{namespace}/certificates/{id}"
	// DeleteCertificateURL is the path to delete a certificate.
	DeleteCertificateURL = "/api/v1/namespaces/{namespace}/certificates/{id}"
)
View Source
const (
	// ListConnectionsPath is the path to list connections in a namespace.
	ListConnectionsPath = "/api/v1/namespaces/{namespace}/connections"
	// GetConnectionPath is the path to get a connection by ID in a namespace.
	GetConnectionPath = "/api/v1/namespaces/{namespace}/connections/{id}"
)

API paths for connection resources.

View Source
const (
	// ListContainerURL is the path to list all discovered containers.
	ListContainerURL = "/api/v1/containers"
	// GetContainerURL is the path to get a container by ID.
	GetContainerURL = "/api/v1/containers/{id}"
	// ListContainerAgentsURL is the path to list the agents running in a container.
	ListContainerAgentsURL = "/api/v1/containers/{id}/agents"
)
View Source
const (
	// ListHostURL is the path to list all discovered hosts.
	ListHostURL = "/api/v1/hosts"
	// GetHostURL is the path to get a host by ID.
	GetHostURL = "/api/v1/hosts/{id}"
	// ListHostAgentsURL is the path to list the agents running on a host.
	ListHostAgentsURL = "/api/v1/hosts/{id}/agents"
)
View Source
const (
	// ListNamespaceURL is the path to list all namespaces.
	ListNamespaceURL = "/api/v1/namespaces"
	// GetNamespaceURL is the path to get a namespace by name.
	GetNamespaceURL = "/api/v1/namespaces/{id}"
	// CreateNamespaceURL is the path to create a new namespace.
	CreateNamespaceURL = "/api/v1/namespaces"
	// UpdateNamespaceURL is the path to update an existing namespace.
	UpdateNamespaceURL = "/api/v1/namespaces/{id}"
	// DeleteNamespaceURL is the path to delete a namespace.
	DeleteNamespaceURL = "/api/v1/namespaces/{id}"
)
View Source
const (
	// ListRoleURL is the path to list all roles.
	ListRoleURL = "/api/v1/roles"
	// GetRoleURL is the path to get a role by ID.
	GetRoleURL = "/api/v1/roles/{id}"
	// CreateRoleURL is the path to create a new role.
	CreateRoleURL = "/api/v1/roles"
	// UpdateRoleURL is the path to update an existing role.
	UpdateRoleURL = "/api/v1/roles/{id}"
	// DeleteRoleURL is the path to delete a role.
	DeleteRoleURL = "/api/v1/roles/{id}"
)
View Source
const (
	// ListRoleBindingURL is the path to list all role bindings within a namespace.
	ListRoleBindingURL = "/api/v1/namespaces/{namespace}/rolebindings"
	// GetRoleBindingURL is the path to get a role binding by namespace and name.
	GetRoleBindingURL = "/api/v1/namespaces/{namespace}/rolebindings/{id}"
	// CreateRoleBindingURL is the path to create a new role binding.
	CreateRoleBindingURL = "/api/v1/namespaces/{namespace}/rolebindings"
	// UpdateRoleBindingURL is the path to update an existing role binding.
	UpdateRoleBindingURL = "/api/v1/namespaces/{namespace}/rolebindings/{id}"
	// DeleteRoleBindingURL is the path to delete a role binding.
	DeleteRoleBindingURL = "/api/v1/namespaces/{namespace}/rolebindings/{id}"
)
View Source
const (
	// ListUserURL is the path to list all users.
	ListUserURL = "/api/v1/users"
	// GetUserURL is the path to get a user by ID.
	GetUserURL = "/api/v1/users/{id}"
	// CreateUserURL is the path to create a new user.
	CreateUserURL = "/api/v1/users"
	// DeleteUserURL is the path to delete a user.
	DeleteUserURL = "/api/v1/users/{id}"
	// GetUserProfileURL is the path to get the current user's profile.
	GetUserProfileURL = "/api/v1/users/me"
)

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 AgentGroupListResponse ¶ added in v0.1.27

type AgentGroupListResponse = v1.ListResponse[v1.AgentGroup]

AgentGroupListResponse represents a list of agent groups with metadata.

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,
	namespace string,
	createRequest *v1.AgentGroup,
) (*v1.AgentGroup, error)

CreateAgentGroup creates a new agent group.

func (*AgentGroupService) DeleteAgentGroup ¶ added in v0.1.20

func (s *AgentGroupService) DeleteAgentGroup(ctx context.Context, namespace string, name string) error

DeleteAgentGroup deletes an agent group by its namespace and name.

func (*AgentGroupService) GetAgentGroup ¶ added in v0.1.20

func (s *AgentGroupService) GetAgentGroup(
	ctx context.Context,
	namespace string,
	name string,
	opts ...GetOption,
) (*v1.AgentGroup, error)

GetAgentGroup retrieves an agent group by its namespace and name.

func (*AgentGroupService) ListAgentGroups ¶ added in v0.1.20

func (s *AgentGroupService) ListAgentGroups(
	ctx context.Context,
	namespace string,
	opts ...ListOption,
) (*AgentGroupListResponse, error)

ListAgentGroups lists all agent groups in a namespace.

func (*AgentGroupService) ListAgentsByAgentGroup ¶ added in v0.1.22

func (s *AgentGroupService) ListAgentsByAgentGroup(
	ctx context.Context,
	namespace string,
	name string,
	opts ...ListOption,
) (*AgentListResponse, 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 *v1.AgentGroup,
) (*v1.AgentGroup, error)

UpdateAgentGroup updates an existing agent group.

type AgentListResponse ¶ added in v0.1.27

type AgentListResponse = v1.ListResponse[v1.Agent]

AgentListResponse represents a list of agents with metadata.

type AgentPackageListResponse ¶ added in v0.1.28

type AgentPackageListResponse = v1.ListResponse[v1.AgentPackage]

AgentPackageListResponse represents a list of agent packages with metadata.

type AgentPackageService ¶ added in v0.1.28

type AgentPackageService struct {
	// contains filtered or unexported fields
}

AgentPackageService provides methods to interact with agent packages.

func NewAgentPackageService ¶ added in v0.1.28

func NewAgentPackageService(service *service) *AgentPackageService

NewAgentPackageService creates a new AgentPackageService.

func (*AgentPackageService) CreateAgentPackage ¶ added in v0.1.28

func (s *AgentPackageService) CreateAgentPackage(
	ctx context.Context,
	namespace string,
	createRequest *v1.AgentPackage,
) (*v1.AgentPackage, error)

CreateAgentPackage creates a new agent package.

func (*AgentPackageService) DeleteAgentPackage ¶ added in v0.1.28

func (s *AgentPackageService) DeleteAgentPackage(
	ctx context.Context,
	namespace string,
	name string,
) error

DeleteAgentPackage deletes an agent package by its namespace and name.

func (*AgentPackageService) GetAgentPackage ¶ added in v0.1.28

func (s *AgentPackageService) GetAgentPackage(
	ctx context.Context,
	namespace string,
	name string,
	opts ...GetOption,
) (*v1.AgentPackage, error)

GetAgentPackage retrieves an agent package by its namespace and name.

func (*AgentPackageService) ListAgentPackages ¶ added in v0.1.28

func (s *AgentPackageService) ListAgentPackages(
	ctx context.Context,
	namespace string,
	opts ...ListOption,
) (*AgentPackageListResponse, error)

ListAgentPackages lists all agent packages in a namespace.

func (*AgentPackageService) UpdateAgentPackage ¶ added in v0.1.28

func (s *AgentPackageService) UpdateAgentPackage(
	ctx context.Context,
	updateRequest *v1.AgentPackage,
) (*v1.AgentPackage, error)

UpdateAgentPackage updates an existing agent package.

type AgentRemoteConfigListResponse ¶ added in v0.1.28

type AgentRemoteConfigListResponse = v1.ListResponse[v1.AgentRemoteConfig]

AgentRemoteConfigListResponse represents a list of agent remote configs with metadata.

type AgentRemoteConfigService ¶ added in v0.1.28

type AgentRemoteConfigService struct {
	// contains filtered or unexported fields
}

AgentRemoteConfigService provides methods to interact with agent remote configs.

func NewAgentRemoteConfigService ¶ added in v0.1.28

func NewAgentRemoteConfigService(service *service) *AgentRemoteConfigService

NewAgentRemoteConfigService creates a new AgentRemoteConfigService.

func (*AgentRemoteConfigService) CreateAgentRemoteConfig ¶ added in v0.1.28

func (s *AgentRemoteConfigService) CreateAgentRemoteConfig(
	ctx context.Context,
	namespace string,
	createRequest *v1.AgentRemoteConfig,
) (*v1.AgentRemoteConfig, error)

CreateAgentRemoteConfig creates a new agent remote config.

func (*AgentRemoteConfigService) DeleteAgentRemoteConfig ¶ added in v0.1.28

func (s *AgentRemoteConfigService) DeleteAgentRemoteConfig(
	ctx context.Context,
	namespace string,
	name string,
) error

DeleteAgentRemoteConfig deletes an agent remote config by namespace and name.

func (*AgentRemoteConfigService) GetAgentRemoteConfig ¶ added in v0.1.28

func (s *AgentRemoteConfigService) GetAgentRemoteConfig(
	ctx context.Context,
	namespace string,
	name string,
	opts ...GetOption,
) (*v1.AgentRemoteConfig, error)

GetAgentRemoteConfig retrieves an agent remote config by its namespace and name.

func (*AgentRemoteConfigService) ListAgentRemoteConfigs ¶ added in v0.1.28

func (s *AgentRemoteConfigService) ListAgentRemoteConfigs(
	ctx context.Context,
	namespace string,
	opts ...ListOption,
) (*AgentRemoteConfigListResponse, error)

ListAgentRemoteConfigs lists all agent remote configs in a namespace.

func (*AgentRemoteConfigService) UpdateAgentRemoteConfig ¶ added in v0.1.28

func (s *AgentRemoteConfigService) UpdateAgentRemoteConfig(
	ctx context.Context,
	updateRequest *v1.AgentRemoteConfig,
) (*v1.AgentRemoteConfig, error)

UpdateAgentRemoteConfig updates an existing agent remote config.

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) DeleteAgent ¶ added in v0.1.41

func (s *AgentService) DeleteAgent(
	ctx context.Context,
	namespace string,
	id uuid.UUID,
) error

DeleteAgent deletes a disconnected agent by its namespace and ID. The server rejects deletion of connected agents with a 409 Conflict.

func (*AgentService) GetAgent ¶ added in v0.1.1

func (s *AgentService) GetAgent(
	ctx context.Context,
	namespace string,
	id uuid.UUID,
) (*v1.Agent, error)

GetAgent retrieves an agent by its namespace and ID.

func (*AgentService) ListAgents ¶ added in v0.1.1

func (s *AgentService) ListAgents(
	ctx context.Context,
	namespace string,
	opts ...ListOption,
) (*AgentListResponse, error)

ListAgents lists all agents in a namespace.

func (*AgentService) RestartAgent ¶ added in v0.1.24

func (s *AgentService) RestartAgent(
	ctx context.Context,
	namespace string,
	id uuid.UUID,
) (*v1.Agent, error)

RestartAgent restarts an agent by its ID.

func (*AgentService) SearchAgents ¶ added in v0.1.25

func (s *AgentService) SearchAgents(
	ctx context.Context,
	namespace string,
	query string,
	opts ...ListOption,
) (*AgentListResponse, error)

SearchAgents searches agents by query in a namespace.

func (*AgentService) SetAgentNewInstanceUID ¶ added in v0.1.24

func (s *AgentService) SetAgentNewInstanceUID(
	ctx context.Context,
	namespace string,
	id uuid.UUID,
	request SetNewInstanceUIDRequest,
) (*v1.Agent, error)

SetAgentNewInstanceUID sets a new instance UID for an agent.

func (*AgentService) UpdateAgent ¶ added in v0.1.27

func (s *AgentService) UpdateAgent(
	ctx context.Context,
	namespace string,
	id uuid.UUID,
	agent *v1.Agent,
) (*v1.Agent, error)

UpdateAgent updates an agent with the given spec in a namespace.

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) GetAuthCodeURL ¶ added in v0.1.39

func (s *AuthService) GetAuthCodeURL(redirectURI string) (*v1auth.OAuth2AuthCodeURLResponse, error)

GetAuthCodeURL retrieves a GitHub OAuth2 authorization URL bound to the given loopback redirect URI. The server encodes the redirect URI into the state JWT; on callback the browser is redirected to the loopback URI with the tokens as query parameters.

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.

func (*AuthService) Refresh ¶ added in v0.1.39

func (s *AuthService) Refresh(refreshToken string) (*v1auth.AuthnTokenResponse, error)

Refresh exchanges a refresh token for a new access (and rotated refresh) token.

type CertificateListResponse ¶ added in v0.1.28

type CertificateListResponse = v1.ListResponse[v1.Certificate]

CertificateListResponse represents a list of certificates with metadata.

type CertificateService ¶ added in v0.1.28

type CertificateService struct {
	// contains filtered or unexported fields
}

CertificateService provides methods to interact with certificates.

func NewCertificateService ¶ added in v0.1.28

func NewCertificateService(service *service) *CertificateService

NewCertificateService creates a new CertificateService.

func (*CertificateService) CreateCertificate ¶ added in v0.1.28

func (s *CertificateService) CreateCertificate(
	ctx context.Context,
	namespace string,
	createRequest *v1.Certificate,
) (*v1.Certificate, error)

CreateCertificate creates a new certificate.

func (*CertificateService) DeleteCertificate ¶ added in v0.1.28

func (s *CertificateService) DeleteCertificate(
	ctx context.Context,
	namespace string,
	name string,
) error

DeleteCertificate deletes a certificate by its namespace and name.

func (*CertificateService) GetCertificate ¶ added in v0.1.28

func (s *CertificateService) GetCertificate(
	ctx context.Context,
	namespace string,
	name string,
	opts ...GetOption,
) (*v1.Certificate, error)

GetCertificate retrieves a certificate by its namespace and name.

func (*CertificateService) ListCertificates ¶ added in v0.1.28

func (s *CertificateService) ListCertificates(
	ctx context.Context,
	namespace string,
	opts ...ListOption,
) (*CertificateListResponse, error)

ListCertificates lists all certificates in a namespace.

func (*CertificateService) UpdateCertificate ¶ added in v0.1.28

func (s *CertificateService) UpdateCertificate(
	ctx context.Context,
	updateRequest *v1.Certificate,
) (*v1.Certificate, error)

UpdateCertificate updates an existing certificate.

type Client ¶

type Client struct {
	Endpoint string

	AgentService             *AgentService
	AgentGroupService        *AgentGroupService
	AgentPackageService      *AgentPackageService
	AgentRemoteConfigService *AgentRemoteConfigService
	CertificateService       *CertificateService
	ConnectionService        *ConnectionService
	AuthService              *AuthService
	NamespaceService         *NamespaceService
	HostService              *HostService
	ContainerService         *ContainerService
	UserService              *UserService
	RoleService              *RoleService
	RoleBindingService       *RoleBindingService
	// contains filtered or unexported fields
}

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

func New ¶ added in v0.1.1

func New(endpoint string, opt ...Option) *Client

New creates a new client for opampcommander's apiserver.

func (*Client) GetServerVersion ¶ added in v0.1.18

func (c *Client) GetServerVersion(ctx context.Context) (*v1version.Info, error)

GetServerVersion retrieves the server version information.

func (*Client) Ping ¶ added in v0.1.30

func (c *Client) Ping() error

Ping checks if the server is alive.

func (*Client) SetAuthToken ¶ added in v0.1.1

func (c *Client) SetAuthToken(bearerToken string)

SetAuthToken sets the authentication token for the client.

func (*Client) SetBasicAuth ¶ added in v0.1.30

func (c *Client) SetBasicAuth(username, password string)

SetBasicAuth sets the basic authentication credentials for the client.

func (*Client) SetLogger ¶ added in v0.1.10

func (c *Client) SetLogger(logger *slog.Logger)

SetLogger sets the logger for the client.

func (*Client) SetVerbose ¶ added in v0.1.10

func (c *Client) SetVerbose(verbose bool)

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,
	namespace string,
	id uuid.UUID,
) (*v1.Connection, error)

GetConnection retrieves a connection by its namespace and ID.

func (*ConnectionService) ListConnections ¶ added in v0.1.1

func (s *ConnectionService) ListConnections(
	ctx context.Context,
	namespace string,
	opts ...ListOption,
) (*v1.ConnectionListResponse, error)

ListConnections lists connections in a namespace.

type ContainerListResponse ¶ added in v0.1.41

type ContainerListResponse = v1.ListResponse[v1.Container]

ContainerListResponse represents a list of containers with metadata.

type ContainerService ¶ added in v0.1.41

type ContainerService struct {
	// contains filtered or unexported fields
}

ContainerService provides methods to interact with containers.

func NewContainerService ¶ added in v0.1.41

func NewContainerService(service *service) *ContainerService

NewContainerService creates a new ContainerService.

func (*ContainerService) GetContainer ¶ added in v0.1.41

func (s *ContainerService) GetContainer(ctx context.Context, id string) (*v1.Container, error)

GetContainer retrieves a container by its ID.

func (*ContainerService) ListAgentsByContainer ¶ added in v0.1.41

func (s *ContainerService) ListAgentsByContainer(
	ctx context.Context,
	id string,
	opts ...ListOption,
) (*AgentListResponse, error)

ListAgentsByContainer lists the agents running in a container.

func (*ContainerService) ListContainers ¶ added in v0.1.41

func (s *ContainerService) ListContainers(ctx context.Context, opts ...ListOption) (*ContainerListResponse, error)

ListContainers lists all discovered containers.

type GetOption ¶ added in v0.1.30

type GetOption interface {
	Apply(settings *GetSettings)
}

GetOption is an interface for options that can be applied to get operations.

func WithGetIncludeDeleted ¶ added in v0.1.30

func WithGetIncludeDeleted(includeDeleted bool) GetOption

WithGetIncludeDeleted sets whether to include deleted resources for get operations.

type GetOptionFunc ¶ added in v0.1.30

type GetOptionFunc func(*GetSettings)

GetOptionFunc is a function type that implements the GetOption interface.

func (GetOptionFunc) Apply ¶ added in v0.1.30

func (f GetOptionFunc) Apply(opt *GetSettings)

Apply applies the GetOptionFunc to the GetSettings.

type GetSettings ¶ added in v0.1.30

type GetSettings struct {
	// contains filtered or unexported fields
}

GetSettings holds the settings for getting a single resource.

type HostListResponse ¶ added in v0.1.41

type HostListResponse = v1.ListResponse[v1.Host]

HostListResponse represents a list of hosts with metadata.

type HostService ¶ added in v0.1.41

type HostService struct {
	// contains filtered or unexported fields
}

HostService provides methods to interact with hosts.

func NewHostService ¶ added in v0.1.41

func NewHostService(service *service) *HostService

NewHostService creates a new HostService.

func (*HostService) GetHost ¶ added in v0.1.41

func (s *HostService) GetHost(ctx context.Context, id string) (*v1.Host, error)

GetHost retrieves a host by its ID.

func (*HostService) ListAgentsByHost ¶ added in v0.1.41

func (s *HostService) ListAgentsByHost(
	ctx context.Context,
	id string,
	opts ...ListOption,
) (*AgentListResponse, error)

ListAgentsByHost lists the agents running on a host.

func (*HostService) ListHosts ¶ added in v0.1.41

func (s *HostService) ListHosts(ctx context.Context, opts ...ListOption) (*HostListResponse, error)

ListHosts lists all discovered hosts.

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 WithIncludeDeleted ¶ added in v0.1.30

func WithIncludeDeleted(includeDeleted bool) ListOption

WithIncludeDeleted sets whether to include deleted resources.

func WithLimit ¶ added in v0.1.18

func WithLimit(limit int) ListOption

WithLimit sets the limit for the number of items to return.

func WithNonIdentifyingSelector ¶ added in v0.1.41

func WithNonIdentifyingSelector(selector map[string]string) ListOption

WithNonIdentifyingSelector filters an agent listing by non-identifying attributes, matching every key=value pair exactly. An empty map applies no filter.

func WithSelector ¶ added in v0.1.41

func WithSelector(selector map[string]string) ListOption

WithSelector filters an agent listing by identifying attributes, matching every key=value pair exactly. An empty map applies no filter.

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 NamespaceListResponse ¶ added in v0.1.30

type NamespaceListResponse = v1.ListResponse[v1.Namespace]

NamespaceListResponse represents a list of namespaces with metadata.

type NamespaceService ¶ added in v0.1.30

type NamespaceService struct {
	// contains filtered or unexported fields
}

NamespaceService provides methods to interact with namespaces.

func NewNamespaceService ¶ added in v0.1.30

func NewNamespaceService(service *service) *NamespaceService

NewNamespaceService creates a new NamespaceService.

func (*NamespaceService) CreateNamespace ¶ added in v0.1.30

func (s *NamespaceService) CreateNamespace(
	ctx context.Context,
	createRequest *v1.Namespace,
) (*v1.Namespace, error)

CreateNamespace creates a new namespace.

func (*NamespaceService) DeleteNamespace ¶ added in v0.1.30

func (s *NamespaceService) DeleteNamespace(
	ctx context.Context,
	name string,
) error

DeleteNamespace deletes a namespace by name.

func (*NamespaceService) GetNamespace ¶ added in v0.1.30

func (s *NamespaceService) GetNamespace(
	ctx context.Context,
	name string,
	opts ...GetOption,
) (*v1.Namespace, error)

GetNamespace retrieves a namespace by its name.

func (*NamespaceService) ListNamespaces ¶ added in v0.1.30

func (s *NamespaceService) ListNamespaces(
	ctx context.Context,
	opts ...ListOption,
) (*NamespaceListResponse, error)

ListNamespaces lists all namespaces.

func (*NamespaceService) UpdateNamespace ¶ added in v0.1.30

func (s *NamespaceService) UpdateNamespace(
	ctx context.Context,
	name string,
	updateRequest *v1.Namespace,
) (*v1.Namespace, error)

UpdateNamespace updates an existing namespace.

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 WithBasicAuth ¶ added in v0.1.30

func WithBasicAuth(username, password string) OptionFunc

WithBasicAuth exchanges the given credentials for a JWT via /api/v1/auth/basic and configures the client to use the resulting Bearer token. If the exchange fails (e.g. server not yet ready), the client is left unauthenticated.

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 ¶

type ResponseError struct {
	StatusCode   int
	ErrorMessage string
}

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.

type RoleBindingListResponse ¶ added in v0.1.30

type RoleBindingListResponse = v1.ListResponse[v1.RoleBinding]

RoleBindingListResponse represents a list of role bindings with metadata.

type RoleBindingService ¶ added in v0.1.30

type RoleBindingService struct {
	// contains filtered or unexported fields
}

RoleBindingService provides methods to interact with role bindings.

func NewRoleBindingService ¶ added in v0.1.30

func NewRoleBindingService(service *service) *RoleBindingService

NewRoleBindingService creates a new RoleBindingService.

func (*RoleBindingService) CreateRoleBinding ¶ added in v0.1.30

func (s *RoleBindingService) CreateRoleBinding(
	ctx context.Context,
	namespace string,
	createRequest *v1.RoleBinding,
) (*v1.RoleBinding, error)

CreateRoleBinding creates a new role binding.

func (*RoleBindingService) DeleteRoleBinding ¶ added in v0.1.30

func (s *RoleBindingService) DeleteRoleBinding(ctx context.Context, namespace string, name string) error

DeleteRoleBinding deletes a role binding by its namespace and name.

func (*RoleBindingService) GetRoleBinding ¶ added in v0.1.30

func (s *RoleBindingService) GetRoleBinding(
	ctx context.Context,
	namespace string,
	name string,
	opts ...GetOption,
) (*v1.RoleBinding, error)

GetRoleBinding retrieves a role binding by its namespace and name.

func (*RoleBindingService) ListRoleBindings ¶ added in v0.1.30

func (s *RoleBindingService) ListRoleBindings(
	ctx context.Context,
	namespace string,
	opts ...ListOption,
) (*RoleBindingListResponse, error)

ListRoleBindings lists all role bindings in a namespace.

func (*RoleBindingService) UpdateRoleBinding ¶ added in v0.1.30

func (s *RoleBindingService) UpdateRoleBinding(
	ctx context.Context,
	updateRequest *v1.RoleBinding,
) (*v1.RoleBinding, error)

UpdateRoleBinding updates an existing role binding.

type RoleListResponse ¶ added in v0.1.30

type RoleListResponse = v1.ListResponse[v1.Role]

RoleListResponse represents a list of roles with metadata.

type RoleService ¶ added in v0.1.30

type RoleService struct {
	// contains filtered or unexported fields
}

RoleService provides methods to interact with roles.

func NewRoleService ¶ added in v0.1.30

func NewRoleService(service *service) *RoleService

NewRoleService creates a new RoleService.

func (*RoleService) CreateRole ¶ added in v0.1.30

func (s *RoleService) CreateRole(ctx context.Context, role *v1.Role) (*v1.Role, error)

CreateRole creates a new role.

func (*RoleService) DeleteRole ¶ added in v0.1.30

func (s *RoleService) DeleteRole(ctx context.Context, uid string) error

DeleteRole deletes a role by its UID.

func (*RoleService) GetRole ¶ added in v0.1.30

func (s *RoleService) GetRole(ctx context.Context, uid string, opts ...GetOption) (*v1.Role, error)

GetRole retrieves a role by its UID.

func (*RoleService) ListRoles ¶ added in v0.1.30

func (s *RoleService) ListRoles(
	ctx context.Context,
	opts ...ListOption,
) (*RoleListResponse, error)

ListRoles lists all roles.

func (*RoleService) UpdateRole ¶ added in v0.1.30

func (s *RoleService) UpdateRole(ctx context.Context, uid string, role *v1.Role) (*v1.Role, error)

UpdateRole updates an existing role.

type SetNewInstanceUIDRequest ¶ added in v0.1.27

type SetNewInstanceUIDRequest struct {
	NewInstanceUID uuid.UUID `binding:"required" json:"newInstanceUid"`
}

SetNewInstanceUIDRequest is a struct that represents the request to set a new instance UID for the agent.

type UserListResponse ¶ added in v0.1.30

type UserListResponse = v1.ListResponse[v1.User]

UserListResponse represents a list of users with metadata.

type UserService ¶ added in v0.1.30

type UserService struct {
	// contains filtered or unexported fields
}

UserService provides methods to interact with users.

func NewUserService ¶ added in v0.1.30

func NewUserService(service *service) *UserService

NewUserService creates a new UserService.

func (*UserService) CreateUser ¶ added in v0.1.30

func (s *UserService) CreateUser(ctx context.Context, user *v1.User) (*v1.User, error)

CreateUser creates a new user.

func (*UserService) DeleteUser ¶ added in v0.1.30

func (s *UserService) DeleteUser(ctx context.Context, uid string) error

DeleteUser deletes a user by its UID.

func (*UserService) GetMyProfile ¶ added in v0.1.30

func (s *UserService) GetMyProfile(ctx context.Context) (*v1.UserProfileResponse, error)

GetMyProfile retrieves the current user's profile with roles and permissions.

func (*UserService) GetUser ¶ added in v0.1.30

func (s *UserService) GetUser(ctx context.Context, uid string, opts ...GetOption) (*v1.User, error)

GetUser retrieves a user by its UID.

func (*UserService) ListUsers ¶ added in v0.1.30

func (s *UserService) ListUsers(
	ctx context.Context,
	opts ...ListOption,
) (*UserListResponse, error)

ListUsers lists all users.

Jump to

Keyboard shortcuts

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