gensupport

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0, BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponse

func DecodeResponse(target interface{}, res *http.Response) error

DecodeResponse decodes the body of res into target. If there is no body, target is unchanged.

func MarshalJSON

func MarshalJSON(schema interface{}, forceSendFields, nullFields []string) ([]byte, error)

MarshalJSON returns a JSON encoding of schema containing only selected fields. A field is selected if any of the following is true:

  • it has a non-empty value
  • its field name is present in forceSendFields and it is not a nil pointer or nil interface
  • its field name is present in nullFields.

The JSON key for each selected field is taken from the field's json: struct tag.

func SendRequest

func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)

SendRequest sends a single HTTP request using the given client. If ctx is non-nil, it calls all hooks, then sends the request with req.WithContext, then calls any functions returned by the hooks in reverse order.

func SendRequestWithRetry

func SendRequestWithRetry(ctx context.Context, client *http.Client, req *http.Request, retry *RetryConfig) (*http.Response, error)

SendRequestWithRetry sends a single HTTP request using the given client, with retries if a retryable error is returned. If ctx is non-nil, it calls all hooks, then sends the request with req.WithContext, then calls any functions returned by the hooks in reverse order.

func SetOptions

func SetOptions(u URLParams, opts ...googleapi.CallOption)

SetOptions sets the URL params and any additional `CallOption` or `MultiCallOption` passed in.

func WrapError

func WrapError(err error) error

WrapError creates an apierror.APIError from err, wraps it in err, and returns err. If err is not a googleapi.Error (or a google.golang.org/grpc/status.Status), it returns err without modification.

Types

type Backoff

type Backoff interface {
	Pause() time.Duration
}

Backoff is an interface around gax.Backoff's Pause method, allowing tests to provide their own implementation.

type RetryConfig

type RetryConfig struct {
	Backoff     *gax.Backoff
	ShouldRetry func(err error) bool
}

RetryConfig allows configuration of backoff timing and retryable errors.

type URLParams

type URLParams map[string][]string

URLParams is a simplified replacement for url.Values that safely builds up URL parameters for encoding.

func (URLParams) Encode

func (u URLParams) Encode() string

Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") sorted by key.

func (URLParams) Get

func (u URLParams) Get(key string) string

Get returns the first value for the given key, or "".

func (URLParams) Set

func (u URLParams) Set(key, value string)

Set sets the key to value. It replaces any existing values.

func (URLParams) SetMulti

func (u URLParams) SetMulti(key string, values []string)

SetMulti sets the key to an array of values. It replaces any existing values. Note that values must not be modified after calling SetMulti so the caller is responsible for making a copy if necessary.

Jump to

Keyboard shortcuts

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