client

package
v6.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MustDefaultErrHandler = func(err error) {
	die.Die(fmt.Errorf("failed getting client: %w", err).Error())
}

Functions

func TestCreds added in v6.7.0

func TestCreds(user, pass, token string) error

Types

type Client

type Client struct {
	CloudClient        *cloudv6.APIClient
	AuthClient         *sdkgoauth.APIClient
	CertManagerClient  *certmanager.APIClient
	PostgresClient     *postgres.APIClient
	MongoClient        *mongo.APIClient
	DataplatformClient *dataplatform.APIClient
	RegistryClient     *registry.APIClient
	DnsClient          *dns.APIClient
	// contains filtered or unexported fields
}

func Get

func Get() (*Client, error)

Get a client and possibly fail. Uses viper to get the credentials and API URL. The returned client is guaranteed to have working credentials Order: Explicit flags ( e.g. --token ) Environment Variables ( e.g. IONOS_TOKEN ) Config File ( e.g. userdata.token )

func Must

func Must(ehs ...func(error)) *Client

Must gets the client obj or fatally dies You can provide some optional custom error handlers as params. The err is sent to each error handler in order. The default error handler is die.Die which exits with code 1 and violently terminates the program

func NewClient added in v6.7.0

func NewClient(name, pwd, token, hostUrl string) *Client

NewClient bypasses the singleton check, not recommended for normal use.

func NewClientFromCfgData added in v6.7.0

func NewClientFromCfgData(values map[string]string) *Client

func (*Client) IsTokenAuth added in v6.7.0

func (c *Client) IsTokenAuth() bool

IsTokenAuth returns true if a token is being used for authentication. Otherwise, username & password were used.

func (*Client) TestCreds added in v6.7.0

func (c *Client) TestCreds() error

func (*Client) UsedLayer added in v6.7.0

func (c *Client) UsedLayer() *Layer

type Layer added in v6.7.0

type Layer struct {
	TokenKey    string
	UsernameKey string
	PasswordKey string
	Description string // You can optionally pass a string to describe to the user what this layer is and how to set its values
}

Layer represents an authentication layer. E.g., flags, env vars, config file. A client can use one of these layers to authenticate against CloudAPI, each layer has priority over layers that are defined after it. the Token has priority over username & password pairs of the same authentication layer.

Jump to

Keyboard shortcuts

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