client

package
v6.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

all possible sources in priority order

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

Functions

func EnforceClient added in v6.7.2

func EnforceClient(user, pass, token, hostUrl string)

EnforceClient sets the global client instance to a new client with the given credentials ( use only for testing/special cases)

func TestCreds added in v6.7.0

func TestCreds(user, pass, token string) error

Types

type AuthSource added in v6.9.0

type AuthSource string

AuthSource represents a human-readable description of where the client's authentication credentials were sourced from.

const (
	AuthSourceEnvBearer AuthSource = "environment variable: IONOS_TOKEN"
	AuthSourceEnvBasic  AuthSource = "environment variables: IONOS_USERNAME, IONOS_PASSWORD"
	AuthSourceCfgBearer AuthSource = "credentials from config file: token"
	AuthSourceCfgBasic  AuthSource = "credentials from config file: username, password"
	AuthSourceNone      AuthSource = "no authentication provided"
)

type Client

type Client struct {
	Config      *fileconfiguration.FileConfig
	ConfigPath  string // Path to the config file used to create this client, if any.
	AuthSource  AuthSource
	URLOverride string // If the client was created with a specific URL override, this will hold that value. If we notice a change in the URL, we need to re-create the client.

	Apigateway           *apigateway.APIClient
	CloudClient          *cloudv6.APIClient
	AuthClient           *auth.APIClient
	CertManagerClient    *cert.APIClient
	RegistryClient       *containerregistry.APIClient
	DnsClient            *dns.APIClient
	LoggingServiceClient *logging.APIClient
	VMAscClient          *vmasc.AutoScalingGroupsApiService
	VPNClient            *vpn.APIClient
	CDNClient            *cdn.APIClient
	Kafka                *kafka.APIClient
	Monitoring           *monitoring.APIClient

	PostgresClient   *psql.APIClient
	MongoClient      *mongo.APIClient
	MariaClient      *mariadb.APIClient
	InMemoryDBClient *inmemorydb.APIClient
}

func Get

func Get() (*Client, error)

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 creates a new client with the given credentials. It is used for testing purposes or when you want to create a client with specific credentials. It is highly recommended to use the Get() or Must() functions instead, as they handle the configuration file and environment variables automatically.

func (*Client) TestCreds added in v6.7.0

func (c *Client) TestCreds() error

type ConfigSource added in v6.9.1

type ConfigSource struct {
	Config *fileconfiguration.FileConfig
	Path   string
}

ConfigSource holds a loaded FileConfig (or nil) plus the path it came from.

Jump to

Keyboard shortcuts

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