googleclient

package
v0.0.0-...-4511d6e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FINGERPRINT_FAIL_ERRORS = []string{"Invalid fingerprint.", "Supplied fingerprint does not match current metadata fingerprint."}

We've encountered a few common fingerprint-related strings; if this is one of them, we're confident this is an error due to fingerprints.

Functions

func ClientWithAdditionalRetries

func ClientWithAdditionalRetries(baseClient *http.Client, predicates ...RetryErrorPredicateFunc) *http.Client

ClientWithAdditionalRetries is a helper method to create a shallow copy of an HTTP client with a shallow-copied retryTransport s.t. the base HTTP transport is the same (i.e. client connection pools are shared, retryPredicates are different)

func NewTransportWithDefaultRetries

func NewTransportWithDefaultRetries(t http.RoundTripper) *retryTransport

NewTransportWithDefaultRetries constructs a default retryTransport that will retry common temporary errors

Types

type Config

type Config struct {
	Credentials                        string
	AccessToken                        string
	ImpersonateServiceAccount          string
	ImpersonateServiceAccountDelegates []string
	Scopes                             []string
	PulumiVersion                      string
	ProviderVersion                    string
	PartnerName                        string
	AppendUserAgent                    string
}

Config is a bag of authentication related options used to instantiate a GoogleClient

type GoogleClient

type GoogleClient struct {
	// contains filtered or unexported fields
}

GoogleClient is an appropriately initialized HTTP client used by the Google Native provider. The client checks if its credentials are valid and automatically refreshes if they have expired.

func New

func New(ctx context.Context, config Config) (*GoogleClient, error)

New returns a new GoogleClient with credentials based on the provided Config.

func (*GoogleClient) HTTPClient

func (c *GoogleClient) HTTPClient() *http.Client

HTTPClient returns an initialized HTTP client for Google Cloud.

func (*GoogleClient) OAuth2Token

func (c *GoogleClient) OAuth2Token() (*oauth2.Token, error)

OAuth2Token returns the active OAuth2 token used by the provider to communicate with Google Cloud.

func (*GoogleClient) RequestWithTimeout

func (c *GoogleClient) RequestWithTimeout(
	method, rawurl string,
	contentType string,
	body interface{},
	timeout time.Duration,
) (map[string]interface{}, error)

RequestWithTimeout performs the specified request using the specified HTTP method and with the specified timeout. TODO: This is taken from the TF provider (cut down to a minimal viable thing). We need to make it "good".

func (*GoogleClient) UploadWithTimeout

func (c *GoogleClient) UploadWithTimeout(
	method, rawurl string,
	metadata map[string]interface{},
	binary []byte,
	timeout time.Duration,
) (map[string]interface{}, error)

UploadWithTimeout performs a multi-part upload using the specified HTTP method, rawurl, etc. using the specified timeout.

type RetryErrorPredicateFunc

type RetryErrorPredicateFunc func(error) (bool, string)

Jump to

Keyboard shortcuts

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