Documentation ¶
Index ¶
- func DecodeResponse(target interface{}, res *http.Response) error
- func MarshalJSON(schema interface{}, forceSendFields, nullFields []string) ([]byte, error)
- func SendRequest(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
- func SendRequestWithRetry(ctx context.Context, client *http.Client, req *http.Request, ...) (*http.Response, error)
- func SetOptions(u URLParams, opts ...googleapi.CallOption)
- func WrapError(err error) error
- type Backoff
- type RetryConfig
- type URLParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeResponse ¶
DecodeResponse decodes the body of res into target. If there is no body, target is unchanged.
func MarshalJSON ¶
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 ¶
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 ¶
Backoff is an interface around gax.Backoff's Pause method, allowing tests to provide their own implementation.
type RetryConfig ¶
RetryConfig allows configuration of backoff timing and retryable errors.
type URLParams ¶
URLParams is a simplified replacement for url.Values that safely builds up URL parameters for encoding.
func (URLParams) Encode ¶
Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") sorted by key.