client

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the current version of the SDK.

Types

type AuthTokenProvider

type AuthTokenProvider interface {
	// GetAccessToken returns an access token or an error.
	// If there is no current access token then the provider will attempt to refresh
	// and get a new access token.
	// An error is returned if there is no access token and the refresh operation fails
	GetAccessToken(ctx context.Context) (string, error)
	// RefreshAccessToken refreshes the current access token.
	// If there is already an existing access token that token will be returned unless
	// force=true is passed.
	// If the refresh network operation fails then an error will be returned
	// On successful refresh the internal state of the provider will be updated with the new token
	// and successive calls to GetAccessToken() will return the new token.
	RefreshAccessToken(ctx context.Context, force bool) (string, error)
}

AuthTokenProvider is the interface which must be passed into the WithAuthToken{Unary,Stream}Interceptor so that it can authenticate outgoing requests. This is a thread-safe interface.

type Options

type Options struct {
	// ClientID is your Stately Client ID. If not set, this is loaded from the
	// STATELY_CLIENT_ID environment variable when using the default
	// AuthTokenProvider.
	ClientID string
	// ClientSecret is your Stately Client ID. If not set, this is loaded from the
	// STATELY_CLIENT_SECRET environment variable when using the default
	// AuthTokenProvider.
	ClientSecret string

	// AuthTokenProvider handles fetching auth tokens for requests. It is
	// defaulted to an appropriate implementation for most services.
	AuthTokenProvider

	// Endpoint is the Stately API endpoint.
	// Defaults to https://api.stately.cloud
	Endpoint string
}

Options is a set of common options for a stately API client.

func (*Options) ApplyDefaults

func (o *Options) ApplyDefaults(appCtx context.Context) (*Options, error)

ApplyDefaults applies the default values to the options.

func (*Options) HTTPClient

func (o *Options) HTTPClient() *http.Client

HTTPClient builds an HTTP/2 client for the given options.

func (*Options) Merge

func (o *Options) Merge(o2 *Options) *Options

Merge merges non-default settings from o2 into o.

type OrganizationID

type OrganizationID uint64

OrganizationID is a globally-unique identifier for an organization.

type ProjectID

type ProjectID uint64

ProjectID is a globally-unique identifier for a project.

type StoreID

type StoreID uint64

StoreID is a globally-unique identifier for a store.

type UserID

type UserID uint64

UserID is a globally-unique identifier for a Stately user.

Jump to

Keyboard shortcuts

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