sdk

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Overview

Package sdk provide an abstraction for communication with API.

Index

Constants

View Source
const (
	HeaderOrganization  = "organization"
	HeaderProject       = "project"
	HeaderAuthorization = "Authorization"
	HeaderUserAgent     = "User-Agent"
	HeaderClientID      = "ClientID"
)

HTTP headers keys used across app

View Source
const (
	QueryKeyName              = "name"
	QueryKeyTime              = "t"
	QueryKeyFrom              = "from"
	QueryKeyTo                = "to"
	QueryKeySeries            = "series"
	QueryKeySteps             = "steps"
	QueryKeySlo               = "slo"
	QueryKeyTimeWindow        = "window"
	QueryKeyPercentiles       = "q"
	QueryKeyPermissionFilter  = "pf"
	QueryKeyLabelsFilter      = "labels"
	QueryKeyServiceName       = "service_name"
	QueryKeyDryRun            = "dry_run"
	QueryKeyTextSearch        = "text_search"
	QueryKeySystemAnnotations = "system_annotations"
	QueryKeyUserAnnotations   = "user_annotations"
)

HTTP GET query keys used across app

View Source
const DefaultProject = "default"

DefaultProject is a value of the default project.

View Source
const ProjectsWildcard = "*"

ProjectsWildcard is used in HeaderProject when requesting for all projects.

View Source
const (
	Timeout = 10 * time.Second
)

Timeout use for every request

Variables

This section is empty.

Functions

func IsObjectAvailable

func IsObjectAvailable(o Object) bool

IsObjectAvailable returns true if given object is available in SDK.

Types

type AnyJSONObj

type AnyJSONObj = map[string]interface{}

AnyJSONObj can store a generic representation on any valid JSON.

func Annotate

func Annotate(
	object AnyJSONObj,
	annotations map[string]string,
	project string,
	isProjectOverwritten bool,
) (AnyJSONObj, error)

Annotate injects to objects additional fields with values passed as map in parameter If objects does not contain project - default value is added.

type Client

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

Client represents API high level client.

func NewClient

func NewClient(ingestURL, intakeURL, organization, project, userAgent string, client *http.Client) (Client, error)

NewClient returns fully configured instance of API high level client with default timeout.

func NewClientWithTimeout

func NewClientWithTimeout(
	ingestURL, intakeURL, organization, project, userAgent string, client *http.Client,
) (Client, error)

NewClientWithTimeout returns fully configured instance of API high level client with timeout used for every request.

func (*Client) ApplyObjects

func (c *Client) ApplyObjects(ctx context.Context, objects []AnyJSONObj, dryRun bool) error

ApplyObjects applies (create or update) list of objects passed as argument via API.

func (*Client) Authorization

func (c *Client) Authorization() string

Authorization returns authorization header value that is used in the requests.

func (*Client) DeleteObjects

func (c *Client) DeleteObjects(ctx context.Context, objects []AnyJSONObj, dryRun bool) error

DeleteObjects deletes list of objects passed as argument via API.

func (*Client) DeleteObjectsByName

func (c *Client) DeleteObjectsByName(ctx context.Context, object Object, dryRun bool, names ...string) error

DeleteObjectsByName makes a call to endpoint for deleting objects with passed names and object types.

func (*Client) GetAWSExternalID

func (c *Client) GetAWSExternalID(ctx context.Context) (string, error)

func (*Client) GetAgentCredentials added in v0.2.0

func (c *Client) GetAgentCredentials(ctx context.Context, agentsName string) (creds M2MAppCredentials, err error)

GetAgentCredentials gets agent credentials from Okta.

func (*Client) GetObject

func (c *Client) GetObject(
	ctx context.Context,
	object Object,
	timestamp string,
	filterLabel map[string][]string,
	names ...string,
) ([]AnyJSONObj, error)

GetObject returns array of supported type of Objects, when names are passed - query for these names otherwise returns list of all available objects.

func (*Client) Organization

func (c *Client) Organization() string

Organization gets an organization that will be used in future requests.

func (*Client) PostMetrics

func (c *Client) PostMetrics(ctx context.Context, points models.Points, accessToken string) error

func (*Client) Project added in v0.7.1

func (c *Client) Project() string

func (*Client) SetAuth

func (c *Client) SetAuth(authorization string)

SetAuth sets an authorization header which should used in future requests.

func (*Client) SetOrganization

func (c *Client) SetOrganization(organization string)

SetOrganization sets an organization which should used in future requests.

func (*Client) SetProject added in v0.7.1

func (c *Client) SetProject(project string)

func (*Client) UserAgent

func (c *Client) UserAgent() string

UserAgent returns users version.

type M2MAppCredentials added in v0.2.0

type M2MAppCredentials struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

M2MAppCredentials is used for storing client_id and client_secret.

type Object

type Object string

Object represents available objects in API to perform operations.

const (
	ObjectSLO          Object = "SLO"
	ObjectService      Object = "Service"
	ObjectAgent        Object = "Agent"
	ObjectAlertPolicy  Object = "AlertPolicy"
	ObjectAlertSilence Object = "AlertSilence"
	// ObjectAlert represents object used only to return list of Alerts. Applying and deleting alerts is disabled.
	ObjectAlert Object = "Alert"
	// ObjectProject represents object used only to return list of Projects.
	// Applying and deleting projects is not supported.
	ObjectProject     Object = "Project"
	ObjectAlertMethod Object = "AlertMethod"
	// ObjectMetricSource represents ephemeral object used only to return concatenated list of Agents and Directs.
	ObjectMetricSource         Object = "MetricSource"
	ObjectDirect               Object = "Direct"
	ObjectDataExport           Object = "DataExport"
	ObjectUsageSummary         Object = "UsageSummary"
	ObjectRoleBinding          Object = "RoleBinding"
	ObjectSLOErrorBudgetStatus Object = "SLOErrorBudgetStatus"
	ObjectAnnotation           Object = "Annotation"
)

List of available objects in API.

func ObjectName

func ObjectName(apiObject string) Object

func (Object) String

func (o Object) String() string

type Operation

type Operation int

Operation is an enum that represents an operation that can be done over an object kind.

const (
	Get Operation = iota + 1
	TimeSeries
	Reports
)

Possible values of Operation.

func ParseOperation

func ParseOperation(val string) (Operation, error)

ParseOperation return Operation matching given string.

func (Operation) String

func (operation Operation) String() string

Directories

Path Synopsis
Package credentials provides utilities for working with customer identity credentials and the credentials file.
Package credentials provides utilities for working with customer identity credentials and the credentials file.
Package ts provides basic types work with time series in SDK
Package ts provides basic types work with time series in SDK

Jump to

Keyboard shortcuts

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