client

package
v0.0.0-...-6e126a9 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthenticationFailed = errors.New("could not retrieve an OAuth token from the API")
View Source
var ErrRequestFailed = errors.New("the API returned a response with a status outside of the 2xx range")

Functions

func NewAPIClient

func NewAPIClient(config apiConfig, options ...APIClientOption) *apiClient

NewAPIClient creates and returns a new APIClient

func NewAPIConfig

func NewAPIConfig(serverURL, token string, opts ...APIConfigOption) (*apiConfig, error)

NewAPIConfig returns a new apiConfig that can be used for initializing a DTAPIClient with the NewAPIClient function

Types

type APIClientOption

type APIClientOption func(client *apiClient)

func WithHTTPClient

func WithHTTPClient(httpClient http.Client) APIClientOption

WithHTTPClient injects the given HTTP client into an APIClient

func WithLogger

func WithLogger(logger logr.Logger) APIClientOption

WithLogger injects the given logger into an APIClient

type APIConfigOption

type APIConfigOption func(config *apiConfig)

func WithAuthURL

func WithAuthURL(authURL string) APIConfigOption

func WithScopes

func WithScopes(scopes []OAuthScope) APIConfigOption

WithScopes passes the given scopes to the client config

type DTAPIClient

type DTAPIClient interface {
	Do(ctx context.Context, path, method string, payload []byte) ([]byte, int, error)
}

type OAuthResponse

type OAuthResponse struct {
	AccessToken string `json:"access_token"`
}

type OAuthScope

type OAuthScope string

OAuthScope represents a scope provided for the registered OAuth client interacting with the DT API

const (
	OAuthScopeStorageMetricsRead    OAuthScope = "storage:metrics:read"
	OAuthScopeEnvironmentRoleViewer OAuthScope = "environment:roles:viewer"
)

These constants define the scopes that we currently need for the DQL metric functionality. This list might extend as new features will be added. For now, we keep this at the minimum set of scopes required, as these are currently likely to change

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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