package gensupport
Import Path
google.golang.org/api/internal/gensupport (on go.dev)
Dependency Relation
imports 21 packages, and imported by one package
Involved Source Files
buffer.go
Package gensupport is an internal implementation detail used by code
generated by the google-api-go-generator tool.
This package may be modified at any time without regard for backwards
compatibility. It should not be used directly by API users.
json.go
jsonfloat.go
media.go
params.go
resumable.go
send.go
version.go
Package-Level Type Names (total 12, in which 7 are exported)
Backoff is an interface around gax.Backoff's Pause method, allowing tests to provide their
own implementation.
( T) Pause() time.Duration
*github.com/googleapis/gax-go/v2.Backoff
Hook is the type of a function that is called once before each HTTP request
that is sent by a generated API. It returns a function that is called after
the request returns.
Hooks are not called if the context is nil.
func RegisterHook(h Hook)
JSONFloat64 is a float64 that supports proper unmarshaling of special float
values in JSON, according to
https://developers.google.com/protocol-buffers/docs/proto3#json. Although
that 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) has
similar functionality, but only for direct translation from proto messages
to JSON.
(*T) UnmarshalJSON(data []byte) error
*T : encoding/json.Unmarshaler
MediaBuffer buffers data from an io.Reader to support uploading media in
retryable chunks. It should be created with NewMediaBuffer.
// The current chunk which is pending upload. The capacity is the chunk size.
// Any error generated when populating chunk by reading media.
media io.Reader
The absolute position of chunk in the underlying media.
Chunk returns the current buffered chunk, the offset in the underlying media
from which the chunk is drawn, and the size of the chunk.
Successive calls to Chunk return the same chunk between calls to 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.
loadChunk will read from media into chunk, up to the capacity of chunk.
func NewMediaBuffer(media io.Reader, chunkSize int) *MediaBuffer
func PrepareUpload(media io.Reader, chunkSize int) (r io.Reader, mb *MediaBuffer, singleChunk bool)
MediaInfo holds information for media uploads. It is intended for use by generated
code only.
buffer *MediaBuffer
mType string
At most one of Media and MediaBuffer will be set.
progressUpdater googleapi.ProgressUpdater
singleChunk bool
// mediaSize, if known. Used only for calls to progressUpdater_.
ResumableUpload returns an appropriately configured ResumableUpload value if the
upload is resumable, or nil otherwise.
SetProgressUpdater sets the progress updater for the media info.
UploadRequest sets up an HTTP request for media upload. It adds headers
as necessary, and returns a replacement for the body and a function for http.Request.GetBody.
UploadType determines the type of upload: a single request, or a resumable
series of requests.
func NewInfoFromMedia(r io.Reader, options []googleapi.MediaOption) *MediaInfo
func NewInfoFromResumableMedia(r io.ReaderAt, size int64, mediaType string) *MediaInfo
ResumableUpload is used by the generated APIs to provide resumable uploads.
It is not used by developers directly.
Callback is an optional function that will be periodically called with the cumulative number of bytes uploaded.
Client *http.Client
Media is the object being uploaded.
MediaType defines the media type, e.g. "image/jpeg".
URI is the resumable resource destination provided by the server after specifying "&uploadType=resumable".
// User-Agent for header of the request
// guards progress
// number of bytes uploaded so far
Progress returns the number of bytes uploaded at this point.
Upload starts the process of a resumable upload with a cancellable context.
It retries using the provided back off strategy until cancelled or the
strategy indicates to stop retrying.
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.
doUploadRequest performs a single HTTP request to upload data.
off specifies the offset in rx.Media from which data is drawn.
size is the number of bytes in data.
final specifies whether data is the final chunk to be uploaded.
reportProgress calls a user-supplied callback to report upload progress.
If old==updated, the callback is not called.
transferChunk performs a single HTTP request to upload a single chunk from rx.Media.
func (*MediaInfo).ResumableUpload(locURI string) *ResumableUpload
URLParams is a simplified replacement for url.Values
that safely builds up URL parameters for encoding.
Encode encodes the values into ``URL encoded'' form
("bar=baz&foo=quux") sorted by key.
Get returns the first value for the given key, or "".
Set sets the key to value.
It replaces any existing values.
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.
T : github.com/go-redis/redis/v8.ConsistentHash
T : go.opentelemetry.io/otel/api/propagation.HTTPSupplier
func SetOptions(u URLParams, opts ...googleapi.CallOption)
Package-Level Functions (total 31, in which 15 are exported)
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.
DecodeResponse decodes the body of res into target. If there is no body,
target is unchanged.
DetermineContentType determines the content type of the supplied reader.
If the content type is already known, it can be specified via ctype.
Otherwise, the content of media will be sniffed to determine the content type.
If media implements googleapi.ContentTyper (deprecated), this will be used
instead of sniffing the content.
After calling DetectContentType the caller must not perform further reads on
media, but rather read from the Reader that is returned.
GoVersion returns the Go runtime version. The returned string
has no whitespace.
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.
NewInfoFromMedia should be invoked from the Media method of a call. It returns a
MediaInfo populated with chunk size and content type, and a reader or MediaBuffer
if needed.
NewInfoFromResumableMedia should be invoked from the ResumableMedia method of a
call. It returns a MediaInfo using the given reader, size and media type.
NewMediaBuffer initializes a MediaBuffer.
PrepareUpload determines whether the data in the supplied reader should be
uploaded 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 other
two return values are nil, true.
Otherwise, a MediaBuffer is returned, along with a bool indicating whether the
contents of media fit in a single chunk.
After PrepareUpload has been called, media should no longer be used: the
media content should be accessed via one of the return values.
ReaderAtToReader adapts a ReaderAt to be used as a Reader.
If ra implements googleapi.ContentTyper, then the returned reader
will also implement googleapi.ContentTyper, delegating to ra.
RegisterHook registers a Hook to be called before each HTTP request by a
generated API. Hooks are called in the order they are registered. Each
hook can return a function; if it is non-nil, it is called after the HTTP
request returns. These functions are called in the reverse order.
RegisterHook should not be called concurrently with itself or SendRequest.
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.
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.
SetGetBody sets the GetBody field of req to f. This was once needed
to gracefully support Go 1.7 and earlier which didn't have that
field.
Deprecated: the code generator no longer uses this as of
2019-02-19. Nothing else should be calling this anyway, but we
won't delete this immediately; it will be deleted in as early as 6
months.
SetOptions sets the URL params and any additional call options.
Package-Level Variables (total 5, none are exported)
Package-Level Constants (total 3, none are exported)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |