Documentation
¶
Overview ¶
This package is a fork from the Community STACKIT Go Client
See: https://github.com/SchwarzIT/community-stackit-go-client
Index ¶
- Constants
- func Do(client *http.Client, req *http.Request, cfg *RetryConfig) (resp *http.Response, err error)
- type KeyFlow
- func (c *KeyFlow) GetAccessToken() (string, error)
- func (c *KeyFlow) GetConfig() KeyFlowConfig
- func (c *KeyFlow) GetServiceAccountEmail() string
- func (c *KeyFlow) GetToken() TokenResponseBody
- func (c *KeyFlow) Init(cfg *KeyFlowConfig) error
- func (c *KeyFlow) RoundTrip(req *http.Request) (*http.Response, error)
- func (c *KeyFlow) SetToken(accessToken, refreshToken string) error
- type KeyFlowConfig
- type NoAuthFlow
- type NoAuthFlowConfig
- type RetryConfig
- type ServiceAccountKeyCredentials
- type ServiceAccountKeyResponse
- type TokenFlow
- type TokenFlowConfig
- type TokenResponseBody
Constants ¶
const ( // Known error messages ClientTimeoutErr = "Client.Timeout exceeded while awaiting headers" ClientContextDeadlineErr = "context deadline exceeded" ClientConnectionRefusedErr = "connection refused" ClientEOFError = "unexpected EOF" )
const ( DefaultClientTimeout = time.Minute DefaultRetryMaxRetries = 3 DefaultRetryWaitBetweenCalls = 30 * time.Second DefaultRetryTimeout = 2 * time.Minute )
const ( // Service Account Key Flow // Auth flow env variables ServiceAccountKey = "STACKIT_SERVICE_ACCOUNT_KEY" PrivateKey = "STACKIT_PRIVATE_KEY" ServiceAccountKeyPath = "STACKIT_SERVICE_ACCOUNT_KEY_PATH" PrivateKeyPath = "STACKIT_PRIVATE_KEY_PATH" )
const (
// API configuration options:
Environment = "STACKIT_ENV"
)
const ( // Service Account Token Flow // Auth flow env variables ServiceAccountToken = "STACKIT_SERVICE_ACCOUNT_TOKEN" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KeyFlow ¶
type KeyFlow struct {
// contains filtered or unexported fields
}
KeyFlow handles auth with SA key
func (*KeyFlow) GetAccessToken ¶
GetAccessToken returns a short-lived access token and saves the access and refresh tokens in the token field
func (*KeyFlow) GetConfig ¶
func (c *KeyFlow) GetConfig() KeyFlowConfig
GetConfig returns the flow configuration
func (*KeyFlow) GetServiceAccountEmail ¶
GetServiceAccountEmail returns the service account email
func (*KeyFlow) GetToken ¶
func (c *KeyFlow) GetToken() TokenResponseBody
GetToken returns the token field
func (*KeyFlow) Init ¶
func (c *KeyFlow) Init(cfg *KeyFlowConfig) error
type KeyFlowConfig ¶
type KeyFlowConfig struct { ServiceAccountKey *ServiceAccountKeyResponse PrivateKey string ClientRetry *RetryConfig TokenUrl string }
KeyFlowConfig is the flow config
type NoAuthFlow ¶
type NoAuthFlow struct {
// contains filtered or unexported fields
}
func (*NoAuthFlow) Clone ¶
func (c *NoAuthFlow) Clone() interface{}
Clone creates a clone of the client
func (*NoAuthFlow) GetConfig ¶
func (c *NoAuthFlow) GetConfig() NoAuthFlowConfig
GetConfig returns the flow configuration
func (*NoAuthFlow) Init ¶
func (c *NoAuthFlow) Init(cfg NoAuthFlowConfig) error
type NoAuthFlowConfig ¶
type NoAuthFlowConfig struct {
ClientRetry *RetryConfig
}
NoAuthFlowConfig holds the configuration for the unauthenticated flow
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 }
func NewRetryConfig ¶
func NewRetryConfig() *RetryConfig
type ServiceAccountKeyResponse ¶
type ServiceAccountKeyResponse struct { Active bool `json:"active"` CreatedAt time.Time `json:"createdAt"` Credentials *ServiceAccountKeyCredentials `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"` }
ServiceAccountKeyResponse 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) GetConfig ¶
func (c *TokenFlow) GetConfig() TokenFlowConfig
GetConfig returns the flow configuration
func (*TokenFlow) Init ¶
func (c *TokenFlow) Init(cfg *TokenFlowConfig) error
type TokenFlowConfig ¶
type TokenFlowConfig struct { ServiceAccountEmail string ServiceAccountToken string ClientRetry *RetryConfig }
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