googleapi - ActiveState ActiveGo 1.8
...

Package googleapi

import "google.golang.org/api/googleapi"
Overview
Index
Subdirectories

Overview ▾

Package googleapi contains the common code shared by all Google API libraries.

Index ▾

Constants
Variables
func Bool(v bool) *bool
func CheckMediaResponse(res *http.Response) error
func CheckResponse(res *http.Response) 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
    func QuotaUser(u string) CallOption
    func Trace(traceToken string) CallOption
    func UserIP(ip string) CallOption
type ContentTyper
type Error
    func (e *Error) Error() string
type ErrorItem
type Field
type Float64s
    func (s Float64s) MarshalJSON() ([]byte, error)
    func (q *Float64s) UnmarshalJSON(raw []byte) error
type Int32s
    func (s Int32s) MarshalJSON() ([]byte, error)
    func (q *Int32s) UnmarshalJSON(raw []byte) error
type Int64s
    func (s Int64s) MarshalJSON() ([]byte, error)
    func (q *Int64s) UnmarshalJSON(raw []byte) error
type MarshalStyle
    func (wrap MarshalStyle) JSONReader(v interface{}) (io.Reader, error)
type MediaOption
    func ChunkSize(size int) MediaOption
    func ContentType(ctype string) MediaOption
type MediaOptions
    func ProcessMediaOptions(opts []MediaOption) *MediaOptions
type ProgressUpdater
type RawMessage
    func (m RawMessage) MarshalJSON() ([]byte, error)
    func (m *RawMessage) UnmarshalJSON(data []byte) error
type ServerResponse
type SizeReaderAt
type Uint32s
    func (s Uint32s) MarshalJSON() ([]byte, error)
    func (q *Uint32s) UnmarshalJSON(raw []byte) error
type Uint64s
    func (s Uint64s) MarshalJSON() ([]byte, error)
    func (q *Uint64s) UnmarshalJSON(raw []byte) error

Package files

googleapi.go types.go

Constants

const (
    Version = "0.5"

    // UserAgent is the header string used to identify this package.
    UserAgent = "google-api-go-client/" + Version

    // The default chunk size to use for resumable uploads if not specified by the user.
    DefaultUploadChunkSize = 8 * 1024 * 1024

    // 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)
var WithoutDataWrapper = MarshalStyle(false)

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckMediaResponse

func CheckMediaResponse(res *http.Response) error

CheckMediaResponse returns an error (of type *Error) if the response status code is not 2xx. Unlike CheckResponse it does not assume the body is a JSON error document. It is the caller's responsibility to close res.Body.

func CheckResponse

func CheckResponse(res *http.Response) error

CheckResponse returns an error (of type *Error) if the response status code is not 2xx.

func CloseBody

func CloseBody(res *http.Response)

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.

func CombineFields

func CombineFields(s []Field) string

CombineFields combines fields into a single string.

func ConvertVariant

func ConvertVariant(v map[string]interface{}, dst interface{}) bool

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.

func Expand

func Expand(u *url.URL, expansions map[string]string)

Expand subsitutes any {encoded} strings in the URL passed in using the map supplied.

This calls SetOpaque to avoid encoding of the parameters in the URL path.

func Float64

func Float64(v float64) *float64

Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.

func Int32

func Int32(v int32) *int32

Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.

func IsNotModified

func IsNotModified(err error) bool

IsNotModified reports whether err is the result of the server replying with http.StatusNotModified. Such error values are sometimes returned by "Do" methods on calls when If-None-Match is used.

func ResolveRelative

func ResolveRelative(basestr, relstr string) string

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Uint32

func Uint32(v uint32) *uint32

Uint32 is a helper routine that allocates a new uint32 value to store v and returns a pointer to it.

func Uint64

func Uint64(v uint64) *uint64

Uint64 is a helper routine that allocates a new uint64 value to store v and returns a pointer to it.

func VariantType

func VariantType(t map[string]interface{}) string

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.

type CallOption

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 is not specific to that API; for instance, controlling the quota user for an API call is common across many APIs, and is thus a CallOption.

type CallOption interface {
    Get() (key, value string)
}

func QuotaUser

func QuotaUser(u string) 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 UserIP if both are provided.

func Trace

func Trace(traceToken string) CallOption

Trace returns a CallOption that enables diagnostic tracing for a call. traceToken is an ID supplied by Google support.

func UserIP

func UserIP(ip string) CallOption

UserIP returns a CallOption that will set the "userIp" parameter of a call. This should be the IP address of the originating request.

type ContentTyper

ContentTyper is an interface for Readers which know (or would like to override) their Content-Type. If a media body doesn't implement ContentTyper, the type is sniffed from the content using http.DetectContentType.

type ContentTyper interface {
    ContentType() string
}

type Error

Error contains an error response from the server.

type Error struct {
    // Code is the HTTP response status code and will always be populated.
    Code int `json:"code"`
    // Message is the server response message and is only populated when
    // explicitly referenced by the JSON server response.
    Message string `json:"message"`
    // Body is the raw response returned by the server.
    // It is often but not always JSON, depending on how the request fails.
    Body string
    // Header contains the response header fields from the server.
    Header http.Header

    Errors []ErrorItem
}

func (*Error) Error

func (e *Error) Error() string

type ErrorItem

ErrorItem is a detailed error code & message from the Google API frontend.

type ErrorItem struct {
    // Reason is the typed error code. For example: "some_example".
    Reason string `json:"reason"`
    // Message is the human-readable description of the error.
    Message string `json:"message"`
}

type Field

A Field names a field to be retrieved with a partial response. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse

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 fields that 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()

More information about field formatting can be found here: https://developers.google.com/+/api/#fields-syntax

Another way to find field names is through the Google API explorer: https://developers.google.com/apis-explorer/#p/

type Field string

type Float64s

Float64s is a slice of float64s that marshal as quoted strings in JSON.

type Float64s []float64

func (Float64s) MarshalJSON

func (s Float64s) MarshalJSON() ([]byte, error)

func (*Float64s) UnmarshalJSON

func (q *Float64s) UnmarshalJSON(raw []byte) error

type Int32s

Int32s is a slice of int32s that marshal as quoted strings in JSON.

type Int32s []int32

func (Int32s) MarshalJSON

func (s Int32s) MarshalJSON() ([]byte, error)

func (*Int32s) UnmarshalJSON

func (q *Int32s) UnmarshalJSON(raw []byte) error

type Int64s

Int64s is a slice of int64s that marshal as quoted strings in JSON.

type Int64s []int64

func (Int64s) MarshalJSON

func (s Int64s) MarshalJSON() ([]byte, error)

func (*Int64s) UnmarshalJSON

func (q *Int64s) UnmarshalJSON(raw []byte) error

type MarshalStyle

type MarshalStyle bool

func (MarshalStyle) JSONReader

func (wrap MarshalStyle) JSONReader(v interface{}) (io.Reader, error)

type MediaOption

type MediaOption interface {
    // contains filtered or unexported methods
}

func ChunkSize

func ChunkSize(size int) 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.

func ContentType

func ContentType(ctype string) 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.

type MediaOptions

MediaOptions stores options for customizing media upload. It is not used by developers directly.

type MediaOptions struct {
    ContentType           string
    ForceEmptyContentType bool

    ChunkSize int
}

func ProcessMediaOptions

func ProcessMediaOptions(opts []MediaOption) *MediaOptions

ProcessMediaOptions stores options from opts in a MediaOptions. It is not used by developers directly.

type ProgressUpdater

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.

type ProgressUpdater func(current, total int64)

type RawMessage

RawMessage is a raw encoded JSON value. It is identical to json.RawMessage, except it does not suffer from https://golang.org/issue/14493.

type RawMessage []byte

func (RawMessage) MarshalJSON

func (m RawMessage) MarshalJSON() ([]byte, error)

MarshalJSON returns m.

func (*RawMessage) UnmarshalJSON

func (m *RawMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type ServerResponse

ServerResponse is embedded in each Do response and provides the HTTP status code and header sent by the server.

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.
    HTTPStatusCode int
    // Header contains the response header fields from the server.
    Header http.Header
}

type SizeReaderAt

A SizeReaderAt is a ReaderAt with a Size method. An io.SectionReader implements SizeReaderAt.

type SizeReaderAt interface {
    io.ReaderAt
    Size() int64
}

type Uint32s

Uint32s is a slice of uint32s that marshal as quoted strings in JSON.

type Uint32s []uint32

func (Uint32s) MarshalJSON

func (s Uint32s) MarshalJSON() ([]byte, error)

func (*Uint32s) UnmarshalJSON

func (q *Uint32s) UnmarshalJSON(raw []byte) error

type Uint64s

Uint64s is a slice of uint64s that marshal as quoted strings in JSON.

type Uint64s []uint64

func (Uint64s) MarshalJSON

func (s Uint64s) MarshalJSON() ([]byte, error)

func (*Uint64s) UnmarshalJSON

func (q *Uint64s) UnmarshalJSON(raw []byte) error

Subdirectories

Name Synopsis
..
transport Package transport contains HTTP transports used to make authenticated API requests.