utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package utils provides utility functions for the provider and resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHTTPStatusCode

func AddHTTPStatusCode(props map[string]any, httpResponse *http.Response) map[string]any

If httpResponse is not nil, add the status code to the properties map.

func Float32PtrToIntString

func Float32PtrToIntString(f *float32) string

Some of the ids are returned as numbers, and our SDK client represents them as float32, but we need them as strings.

func GetStringListValue

func GetStringListValue(ctx context.Context, list types.List, diags *diag.Diagnostics) []string

Converts a TF list of strings into Go list of strings.

func IsEmptyList

func IsEmptyList(value types.List) bool

Returns true if the list value is null, unknown, or empty.

func IsEmptyMap

func IsEmptyMap(value types.Map) bool

Returns true if the map value is null, unknown, or empty.

func IsEmptyObject

func IsEmptyObject(value types.Object) bool

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

type ProviderData struct {
	Client            *api.APIClient
	RootFolderIDCache *map[string]string
}

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

func (*ThrottledTransport) RoundTrip added in v0.0.4

func (c *ThrottledTransport) RoundTrip(r *http.Request) (*http.Response, error)

Implements the RoundTripper interface.

Jump to

Keyboard shortcuts

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