Commit 78a6a77a authored by Wojciech Tyczynski's avatar Wojciech Tyczynski

Update Google API dependencies

parent dbb8bf52
...@@ -2530,31 +2530,31 @@ ...@@ -2530,31 +2530,31 @@
}, },
{ {
"ImportPath": "google.golang.org/api/cloudmonitoring/v2beta2", "ImportPath": "google.golang.org/api/cloudmonitoring/v2beta2",
"Rev": "a69f0f19d246419bb931b0ac8f4f8d3f3e6d4feb" "Rev": "55146ba61254fdb1c26d65ff3c04bc1611ad73fb"
}, },
{ {
"ImportPath": "google.golang.org/api/compute/v1", "ImportPath": "google.golang.org/api/compute/v1",
"Rev": "a69f0f19d246419bb931b0ac8f4f8d3f3e6d4feb" "Rev": "55146ba61254fdb1c26d65ff3c04bc1611ad73fb"
}, },
{ {
"ImportPath": "google.golang.org/api/container/v1", "ImportPath": "google.golang.org/api/container/v1",
"Rev": "a69f0f19d246419bb931b0ac8f4f8d3f3e6d4feb" "Rev": "55146ba61254fdb1c26d65ff3c04bc1611ad73fb"
}, },
{ {
"ImportPath": "google.golang.org/api/dns/v1", "ImportPath": "google.golang.org/api/dns/v1",
"Rev": "a69f0f19d246419bb931b0ac8f4f8d3f3e6d4feb" "Rev": "55146ba61254fdb1c26d65ff3c04bc1611ad73fb"
}, },
{ {
"ImportPath": "google.golang.org/api/gensupport", "ImportPath": "google.golang.org/api/gensupport",
"Rev": "a69f0f19d246419bb931b0ac8f4f8d3f3e6d4feb" "Rev": "55146ba61254fdb1c26d65ff3c04bc1611ad73fb"
}, },
{ {
"ImportPath": "google.golang.org/api/googleapi", "ImportPath": "google.golang.org/api/googleapi",
"Rev": "a69f0f19d246419bb931b0ac8f4f8d3f3e6d4feb" "Rev": "55146ba61254fdb1c26d65ff3c04bc1611ad73fb"
}, },
{ {
"ImportPath": "google.golang.org/api/googleapi/internal/uritemplates", "ImportPath": "google.golang.org/api/googleapi/internal/uritemplates",
"Rev": "a69f0f19d246419bb931b0ac8f4f8d3f3e6d4feb" "Rev": "55146ba61254fdb1c26d65ff3c04bc1611ad73fb"
}, },
{ {
"ImportPath": "google.golang.org/appengine", "ImportPath": "google.golang.org/appengine",
......
{ {
"kind": "discovery#restDescription", "kind": "discovery#restDescription",
"etag": "\"bRFOOrZKfO9LweMbPqu0kcu6De8/A2G_NAa29vne9MPSojupRQ5bVuo\"", "etag": "\"tbys6C40o18GZwyMen5GMkdK-3s/mLggzdz9EvP0lVEQoxoRvdSJShg\"",
"discoveryVersion": "v1", "discoveryVersion": "v1",
"id": "cloudmonitoring:v2beta2", "id": "cloudmonitoring:v2beta2",
"name": "cloudmonitoring", "name": "cloudmonitoring",
"canonicalName": "Cloud Monitoring", "canonicalName": "Cloud Monitoring",
"version": "v2beta2", "version": "v2beta2",
"revision": "20160314", "revision": "20161031",
"title": "Cloud Monitoring API", "title": "Cloud Monitoring API",
"description": "Accesses Google Cloud Monitoring data.", "description": "Accesses Google Cloud Monitoring data.",
"ownerDomain": "google.com", "ownerDomain": "google.com",
"ownerName": "Google", "ownerName": "Google",
"icons": { "icons": {
"x16": "http://www.google.com/images/icons/product/search-16.gif", "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
"x32": "http://www.google.com/images/icons/product/search-32.gif" "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
}, },
"documentationLink": "https://cloud.google.com/monitoring/v2beta2/", "documentationLink": "https://cloud.google.com/monitoring/v2beta2/",
"protocol": "rest", "protocol": "rest",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"kind": "discovery#restDescription", "kind": "discovery#restDescription",
"etag": "\"jQLIOHBVnDZie4rQHGH1WJF-INE/ctEt-71wWAltEdgLnIcGLfJZeFE\"", "etag": "\"tbys6C40o18GZwyMen5GMkdK-3s/RqBsQyB2YZT-ZAkK7pcLByI9SZs\"",
"discoveryVersion": "v1", "discoveryVersion": "v1",
"id": "dns:v1", "id": "dns:v1",
"name": "dns", "name": "dns",
"version": "v1", "version": "v1",
"revision": "20160413", "revision": "20161110",
"title": "Google Cloud DNS API", "title": "Google Cloud DNS API",
"description": "Configures and serves authoritative DNS records.", "description": "Configures and serves authoritative DNS records.",
"ownerDomain": "google.com", "ownerDomain": "google.com",
"ownerName": "Google", "ownerName": "Google",
"icons": { "icons": {
"x16": "http://www.google.com/images/icons/product/search-16.gif", "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
"x32": "http://www.google.com/images/icons/product/search-32.gif" "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
}, },
"documentationLink": "https://developers.google.com/cloud-dns", "documentationLink": "https://developers.google.com/cloud-dns",
"protocol": "rest", "protocol": "rest",
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
}, },
"name": { "name": {
"type": "string", "type": "string",
"description": "User assigned name for this resource. Must be unique within the project. The name must be 1-32 characters long, must begin with a letter, end with a letter or digit, and only contain lowercase letters, digits or dashes." "description": "User assigned name for this resource. Must be unique within the project. The name must be 1-63 characters long, must begin with a letter, end with a letter or digit, and only contain lowercase letters, digits or dashes."
}, },
"nameServerSet": { "nameServerSet": {
"type": "string", "type": "string",
......
...@@ -12,13 +12,13 @@ import ( ...@@ -12,13 +12,13 @@ import (
) )
// MarshalJSON returns a JSON encoding of schema containing only selected fields. // MarshalJSON returns a JSON encoding of schema containing only selected fields.
// A field is selected if: // A field is selected if any of the following is true:
// * it has a non-empty value, or // * it has a non-empty value
// * its field name is present in forceSendFields, and // * its field name is present in forceSendFields and it is not a nil pointer or nil interface
// * 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. // The JSON key for each selected field is taken from the field's json: struct tag.
func MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error) { func MarshalJSON(schema interface{}, forceSendFields, nullFields []string) ([]byte, error) {
if len(forceSendFields) == 0 { if len(forceSendFields) == 0 && len(nullFields) == 0 {
return json.Marshal(schema) return json.Marshal(schema)
} }
...@@ -26,15 +26,19 @@ func MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error) { ...@@ -26,15 +26,19 @@ func MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error) {
for _, f := range forceSendFields { for _, f := range forceSendFields {
mustInclude[f] = struct{}{} mustInclude[f] = struct{}{}
} }
useNull := make(map[string]struct{})
for _, f := range nullFields {
useNull[f] = struct{}{}
}
dataMap, err := schemaToMap(schema, mustInclude) dataMap, err := schemaToMap(schema, mustInclude, useNull)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return json.Marshal(dataMap) return json.Marshal(dataMap)
} }
func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[string]interface{}, error) { func schemaToMap(schema interface{}, mustInclude, useNull map[string]struct{}) (map[string]interface{}, error) {
m := make(map[string]interface{}) m := make(map[string]interface{})
s := reflect.ValueOf(schema) s := reflect.ValueOf(schema)
st := s.Type() st := s.Type()
...@@ -54,6 +58,14 @@ func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[strin ...@@ -54,6 +58,14 @@ func schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[strin
v := s.Field(i) v := s.Field(i)
f := st.Field(i) f := st.Field(i)
if _, ok := useNull[f.Name]; ok {
if !isEmptyValue(v) {
return nil, fmt.Errorf("field %q in NullFields has non-empty value", f.Name)
}
m[tag.apiName] = nil
continue
}
if !includeField(v, f, mustInclude) { if !includeField(v, f, mustInclude) {
continue continue
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package gensupport package gensupport
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
...@@ -15,10 +16,6 @@ import ( ...@@ -15,10 +16,6 @@ import (
) )
const ( const (
// statusResumeIncomplete is the code returned by the Google uploader
// when the transfer is not yet complete.
statusResumeIncomplete = 308
// statusTooManyRequests is returned by the storage API if the // statusTooManyRequests is returned by the storage API if the
// per-project limits have been temporarily exceeded. The request // per-project limits have been temporarily exceeded. The request
// should be retried. // should be retried.
...@@ -79,8 +76,23 @@ func (rx *ResumableUpload) doUploadRequest(ctx context.Context, data io.Reader, ...@@ -79,8 +76,23 @@ func (rx *ResumableUpload) doUploadRequest(ctx context.Context, data io.Reader,
req.Header.Set("Content-Range", contentRange) req.Header.Set("Content-Range", contentRange)
req.Header.Set("Content-Type", rx.MediaType) req.Header.Set("Content-Type", rx.MediaType)
req.Header.Set("User-Agent", rx.UserAgent) req.Header.Set("User-Agent", rx.UserAgent)
// Google's upload endpoint uses status code 308 for a
// different purpose than the "308 Permanent Redirect"
// since-standardized in RFC 7238. Because of the conflict in
// semantics, Google added this new request header which
// causes it to not use "308" and instead reply with 200 OK
// and sets the upload-specific "X-HTTP-Status-Code-Override:
// 308" response header.
req.Header.Set("X-GUploader-No-308", "yes")
return SendRequest(ctx, rx.Client, req) return SendRequest(ctx, rx.Client, req)
}
func statusResumeIncomplete(resp *http.Response) bool {
// This is how the server signals "status resume incomplete"
// when X-GUploader-No-308 is set to "yes":
return resp != nil && resp.Header.Get("X-Http-Status-Code-Override") == "308"
} }
// reportProgress calls a user-supplied callback to report upload progress. // reportProgress calls a user-supplied callback to report upload progress.
...@@ -111,11 +123,17 @@ func (rx *ResumableUpload) transferChunk(ctx context.Context) (*http.Response, e ...@@ -111,11 +123,17 @@ func (rx *ResumableUpload) transferChunk(ctx context.Context) (*http.Response, e
return res, err return res, err
} }
if res.StatusCode == statusResumeIncomplete || res.StatusCode == http.StatusOK { // We sent "X-GUploader-No-308: yes" (see comment elsewhere in
// this file), so we don't expect to get a 308.
if res.StatusCode == 308 {
return nil, errors.New("unexpected 308 response status code")
}
if res.StatusCode == http.StatusOK {
rx.reportProgress(off, off+int64(size)) rx.reportProgress(off, off+int64(size))
} }
if res.StatusCode == statusResumeIncomplete { if statusResumeIncomplete(res) {
rx.Media.Next() rx.Media.Next()
} }
return res, nil return res, nil
...@@ -177,7 +195,7 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err ...@@ -177,7 +195,7 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
// If the chunk was uploaded successfully, but there's still // If the chunk was uploaded successfully, but there's still
// more to go, upload the next chunk without any delay. // more to go, upload the next chunk without any delay.
if status == statusResumeIncomplete { if statusResumeIncomplete(resp) {
pause = 0 pause = 0
backoff.Reset() backoff.Reset()
resp.Body.Close() resp.Body.Close()
......
...@@ -55,23 +55,17 @@ func DefaultBackoffStrategy() BackoffStrategy { ...@@ -55,23 +55,17 @@ func DefaultBackoffStrategy() BackoffStrategy {
// shouldRetry returns true if the HTTP response / error indicates that the // shouldRetry returns true if the HTTP response / error indicates that the
// request should be attempted again. // request should be attempted again.
func shouldRetry(status int, err error) bool { func shouldRetry(status int, err error) bool {
// Retry for 5xx response codes. if 500 <= status && status <= 599 {
if 500 <= status && status < 600 {
return true return true
} }
// Retry on statusTooManyRequests{
if status == statusTooManyRequests { if status == statusTooManyRequests {
return true return true
} }
// Retry on unexpected EOFs and temporary network errors.
if err == io.ErrUnexpectedEOF { if err == io.ErrUnexpectedEOF {
return true return true
} }
if err, ok := err.(net.Error); ok { if err, ok := err.(net.Error); ok {
return err.Temporary() return err.Temporary()
} }
return false return false
} }
...@@ -50,7 +50,7 @@ const ( ...@@ -50,7 +50,7 @@ const (
// UserAgent is the header string used to identify this package. // UserAgent is the header string used to identify this package.
UserAgent = "google-api-go-client/" + Version UserAgent = "google-api-go-client/" + Version
// The default chunk size to use for resumable uplods if not specified by the user. // The default chunk size to use for resumable uploads if not specified by the user.
DefaultUploadChunkSize = 8 * 1024 * 1024 DefaultUploadChunkSize = 8 * 1024 * 1024
// The minimum chunk size that can be used for resumable uploads. All // The minimum chunk size that can be used for resumable uploads. All
......
...@@ -6,6 +6,7 @@ package googleapi ...@@ -6,6 +6,7 @@ package googleapi
import ( import (
"encoding/json" "encoding/json"
"errors"
"strconv" "strconv"
) )
...@@ -149,6 +150,25 @@ func (s Float64s) MarshalJSON() ([]byte, error) { ...@@ -149,6 +150,25 @@ func (s Float64s) MarshalJSON() ([]byte, error) {
}) })
} }
// 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
// MarshalJSON returns m.
func (m RawMessage) MarshalJSON() ([]byte, error) {
return m, nil
}
// UnmarshalJSON sets *m to a copy of data.
func (m *RawMessage) UnmarshalJSON(data []byte) error {
if m == nil {
return errors.New("googleapi.RawMessage: UnmarshalJSON on nil pointer")
}
*m = append((*m)[:0], data...)
return nil
}
/* /*
* Helper routines for simplifying the creation of optional fields of basic type. * Helper routines for simplifying the creation of optional fields of basic type.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment