client

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Overview

Package client provides a go client for interacting with the BindPlane OP server. Most of the functions depend on the BindPlane REST API internally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentInstallOptions

type AgentInstallOptions struct {
	// Platform is the platform the agent will run on, e.g. "linux"
	Platform string

	// Version is the agent release version to install. Available release versions of the observiq-otel-collector are
	// available at [observiq-otel-collector Releases]
	//
	// [observiq-otel-collector Releases]: https://github.com/observIQ/observiq-otel-collector/releases
	Version string

	// Labels is a string representation of the agents labels, e.g. "platform=dev,os=windows,app=nginx"
	Labels string

	// SecretKey is the secret key used to authenticate agents with BindPlane OP
	SecretKey string

	// RemoteURL is the URL that the agent will use to connect to BindPlane OP
	RemoteURL string
}

AgentInstallOptions contains configuration options used for installing an agent.

type BindPlane

type BindPlane interface {
	// Agents returns a list of Agents.
	Agents(ctx context.Context, options ...QueryOption) ([]*model.Agent, error)
	// Agent returns a single Agent.
	Agent(ctx context.Context, id string) (*model.Agent, error)
	// DeleteAgents deletes multiple agents by ID.
	DeleteAgents(ctx context.Context, agentIDs []string) ([]*model.Agent, error)

	// AgentVersions returns a list of AgentVersion resources.
	AgentVersions(ctx context.Context) ([]*model.AgentVersion, error)
	// AgentVersion returns a single AgentVersion resources by name.
	AgentVersion(ctx context.Context, name string) (*model.AgentVersion, error)
	// DeleteAgentVersion deletes an AgentVersion resource by name.
	DeleteAgentVersion(ctx context.Context, name string) error

	// SyncAgentVersions builds agent-version from the release data in GitHub.
	// If version is empty, it syncs the last 10 releases.
	SyncAgentVersions(ctx context.Context, version string) ([]*model.AnyResourceStatus, error)

	// Configurations returns a list of Configuration resources.
	Configurations(ctx context.Context) ([]*model.Configuration, error)
	// Configuration returns a single Configuration resource from GET /v1/configurations/:name
	Configuration(ctx context.Context, name string) (*model.Configuration, error)
	// Delete configuration deletes a single configuration reseource.
	DeleteConfiguration(ctx context.Context, name string) error
	// RawConfiguration returns the raw OpenTelemetry configuration for the configuration with
	// the specified name. This can either be the raw value of a raw configuration or the
	// rendered value of a configuration with sources and destinations.
	RawConfiguration(ctx context.Context, name string) (string, error)
	// CopyConfig creates a deep copy of an existing resource under a new name.
	CopyConfig(ctx context.Context, name, copyName string) error

	// Sources returns a list of all Source resources.
	Sources(ctx context.Context) ([]*model.Source, error)
	// Source returns a single Source resource by name.
	Source(ctx context.Context, name string) (*model.Source, error)
	// DeleteSource deletes a single Source resource by name.
	DeleteSource(ctx context.Context, name string) error

	// SourceTypes returns a list of all SourceType resources.
	SourceTypes(ctx context.Context) ([]*model.SourceType, error)
	// SourceType returns a single SourceType resource by name.
	SourceType(ctx context.Context, name string) (*model.SourceType, error)
	// DeleteSourceType deletes a single SourceType resource by name.
	DeleteSourceType(ctx context.Context, name string) error

	// Processors returns a list of all Processor resources.
	Processors(ctx context.Context) ([]*model.Processor, error)
	// Processor returns a single Processor resource by name.
	Processor(ctx context.Context, name string) (*model.Processor, error)
	// DeleteProcessor deletes a single Processor resource by name.
	DeleteProcessor(ctx context.Context, name string) error

	// ProcessorTypes returns a list of all ProcessorType resources.
	ProcessorTypes(ctx context.Context) ([]*model.ProcessorType, error)
	// ProcessorType returns a single ProcessorType resource by name.
	ProcessorType(ctx context.Context, name string) (*model.ProcessorType, error)
	// DeleteProcessorType deletes a single ProcessorType resource by name.
	DeleteProcessorType(ctx context.Context, name string) error

	// Destinations returns a list of all Destination resources.
	Destinations(ctx context.Context) ([]*model.Destination, error)
	// Destination returns a single Destination resource by name.
	Destination(ctx context.Context, name string) (*model.Destination, error)
	// DeleteDestination deletes a single Destination resource by name.
	DeleteDestination(ctx context.Context, name string) error

	// DestinationTypes returns a list of all DestinationType resources.
	DestinationTypes(ctx context.Context) ([]*model.DestinationType, error)
	// DestinationType returns a single DestinationType by name.
	DestinationType(ctx context.Context, name string) (*model.DestinationType, error)
	// DeleteDestinationType deletes a single Destination resource by name.
	DeleteDestinationType(ctx context.Context, name string) error

	// Apply upserts multiple resources of any kind.
	Apply(ctx context.Context, r []*model.AnyResource) ([]*model.AnyResourceStatus, error)
	// Delete deletes multiple resources, minimum required fields to delete are Kind and Metadata.Name.
	Delete(ctx context.Context, r []*model.AnyResource) ([]*model.AnyResourceStatus, error)

	// Version returns the version of the BindPlane-OP server.
	Version(ctx context.Context) (version.Version, error)

	// AgentInstallCommand returns the installation command for the given AgentInstallationOptions.
	AgentInstallCommand(ctx context.Context, options AgentInstallOptions) (string, error)
	// AgentUpgrade upgrades the agent with given ID to the specified version.
	AgentUpgrade(ctx context.Context, id string, version string) error

	// AgentLabels gets the labels for an agent
	AgentLabels(ctx context.Context, id string) (*model.Labels, error)
	// ApplyAgentLabels applies the specified labels to an agent, merging the specified labels with the existing labels
	// and returning the labels of the agent
	ApplyAgentLabels(ctx context.Context, id string, labels *model.Labels, override bool) (*model.Labels, error)
}

BindPlane is a REST client for BindPlane OP.

func NewBindPlane

func NewBindPlane(config *common.Client, logger *zap.Logger) (BindPlane, error)

NewBindPlane takes a client configuration, logger and returns a new BindPlane.

type QueryOption

type QueryOption func(*queryOptions)

QueryOption is an option used in many Store queries

func WithLimit

func WithLimit(limit int) QueryOption

WithLimit sets the maximum number of results to return. For paging, if the pages have 10 items per page, set the limit to 10.

func WithOffset

func WithOffset(offset int) QueryOption

WithOffset sets the offset for the results to return. For paging, if the pages have 10 items per page and this is the 3rd page, set the offset to 20.

func WithQuery

func WithQuery(query string) QueryOption

WithQuery adds a search query string to the query options

func WithSelector

func WithSelector(selector string) QueryOption

WithSelector adds a selector to the query options

func WithSort

func WithSort(field string) QueryOption

WithSort sets the sort order for the request. The sort value is the name of the field, sorted ascending. To sort descending, prefix the field with a minus sign (-). Some Stores only allow sorting by certain fields. Sort values not supported will be ignored.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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