Documentation
¶
Index ¶
- func DefaultRetryCondition(resp *http.Response, err error) bool
- func WithContext(ctx context.Context, req *http.Request) *http.Request
- type Client
- func New(bearer string, organization string) *Client
- func NewWithBaseURL(bearer string, organization string, baseURL string) *Client
- func NewWithOptions(bearer string, organization string, opts *ClientOptions) *Client
- func NewWithRateLimit(bearer string, organization string, config *RateLimitConfig) *Client
- func NewWithRateLimitAndBaseURL(bearer string, organization string, config *RateLimitConfig, baseURL string) *Client
- type ClientOptions
- type RateLimitConfig
- type RateLimitedHTTPClient
- type RateLimitedRoundTripper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRetryCondition ¶
DefaultRetryCondition determines if a request should be retried
Types ¶
type Client ¶
type Client struct {
AuthContext context.Context
Bearer string
Organization string
Instance *openapi.APIClient
// RulesMutex serialises rule modifications across resources that operate on a shared backend file
RulesMutex *sync.Mutex
// contains filtered or unexported fields
}
func New ¶
Rather than the practioner providing an organization for all resources managed by the terraform instance we scope the data client to an organization with provider configuration.
func NewWithBaseURL ¶
NewWithBaseURL creates a new client with custom base URL
func NewWithOptions ¶
func NewWithOptions(bearer string, organization string, opts *ClientOptions) *Client
NewWithOptions creates a new client with custom options
func NewWithRateLimit ¶
func NewWithRateLimit(bearer string, organization string, config *RateLimitConfig) *Client
NewWithRateLimit creates a new client with custom rate limiting configuration
func NewWithRateLimitAndBaseURL ¶
func NewWithRateLimitAndBaseURL(bearer string, organization string, config *RateLimitConfig, baseURL string) *Client
NewWithRateLimitAndBaseURL creates a new client with both rate limiting and base URL configuration
func (*Client) GetRateLimitConfig ¶
func (c *Client) GetRateLimitConfig() *RateLimitConfig
GetRateLimitConfig returns the current rate limit configuration
func (*Client) UpdateRateLimitConfig ¶
func (c *Client) UpdateRateLimitConfig(config *RateLimitConfig)
UpdateRateLimitConfig updates the rate limit configuration Note: This requires creating a new HTTP client instance
type ClientOptions ¶
type ClientOptions struct {
RateLimitConfig *RateLimitConfig
HTTPClient *http.Client
BaseURL string
}
ClientOptions allows customization of the client
type RateLimitConfig ¶
type RateLimitConfig struct {
// Maximum number of requests per second
RequestsPerSecond float64
// Maximum number of retry attempts
MaxRetries int
// Base delay for exponential backoff (in milliseconds)
BaseDelay time.Duration
// Maximum delay for exponential backoff (in milliseconds)
MaxDelay time.Duration
// Whether to add jitter to delays
EnableJitter bool
// Custom retry condition function
RetryCondition func(*http.Response, error) bool
// Per-request timeout (optional, for fine-grained timeout control)
RequestTimeout time.Duration
// Retries allowed for the rules API's advisory 409 lock, counted separately
// from MaxRetries: the lock is expected contention, not a fault, and a
// project with many rules changing at once needs a longer wait.
MaxLockRetries int
// Minimum delay before re-sending after a rules lock 409
LockRetryDelay time.Duration
}
RateLimitConfig holds configuration for rate limiting
func DefaultRateLimitConfig ¶
func DefaultRateLimitConfig() *RateLimitConfig
DefaultRateLimitConfig returns sensible defaults for rate limiting
type RateLimitedHTTPClient ¶
RateLimitedHTTPClient wraps an HTTP client with rate limiting
func NewRateLimitedHTTPClient ¶
func NewRateLimitedHTTPClient(config *RateLimitConfig) *RateLimitedHTTPClient
NewRateLimitedHTTPClient creates a new HTTP client with rate limiting
func (*RateLimitedHTTPClient) Close ¶
func (c *RateLimitedHTTPClient) Close()
Close cleans up resources
type RateLimitedRoundTripper ¶
type RateLimitedRoundTripper struct {
// contains filtered or unexported fields
}
RateLimitedRoundTripper implements http.RoundTripper with rate limiting and retry logic
func NewRateLimitedRoundTripper ¶
func NewRateLimitedRoundTripper(transport http.RoundTripper, config *RateLimitConfig) *RateLimitedRoundTripper
NewRateLimitedRoundTripper creates a new rate-limited round tripper
func (*RateLimitedRoundTripper) Close ¶
func (rt *RateLimitedRoundTripper) Close()
Close cleans up the rate limiter resources