redskyapi

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultUserAgent string

Functions

func ConfigureOAuth2

func ConfigureOAuth2(cfg *Config, ctx context.Context, transport http.RoundTripper) (http.RoundTripper, error)

ConfigureOAuth2 checks the supplied to configuration to see if the (possibly nil) transport needs to be wrapped to perform authentication. The context is used for token management if necessary.

func GetAddress

func GetAddress(cfg *Config) (*url.URL, error)

GetAddress returns the URL representation of the address configuration parameter

Types

type Client

type Client interface {
	URL(endpoint string) *url.URL
	Do(context.Context, *http.Request) (*http.Response, []byte, error)
}

func NewClient

func NewClient(cfg *Config, ctx context.Context, transport http.RoundTripper) (Client, error)

type Config

type Config struct {
	// Filename is the full path to the configuration file (defaults to ~/.redsky)
	Filename string `json:"-"`
	// Address is the fully qualified URL of the Red Sky API
	Address string `json:"address,omitempty"`
	// OAuth2 is the authentication configuration for the Red Sky API
	OAuth2 OAuth2 `json:"oauth2,omitempty"`
	// Manager is additional configuration for the Red Sky Manager program
	Manager Manager `json:"manager,omitempty"`
}

Config is the client configuration information

func DefaultConfig

func DefaultConfig() (*Config, error)

DefaultConfig creates a new configuration

func (*Config) Complete

func (c *Config) Complete() error

Complete fills in default values and normalizes values

func (*Config) LoadEnv

func (c *Config) LoadEnv()

LoadEnv overwrites values in the configuration using environment variables

func (*Config) Read

func (c *Config) Read() error

Read unmashals the configuration from disk using the filename field

func (*Config) Set

func (c *Config) Set(key, value string) error

Set attempts to set a configuration value using a JSON Path expression

func (*Config) Write

func (c *Config) Write() error

Write marshals the configuration to disk using the filename field

type Manager

type Manager struct {
	// Environment is list of additional environment variables to expose to the manager
	Environment []ManagerEnvVar `json:"env,omitempty"`
}

Manager is additional configuration for the Red Sky Manager program

type ManagerEnvVar

type ManagerEnvVar struct {
	// Name is the case-sensitive name of the environment variable
	Name string `json:"name"`
	// Value is the environment variable value
	Value string `json:"value"`
}

ManagerEnvVar is a single environment variable to expose to the manager

type OAuth2

type OAuth2 struct {
	// ClientID is used to authenticate for a client credentials grant
	ClientID string `json:"client_id,omitempty"`
	// ClientSecret is used to authenticate for a client credentials grant
	ClientSecret string `json:"client_secret,omitempty"`
	// TokenURL is used to obtain an access token (defaults to `./auth/token/` relative to the server address)
	TokenURL string `json:"token_url,omitempty"`

	// Token is the static access token to use instead of the client credential grant
	Token string `json:"token,omitempty"`
}

OAuth2 is the authentication configuration for the Red Sky API

Directories

Path Synopsis
redsky

Jump to

Keyboard shortcuts

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