googleapi
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 googleapi contains the common code shared by all Google APIlibraries.
Index¶
- Constants
- Variables
- func Bool(v bool) *bool
- func CheckMediaResponse(res *http.Response) error
- func CheckResponse(res *http.Response) error
- func CheckResponseWithBody(res *http.Response, body []byte) error
- func CloseBody(res *http.Response)
- func CombineFields(s []Field) string
- func ConvertVariant(v map[string]interface{}, dst interface{}) bool
- func Expand(u *url.URL, expansions map[string]string)
- func Float64(v float64) *float64
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func IsNotModified(err error) bool
- func ResolveRelative(basestr, relstr string) string
- func String(v string) *string
- func Uint32(v uint32) *uint32
- func Uint64(v uint64) *uint64
- func VariantType(t map[string]interface{}) string
- type CallOption
- type ContentTyper
- type Error
- type ErrorItem
- type Field
- type Float64s
- type Int32s
- type Int64s
- type MarshalStyle
- type MediaOption
- type MediaOptions
- type MultiCallOption
- type ProgressUpdater
- type RawMessage
- type ServerResponse
- type SizeReaderAt
- type Uint32s
- type Uint64s
Constants¶
const (// Version defines the gax version being used. This is typically sent// in an HTTP header to services.Version = "0.5"// UserAgent is the header string used to identify this package.UserAgent = "google-api-go-client/" +Version// DefaultUploadChunkSize is the default chunk size to use for resumable// uploads if not specified by the user.DefaultUploadChunkSize = 16 * 1024 * 1024// MinUploadChunkSize is the minimum chunk size that can be used for// resumable uploads. All user-specified chunk sizes must be multiple of// this value.MinUploadChunkSize = 256 * 1024)
Variables¶
var WithDataWrapper =MarshalStyle(true)WithDataWrapper marshals JSON with a {"data": ...} wrapper.
var WithoutDataWrapper =MarshalStyle(false)WithoutDataWrapper marshals JSON without a {"data": ...} wrapper.
Functions¶
funcBool¶
Bool is a helper routine that allocates a new bool valueto store v and returns a pointer to it.
funcCheckMediaResponse¶
CheckMediaResponse returns an error (of type *Error) if the responsestatus code is not 2xx. Unlike CheckResponse it does not assume thebody is a JSON error document.It is the caller's responsibility to close res.Body.
funcCheckResponse¶
CheckResponse returns an error (of type *Error) if the responsestatus code is not 2xx.
funcCheckResponseWithBody¶added inv0.218.0
CheckResponseWithBody returns an error (of type *Error) if the responsestatus code is not 2xx. Distinct from CheckResponse to allow for checkinga previously-read body to maintain error detail content.
funcCloseBody¶
CloseBody is used to close res.Body.Prior to calling Close, it also tries to Read a small amount to see an EOF.Not seeing an EOF can prevent HTTP Transports from reusing connections.
funcCombineFields¶
CombineFields combines fields into a single string.
funcConvertVariant¶
ConvertVariant uses the JSON encoder/decoder to fill in the struct 'dst' with the fields found in variant 'v'.This is used to support "variant" APIs that can return one of a number of different types.It reports whether the conversion was successful.
funcExpand¶
Expand subsitutes any {encoded} strings in the URL passed in usingthe map supplied.
This calls SetOpaque to avoid encoding of the parameters in the URL path.
funcFloat64¶
Float64 is a helper routine that allocates a new float64 valueto store v and returns a pointer to it.
funcInt32¶
Int32 is a helper routine that allocates a new int32 valueto store v and returns a pointer to it.
funcInt64¶
Int64 is a helper routine that allocates a new int64 valueto store v and returns a pointer to it.
funcIsNotModified¶
IsNotModified reports whether err is the result of theserver replying with http.StatusNotModified.Such error values are sometimes returned by "Do" methodson calls when If-None-Match is used.
funcResolveRelative¶
ResolveRelative resolves relatives such as "http://www.golang.org/" and"topics/myproject/mytopic" into a single string, such as"http://www.golang.org/topics/myproject/mytopic". It strips all parentreferences (e.g. ../..) as well as anything after the host(e.g. /bar/gaz gets stripped out of foo.com/bar/gaz).
ResolveRelative panics if either basestr or relstr is not able to be parsed.
funcString¶
String is a helper routine that allocates a new string valueto store v and returns a pointer to it.
funcUint32¶
Uint32 is a helper routine that allocates a new uint32 valueto store v and returns a pointer to it.
funcUint64¶
Uint64 is a helper routine that allocates a new uint64 valueto store v and returns a pointer to it.
funcVariantType¶
VariantType returns the type name of the given variant.If the map doesn't contain the named key or the value is not a []interface{}, "" is returned.This is used to support "variant" APIs that can return one of a number of different types.
Types¶
typeCallOption¶
type CallOption interface {Get() (key, valuestring)}A CallOption is an optional argument to an API call.It should be treated as an opaque value by users of Google APIs.
A CallOption is something that configures an API call in a way that isnot specific to that API; for instance, controlling the quota user foran API call is common across many APIs, and is thus a CallOption.
funcQueryParameter¶added inv0.53.0
func QueryParameter(keystring, values ...string)CallOption
QueryParameter allows setting the value(s) of an arbitrary key.
funcQuotaUser¶
func QuotaUser(ustring)CallOption
QuotaUser returns a CallOption that will set the quota user for a call.The quota user can be used by server-side applications to control accounting.It can be an arbitrary string up to 40 characters, and will override UserIPif both are provided.
funcTrace¶
func Trace(traceTokenstring)CallOption
Trace returns a CallOption that enables diagnostic tracing for a call.traceToken is an ID supplied by Google support.
funcUserIP¶
func UserIP(ipstring)CallOption
UserIP returns a CallOption that will set the "userIp" parameter of a call.This should be the IP address of the originating request.
typeContentTyper¶
type ContentTyper interface {ContentType()string}ContentTyper is an interface for Readers which know (or would liketo override) their Content-Type. If a media body doesn't implementContentTyper, the type is sniffed from the content usinghttp.DetectContentType.
typeError¶
type Error struct {// Code is the HTTP response status code and will always be populated.Codeint `json:"code"`// Message is the server response message and is only populated when// explicitly referenced by the JSON server response.Messagestring `json:"message"`// Details provide more context to an error.Details []interface{} `json:"details"`// Body is the raw response returned by the server.// It is often but not always JSON, depending on how the request fails.Bodystring// Header contains the response header fields from the server.Headerhttp.HeaderErrors []ErrorItem// contains filtered or unexported fields}Error contains an error response from the server.
func (*Error)Wrap¶added inv0.103.0
Wrap allows an existing Error to wrap another error. See alsoError.Unwrap.
typeErrorItem¶
type ErrorItem struct {// Reason is the typed error code. For example: "some_example".Reasonstring `json:"reason"`// Message is the human-readable description of the error.Messagestring `json:"message"`}ErrorItem is a detailed error code & message from the Google API frontend.
typeField¶
type Fieldstring
A Field names a field to be retrieved with a partial response.https://cloud.google.com/storage/docs/json_api/v1/how-tos/performance
Partial responses can dramatically reduce the amount of data that must be sent to your application.In order to request partial responses, you can specify the full list of fieldsthat your application needs by adding the Fields option to your request.
Field strings use camelCase with leading lower-case characters to identify fields within the response.
For example, if your response has a "NextPageToken" and a slice of "Items" with "Id" fields,you could request just those fields like this:
svc.Events.List().Fields("nextPageToken", "items/id").Do()or if you were also interested in each Item's "Updated" field, you can combine them like this:
svc.Events.List().Fields("nextPageToken", "items(id,updated)").Do()Another way to find field names is through the Google API explorer:https://developers.google.com/apis-explorer/#p/
typeFloat64s¶
type Float64s []float64
Float64s is a slice of float64s that marshal as quoted strings in JSON.
func (Float64s)MarshalJSON¶
func (*Float64s)UnmarshalJSON¶
typeInt32s¶
type Int32s []int32
Int32s is a slice of int32s that marshal as quoted strings in JSON.
func (Int32s)MarshalJSON¶
func (*Int32s)UnmarshalJSON¶
typeInt64s¶
type Int64s []int64
Int64s is a slice of int64s that marshal as quoted strings in JSON.
func (Int64s)MarshalJSON¶
func (*Int64s)UnmarshalJSON¶
typeMarshalStyle¶
type MarshalStylebool
MarshalStyle defines whether to marshal JSON with a {"data": ...} wrapper.
func (MarshalStyle)JSONBuffer¶added inv0.212.0
func (wrapMarshalStyle) JSONBuffer(v interface{}) (*bytes.Buffer,error)
JSONBuffer encodes the body and wraps it if needed.
func (MarshalStyle)JSONReader¶
func (wrapMarshalStyle) JSONReader(v interface{}) (io.Reader,error)
JSONReader is like JSONBuffer, but returns an io.Reader instead.
typeMediaOption¶
type MediaOption interface {// contains filtered or unexported methods}MediaOption defines the interface for setting media options.
funcChunkRetryDeadline¶added inv0.67.0
func ChunkRetryDeadline(deadlinetime.Duration)MediaOption
ChunkRetryDeadline returns a MediaOption which sets a per-chunk retrydeadline. If a single chunk has been attempting to upload for longer thanthis time and the request fails, it will no longer be retried, and the errorwill be returned to the caller.This is only applicable for files which are large enough to requirea multi-chunk resumable upload.The default value is 32s.To set a deadline on the entire upload, use context timeout or cancellation.
funcChunkSize¶
func ChunkSize(sizeint)MediaOption
ChunkSize returns a MediaOption which sets the chunk size for media uploads.size will be rounded up to the nearest multiple of 256K.Media which contains fewer than size bytes will be uploaded in a single request.Media which contains size bytes or more will be uploaded in separate chunks.If size is zero, media will be uploaded in a single request.
funcChunkTransferTimeout¶added inv0.208.0
func ChunkTransferTimeout(timeouttime.Duration)MediaOption
ChunkTransferTimeout returns a MediaOption which sets a per-chunktransfer timeout for resumable uploads. If a single chunk has beenattempting to upload for longer than this time then the old req got canceled and retried.The default is no timeout for the request.
funcContentType¶
func ContentType(ctypestring)MediaOption
ContentType returns a MediaOption which sets the Content-Type header for media uploads.If ctype is empty, the Content-Type header will be omitted.
typeMediaOptions¶
type MediaOptions struct {ContentTypestringForceEmptyContentTypeboolChunkSizeintChunkRetryDeadlinetime.DurationChunkTransferTimeouttime.Duration}MediaOptions stores options for customizing media upload. It is not used by developers directly.
funcProcessMediaOptions¶
func ProcessMediaOptions(opts []MediaOption) *MediaOptions
ProcessMediaOptions stores options from opts in a MediaOptions.It is not used by developers directly.
typeMultiCallOption¶added inv0.53.0
type MultiCallOption interface {CallOptionGetMulti() (keystring, value []string)}A MultiCallOption is an option argument to an API call and can be passedanywhere a CallOption is accepted. It additionally supports returning a sliceof values for a given key.
typeProgressUpdater¶
type ProgressUpdater func(current, totalint64)
ProgressUpdater is a function that is called upon every progress update of a resumable upload.This is the only part of a resumable upload (from googleapi) that is usable by the developer.The remaining usable pieces of resumable uploads is exposed in each auto-generated API.
typeRawMessage¶
type RawMessage []byte
RawMessage is a raw encoded JSON value.It is identical to json.RawMessage, except it does not suffer fromhttps://golang.org/issue/14493.
func (*RawMessage)UnmarshalJSON¶
func (m *RawMessage) UnmarshalJSON(data []byte)error
UnmarshalJSON sets *m to a copy of data.
typeServerResponse¶
type ServerResponse struct {// HTTPStatusCode is the server's response status code. When using a// resource method's Do call, this will always be in the 2xx range.HTTPStatusCodeint// Header contains the response header fields from the server.Headerhttp.Header}ServerResponse is embedded in each Do response andprovides the HTTP status code and header sent by the server.
typeSizeReaderAt¶
A SizeReaderAt is a ReaderAt with a Size method.An io.SectionReader implements SizeReaderAt.
typeUint32s¶
type Uint32s []uint32
Uint32s is a slice of uint32s that marshal as quoted strings in JSON.