Documentation ¶
Overview ¶
Package utils provides utility functions for the provider and resources.
Index ¶
- func AddHTTPStatusCode(props map[string]any, httpResponse *http.Response) map[string]any
- func Float32PtrToIntString(f *float32) string
- func GetStringListValue(ctx context.Context, list types.List, diags *diag.Diagnostics) []string
- func IsEmptyList(value types.List) bool
- func IsEmptyMap(value types.Map) bool
- func IsEmptyObject(value types.Object) bool
- func NewThrottledTransport(limitPeriod time.Duration, requestCount int, transportWrap http.RoundTripper) http.RoundTripper
- type ProviderData
- type ThrottledTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHTTPStatusCode ¶
If httpResponse is not nil, add the status code to the properties map.
func Float32PtrToIntString ¶
Some of the ids are returned as numbers, and our SDK client represents them as float32, but we need them as strings.
func GetStringListValue ¶
Converts a TF list of strings into Go list of strings.
func IsEmptyList ¶
Returns true if the list value is null, unknown, or empty.
func IsEmptyMap ¶
Returns true if the map value is null, unknown, or empty.
func IsEmptyObject ¶
Returns true if the object value is null or unknown.
func NewThrottledTransport ¶ added in v0.0.4
func NewThrottledTransport(limitPeriod time.Duration, requestCount int, transportWrap http.RoundTripper) http.RoundTripper
NewThrottledTransport wraps transportWrap with a rate limitter example usage: client := http.DefaultClient client.Transport = NewThrottledTransport(10*time.Seconds, 60, http.DefaultTransport) allows 60 requests every 10 seconds.
Types ¶
type ProviderData ¶
providerData is the data structure that is passed to the DataSource and Resource.
type ThrottledTransport ¶ added in v0.0.4
type ThrottledTransport struct {
// contains filtered or unexported fields
}
ThrottledTransport Rate Limited HTTP Client Copied as-is from https://gist.github.com/zdebra/10f0e284c4672e99f0cb767298f20c11