client

package
v0.15.12 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromConfig

func FromConfig(ctx context.Context, cfg *cliconfig.Config, opts ...func(co *ClientOpts)) (*types.ClientWithResponses, error)

FromConfig creates a new client from a Common Fate CLI config. The client loads the OAuth2.0 tokens from the system keychain. The client automatically refreshes the access token if it is expired.

func New

func New(ctx context.Context, server, context string, oauthConfig *oauth2.Config, opts ...func(co *ClientOpts)) (*types.ClientWithResponses, error)

New creates a new client, specifying the URL and context directly. The client loads the OAuth2.0 tokens from the system keychain. The client automatically refreshes the access token if it is expired.

func WithAPIURL

func WithAPIURL(url string) func(co *ClientOpts)

WithAPIURL overrides the API URL. If the url is empty, it is not overriden and the regular API URL from aws-exports.json is used instead.

This can be used for local development to provider a localhost URL.

func WithKeyring

func WithKeyring(k keyring.Keyring) func(co *ClientOpts)

WithKeyring configures the client to use a custom keyring, rather than the default one configured using 'COMMONFATE_' environment variables

func WithLoginHint

func WithLoginHint(hint string) func(co *ClientOpts)

Types

type Client

type Client = types.ClientWithResponses

Client is an alias for the exported Go SDK client type

type ClientOpts

type ClientOpts struct {
	// LoginHint is the login command which will be shown to the user if there are any auth errors.
	LoginHint string
	Keyring   keyring.Keyring
	APIURL    string
}

type ErrorHandlingClient

type ErrorHandlingClient struct {
	Client    *http.Client
	LoginHint string
}

ErrorHandlingClient checks the response status code and creates an error if the API returns greater than 300.

func (*ErrorHandlingClient) Do

Jump to

Keyboard shortcuts

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