Movatterモバイル変換


[0]ホーム

URL:


gensupport

package
v0.257.0Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:25Imported by:0

Details

Repository

github.com/googleapis/google-api-go-client

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

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

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

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

funcDecodeResponseBytesadded inv0.212.0

func DecodeResponseBytes(target interface{}, res *http.Response) ([]byte,error)

DecodeResponseBytes decodes the body of res into target and returns bytes readfrom the body. If there is no body, target is unchanged.

funcGoVersionadded inv0.20.0

func GoVersion()string

GoVersion returns the Go runtime version. The returned stringhas no whitespace.

funcMarshalJSON

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.

funcReaderAtToReader

func ReaderAtToReader(raio.ReaderAt, sizeint64)io.Reader

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

func SendRequest(ctxcontext.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 withreq.WithContext, then calls any functions returned by the hooks inreverse order.

funcSendRequestWithRetryadded 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.

funcSetHeadersadded inv0.177.0

func SetHeaders(userAgent, contentTypestring, userHeadershttp.Header, keyvals ...string)http.Header

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.

funcWrapErroradded inv0.103.0

func WrapError(errerror)error

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

type Backoff interface {Pause()time.Duration}

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

func PrepareUpload(mediaio.Reader, chunkSizeint) (rio.Reader, mb *MediaBuffer, singleChunkbool)

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

func (mb *MediaBuffer) Chunk() (chunkio.Reader, offint64, sizeint, errerror)

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

func NewInfoFromResumableMedia(rio.ReaderAt, sizeint64, mediaTypestring) *MediaInfo

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

func (mi *MediaInfo) UploadType()string

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.

typeRetryConfigadded inv0.63.0

type RetryConfig struct {Backoff     *gax.BackoffShouldRetry func(errerror)bool}

RetryConfig allows configuration of backoff timing and retryable errors.

typeURLParams

type URLParams map[string][]string

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

func (URLParams)Encode

func (uURLParams) Encode()string

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

func (URLParams)Get

func (uURLParams) Get(keystring)string

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

func (URLParams)Set

func (uURLParams) Set(key, valuestring)

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

func (URLParams)SetMulti

func (uURLParams) SetMulti(keystring, 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 SetMultiso the caller is responsible for making a copy if necessary.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp