Documentation ¶
Index ¶
- Constants
- type KeyFlow
- func (c *KeyFlow) Clone() interface{}
- func (c *KeyFlow) Do(req *http.Request) (*http.Response, error)
- func (c *KeyFlow) GetAccessToken() (string, error)
- func (c *KeyFlow) GetConfig() KeyFlowConfig
- func (c *KeyFlow) GetEnvironment() env.Environment
- func (c *KeyFlow) GetServiceAccountEmail() string
- func (c *KeyFlow) GetTraceparent() *traceparent.Traceparent
- func (c *KeyFlow) Init(ctx context.Context, cfg ...KeyFlowConfig) error
- type KeyFlowConfig
- type RetryConfig
- type ServiceAccountKeyPrivateResponse
- type TokenFlow
- func (c *TokenFlow) Clone() interface{}
- func (c *TokenFlow) Do(req *http.Request) (*http.Response, error)
- func (c *TokenFlow) GetConfig() TokenFlowConfig
- func (c *TokenFlow) GetEnvironment() env.Environment
- func (c *TokenFlow) GetServiceAccountEmail() string
- func (c *TokenFlow) GetTraceparent() *traceparent.Traceparent
- func (c *TokenFlow) Init(ctx context.Context, cfg ...TokenFlowConfig) error
- 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 ( // 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" )
const ( // Service Account Token Flow // Auth flow env variables ServiceAccountEmail = "STACKIT_SERVICE_ACCOUNT_EMAIL" ServiceAccountToken = "STACKIT_SERVICE_ACCOUNT_TOKEN" )
const (
// API configuration options:
Environment = "STACKIT_ENV"
)
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) GetAccessToken ¶
GetAccessToken returns short-lived access token
func (*KeyFlow) GetConfig ¶
func (c *KeyFlow) GetConfig() KeyFlowConfig
GetConfig returns the flow configuration
func (*KeyFlow) GetEnvironment ¶
func (c *KeyFlow) GetEnvironment() env.Environment
GetEnvironment returns the defined API environment
func (*KeyFlow) GetServiceAccountEmail ¶
GetServiceAccountEmail returns the service account email
func (*KeyFlow) GetTraceparent ¶ added in v1.22.0
func (c *KeyFlow) GetTraceparent() *traceparent.Traceparent
GetTraceparent returns the defined Traceparent
type KeyFlowConfig ¶
type KeyFlowConfig struct { ServiceAccountKeyPath string PrivateKeyPath string ServiceAccountKey []byte PrivateKey []byte Environment env.Environment ClientRetry *RetryConfig Traceparent *traceparent.Traceparent }
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 }
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) GetConfig ¶
func (c *TokenFlow) GetConfig() TokenFlowConfig
GetConfig returns the flow configuration
func (*TokenFlow) GetEnvironment ¶
func (c *TokenFlow) GetEnvironment() env.Environment
GetEnvironment returns the defined API environment
func (*TokenFlow) GetServiceAccountEmail ¶
GetServiceAccountEmail returns the service account email
func (*TokenFlow) GetTraceparent ¶ added in v1.22.0
func (c *TokenFlow) GetTraceparent() *traceparent.Traceparent
GetTraceparent returns the defined Traceparent
type TokenFlowConfig ¶
type TokenFlowConfig struct { ServiceAccountEmail string ServiceAccountToken string Environment env.Environment ClientRetry *RetryConfig Traceparent *traceparent.Traceparent }
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