clients

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Known error messages
	ClientTimeoutErr           = "Client.Timeout exceeded while awaiting headers"
	ClientContextDeadlineErr   = "context deadline exceeded"
	ClientConnectionRefusedErr = "connection refused"
	ClientEOFError             = "unexpected EOF"
)
View Source
const (
	DefaultClientTimeout         = time.Minute
	DefaultRetryMaxRetries       = 3
	DefaultRetryWaitBetweenCalls = 30 * time.Second
	DefaultRetryTimeout          = 2 * time.Minute
	DefaultTraceparent           = false
)
View Source
const (
	// Key Flow optional env variable (1)
	ServiceAccountKey = "STACKIT_SERVICE_ACCOUNT_KEY"
	PrivateKey        = "STACKIT_PRIVATE_KEY"

	// Key Flow optional env variable (2) using file paths
	ServiceAccountKeyPath = "STACKIT_SERVICE_ACCOUNT_KEY_PATH"
	PrivateKeyPath        = "STACKIT_PRIVATE_KEY_PATH"
)
View Source
const (
	// Service Account Token Flow
	// Auth flow env variables
	ServiceAccountEmail = "STACKIT_SERVICE_ACCOUNT_EMAIL"
	ServiceAccountToken = "STACKIT_SERVICE_ACCOUNT_TOKEN"
)
View Source
const (
	PrivateKeyBlockType = "PRIVATE KEY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyFlow

type KeyFlow struct {
	// contains filtered or unexported fields
}

KeyFlow handles auth with SA key

func (*KeyFlow) Clone

func (c *KeyFlow) Clone() interface{}

Clone creates a clone of the client

func (*KeyFlow) Do

func (c *KeyFlow) Do(req *http.Request) (*http.Response, error)

Do performs the reuqest

func (*KeyFlow) GetAccessToken

func (c *KeyFlow) GetAccessToken() (string, error)

GetAccessToken returns short-lived access token

func (*KeyFlow) GetConfig

func (c *KeyFlow) GetConfig() KeyFlowConfig

GetConfig returns the flow configuration

func (*KeyFlow) GetServiceAccountEmail

func (c *KeyFlow) GetServiceAccountEmail() string

GetServiceAccountEmail returns the service account email

func (*KeyFlow) Init

func (c *KeyFlow) Init(ctx context.Context, cfg ...KeyFlowConfig) error

Init intializes the flow

type KeyFlowConfig

type KeyFlowConfig struct {
	ServiceAccountKeyPath string
	PrivateKeyPath        string
	ServiceAccountKey     []byte
	PrivateKey            []byte
	ClientRetry           *RetryConfig
	EnableTraceparent     bool
}

KeyFlowConfig is the flow config

type RetryConfig

type RetryConfig struct {
	MaxRetries       int           // Max retries
	WaitBetweenCalls time.Duration // Time to wait between requests
	RetryTimeout     time.Duration // Max time to re-try
	ClientTimeout    time.Duration // HTTP Client timeout
	Traceparent      *bool         // Add traceparent header?
}

func NewRetryConfig

func NewRetryConfig() *RetryConfig

type ServiceAccountKeyPrivateResponse

type ServiceAccountKeyPrivateResponse struct {
	Active      bool      `json:"active"`
	CreatedAt   time.Time `json:"createdAt"`
	Credentials struct {
		Aud        string    `json:"aud"`
		Iss        string    `json:"iss"`
		Kid        string    `json:"kid"`
		PrivateKey *string   `json:"privateKey,omitempty"`
		Sub        uuid.UUID `json:"sub"`
	} `json:"credentials"`
	ID           uuid.UUID  `json:"id"`
	KeyAlgorithm string     `json:"keyAlgorithm"`
	KeyOrigin    string     `json:"keyOrigin"`
	KeyType      string     `json:"keyType"`
	PublicKey    string     `json:"publicKey"`
	ValidUntil   *time.Time `json:"validUntil,omitempty"`
}

ServiceAccountKeyPrivateResponse is the API response when creating a new SA key

type TokenFlow

type TokenFlow struct {
	// contains filtered or unexported fields
}

TokenFlow handles auth with SA static token

func (*TokenFlow) Clone

func (c *TokenFlow) Clone() interface{}

Clone creates a clone of the client

func (*TokenFlow) Do

func (c *TokenFlow) Do(req *http.Request) (*http.Response, error)

Do performs the request

func (*TokenFlow) GetConfig

func (c *TokenFlow) GetConfig() TokenFlowConfig

GetConfig returns the flow configuration

func (*TokenFlow) GetServiceAccountEmail

func (c *TokenFlow) GetServiceAccountEmail() string

GetServiceAccountEmail returns the service account email

func (*TokenFlow) Init

func (c *TokenFlow) Init(ctx context.Context, cfg ...TokenFlowConfig) error

type TokenFlowConfig

type TokenFlowConfig struct {
	ServiceAccountEmail string
	ServiceAccountToken string
	ClientRetry         *RetryConfig
	EnableTraceparent   bool
}

TokenFlowConfig is the flow config

type TokenResponseBody

type TokenResponseBody struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	TokenType    string `json:"token_type"`
}

TokenResponseBody is the API response when requesting a new token

Jump to

Keyboard shortcuts

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