Documentation ¶
Overview ¶
Package sdk provide an abstraction for communication with API.
Index ¶
- Constants
- Variables
- func GetDefaultConfigPath() (string, error)
- type Client
- func (c *Client) ApplyObjects(ctx context.Context, objects []manifest.Object, dryRun bool) error
- func (c *Client) CreateRequest(ctx context.Context, method, endpoint, project string, q url.Values, ...) (*http.Request, error)
- func (c *Client) DeleteObjects(ctx context.Context, objects []manifest.Object, dryRun bool) error
- func (c *Client) DeleteObjectsByName(ctx context.Context, project string, kind manifest.Kind, dryRun bool, ...) error
- func (c *Client) GetAWSExternalID(ctx context.Context, project string) (string, error)
- func (c *Client) GetAgentCredentials(ctx context.Context, project, agentsName string) (creds M2MAppCredentials, err error)
- func (c *Client) GetObjects(ctx context.Context, project string, kind manifest.Kind, ...) ([]manifest.Object, error)
- func (c *Client) GetObjectsWithParams(ctx context.Context, project string, kind manifest.Kind, q url.Values) (response Response, err error)
- func (c *Client) GetOrganization(ctx context.Context) (string, error)
- func (c *Client) SetUserAgent(userAgent string)
- type Config
- type ConfigOption
- type ContextConfig
- type ContextlessConfig
- type FileConfig
- type M2MAppCredentials
- type Response
Constants ¶
const ( HeaderOrganization = "Organization" HeaderProject = "Project" HeaderAuthorization = "Authorization" HeaderUserAgent = "User-Agent" HeaderTruncatedLimitMax = "Truncated-Limit-Max" HeaderTraceID = "Trace-Id" )
HTTP headers keys used across app
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" QueryKeyAlertPolicy = "alert_policy" QueryKeyObjective = "objective" QueryKeyObjectiveValue = "objective_value" QueryKeyResolved = "resolved" QueryKeyTriggered = "triggered" )
HTTP GET query keys used across app
const DefaultProject = "default"
DefaultProject is a value of the default project.
const (
EnvPrefix = "NOBL9_SDK_"
)
const ProjectsWildcard = "*"
ProjectsWildcard is used in HeaderProject when requesting for all projects.
Variables ¶
var ErrConcurrencyIssue = errors.New("operation failed due to concurrency issue but can be retried")
Functions ¶
func GetDefaultConfigPath ¶ added in v0.30.0
GetDefaultConfigPath returns the default path to Nobl9 configuration file, config.toml.
Types ¶
type Client ¶
Client represents API high level client.
func DefaultClient ¶ added in v0.8.2
DefaultClient returns fully configured instance of Client with default Config and HTTP client.
func (*Client) ApplyObjects ¶
ApplyObjects applies (create or update) list of objects passed as argument via API.
func (*Client) CreateRequest ¶ added in v0.29.0
func (c *Client) CreateRequest( ctx context.Context, method, endpoint, project string, q url.Values, body io.Reader, ) (*http.Request, error)
CreateRequest creates a new http.Request pointing at the Nobl9 API URL. It also adds all the mandatory headers to the request and encodes query parameters.
func (*Client) DeleteObjects ¶
DeleteObjects deletes list of objects passed as argument via API.
func (*Client) DeleteObjectsByName ¶
func (c *Client) DeleteObjectsByName( ctx context.Context, project string, kind manifest.Kind, dryRun bool, names ...string, ) error
DeleteObjectsByName makes a call to endpoint for deleting objects with passed names and object types.
func (*Client) GetAWSExternalID ¶
func (*Client) GetAgentCredentials ¶ added in v0.2.0
func (c *Client) GetAgentCredentials( ctx context.Context, project, agentsName string, ) (creds M2MAppCredentials, err error)
GetAgentCredentials retrieves manifest.KindAgent credentials.
func (*Client) GetObjects ¶ added in v0.8.2
func (c *Client) GetObjects( ctx context.Context, project string, kind manifest.Kind, filterLabel map[string][]string, names ...string, ) ([]manifest.Object, error)
GetObjects returns array of supported type of Objects, when names are passed - query for these names otherwise returns list of all available objects.
func (*Client) GetObjectsWithParams ¶ added in v0.8.2
func (*Client) GetOrganization ¶ added in v0.30.0
GetOrganization returns the organization read from JWT token claims.
func (*Client) SetUserAgent ¶ added in v0.30.0
SetUserAgent will set HeaderUserAgent to the provided value.
type Config ¶ added in v0.30.0
type Config struct { ClientID string ClientSecret string AccessToken string Project string URL *url.URL OktaOrgURL *url.URL OktaAuthServer string DisableOkta bool Timeout time.Duration FilesPromptEnabled bool FilesPromptThreshold int // contains filtered or unexported fields }
Config combines the ContextlessConfig and ContextConfig of the current, selected context.
func ReadConfig ¶ added in v0.30.0
func ReadConfig(options ...ConfigOption) (*Config, error)
ReadConfig reads the configuration from either (with precedence from top to bottom): - provided ConfigOption - environment variables - config file - default values where applicable
Detailed flow can be found in config_activity.png (generated from config_activity.puml).
func (*Config) GetCurrentContext ¶ added in v0.30.0
func (*Config) GetFileConfig ¶ added in v0.30.0
func (c *Config) GetFileConfig() FileConfig
GetFileConfig returns a copy of FileConfig.
type ConfigOption ¶ added in v0.30.0
type ConfigOption func(conf *Config)
ConfigOption conveys extra configuration details for ReadConfig function.
func ConfigOptionEnvPrefix ¶ added in v0.30.0
func ConfigOptionEnvPrefix(prefix string) ConfigOption
ConfigOptionEnvPrefix instructs Config to lookup environment variables with the provided prefix. Example:
ConfigOptionEnvPrefix("SLOCTL_") --> looks up SLOCTL_CLIENT_ID env and assigns it to Config.ClientID
func ConfigOptionFilePath ¶ added in v0.30.0
func ConfigOptionFilePath(path string) ConfigOption
ConfigOptionFilePath instructs Config to load config file from the provided path. It has no effect if ConfigOptionNoConfigFile is provided.
func ConfigOptionNoConfigFile ¶ added in v0.30.0
func ConfigOptionNoConfigFile() ConfigOption
ConfigOptionNoConfigFile instructs Config to not try reading config.toml file at all.
func ConfigOptionUseContext ¶ added in v0.30.0
func ConfigOptionUseContext(context string) ConfigOption
ConfigOptionUseContext instructs Config to use the provided context name. It has no effect if ConfigOptionNoConfigFile is provided.
func ConfigOptionWithCredentials ¶ added in v0.30.0
func ConfigOptionWithCredentials(clientID, clientSecret string) ConfigOption
ConfigOptionWithCredentials creates a minimal configuration using provided client id and secret.
type ContextConfig ¶ added in v0.30.0
type ContextConfig struct { ClientID string `toml:"clientId" env:"CLIENT_ID"` ClientSecret string `toml:"clientSecret" env:"CLIENT_SECRET"` AccessToken string `toml:"accessToken,omitempty" env:"ACCESS_TOKEN"` Project string `toml:"project,omitempty" env:"PROJECT"` URL string `toml:"url,omitempty" env:"URL"` OktaOrgURL string `toml:"oktaOrgURL,omitempty" env:"OKTA_ORG_URL"` OktaAuthServer string `toml:"oktaAuthServer,omitempty" env:"OKTA_AUTH_SERVER"` DisableOkta *bool `toml:"disableOkta,omitempty" env:"DISABLE_OKTA"` Timeout *time.Duration `toml:"timeout,omitempty" env:"TIMEOUT"` }
ContextConfig stores context specific config.
type ContextlessConfig ¶ added in v0.30.0
type ContextlessConfig struct { DefaultContext string `toml:"defaultContext" env:"DEFAULT_CONTEXT"` // Sloctl exclusive. FilesPromptEnabled *bool `toml:"filesPromptEnabled" env:"FILES_PROMPT_ENABLED"` FilesPromptThreshold *int `toml:"filesPromptThreshold" env:"FILES_PROMPT_THRESHOLD"` }
ContextlessConfig stores config not tied to any specific context.
type FileConfig ¶ added in v0.30.0
type FileConfig struct { ContextlessConfig `toml:",inline"` Contexts map[string]ContextConfig `toml:"contexts"` // contains filtered or unexported fields }
FileConfig contains fully parsed config file.
func (*FileConfig) GetPath ¶ added in v0.30.0
func (f *FileConfig) GetPath() string
GetPath retrieves the file path FileConfig was loaded from.
func (*FileConfig) Load ¶ added in v0.30.0
func (f *FileConfig) Load(path string) error
Load reads the config file from the provided path. If the file does not exist, it will create a default configuration file.
func (*FileConfig) Save ¶ added in v0.30.0
func (f *FileConfig) Save(path string) (err error)
Save saves FileConfig into provided path, encoding it in TOML format.
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package definitions provides functions for reading, parsing and converting object's definitions.
|
Package definitions provides functions for reading, parsing and converting object's definitions. |
Package retryhttp configures retryablehttp.Client with sane defaults and defines its retry policy.
|
Package retryhttp configures retryablehttp.Client with sane defaults and defines its retry policy. |