gensupport
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package gensupport is an internal implementation detail used by codegenerated by the google-api-go-generator tool.
This package may be modified at any time without regard for backwardscompatibility. It should not be used directly by API users.
Index¶
- func CombineBodyMedia(body io.Reader, bodyContentType string, media io.Reader, ...) (io.ReadCloser, string)
- func DecodeResponse(target interface{}, res *http.Response) error
- func DecodeResponseBytes(target interface{}, res *http.Response) ([]byte, error)
- func GoVersion() string
- func MarshalJSON(schema interface{}, forceSendFields, nullFields []string) ([]byte, error)
- func ReaderAtToReader(ra io.ReaderAt, size int64) io.Reader
- 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 SetGetBody(req *http.Request, f func() (io.ReadCloser, error))deprecated
- func SetHeaders(userAgent, contentType string, userHeaders http.Header, keyvals ...string) http.Header
- func SetOptions(u URLParams, opts ...googleapi.CallOption)
- func WrapError(err error) error
- type Backoff
- type JSONFloat64
- type MediaBuffer
- type MediaInfo
- func (mi *MediaInfo) ResumableUpload(locURI string) *ResumableUpload
- func (mi *MediaInfo) SetProgressUpdater(pu googleapi.ProgressUpdater)
- func (mi *MediaInfo) UploadRequest(reqHeaders http.Header, body io.Reader) (newBody io.Reader, getBody func() (io.ReadCloser, error), cleanup func())
- func (mi *MediaInfo) UploadType() string
- type ResumableUpload
- type RetryConfig
- type URLParams
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcCombineBodyMedia¶
func CombineBodyMedia(bodyio.Reader, bodyContentTypestring, mediaio.Reader, mediaContentTypestring) (io.ReadCloser,string)
CombineBodyMedia combines a json body with media content to create a multipart/related HTTP body.It returns a ReadCloser containing the combined body, and the overall "multipart/related" content type, with random boundary.
The caller must call Close on the returned ReadCloser if reads are abandoned before reaching EOF.
funcDecodeResponse¶
DecodeResponse decodes the body of res into target. If there is no body,target is unchanged.
funcDecodeResponseBytes¶added inv0.212.0
DecodeResponseBytes decodes the body of res into target and returns bytes readfrom the body. If there is no body, target is unchanged.
funcGoVersion¶added inv0.20.0
func GoVersion()string
GoVersion returns the Go runtime version. The returned stringhas no whitespace.
funcMarshalJSON¶
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.
funcReaderAtToReader¶
ReaderAtToReader adapts a ReaderAt to be used as a Reader.If ra implements googleapi.ContentTyper, then the returned readerwill also implement googleapi.ContentTyper, delegating to ra.
funcSendRequest¶
SendRequest sends a single HTTP request using the given client.If ctx is non-nil, it calls all hooks, then sends the request withreq.WithContext, then calls any functions returned by the hooks inreverse order.
funcSendRequestWithRetry¶added inv0.28.0
func SendRequestWithRetry(ctxcontext.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 withreq.WithContext, then calls any functions returned by the hooks inreverse order.
funcSetGetBodydeprecated
func SetGetBody(req *http.Request, f func() (io.ReadCloser,error))
SetGetBody sets the GetBody field of req to f. This was once neededto gracefully support Go 1.7 and earlier which didn't have thatfield.
Deprecated: the code generator no longer uses this as of2019-02-19. Nothing else should be calling this anyway, but wewon't delete this immediately; it will be deleted in as early as 6months.
funcSetHeaders¶added inv0.177.0
SetHeaders sets common headers for all requests. The keyvals header pairsshould have a corresponding value for every key provided. If there is an oddnumber of keyvals this method will panic.
funcSetOptions¶
func SetOptions(uURLParams, opts ...googleapi.CallOption)
SetOptions sets the URL params and any additional `CallOption` or`MultiCallOption` passed in.
funcWrapError¶added inv0.103.0
WrapError creates anapierror.APIError from err, wraps it in err, andreturns err. If err is not agoogleapi.Error (or agoogle.golang.org/grpc/status.Status), it returns err without modification.
Types¶
typeBackoff¶
Backoff is an interface around gax.Backoff's Pause method, allowing tests to provide theirown implementation.
typeJSONFloat64¶
type JSONFloat64float64
JSONFloat64 is a float64 that supports proper unmarshaling of special floatvalues in JSON, according tohttps://developers.google.com/protocol-buffers/docs/proto3#json. Althoughthat is a proto-to-JSON spec, it applies to all Google APIs.
The jsonpb package(https://github.com/golang/protobuf/blob/master/jsonpb/jsonpb.go) hassimilar functionality, but only for direct translation from proto messagesto JSON.
func (*JSONFloat64)UnmarshalJSON¶
func (f *JSONFloat64) UnmarshalJSON(data []byte)error
typeMediaBuffer¶
type MediaBuffer struct {// contains filtered or unexported fields}MediaBuffer buffers data from an io.Reader to support uploading media inretryable chunks. It should be created with NewMediaBuffer.
funcNewMediaBuffer¶
func NewMediaBuffer(mediaio.Reader, chunkSizeint) *MediaBuffer
NewMediaBuffer initializes a MediaBuffer.
funcPrepareUpload¶
PrepareUpload determines whether the data in the supplied reader should beuploaded in a single request, or in sequential chunks.chunkSize is the size of the chunk that media should be split into.
If chunkSize is zero, media is returned as the first value, and the othertwo return values are nil, true.
Otherwise, a MediaBuffer is returned, along with a bool indicating whether thecontents of media fit in a single chunk.
After PrepareUpload has been called, media should no longer be used: themedia content should be accessed via one of the return values.
func (*MediaBuffer)Chunk¶
Chunk returns the current buffered chunk, the offset in the underlying mediafrom which the chunk is drawn, and the size of the chunk.Successive calls to Chunk return the same chunk between calls to Next.
func (*MediaBuffer)Next¶
func (mb *MediaBuffer) Next()
Next advances to the next chunk, which will be returned by the next call to Chunk.Calls to Next without a corresponding prior call to Chunk will have no effect.
typeMediaInfo¶
type MediaInfo struct {// contains filtered or unexported fields}MediaInfo holds information for media uploads. It is intended for use by generatedcode only.
funcNewInfoFromMedia¶
func NewInfoFromMedia(rio.Reader, options []googleapi.MediaOption) *MediaInfo
NewInfoFromMedia should be invoked from the Media method of a call. It returns aMediaInfo populated with chunk size and content type, and a reader or MediaBufferif needed.
funcNewInfoFromResumableMedia¶
NewInfoFromResumableMedia should be invoked from the ResumableMedia method of acall. It returns a MediaInfo using the given reader, size and media type.
func (*MediaInfo)ResumableUpload¶
func (mi *MediaInfo) ResumableUpload(locURIstring) *ResumableUpload
ResumableUpload returns an appropriately configured ResumableUpload value if theupload is resumable, or nil otherwise.
func (*MediaInfo)SetProgressUpdater¶
func (mi *MediaInfo) SetProgressUpdater(pugoogleapi.ProgressUpdater)
SetProgressUpdater sets the progress updater for the media info.
func (*MediaInfo)UploadRequest¶
func (mi *MediaInfo) UploadRequest(reqHeadershttp.Header, bodyio.Reader) (newBodyio.Reader, getBody func() (io.ReadCloser,error), cleanup func())
UploadRequest sets up an HTTP request for media upload. It adds headersas necessary, and returns a replacement for the body and a function for http.Request.GetBody.
func (*MediaInfo)UploadType¶
UploadType determines the type of upload: a single request, or a resumableseries of requests.
typeResumableUpload¶
type ResumableUpload struct {Client *http.Client// URI is the resumable resource destination provided by the server after specifying "&uploadType=resumable".URIstringUserAgentstring// User-Agent for header of the request// Media is the object being uploaded.Media *MediaBuffer// MediaType defines the media type, e.g. "image/jpeg".MediaTypestring// Callback is an optional function that will be periodically called with the cumulative number of bytes uploaded.Callback func(int64)// Retry optionally configures retries for requests made against the upload.Retry *RetryConfig// ChunkRetryDeadline configures the per-chunk deadline after which no further// retries should happen.ChunkRetryDeadlinetime.Duration// ChunkTransferTimeout configures the per-chunk transfer timeout. If a chunk upload stalls for longer than// this duration, the upload will be retried.ChunkTransferTimeouttime.Duration// contains filtered or unexported fields}ResumableUpload is used by the generated APIs to provide resumable uploads.It is not used by developers directly.
func (*ResumableUpload)Progress¶
func (rx *ResumableUpload) Progress()int64
Progress returns the number of bytes uploaded at this point.
func (*ResumableUpload)Upload¶
Upload starts the process of a resumable upload with a cancellable context.It is called from the auto-generated API code and is not visible to the user.Before sending an HTTP request, Upload calls any registered hook functions,and calls the returned functions after the request returns (see send.go).rx is private to the auto-generated API code.Exactly one of resp or err will be nil. If resp is non-nil, the caller must call resp.Body.Close.Upload does not parse the response into the error on a non 200 response;it is the caller's responsibility to call resp.Body.Close.
typeRetryConfig¶added inv0.63.0
RetryConfig allows configuration of backoff timing and retryable errors.
typeURLParams¶
URLParams is a simplified replacement for url.Valuesthat 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.