Vendor dependencies for GCS

This commit is contained in:
Alexander Neumann 2017-08-05 20:17:15 +02:00
parent ba75a3884c
commit 8ca6a9a240
1228 changed files with 1769186 additions and 1 deletions

View file

@ -0,0 +1,442 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"math"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"strings"
"testing"
"testing/iotest"
"golang.org/x/net/context"
// If you add a client, add a matching go:generate line below.
dfa "google.golang.org/api/dfareporting/v2.7"
mon "google.golang.org/api/monitoring/v3"
storage "google.golang.org/api/storage/v1"
)
//go:generate -command api go run gen.go docurls.go -install -api
//go:generate api dfareporting:v2.7
//go:generate api monitoring:v3
//go:generate api storage:v1
type myHandler struct {
location string
r *http.Request
body []byte
reqURIs []string
err error
}
func (h *myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.r = r
v, err := url.ParseRequestURI(r.URL.RequestURI())
if err != nil {
h.err = err
return
}
h.reqURIs = append(h.reqURIs, v.String())
if h.location != "" {
w.Header().Set("Location", h.location)
}
h.body, h.err = ioutil.ReadAll(r.Body)
fmt.Fprintf(w, "{}")
}
func TestMedia(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := storage.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
const body = "fake media data"
f := strings.NewReader(body)
o := &storage.Object{
Bucket: "mybucket",
Name: "filename",
ContentType: "plain/text",
ContentEncoding: "utf-8",
ContentLanguage: "en",
}
_, err = s.Objects.Insert("mybucket", o).Media(f).Do()
if err != nil {
t.Fatalf("unable to insert object: %v", err)
}
g := handler.r
if w := "POST"; g.Method != w {
t.Errorf("Method = %q; want %q", g.Method, w)
}
if w := "HTTP/1.1"; g.Proto != w {
t.Errorf("Proto = %q; want %q", g.Proto, w)
}
if w := 1; g.ProtoMajor != w {
t.Errorf("ProtoMajor = %v; want %v", g.ProtoMajor, w)
}
if w := 1; g.ProtoMinor != w {
t.Errorf("ProtoMinor = %v; want %v", g.ProtoMinor, w)
}
if w, k := "google-api-go-client/0.5", "User-Agent"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if w, k := "multipart/related; boundary=", "Content-Type"; len(g.Header[k]) != 1 || !strings.HasPrefix(g.Header[k][0], w) {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if w, k := "gzip", "Accept-Encoding"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if w := int64(-1); g.ContentLength != w {
t.Errorf("ContentLength = %v; want %v", g.ContentLength, w)
}
if w := "chunked"; len(g.TransferEncoding) != 1 || g.TransferEncoding[0] != w {
t.Errorf("TransferEncoding = %#v; want %q", g.TransferEncoding, w)
}
if w := strings.TrimPrefix(s.BasePath, "http://"); g.Host != w {
t.Errorf("Host = %q; want %q", g.Host, w)
}
if g.Form != nil {
t.Errorf("Form = %#v; want nil", g.Form)
}
if g.PostForm != nil {
t.Errorf("PostForm = %#v; want nil", g.PostForm)
}
if g.MultipartForm != nil {
t.Errorf("MultipartForm = %#v; want nil", g.MultipartForm)
}
if w := "/b/mybucket/o?alt=json&uploadType=multipart"; g.RequestURI != w {
t.Errorf("RequestURI = %q; want %q", g.RequestURI, w)
}
if w := "\r\n\r\n" + body + "\r\n"; !strings.Contains(string(handler.body), w) {
t.Errorf("Body = %q, want substring %q", handler.body, w)
}
if handler.err != nil {
t.Errorf("handler err = %v, want nil", handler.err)
}
}
func TestResumableMedia(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
handler.location = server.URL
client := &http.Client{}
s, err := storage.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
const data = "fake resumable media data"
mediaSize := len(data)
f := strings.NewReader(data)
o := &storage.Object{
Bucket: "mybucket",
Name: "filename",
ContentType: "plain/text",
ContentEncoding: "utf-8",
ContentLanguage: "en",
}
_, err = s.Objects.Insert("mybucket", o).Name("filename").ResumableMedia(context.Background(), f, int64(len(data)), "text/plain").Do()
if err != nil {
t.Fatalf("unable to insert object: %v", err)
}
g := handler.r
if w := "POST"; g.Method != w {
t.Errorf("Method = %q; want %q", g.Method, w)
}
if w := "HTTP/1.1"; g.Proto != w {
t.Errorf("Proto = %q; want %q", g.Proto, w)
}
if w := 1; g.ProtoMajor != w {
t.Errorf("ProtoMajor = %v; want %v", g.ProtoMajor, w)
}
if w := 1; g.ProtoMinor != w {
t.Errorf("ProtoMinor = %v; want %v", g.ProtoMinor, w)
}
if w, k := "google-api-go-client/0.5", "User-Agent"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if want, got := []string{"text/plain"}, g.Header["Content-Type"]; !reflect.DeepEqual(got, want) {
t.Errorf("header Content-Type got: %#v; want: %#v", got, want)
}
if w, k := "gzip", "Accept-Encoding"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if w := int64(mediaSize); g.ContentLength != w {
t.Errorf("ContentLength = %v; want %v", g.ContentLength, w)
}
if len(g.TransferEncoding) != 0 {
t.Errorf("TransferEncoding = %#v; want nil", g.TransferEncoding)
}
if g.Form != nil {
t.Errorf("Form = %#v; want nil", g.Form)
}
if g.PostForm != nil {
t.Errorf("PostForm = %#v; want nil", g.PostForm)
}
if g.MultipartForm != nil {
t.Errorf("MultipartForm = %#v; want nil", g.MultipartForm)
}
if handler.err != nil {
t.Errorf("handler err = %v, want nil", handler.err)
}
}
func TestNoMedia(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := storage.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
o := &storage.Object{
Bucket: "mybucket",
Name: "filename",
ContentType: "plain/text",
ContentEncoding: "utf-8",
ContentLanguage: "en",
}
_, err = s.Objects.Insert("mybucket", o).Do()
if err != nil {
t.Fatalf("unable to insert object: %v", err)
}
g := handler.r
if w := "POST"; g.Method != w {
t.Errorf("Method = %q; want %q", g.Method, w)
}
if w := "HTTP/1.1"; g.Proto != w {
t.Errorf("Proto = %q; want %q", g.Proto, w)
}
if w := 1; g.ProtoMajor != w {
t.Errorf("ProtoMajor = %v; want %v", g.ProtoMajor, w)
}
if w := 1; g.ProtoMinor != w {
t.Errorf("ProtoMinor = %v; want %v", g.ProtoMinor, w)
}
if w, k := "google-api-go-client/0.5", "User-Agent"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if w, k := "application/json", "Content-Type"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if w, k := "gzip", "Accept-Encoding"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
if w := int64(116); g.ContentLength != w {
t.Errorf("ContentLength = %v; want %v", g.ContentLength, w)
}
if len(g.TransferEncoding) != 0 {
t.Errorf("TransferEncoding = %#v; want []string{}", g.TransferEncoding)
}
if w := strings.TrimPrefix(s.BasePath, "http://"); g.Host != w {
t.Errorf("Host = %q; want %q", g.Host, w)
}
if g.Form != nil {
t.Errorf("Form = %#v; want nil", g.Form)
}
if g.PostForm != nil {
t.Errorf("PostForm = %#v; want nil", g.PostForm)
}
if g.MultipartForm != nil {
t.Errorf("MultipartForm = %#v; want nil", g.MultipartForm)
}
if w := "/b/mybucket/o?alt=json"; g.RequestURI != w {
t.Errorf("RequestURI = %q; want %q", g.RequestURI, w)
}
if w := `{"bucket":"mybucket","contentEncoding":"utf-8","contentLanguage":"en","contentType":"plain/text","name":"filename"}` + "\n"; string(handler.body) != w {
t.Errorf("Body = %q, want %q", handler.body, w)
}
if handler.err != nil {
t.Errorf("handler err = %v, want nil", handler.err)
}
}
func TestMediaErrHandling(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := storage.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
const body = "fake media data"
f := strings.NewReader(body)
// The combination of TimeoutReader and OneByteReader causes the first byte to
// be successfully delivered, but then a timeout error is reported.
r := iotest.TimeoutReader(iotest.OneByteReader(f))
o := &storage.Object{
Bucket: "mybucket",
Name: "filename",
ContentType: "plain/text",
ContentEncoding: "utf-8",
ContentLanguage: "en",
}
_, err = s.Objects.Insert("mybucket", o).Media(r).Do()
if err == nil || !strings.Contains(err.Error(), "timeout") {
t.Errorf("expected timeout error, got %v", err)
}
if handler.err != nil {
t.Errorf("handler err = %v, want nil", handler.err)
}
}
func TestUserAgent(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := storage.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
s.UserAgent = "myagent/1.0"
f := strings.NewReader("fake media data")
o := &storage.Object{
Bucket: "mybucket",
Name: "filename",
ContentType: "plain/text",
ContentEncoding: "utf-8",
ContentLanguage: "en",
}
_, err = s.Objects.Insert("mybucket", o).Media(f).Do()
if err != nil {
t.Fatalf("unable to insert object: %v", err)
}
g := handler.r
if w, k := "google-api-go-client/0.5 myagent/1.0", "User-Agent"; len(g.Header[k]) != 1 || g.Header[k][0] != w {
t.Errorf("header %q = %#v; want %q", k, g.Header[k], w)
}
}
func myProgressUpdater(current, total int64) {}
func TestParams(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
handler.location = server.URL + "/uploadURL"
client := &http.Client{}
s, err := storage.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
s.UserAgent = "myagent/1.0"
const data = "fake media data"
f := strings.NewReader(data)
o := &storage.Object{
Bucket: "mybucket",
Name: "filename",
ContentType: "plain/text",
ContentEncoding: "utf-8",
ContentLanguage: "en",
}
_, err = s.Objects.Insert("mybucket", o).Name(o.Name).IfGenerationMatch(42).ResumableMedia(context.Background(), f, int64(len(data)), "plain/text").ProgressUpdater(myProgressUpdater).Projection("full").Do()
if err != nil {
t.Fatalf("unable to insert object: %v", err)
}
if g, w := len(handler.reqURIs), 2; g != w {
t.Fatalf("len(reqURIs) = %v, want %v", g, w)
}
want := []string{
"/b/mybucket/o?alt=json&ifGenerationMatch=42&name=filename&projection=full&uploadType=resumable",
"/uploadURL",
}
if !reflect.DeepEqual(handler.reqURIs, want) {
t.Errorf("reqURIs = %#v, want = %#v", handler.reqURIs, want)
}
}
func TestRepeatedParams(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := dfa.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
s.UserAgent = "myagent/1.0"
cs := dfa.NewCreativesService(s)
_, err = cs.List(10).Active(true).MaxResults(1).Ids(2, 3).PageToken("abc").SizeIds(4, 5).Types("def", "ghi").IfNoneMatch("not-a-param").Do()
if err != nil {
t.Fatalf("dfa.List: %v", err)
}
want := []string{
"/userprofiles/10/creatives?active=true&alt=json&ids=2&ids=3&maxResults=1&pageToken=abc&sizeIds=4&sizeIds=5&types=def&types=ghi",
}
if !reflect.DeepEqual(handler.reqURIs, want) {
t.Errorf("reqURIs = %#v, want = %#v", handler.reqURIs, want)
}
}
// This test verifies that the unmarshal code generated for float64s
// (in this case, the one inside mon.TypedValue) compiles and
// behaves correctly.
func TestUnmarshalSpecialFloats(t *testing.T) {
for _, test := range []struct {
in string
want float64
}{
{`{"doubleValue": 3}`, 3},
{`{"doubleValue": "Infinity"}`, math.Inf(1)},
{`{"doubleValue": "-Infinity"}`, math.Inf(-1)},
{`{"doubleValue": "NaN"}`, math.NaN()},
} {
var got mon.TypedValue
if err := json.Unmarshal([]byte(test.in), &got); err != nil {
t.Fatal(err)
}
if !fleq(*got.DoubleValue, test.want) {
t.Errorf("got\n%+v\nwant\n%+v", *got.DoubleValue, test.want)
}
}
}
func fleq(f1, f2 float64) bool {
return f1 == f2 || (math.IsNaN(f1) && math.IsNaN(f2))
}

View file

@ -0,0 +1,156 @@
// Copyright 2015 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
// canonicalDocsURL is a map from auto-generated documentation URL (originating from
// "documentationLink") to a valid (possibly through 301 redirect[s]) URL.
// If the auto-generated URL is not valid, then it maps to "" and will not
// be added to the auto-generated API comments.
// Note that this map is currently updated manually.
var canonicalDocsURL = map[string]string{
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/cancel": "https://cloud.google.com/compute/docs/instance-groups/manager/#cancelrollingupdate",
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/get": "https://cloud.google.com/compute/docs/instance-groups/manager/#getlistrollingupdate",
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/insert": "https://cloud.google.com/compute/docs/instance-groups/manager/#starting_an_update",
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/list": "https://cloud.google.com/compute/docs/instance-groups/manager/#getlistrollingupdate",
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/listInstanceUpdates": "https://cloud.google.com/compute/docs/instance-groups/manager/#getlistrollingupdate",
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/pause": "https://cloud.google.com/compute/docs/instance-groups/manager/#pausing_a_rolling_update",
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/resume": "https://cloud.google.com/compute/docs/instance-groups/manager/#continuerollingupdate",
"https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_servicerollingUpdates/rollback": "https://cloud.google.com/compute/docs/instance-groups/manager/#rollingbackupdate",
"https://developers.google.com/compute/docs/reference/latest/addresses/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/addresses/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/addresses/delete": "https://cloud.google.com/compute/docs/reference/latest/addresses/delete",
"https://developers.google.com/compute/docs/reference/latest/addresses/get": "https://cloud.google.com/compute/docs/reference/latest/addresses/get",
"https://developers.google.com/compute/docs/reference/latest/addresses/insert": "https://cloud.google.com/compute/docs/reference/latest/addresses/insert",
"https://developers.google.com/compute/docs/reference/latest/addresses/list": "https://cloud.google.com/compute/docs/reference/latest/addresses/list",
"https://developers.google.com/compute/docs/reference/latest/backendServices/delete": "https://cloud.google.com/compute/docs/reference/latest/backendServices/delete",
"https://developers.google.com/compute/docs/reference/latest/backendServices/get": "https://cloud.google.com/compute/docs/reference/latest/backendServices/get",
"https://developers.google.com/compute/docs/reference/latest/backendServices/getHealth": "https://cloud.google.com/compute/docs/reference/latest/backendServices/getHealth",
"https://developers.google.com/compute/docs/reference/latest/backendServices/insert": "https://cloud.google.com/compute/docs/reference/latest/backendServices/insert",
"https://developers.google.com/compute/docs/reference/latest/backendServices/list": "https://cloud.google.com/compute/docs/reference/latest/backendServices/list",
"https://developers.google.com/compute/docs/reference/latest/backendServices/patch": "https://cloud.google.com/compute/docs/reference/latest/backendServices/patch",
"https://developers.google.com/compute/docs/reference/latest/backendServices/update": "https://cloud.google.com/compute/docs/reference/latest/backendServices/update",
"https://developers.google.com/compute/docs/reference/latest/diskTypes/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/diskTypes/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/diskTypes/get": "https://cloud.google.com/compute/docs/reference/latest/diskTypes/get",
"https://developers.google.com/compute/docs/reference/latest/diskTypes/list": "https://cloud.google.com/compute/docs/reference/latest/diskTypes/list",
"https://developers.google.com/compute/docs/reference/latest/disks/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/disks/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/disks/createSnapshot": "https://cloud.google.com/compute/docs/reference/latest/disks/createSnapshot",
"https://developers.google.com/compute/docs/reference/latest/disks/delete": "https://cloud.google.com/compute/docs/reference/latest/disks/delete",
"https://developers.google.com/compute/docs/reference/latest/disks/get": "https://cloud.google.com/compute/docs/reference/latest/disks/get",
"https://developers.google.com/compute/docs/reference/latest/disks/insert": "https://cloud.google.com/compute/docs/reference/latest/disks/insert",
"https://developers.google.com/compute/docs/reference/latest/disks/list": "https://cloud.google.com/compute/docs/reference/latest/disks/list",
"https://developers.google.com/compute/docs/reference/latest/firewalls/delete": "https://cloud.google.com/compute/docs/reference/latest/firewalls/delete",
"https://developers.google.com/compute/docs/reference/latest/firewalls/get": "https://cloud.google.com/compute/docs/reference/latest/firewalls/get",
"https://developers.google.com/compute/docs/reference/latest/firewalls/insert": "https://cloud.google.com/compute/docs/reference/latest/firewalls/insert",
"https://developers.google.com/compute/docs/reference/latest/firewalls/list": "https://cloud.google.com/compute/docs/reference/latest/firewalls/list",
"https://developers.google.com/compute/docs/reference/latest/firewalls/patch": "https://cloud.google.com/compute/docs/reference/latest/firewalls/patch",
"https://developers.google.com/compute/docs/reference/latest/firewalls/update": "https://cloud.google.com/compute/docs/reference/latest/firewalls/update",
"https://developers.google.com/compute/docs/reference/latest/forwardingRules/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/forwardingRules/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/forwardingRules/delete": "https://cloud.google.com/compute/docs/reference/latest/forwardingRules/delete",
"https://developers.google.com/compute/docs/reference/latest/forwardingRules/get": "https://cloud.google.com/compute/docs/reference/latest/forwardingRules/get",
"https://developers.google.com/compute/docs/reference/latest/forwardingRules/insert": "https://cloud.google.com/compute/docs/reference/latest/forwardingRules/insert",
"https://developers.google.com/compute/docs/reference/latest/forwardingRules/list": "https://cloud.google.com/compute/docs/reference/latest/forwardingRules/list",
"https://developers.google.com/compute/docs/reference/latest/forwardingRules/setTarget": "https://cloud.google.com/compute/docs/reference/latest/forwardingRules/setTarget",
"https://developers.google.com/compute/docs/reference/latest/globalAddresses/delete": "https://cloud.google.com/compute/docs/reference/latest/globalAddresses/delete",
"https://developers.google.com/compute/docs/reference/latest/globalAddresses/get": "https://cloud.google.com/compute/docs/reference/latest/globalAddresses/get",
"https://developers.google.com/compute/docs/reference/latest/globalAddresses/insert": "https://cloud.google.com/compute/docs/reference/latest/globalAddresses/insert",
"https://developers.google.com/compute/docs/reference/latest/globalAddresses/list": "https://cloud.google.com/compute/docs/reference/latest/globalAddresses/list",
"https://developers.google.com/compute/docs/reference/latest/globalForwardingRules/delete": "https://cloud.google.com/compute/docs/reference/latest/globalForwardingRules/delete",
"https://developers.google.com/compute/docs/reference/latest/globalForwardingRules/get": "https://cloud.google.com/compute/docs/reference/latest/globalForwardingRules/get",
"https://developers.google.com/compute/docs/reference/latest/globalForwardingRules/insert": "https://cloud.google.com/compute/docs/reference/latest/globalForwardingRules/insert",
"https://developers.google.com/compute/docs/reference/latest/globalForwardingRules/list": "https://cloud.google.com/compute/docs/reference/latest/globalForwardingRules/list",
"https://developers.google.com/compute/docs/reference/latest/globalForwardingRules/setTarget": "https://cloud.google.com/compute/docs/reference/latest/globalForwardingRules/setTarget",
"https://developers.google.com/compute/docs/reference/latest/globalOperations/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/globalOperations/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/globalOperations/delete": "https://cloud.google.com/compute/docs/reference/latest/globalOperations/delete",
"https://developers.google.com/compute/docs/reference/latest/globalOperations/get": "https://cloud.google.com/compute/docs/reference/latest/globalOperations/get",
"https://developers.google.com/compute/docs/reference/latest/globalOperations/list": "https://cloud.google.com/compute/docs/reference/latest/globalOperations/list",
"https://developers.google.com/compute/docs/reference/latest/httpHealthChecks/delete": "https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks/delete",
"https://developers.google.com/compute/docs/reference/latest/httpHealthChecks/get": "https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks/get",
"https://developers.google.com/compute/docs/reference/latest/httpHealthChecks/insert": "https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks/insert",
"https://developers.google.com/compute/docs/reference/latest/httpHealthChecks/list": "https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks/list",
"https://developers.google.com/compute/docs/reference/latest/httpHealthChecks/patch": "https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks/patch",
"https://developers.google.com/compute/docs/reference/latest/httpHealthChecks/update": "https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks/update",
"https://developers.google.com/compute/docs/reference/latest/images/delete": "https://cloud.google.com/compute/docs/reference/latest/images/delete",
"https://developers.google.com/compute/docs/reference/latest/images/deprecate": "https://cloud.google.com/compute/docs/reference/latest/images/deprecate",
"https://developers.google.com/compute/docs/reference/latest/images/get": "https://cloud.google.com/compute/docs/reference/latest/images/get",
"https://developers.google.com/compute/docs/reference/latest/images/insert": "https://cloud.google.com/compute/docs/reference/latest/images/insert",
"https://developers.google.com/compute/docs/reference/latest/images/list": "https://cloud.google.com/compute/docs/reference/latest/images/list",
"https://developers.google.com/compute/docs/reference/latest/instanceTemplates/delete": "https://cloud.google.com/compute/docs/reference/latest/instanceTemplates/delete",
"https://developers.google.com/compute/docs/reference/latest/instanceTemplates/get": "https://cloud.google.com/compute/docs/reference/latest/instanceTemplates/get",
"https://developers.google.com/compute/docs/reference/latest/instanceTemplates/insert": "https://cloud.google.com/compute/docs/reference/latest/instanceTemplates/insert",
"https://developers.google.com/compute/docs/reference/latest/instanceTemplates/list": "https://cloud.google.com/compute/docs/reference/latest/instanceTemplates/list",
"https://developers.google.com/compute/docs/reference/latest/instances/addAccessConfig": "https://cloud.google.com/compute/docs/reference/latest/instances/addAccessConfig",
"https://developers.google.com/compute/docs/reference/latest/instances/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/instances/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/instances/attachDisk": "https://cloud.google.com/compute/docs/reference/latest/instances/attachDisk",
"https://developers.google.com/compute/docs/reference/latest/instances/delete": "https://cloud.google.com/compute/docs/reference/latest/instances/delete",
"https://developers.google.com/compute/docs/reference/latest/instances/deleteAccessConfig": "https://cloud.google.com/compute/docs/reference/latest/instances/deleteAccessConfig",
"https://developers.google.com/compute/docs/reference/latest/instances/detachDisk": "https://cloud.google.com/compute/docs/reference/latest/instances/detachDisk",
"https://developers.google.com/compute/docs/reference/latest/instances/get": "https://cloud.google.com/compute/docs/reference/latest/instances/get",
"https://developers.google.com/compute/docs/reference/latest/instances/getSerialPortOutput": "https://cloud.google.com/compute/docs/reference/latest/instances/getSerialPortOutput",
"https://developers.google.com/compute/docs/reference/latest/instances/insert": "https://cloud.google.com/compute/docs/reference/latest/instances/insert",
"https://developers.google.com/compute/docs/reference/latest/instances/list": "https://cloud.google.com/compute/docs/reference/latest/instances/list",
"https://developers.google.com/compute/docs/reference/latest/instances/reset": "https://cloud.google.com/compute/docs/reference/latest/instances/reset",
"https://developers.google.com/compute/docs/reference/latest/instances/setDiskAutoDelete": "https://cloud.google.com/compute/docs/reference/latest/instances/setDiskAutoDelete",
"https://developers.google.com/compute/docs/reference/latest/instances/setMetadata": "https://cloud.google.com/compute/docs/reference/latest/instances/setMetadata",
"https://developers.google.com/compute/docs/reference/latest/instances/setScheduling": "https://cloud.google.com/compute/docs/reference/latest/instances/setScheduling",
"https://developers.google.com/compute/docs/reference/latest/instances/setTags": "https://cloud.google.com/compute/docs/reference/latest/instances/setTags",
"https://developers.google.com/compute/docs/reference/latest/instances/start": "https://cloud.google.com/compute/docs/reference/latest/instances/start",
"https://developers.google.com/compute/docs/reference/latest/instances/stop": "https://cloud.google.com/compute/docs/reference/latest/instances/stop",
"https://developers.google.com/compute/docs/reference/latest/licenses/get": "https://cloud.google.com/compute/docs/reference/latest/licenses/get",
"https://developers.google.com/compute/docs/reference/latest/machineTypes/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/machineTypes/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/machineTypes/get": "https://cloud.google.com/compute/docs/reference/latest/machineTypes/get",
"https://developers.google.com/compute/docs/reference/latest/machineTypes/list": "https://cloud.google.com/compute/docs/reference/latest/machineTypes/list",
"https://developers.google.com/compute/docs/reference/latest/networks/delete": "https://cloud.google.com/compute/docs/reference/latest/networks/delete",
"https://developers.google.com/compute/docs/reference/latest/networks/get": "https://cloud.google.com/compute/docs/reference/latest/networks/get",
"https://developers.google.com/compute/docs/reference/latest/networks/insert": "https://cloud.google.com/compute/docs/reference/latest/networks/insert",
"https://developers.google.com/compute/docs/reference/latest/networks/list": "https://cloud.google.com/compute/docs/reference/latest/networks/list",
"https://developers.google.com/compute/docs/reference/latest/projects/get": "https://cloud.google.com/compute/docs/reference/latest/projects/get",
"https://developers.google.com/compute/docs/reference/latest/projects/setCommonInstanceMetadata": "https://cloud.google.com/compute/docs/reference/latest/projects/setCommonInstanceMetadata",
"https://developers.google.com/compute/docs/reference/latest/projects/setUsageExportBucket": "https://cloud.google.com/compute/docs/reference/latest/projects/setUsageExportBucket",
"https://developers.google.com/compute/docs/reference/latest/regionOperations/delete": "https://cloud.google.com/compute/docs/reference/latest/regionOperations/delete",
"https://developers.google.com/compute/docs/reference/latest/regionOperations/get": "https://cloud.google.com/compute/docs/reference/latest/regionOperations/get",
"https://developers.google.com/compute/docs/reference/latest/regionOperations/list": "https://cloud.google.com/compute/docs/reference/latest/regionOperations/list",
"https://developers.google.com/compute/docs/reference/latest/regions/get": "https://cloud.google.com/compute/docs/reference/latest/regions/get",
"https://developers.google.com/compute/docs/reference/latest/regions/list": "https://cloud.google.com/compute/docs/reference/latest/regions/list",
"https://developers.google.com/compute/docs/reference/latest/routes/delete": "https://cloud.google.com/compute/docs/reference/latest/routes/delete",
"https://developers.google.com/compute/docs/reference/latest/routes/get": "https://cloud.google.com/compute/docs/reference/latest/routes/get",
"https://developers.google.com/compute/docs/reference/latest/routes/insert": "https://cloud.google.com/compute/docs/reference/latest/routes/insert",
"https://developers.google.com/compute/docs/reference/latest/routes/list": "https://cloud.google.com/compute/docs/reference/latest/routes/list",
"https://developers.google.com/compute/docs/reference/latest/snapshots/delete": "https://cloud.google.com/compute/docs/reference/latest/snapshots/delete",
"https://developers.google.com/compute/docs/reference/latest/snapshots/get": "https://cloud.google.com/compute/docs/reference/latest/snapshots/get",
"https://developers.google.com/compute/docs/reference/latest/snapshots/list": "https://cloud.google.com/compute/docs/reference/latest/snapshots/list",
"https://developers.google.com/compute/docs/reference/latest/targetHttpProxies/delete": "https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies/delete",
"https://developers.google.com/compute/docs/reference/latest/targetHttpProxies/get": "https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies/get",
"https://developers.google.com/compute/docs/reference/latest/targetHttpProxies/insert": "https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies/insert",
"https://developers.google.com/compute/docs/reference/latest/targetHttpProxies/list": "https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies/list",
"https://developers.google.com/compute/docs/reference/latest/targetHttpProxies/setUrlMap": "https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies/setUrlMap",
"https://developers.google.com/compute/docs/reference/latest/targetInstances/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/targetInstances/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/targetInstances/delete": "https://cloud.google.com/compute/docs/reference/latest/targetInstances/delete",
"https://developers.google.com/compute/docs/reference/latest/targetInstances/get": "https://cloud.google.com/compute/docs/reference/latest/targetInstances/get",
"https://developers.google.com/compute/docs/reference/latest/targetInstances/insert": "https://cloud.google.com/compute/docs/reference/latest/targetInstances/insert",
"https://developers.google.com/compute/docs/reference/latest/targetInstances/list": "https://cloud.google.com/compute/docs/reference/latest/targetInstances/list",
"https://developers.google.com/compute/docs/reference/latest/targetPools/addHealthCheck": "https://cloud.google.com/compute/docs/reference/latest/targetPools/addHealthCheck",
"https://developers.google.com/compute/docs/reference/latest/targetPools/addInstance": "https://cloud.google.com/compute/docs/reference/latest/targetPools/addInstance",
"https://developers.google.com/compute/docs/reference/latest/targetPools/aggregatedList": "https://cloud.google.com/compute/docs/reference/latest/targetPools/aggregatedList",
"https://developers.google.com/compute/docs/reference/latest/targetPools/delete": "https://cloud.google.com/compute/docs/reference/latest/targetPools/delete",
"https://developers.google.com/compute/docs/reference/latest/targetPools/get": "https://cloud.google.com/compute/docs/reference/latest/targetPools/get",
"https://developers.google.com/compute/docs/reference/latest/targetPools/getHealth": "https://cloud.google.com/compute/docs/reference/latest/targetPools/getHealth",
"https://developers.google.com/compute/docs/reference/latest/targetPools/insert": "https://cloud.google.com/compute/docs/reference/latest/targetPools/insert",
"https://developers.google.com/compute/docs/reference/latest/targetPools/list": "https://cloud.google.com/compute/docs/reference/latest/targetPools/list",
"https://developers.google.com/compute/docs/reference/latest/targetPools/removeHealthCheck": "https://cloud.google.com/compute/docs/reference/latest/targetPools/removeHealthCheck",
"https://developers.google.com/compute/docs/reference/latest/targetPools/removeInstance": "https://cloud.google.com/compute/docs/reference/latest/targetPools/removeInstance",
"https://developers.google.com/compute/docs/reference/latest/targetPools/setBackup": "https://cloud.google.com/compute/docs/reference/latest/targetPools/setBackup",
"https://developers.google.com/compute/docs/reference/latest/urlMaps/delete": "https://cloud.google.com/compute/docs/reference/latest/urlMaps/delete",
"https://developers.google.com/compute/docs/reference/latest/urlMaps/get": "https://cloud.google.com/compute/docs/reference/latest/urlMaps/get",
"https://developers.google.com/compute/docs/reference/latest/urlMaps/insert": "https://cloud.google.com/compute/docs/reference/latest/urlMaps/insert",
"https://developers.google.com/compute/docs/reference/latest/urlMaps/list": "https://cloud.google.com/compute/docs/reference/latest/urlMaps/list",
"https://developers.google.com/compute/docs/reference/latest/urlMaps/patch": "https://cloud.google.com/compute/docs/reference/latest/urlMaps/patch",
"https://developers.google.com/compute/docs/reference/latest/urlMaps/update": "https://cloud.google.com/compute/docs/reference/latest/urlMaps/update",
"https://developers.google.com/compute/docs/reference/latest/urlMaps/validate": "https://cloud.google.com/compute/docs/reference/latest/urlMaps/validate",
"https://developers.google.com/compute/docs/reference/latest/zoneOperations/delete": "https://cloud.google.com/compute/docs/reference/latest/zoneOperations/delete",
"https://developers.google.com/compute/docs/reference/latest/zoneOperations/get": "https://cloud.google.com/compute/docs/reference/latest/zoneOperations/get",
"https://developers.google.com/compute/docs/reference/latest/zoneOperations/list": "https://cloud.google.com/compute/docs/reference/latest/zoneOperations/list",
"https://developers.google.com/compute/docs/reference/latest/zones/get": "https://cloud.google.com/compute/docs/reference/latest/zones/get",
"https://developers.google.com/compute/docs/reference/latest/zones/list": "https://cloud.google.com/compute/docs/reference/latest/zones/list",
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,211 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"bytes"
"flag"
"io/ioutil"
"path/filepath"
"strings"
"testing"
)
var updateGolden = flag.Bool("update_golden", false, "If true, causes TestAPIs to update golden files")
func TestAPIs(t *testing.T) {
names := []string{
"any",
"arrayofarray-1",
"arrayofenum",
"arrayofmapofobjects",
"arrayofmapofstrings",
"blogger-3",
"floats",
"getwithoutbody",
"mapofany",
"mapofarrayofobjects",
"mapofint64strings",
"mapofobjects",
"mapofstrings-1",
"param-rename",
"quotednum",
"repeated",
"resource-named-service", // appengine/v1/appengine-api.json
"unfortunatedefaults",
"variants",
"wrapnewlines",
}
for _, name := range names {
t.Logf("TEST %s", name)
api, err := apiFromFile(filepath.Join("testdata", name+".json"))
if err != nil {
t.Errorf("Error loading API testdata/%s.json: %v", name, err)
continue
}
clean, err := api.GenerateCode()
if err != nil {
t.Errorf("Error generating code for %s: %v", name, err)
continue
}
goldenFile := filepath.Join("testdata", name+".want")
if *updateGolden {
if err := ioutil.WriteFile(goldenFile, clean, 0644); err != nil {
t.Fatal(err)
}
}
want, err := ioutil.ReadFile(goldenFile)
if err != nil {
t.Error(err)
continue
}
if !bytes.Equal(want, clean) {
tf, _ := ioutil.TempFile("", "api-"+name+"-got-json.")
tf.Write(clean)
tf.Close()
t.Errorf("Output for API %s differs: diff -u %s %s", name, goldenFile, tf.Name())
}
}
}
func TestScope(t *testing.T) {
tests := [][]string{
{
"https://www.googleapis.com/auth/somescope",
"SomescopeScope",
},
{
"https://mail.google.com/somescope",
"MailGoogleComSomescopeScope",
},
{
"https://mail.google.com/",
"MailGoogleComScope",
},
}
for _, test := range tests {
if got := scopeIdentifierFromURL(test[0]); got != test[1] {
t.Errorf("scopeIdentifierFromURL(%q) got %q, want %q", test[0], got, test[1])
}
}
}
func TestDepunct(t *testing.T) {
tests := []struct {
needCap bool
in, want string
}{
{
needCap: true,
in: "part__description",
want: "Part__description",
},
{
needCap: true,
in: "Part_description",
want: "PartDescription",
},
{
needCap: false,
in: "part_description",
want: "partDescription",
},
{
needCap: false,
in: "part-description",
want: "partDescription",
},
{
needCap: false,
in: "part.description",
want: "partDescription",
},
{
needCap: false,
in: "part$description",
want: "partDescription",
},
{
needCap: false,
in: "part/description",
want: "partDescription",
},
{
needCap: true,
in: "Part__description_name",
want: "Part__descriptionName",
},
{
needCap: true,
in: "Part_description_name",
want: "PartDescriptionName",
},
{
needCap: true,
in: "Part__description__name",
want: "Part__description__name",
},
{
needCap: true,
in: "Part_description__name",
want: "PartDescription__name",
},
}
for _, test := range tests {
if got := depunct(test.in, test.needCap); got != test.want {
t.Errorf("depunct(%q,%v) = %q; want %q", test.in, test.needCap, got, test.want)
}
}
}
func TestRenameVersion(t *testing.T) {
tests := []struct {
version, want string
}{
{
version: "directory_v1",
want: "directory/v1",
},
{
version: "email_migration_v1",
want: "email_migration/v1",
},
{
version: "my_api_v1.2",
want: "my_api/v1.2",
},
}
for _, test := range tests {
if got := renameVersion(test.version); got != test.want {
t.Errorf("renameVersion(%q) = %q; want %q", test.version, got, test.want)
}
}
}
func TestSupportsPaging(t *testing.T) {
api, err := apiFromFile(filepath.Join("testdata", "paging.json"))
if err != nil {
t.Fatalf("Error loading API testdata/paging.json: %v", err)
}
api.PopulateSchemas()
res := api.doc.Resources[0]
for _, meth := range api.resourceMethods(res) {
_, _, got := meth.supportsPaging()
want := strings.HasPrefix(meth.m.Name, "yes")
if got != want {
t.Errorf("method %s supports paging: got %t, want %t", meth.m.Name, got, want)
}
}
}

View file

@ -0,0 +1,427 @@
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package disco represents Google API discovery documents.
package disco
import (
"encoding/json"
"fmt"
"reflect"
"sort"
"strings"
)
// A Document is an API discovery document.
type Document struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Title string `json:"title"`
RootURL string `json:"rootUrl"`
ServicePath string `json:"servicePath"`
BasePath string `json:"basePath"`
DocumentationLink string `json:"documentationLink"`
Auth Auth `json:"auth"`
Features []string `json:"features"`
Methods MethodList `json:"methods"`
Schemas map[string]*Schema `json:"schemas"`
Resources ResourceList `json:"resources"`
}
// init performs additional initialization and checks that
// were not done during unmarshaling.
func (d *Document) init() error {
schemasByID := map[string]*Schema{}
for _, s := range d.Schemas {
schemasByID[s.ID] = s
}
for name, s := range d.Schemas {
if s.Ref != "" {
return fmt.Errorf("top level schema %q is a reference", name)
}
s.Name = name
if err := s.init(schemasByID); err != nil {
return err
}
}
for _, m := range d.Methods {
if err := m.init(schemasByID); err != nil {
return err
}
}
for _, r := range d.Resources {
if err := r.init("", schemasByID); err != nil {
return err
}
}
return nil
}
// NewDocument unmarshals the bytes into a Document.
// It also validates the document to make sure it is error-free.
func NewDocument(bytes []byte) (*Document, error) {
var doc Document
if err := json.Unmarshal(bytes, &doc); err != nil {
return nil, err
}
if err := doc.init(); err != nil {
return nil, err
}
return &doc, nil
}
// Auth represents the auth section of a discovery document.
// Only OAuth2 information is retained.
type Auth struct {
OAuth2Scopes []Scope
}
// A Scope is an OAuth2 scope.
type Scope struct {
URL string
Description string
}
// UnmarshalJSON implements the json.Unmarshaler interface.
func (a *Auth) UnmarshalJSON(data []byte) error {
// Pull out the oauth2 scopes and turn them into nice structs.
// Ignore other auth information.
var m struct {
OAuth2 struct {
Scopes map[string]struct {
Description string
}
}
}
if err := json.Unmarshal(data, &m); err != nil {
return err
}
// Sort keys to provide a deterministic ordering, mainly for testing.
for _, k := range sortedKeys(m.OAuth2.Scopes) {
a.OAuth2Scopes = append(a.OAuth2Scopes, Scope{
URL: k,
Description: m.OAuth2.Scopes[k].Description,
})
}
return nil
}
// A Schema holds a JSON Schema as defined by
// https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1.
// We only support the subset of JSON Schema needed for Google API generation.
type Schema struct {
ID string // union types not supported
Type string // union types not supported
Format string
Description string
Properties PropertyList
ItemSchema *Schema `json:"items"` // array of schemas not supported
AdditionalProperties *Schema // boolean not supported
Ref string `json:"$ref"`
Default string
Pattern string
Enums []string `json:"enum"`
// Google extensions to JSON Schema
EnumDescriptions []string
Variant *Variant
RefSchema *Schema `json:"-"` // Schema referred to by $ref
Name string `json:"-"` // Schema name, if top level
Kind Kind `json:"-"`
}
type Variant struct {
Discriminant string
Map []*VariantMapItem
}
type VariantMapItem struct {
TypeValue string `json:"type_value"`
Ref string `json:"$ref"`
}
func (s *Schema) init(topLevelSchemas map[string]*Schema) error {
if s == nil {
return nil
}
var err error
if s.Ref != "" {
if s.RefSchema, err = resolveRef(s.Ref, topLevelSchemas); err != nil {
return err
}
}
s.Kind, err = s.initKind()
if err != nil {
return err
}
if s.Kind == ArrayKind && s.ItemSchema == nil {
return fmt.Errorf("schema %+v: array does not have items", s)
}
if s.Kind != ArrayKind && s.ItemSchema != nil {
return fmt.Errorf("schema %+v: non-array has items", s)
}
if err := s.AdditionalProperties.init(topLevelSchemas); err != nil {
return err
}
if err := s.ItemSchema.init(topLevelSchemas); err != nil {
return err
}
for _, p := range s.Properties {
if err := p.Schema.init(topLevelSchemas); err != nil {
return err
}
}
return nil
}
func resolveRef(ref string, topLevelSchemas map[string]*Schema) (*Schema, error) {
rs, ok := topLevelSchemas[ref]
if !ok {
return nil, fmt.Errorf("could not resolve schema reference %q", ref)
}
return rs, nil
}
func (s *Schema) initKind() (Kind, error) {
if s.Ref != "" {
return ReferenceKind, nil
}
switch s.Type {
case "string", "number", "integer", "boolean", "any":
return SimpleKind, nil
case "object":
if s.AdditionalProperties != nil {
if s.AdditionalProperties.Type == "any" {
return AnyStructKind, nil
}
return MapKind, nil
}
return StructKind, nil
case "array":
return ArrayKind, nil
default:
return 0, fmt.Errorf("unknown type %q for schema %q", s.Type, s.ID)
}
}
// ElementSchema returns the schema for the element type of s. For maps,
// this is the schema of the map values. For arrays, it is the schema
// of the array item type.
//
// ElementSchema panics if called on a schema that is not of kind map or array.
func (s *Schema) ElementSchema() *Schema {
switch s.Kind {
case MapKind:
return s.AdditionalProperties
case ArrayKind:
return s.ItemSchema
default:
panic("ElementSchema called on schema of type " + s.Type)
}
}
// IsIntAsString reports whether the schema represents an integer value
// formatted as a string.
func (s *Schema) IsIntAsString() bool {
return s.Type == "string" && strings.Contains(s.Format, "int")
}
// Kind classifies a Schema.
type Kind int
const (
// SimpleKind is the category for any JSON Schema that maps to a
// primitive Go type: strings, numbers, booleans, and "any" (since it
// maps to interface{}).
SimpleKind Kind = iota
// StructKind is the category for a JSON Schema that declares a JSON
// object without any additional (arbitrary) properties.
StructKind
// MapKind is the category for a JSON Schema that declares a JSON
// object with additional (arbitrary) properties that have a non-"any"
// schema type.
MapKind
// AnyStructKind is the category for a JSON Schema that declares a
// JSON object with additional (arbitrary) properties that can be any
// type.
AnyStructKind
// ArrayKind is the category for a JSON Schema that declares an
// "array" type.
ArrayKind
// ReferenceKind is the category for a JSON Schema that is a reference
// to another JSON Schema. During code generation, these references
// are resolved using the API.schemas map.
// See https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.28
// for more details on the format.
ReferenceKind
)
type Property struct {
Name string
Schema *Schema
}
type PropertyList []*Property
func (pl *PropertyList) UnmarshalJSON(data []byte) error {
// In the discovery doc, properties are a map. Convert to a list.
var m map[string]*Schema
if err := json.Unmarshal(data, &m); err != nil {
return err
}
for _, k := range sortedKeys(m) {
*pl = append(*pl, &Property{
Name: k,
Schema: m[k],
})
}
return nil
}
type ResourceList []*Resource
func (rl *ResourceList) UnmarshalJSON(data []byte) error {
// In the discovery doc, resources are a map. Convert to a list.
var m map[string]*Resource
if err := json.Unmarshal(data, &m); err != nil {
return err
}
for _, k := range sortedKeys(m) {
r := m[k]
r.Name = k
*rl = append(*rl, r)
}
return nil
}
// A Resource holds information about a Google API Resource.
type Resource struct {
Name string
FullName string // {parent.FullName}.{Name}
Methods MethodList
Resources ResourceList
}
func (r *Resource) init(parentFullName string, topLevelSchemas map[string]*Schema) error {
r.FullName = fmt.Sprintf("%s.%s", parentFullName, r.Name)
for _, m := range r.Methods {
if err := m.init(topLevelSchemas); err != nil {
return err
}
}
for _, r2 := range r.Resources {
if err := r2.init(r.FullName, topLevelSchemas); err != nil {
return err
}
}
return nil
}
type MethodList []*Method
func (ml *MethodList) UnmarshalJSON(data []byte) error {
// In the discovery doc, resources are a map. Convert to a list.
var m map[string]*Method
if err := json.Unmarshal(data, &m); err != nil {
return err
}
for _, k := range sortedKeys(m) {
meth := m[k]
meth.Name = k
*ml = append(*ml, meth)
}
return nil
}
// A Method holds information about a resource method.
type Method struct {
Name string
ID string
Path string
HTTPMethod string
Description string
Parameters ParameterList
ParameterOrder []string
Request *Schema
Response *Schema
Scopes []string
MediaUpload *MediaUpload
SupportsMediaDownload bool
JSONMap map[string]interface{} `json:"-"`
}
type MediaUpload struct {
Accept []string
MaxSize string
Protocols map[string]Protocol
}
type Protocol struct {
Multipart bool
Path string
}
func (m *Method) init(topLevelSchemas map[string]*Schema) error {
if err := m.Request.init(topLevelSchemas); err != nil {
return err
}
if err := m.Response.init(topLevelSchemas); err != nil {
return err
}
return nil
}
func (m *Method) UnmarshalJSON(data []byte) error {
type T Method // avoid a recursive call to UnmarshalJSON
if err := json.Unmarshal(data, (*T)(m)); err != nil {
return err
}
// Keep the unmarshalled map around, because the generator
// outputs it as a comment after the method body.
// TODO(jba): make this unnecessary.
return json.Unmarshal(data, &m.JSONMap)
}
type ParameterList []*Parameter
func (pl *ParameterList) UnmarshalJSON(data []byte) error {
// In the discovery doc, resources are a map. Convert to a list.
var m map[string]*Parameter
if err := json.Unmarshal(data, &m); err != nil {
return err
}
for _, k := range sortedKeys(m) {
p := m[k]
p.Name = k
*pl = append(*pl, p)
}
return nil
}
// A Parameter holds information about a method parameter.
type Parameter struct {
Name string
Schema
Required bool
Repeated bool
Location string
}
// sortedKeys returns the keys of m, which must be a map[string]T, in sorted order.
func sortedKeys(m interface{}) []string {
vkeys := reflect.ValueOf(m).MapKeys()
var keys []string
for _, vk := range vkeys {
keys = append(keys, vk.Interface().(string))
}
sort.Strings(keys)
return keys
}

View file

@ -0,0 +1,264 @@
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package disco
import (
"io/ioutil"
"reflect"
"testing"
)
var stringSchema = &Schema{
Type: "string",
Kind: SimpleKind,
}
func TestDocument(t *testing.T) {
bytes, err := ioutil.ReadFile("testdata/test-api.json")
if err != nil {
t.Fatal(err)
}
got, err := NewDocument(bytes)
if err != nil {
t.Fatal(err)
}
want := &Document{
ID: "storage:v1",
Name: "storage",
Version: "v1",
Title: "Cloud Storage JSON API",
RootURL: "https://www.googleapis.com/",
ServicePath: "storage/v1/",
BasePath: "/storage/v1/",
DocumentationLink: "https://developers.google.com/storage/docs/json_api/",
Auth: Auth{
OAuth2Scopes: []Scope{
{"https://www.googleapis.com/auth/cloud-platform",
"View and manage your data across Google Cloud Platform services"},
{"https://www.googleapis.com/auth/cloud-platform.read-only",
"View your data across Google Cloud Platform services"},
{"https://www.googleapis.com/auth/devstorage.full_control",
"Manage your data and permissions in Google Cloud Storage"},
{"https://www.googleapis.com/auth/devstorage.read_only",
"View your data in Google Cloud Storage"},
{"https://www.googleapis.com/auth/devstorage.read_write",
"Manage your data in Google Cloud Storage"},
},
},
Features: []string{"dataWrapper"},
Schemas: map[string]*Schema{
"Bucket": &Schema{
Name: "Bucket",
ID: "Bucket",
Type: "object",
Description: "A bucket.",
Kind: StructKind,
Properties: []*Property{
{"cors", &Schema{
Type: "array",
Kind: ArrayKind,
ItemSchema: &Schema{
Type: "object",
Kind: StructKind,
Properties: []*Property{
{"maxAgeSeconds", &Schema{
Type: "integer",
Format: "int32",
Kind: SimpleKind,
}},
{"method", &Schema{
Type: "array",
Kind: ArrayKind,
ItemSchema: stringSchema,
}},
},
},
}},
{"id", stringSchema},
{"kind", &Schema{
Type: "string",
Kind: SimpleKind,
Default: "storage#bucket",
}},
},
},
"Buckets": &Schema{
ID: "Buckets",
Name: "Buckets",
Type: "object",
Kind: StructKind,
Properties: []*Property{
{"items", &Schema{
Type: "array",
Kind: ArrayKind,
ItemSchema: &Schema{
Kind: ReferenceKind,
Ref: "Bucket",
RefSchema: nil,
},
}},
},
},
"VariantExample": &Schema{
ID: "VariantExample",
Name: "VariantExample",
Type: "object",
Kind: StructKind,
Variant: &Variant{
Discriminant: "type",
Map: []*VariantMapItem{
{TypeValue: "Bucket", Ref: "Bucket"},
{TypeValue: "Buckets", Ref: "Buckets"},
},
},
},
},
Methods: MethodList{
&Method{
Name: "getCertForOpenIdConnect",
ID: "oauth2.getCertForOpenIdConnect",
Path: "oauth2/v1/certs",
HTTPMethod: "GET",
Response: &Schema{Ref: "Bucket", Kind: ReferenceKind},
},
},
Resources: ResourceList{
&Resource{
Name: "buckets",
FullName: ".buckets",
Methods: MethodList{
&Method{
Name: "get",
ID: "storage.buckets.get",
Path: "b/{bucket}",
HTTPMethod: "GET",
Description: "d",
Parameters: ParameterList{
&Parameter{
Name: "bucket",
Schema: Schema{
Type: "string",
},
Required: true,
Location: "path",
},
&Parameter{
Name: "ifMetagenerationMatch",
Schema: Schema{
Type: "string",
Format: "int64",
},
Location: "query",
},
&Parameter{
Name: "projection",
Schema: Schema{
Type: "string",
Enums: []string{"full", "noAcl"},
EnumDescriptions: []string{
"Include all properties.",
"Omit owner, acl and defaultObjectAcl properties.",
},
},
Location: "query",
},
},
ParameterOrder: []string{"bucket"},
Response: &Schema{Ref: "Bucket", Kind: ReferenceKind},
Scopes: []string{
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud-platform.read-only",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/devstorage.read_write",
},
SupportsMediaDownload: true,
MediaUpload: &MediaUpload{
Accept: []string{"application/octet-stream"},
MaxSize: "1GB",
Protocols: map[string]Protocol{
"simple": Protocol{
Multipart: true,
Path: "/upload/customDataSources/{customDataSourceId}/uploads",
},
"resumable": Protocol{
Multipart: true,
Path: "/resumable/upload/customDataSources/{customDataSourceId}/uploads",
},
},
},
},
},
},
},
}
// Resolve schema references.
bucket := want.Schemas["Bucket"]
want.Schemas["Buckets"].Properties[0].Schema.ItemSchema.RefSchema = bucket
want.Methods[0].Response.RefSchema = bucket
want.Resources[0].Methods[0].Response.RefSchema = bucket
for k, gs := range got.Schemas {
ws := want.Schemas[k]
if !reflect.DeepEqual(gs, ws) {
t.Fatalf("schema %s: got\n%+v\nwant\n%+v", k, gs, ws)
}
}
if len(got.Schemas) != len(want.Schemas) {
t.Errorf("want %d schemas, got %d", len(got.Schemas), len(want.Schemas))
}
compareMethodLists(t, got.Methods, want.Methods)
for i, gr := range got.Resources {
wr := want.Resources[i]
compareMethodLists(t, gr.Methods, wr.Methods)
if !reflect.DeepEqual(gr, wr) {
t.Fatalf("resource %d: got\n%+v\nwant\n%+v", i, gr, wr)
}
}
if len(got.Resources) != len(want.Resources) {
t.Errorf("want %d resources, got %d", len(got.Resources), len(want.Resources))
}
if !reflect.DeepEqual(got, want) {
t.Errorf("got\n%+v\nwant\n%+v", got, want)
}
}
func compareMethodLists(t *testing.T, got, want MethodList) {
if len(got) != len(want) {
t.Fatalf("got %d methods, want %d", len(got), len(want))
}
for i, gm := range got {
gm.JSONMap = nil // don't compare the raw JSON
wm := want[i]
if !reflect.DeepEqual(gm, wm) {
t.Errorf("#%d: got\n%+v\nwant\n%+v", i, gm, wm)
}
}
}
func TestDocumentErrors(t *testing.T) {
for _, in := range []string{
`{"name": "X"`, // malformed JSON
`{"id": 3}`, // ID is an int instead of a string
`{"auth": "oauth2": { "scopes": "string" }}`, // wrong auth structure
} {
_, err := NewDocument([]byte(in))
if err == nil {
t.Errorf("%s: got nil, want error", in)
}
}
}
func TestSchemaErrors(t *testing.T) {
for _, s := range []*Schema{
{Type: "array"}, // missing item schema
{Type: "string", ItemSchema: &Schema{}}, // items w/o array
{Type: "moose"}, // bad kind
{Ref: "Thing"}, // unresolved reference
} {
if err := s.init(nil); err == nil {
t.Errorf("%+v: got nil, want error", s)
}
}
}

View file

@ -0,0 +1,235 @@
{
"kind": "discovery#restDescription",
"etag": "\"tbys6C40o18GZwyMen5GMkdK-3s/sMgjc4eoIFjgub4daTU-MGW0WMA\"",
"discoveryVersion": "v1",
"id": "storage:v1",
"name": "storage",
"version": "v1",
"revision": "20161109",
"title": "Cloud Storage JSON API",
"description": "Stores and retrieves potentially large, immutable data objects.",
"ownerDomain": "google.com",
"ownerName": "Google",
"icons": {
"x16": "https://www.google.com/images/icons/product/cloud_storage-16.png",
"x32": "https://www.google.com/images/icons/product/cloud_storage-32.png"
},
"documentationLink": "https://developers.google.com/storage/docs/json_api/",
"labels": [
"labs"
],
"protocol": "rest",
"baseUrl": "https://www.googleapis.com/storage/v1/",
"basePath": "/storage/v1/",
"rootUrl": "https://www.googleapis.com/",
"servicePath": "storage/v1/",
"batchPath": "batch",
"parameters": {
"alt": {
"type": "string",
"description": "Data format for the response.",
"default": "json",
"enum": [
"json"
],
"enumDescriptions": [
"Responses with Content-Type of application/json"
],
"location": "query"
},
"fields": {
"type": "string",
"description": "Selector specifying which fields to include in a partial response.",
"location": "query"
},
"key": {
"type": "string",
"description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.",
"location": "query"
},
"oauth_token": {
"type": "string",
"description": "OAuth 2.0 token for the current user.",
"location": "query"
},
"prettyPrint": {
"type": "boolean",
"description": "Returns response with indentations and line breaks.",
"default": "true",
"location": "query"
},
"quotaUser": {
"type": "string",
"description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.",
"location": "query"
},
"userIp": {
"type": "string",
"description": "IP address of the site where the request originates. Use this if you want to enforce per-user limits.",
"location": "query"
}
},
"auth": {
"oauth2": {
"scopes": {
"https://www.googleapis.com/auth/cloud-platform": {
"description": "View and manage your data across Google Cloud Platform services"
},
"https://www.googleapis.com/auth/cloud-platform.read-only": {
"description": "View your data across Google Cloud Platform services"
},
"https://www.googleapis.com/auth/devstorage.full_control": {
"description": "Manage your data and permissions in Google Cloud Storage"
},
"https://www.googleapis.com/auth/devstorage.read_only": {
"description": "View your data in Google Cloud Storage"
},
"https://www.googleapis.com/auth/devstorage.read_write": {
"description": "Manage your data in Google Cloud Storage"
}
}
}
},
"features": [
"dataWrapper"
],
"schemas": {
"Bucket": {
"id": "Bucket",
"type": "object",
"description": "A bucket.",
"properties": {
"cors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"maxAgeSeconds": {
"type": "integer",
"format": "int32"
},
"method": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"id": {
"type": "string"
},
"kind": {
"type": "string",
"default": "storage#bucket"
}
}
},
"Buckets": {
"id": "Buckets",
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "Bucket"
}
}
}
},
"VariantExample": {
"id": "VariantExample",
"type": "object",
"variant": {
"discriminant": "type",
"map": [
{
"type_value": "Bucket",
"$ref": "Bucket"
},
{
"type_value": "Buckets",
"$ref": "Buckets"
}
]
}
}
},
"methods": {
"getCertForOpenIdConnect": {
"id": "oauth2.getCertForOpenIdConnect",
"path": "oauth2/v1/certs",
"httpMethod": "GET",
"response": {
"$ref": "Bucket"
}
}
},
"resources": {
"buckets": {
"methods": {
"get": {
"id": "storage.buckets.get",
"path": "b/{bucket}",
"httpMethod": "GET",
"description": "d",
"parameters": {
"bucket": {
"type": "string",
"required": true,
"location": "path"
},
"ifMetagenerationMatch": {
"type": "string",
"format": "int64",
"location": "query"
},
"projection": {
"type": "string",
"enum": [
"full",
"noAcl"
],
"enumDescriptions": [
"Include all properties.",
"Omit owner, acl and defaultObjectAcl properties."
],
"location": "query"
}
},
"parameterOrder": [
"bucket"
],
"response": {
"$ref": "Bucket"
},
"scopes": [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud-platform.read-only",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/devstorage.read_write"
],
"supportsMediaDownload": true,
"mediaUpload": {
"accept": [
"application/octet-stream"
],
"maxSize": "1GB",
"protocols": {
"simple": {
"multipart": true,
"path": "/upload/customDataSources/{customDataSourceId}/uploads"
},
"resumable": {
"multipart": true,
"path": "/resumable/upload/customDataSources/{customDataSourceId}/uploads"
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,170 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"net/url"
"strconv"
"testing"
"golang.org/x/net/context"
crm "google.golang.org/api/cloudresourcemanager/v1"
)
//go:generate -command api go run gen.go docurls.go -install -api
//go:generate api cloudresourcemanager:v1
// A handler that mimics paging behavior.
type pageHandler struct {
param bool // is page token in a query param, or body?
err error
}
const nPages = 3
func (h *pageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
v, err := url.ParseRequestURI(r.URL.RequestURI())
if err != nil {
h.err = err
return
}
var pageToken string
if h.param {
pts := v.Query()["pageToken"]
if len(pts) > 0 {
pageToken = pts[0]
}
} else {
d := json.NewDecoder(r.Body)
req := struct{ PageToken *string }{&pageToken}
if err := d.Decode(&req); err != nil {
h.err = err
return
}
}
var start int
if pageToken != "" {
start, err = strconv.Atoi(pageToken)
if err != nil {
h.err = err
return
}
}
nextPageToken := ""
if start+1 < nPages {
nextPageToken = strconv.Itoa(start + 1)
}
fmt.Fprintf(w, `{"nextPageToken": %q}`, nextPageToken)
}
func TestPagesParam(t *testing.T) {
handler := &pageHandler{param: true}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := crm.New(client)
if err != nil {
t.Fatal(err)
}
s.BasePath = server.URL
ctx := context.Background()
c := s.Projects.List()
countPages := func() int {
n := 0
err = c.Pages(ctx, func(*crm.ListProjectsResponse) error {
n++
return nil
})
if err != nil {
t.Fatal(err)
}
return n
}
// Pages traverses through all the pages.
if got, want := countPages(), nPages; got != want {
t.Errorf("got %d pages, want %d", got, want)
}
// Pages starts wherever the current page token is.
c.PageToken("1")
if got, want := countPages(), nPages-1; got != want {
t.Errorf("got %d pages, want %d", got, want)
}
// Pages restores the initial state: we will again visit one fewer
// page, because the initial page token was reset to "1".
if got, want := countPages(), nPages-1; got != want {
t.Errorf("got %d pages, want %d", got, want)
}
if handler.err != nil {
t.Fatal(handler.err)
}
}
func TestPagesRequestField(t *testing.T) {
handler := &pageHandler{param: false}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := crm.New(client)
if err != nil {
t.Fatal(err)
}
s.BasePath = server.URL
ctx := context.Background()
c := s.Organizations.Search(&crm.SearchOrganizationsRequest{})
countPages := func() int {
n := 0
err = c.Pages(ctx, func(*crm.SearchOrganizationsResponse) error {
n++
return nil
})
if err != nil {
t.Fatal(err)
}
return n
}
// Pages traverses through all the pages.
if got, want := countPages(), nPages; got != want {
t.Errorf("got %d pages, want %d", got, want)
}
// Pages starts wherever the current page token is.
c = s.Organizations.Search(&crm.SearchOrganizationsRequest{PageToken: "1"})
if got, want := countPages(), nPages-1; got != want {
t.Errorf("got %d pages, want %d", got, want)
}
// Pages restores the initial state: we will again visit one fewer
// page, because the initial page token was reset to "1".
if got, want := countPages(), nPages-1; got != want {
t.Errorf("got %d pages, want %d", got, want)
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,49 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "arrayofarray:v1",
"name": "arrayofarray",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an array of arrays.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"GeoJsonMultiPolygon": {
"id": "GeoJsonMultiPolygon",
"type": "object",
"description": "Multi Polygon",
"properties": {
"coordinates": {
"type": "array",
"description": "Coordinate arrays.",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
}
}
}
},
"type": {
"type": "string",
"description": "Identifies this object as a multi-polygon.",
"enum": [
"MultiPolygon"
],
"enumDescriptions": [
""
]
}
}
}
}
}

View file

@ -0,0 +1,99 @@
// Package arrayofarray provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/arrayofarray/v1"
// ...
// arrayofarrayService, err := arrayofarray.New(oauthHttpClient)
package arrayofarray // import "google.golang.org/api/arrayofarray/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "arrayofarray:v1"
const apiName = "arrayofarray"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
// GeoJsonMultiPolygon: Multi Polygon
type GeoJsonMultiPolygon struct {
// Coordinates: Coordinate arrays.
Coordinates [][][][]float64 `json:"coordinates,omitempty"`
// Type: Identifies this object as a multi-polygon.
//
// Possible values:
// "MultiPolygon"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Coordinates") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Coordinates") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonMultiPolygon) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonMultiPolygon
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

View file

@ -0,0 +1,191 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "arrayofenum:v1",
"name": "arrayofenum",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an array of enums.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"Container": {
"id": "Container",
"type": "object",
"description": "Represents a Google Tag Manager Container.",
"properties": {
"accountId": {
"type": "string",
"description": "GTM Account ID."
},
"containerId": {
"type": "string",
"description": "This is a long description that has URLs in it that shouldn't break. https://sites.google.com/a/google.com/adx-integration/Home/engineering/binary-releases/rtb-api-release https://cs.corp.google.com/#piper///depot/google3/contentads/adx/tools/rtb_api/adxrtb.py"
},
"domainName": {
"type": "array",
"description": "Optional list of domain names associated with the Container.",
"items": {
"type": "string"
}
},
"enabledBuiltInVariable": {
"type": "array",
"description": "List of enabled built-in variables. Valid values include: pageUrl, pageHostname, pagePath, referrer, event, clickElement, clickClasses, clickId, clickTarget, clickUrl, clickText, formElement, formClasses, formId, formTarget, formUrl, formText, errorMessage, errorUrl, errorLine, newHistoryFragment, oldHistoryFragment, newHistoryState, oldHistoryState, historySource, containerVersion, debugMode, randomNumber, containerId.",
"items": {
"type": "string",
"enum": [
"advertiserId",
"advertisingTrackingEnabled",
"appId",
"appName",
"appVersionCode",
"appVersionName",
"clickClasses",
"clickElement",
"clickId",
"clickTarget",
"clickText",
"clickUrl",
"containerId",
"containerVersion",
"debugMode",
"deviceName",
"errorLine",
"errorMessage",
"errorUrl",
"event",
"formClasses",
"formElement",
"formId",
"formTarget",
"formText",
"formUrl",
"historySource",
"language",
"newHistoryFragment",
"newHistoryState",
"oldHistoryFragment",
"oldHistoryState",
"osVersion",
"pageHostname",
"pagePath",
"pageUrl",
"platform",
"randomNumber",
"referrer",
"resolution",
"sdkVersion"
],
"enumDescriptions": [
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
]
}
},
"fingerprint": {
"type": "string",
"description": "The fingerprint of the GTM Container as computed at storage time. This value is recomputed whenever the account is modified."
},
"name": {
"type": "string",
"description": "Container display name.",
"annotations": {
"required": [
"tagmanager.accounts.containers.create"
]
}
},
"notes": {
"type": "string",
"description": "Container Notes."
},
"publicId": {
"type": "string",
"description": "Container Public ID."
},
"timeZoneCountryId": {
"type": "string",
"description": "Container Country ID.",
"annotations": {
"required": [
"tagmanager.accounts.containers.create"
]
}
},
"timeZoneId": {
"type": "string",
"description": "Container Time Zone ID.",
"annotations": {
"required": [
"tagmanager.accounts.containers.create"
]
}
},
"usageContext": {
"type": "array",
"description": "List of Usage Contexts for the Container. Valid values include: web, android, ios.",
"items": {
"type": "string",
"enum": [
"android",
"ios",
"web"
],
"enumDescriptions": [
"",
"",
""
]
},
"annotations": {
"required": [
"tagmanager.accounts.containers.create"
]
}
}
}
}
}
}

View file

@ -0,0 +1,184 @@
// Package arrayofenum provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/arrayofenum/v1"
// ...
// arrayofenumService, err := arrayofenum.New(oauthHttpClient)
package arrayofenum // import "google.golang.org/api/arrayofenum/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "arrayofenum:v1"
const apiName = "arrayofenum"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
// Container: Represents a Google Tag Manager Container.
type Container struct {
// AccountId: GTM Account ID.
AccountId string `json:"accountId,omitempty"`
// ContainerId: This is a long description that has URLs in it that
// shouldn't break.
// https://sites.google.com/a/google.com/adx-integration/Home/engineering/binary-releases/rtb-api-release
// https://cs.corp.google.com/#piper///depot/google3/contentads/adx/tools/rtb_api/adxrtb.py
ContainerId string `json:"containerId,omitempty"`
// DomainName: Optional list of domain names associated with the
// Container.
DomainName []string `json:"domainName,omitempty"`
// EnabledBuiltInVariable: List of enabled built-in variables. Valid
// values include: pageUrl, pageHostname, pagePath, referrer, event,
// clickElement, clickClasses, clickId, clickTarget, clickUrl,
// clickText, formElement, formClasses, formId, formTarget, formUrl,
// formText, errorMessage, errorUrl, errorLine, newHistoryFragment,
// oldHistoryFragment, newHistoryState, oldHistoryState, historySource,
// containerVersion, debugMode, randomNumber, containerId.
//
// Possible values:
// "advertiserId"
// "advertisingTrackingEnabled"
// "appId"
// "appName"
// "appVersionCode"
// "appVersionName"
// "clickClasses"
// "clickElement"
// "clickId"
// "clickTarget"
// "clickText"
// "clickUrl"
// "containerId"
// "containerVersion"
// "debugMode"
// "deviceName"
// "errorLine"
// "errorMessage"
// "errorUrl"
// "event"
// "formClasses"
// "formElement"
// "formId"
// "formTarget"
// "formText"
// "formUrl"
// "historySource"
// "language"
// "newHistoryFragment"
// "newHistoryState"
// "oldHistoryFragment"
// "oldHistoryState"
// "osVersion"
// "pageHostname"
// "pagePath"
// "pageUrl"
// "platform"
// "randomNumber"
// "referrer"
// "resolution"
// "sdkVersion"
EnabledBuiltInVariable []string `json:"enabledBuiltInVariable,omitempty"`
// Fingerprint: The fingerprint of the GTM Container as computed at
// storage time. This value is recomputed whenever the account is
// modified.
Fingerprint string `json:"fingerprint,omitempty"`
// Name: Container display name.
Name string `json:"name,omitempty"`
// Notes: Container Notes.
Notes string `json:"notes,omitempty"`
// PublicId: Container Public ID.
PublicId string `json:"publicId,omitempty"`
// TimeZoneCountryId: Container Country ID.
TimeZoneCountryId string `json:"timeZoneCountryId,omitempty"`
// TimeZoneId: Container Time Zone ID.
TimeZoneId string `json:"timeZoneId,omitempty"`
// UsageContext: List of Usage Contexts for the Container. Valid values
// include: web, android, ios.
//
// Possible values:
// "android"
// "ios"
// "web"
UsageContext []string `json:"usageContext,omitempty"`
// ForceSendFields is a list of field names (e.g. "AccountId") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "AccountId") to include in
// API requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Container) MarshalJSON() ([]byte, error) {
type noMethod Container
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

View file

@ -0,0 +1,36 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "arrayofmapofstrings:v1",
"name": "arrayofmapofstrings",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an array of arrays.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"Analyze": {
"id": "Analyze",
"type": "object",
"properties": {
"errors": {
"type": "array",
"description": "List of errors with the data.",
"items": {
"type": "object",
"additionalProperties": {
"$ref": "Property",
"description": "Error level followed by a detailed error message."
}
}
}
}
},
"Property": {
"id": "Property",
"type": "object"
}
}
}

View file

@ -0,0 +1,95 @@
// Package arrayofmapofstrings provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/arrayofmapofstrings/v1"
// ...
// arrayofmapofstringsService, err := arrayofmapofstrings.New(oauthHttpClient)
package arrayofmapofstrings // import "google.golang.org/api/arrayofmapofstrings/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "arrayofmapofstrings:v1"
const apiName = "arrayofmapofstrings"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
type Analyze struct {
// Errors: List of errors with the data.
Errors []map[string]Property `json:"errors,omitempty"`
// ForceSendFields is a list of field names (e.g. "Errors") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Errors") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Analyze) MarshalJSON() ([]byte, error) {
type noMethod Analyze
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type Property struct {
}

View file

@ -0,0 +1,32 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "arrayofmapofstrings:v1",
"name": "arrayofmapofstrings",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an array of arrays.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"Analyze": {
"id": "Analyze",
"type": "object",
"properties": {
"errors": {
"type": "array",
"description": "List of errors with the data.",
"items": {
"type": "object",
"additionalProperties": {
"type": "string",
"description": "Error level followed by a detailed error message."
}
}
}
}
}
}
}

View file

@ -0,0 +1,92 @@
// Package arrayofmapofstrings provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/arrayofmapofstrings/v1"
// ...
// arrayofmapofstringsService, err := arrayofmapofstrings.New(oauthHttpClient)
package arrayofmapofstrings // import "google.golang.org/api/arrayofmapofstrings/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "arrayofmapofstrings:v1"
const apiName = "arrayofmapofstrings"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
type Analyze struct {
// Errors: List of errors with the data.
Errors []map[string]string `json:"errors,omitempty"`
// ForceSendFields is a list of field names (e.g. "Errors") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Errors") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Analyze) MarshalJSON() ([]byte, error) {
type noMethod Analyze
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,33 @@
{
"kind": "discovery#restDescription",
"discoveryVersion": "v1",
"id": "X:v1",
"name": "X",
"version": "v1",
"title": "X",
"documentationLink": "https://cloud.google.com/appengine/docs/admin-api/",
"baseUrl": "https://appengine.googleapis.com/",
"basePath": "",
"rootUrl": "https://appengine.googleapis.com/",
"servicePath": "",
"batchPath": "batch",
"schemas": {
"Utilization": {
"id": "Utilization",
"type": "object",
"description": "CPU utilization policy.",
"properties": {
"target": {
"type": "number",
"format": "double"
},
"count": {
"type": "integer"
},
"average": {
"type": "number"
}
}
}
}
}

View file

@ -0,0 +1,114 @@
// Package x provides access to the X.
//
// See https://cloud.google.com/appengine/docs/admin-api/
//
// Usage example:
//
// import "google.golang.org/api/x/v1"
// ...
// xService, err := x.New(oauthHttpClient)
package x // import "google.golang.org/api/x/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "X:v1"
const apiName = "X"
const apiVersion = "v1"
const basePath = "https://appengine.googleapis.com/"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
// Utilization: CPU utilization policy.
type Utilization struct {
Average float64 `json:"average,omitempty"`
Count int64 `json:"count,omitempty"`
Target float64 `json:"target,omitempty"`
// ForceSendFields is a list of field names (e.g. "Average") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Average") to include in
// API requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Utilization) MarshalJSON() ([]byte, error) {
type noMethod Utilization
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
func (s *Utilization) UnmarshalJSON(data []byte) error {
type noMethod Utilization
var s1 struct {
Average gensupport.JSONFloat64 `json:"average"`
Target gensupport.JSONFloat64 `json:"target"`
*noMethod
}
s1.noMethod = (*noMethod)(s)
if err := json.Unmarshal(data, &s1); err != nil {
return err
}
s.Average = float64(s1.Average)
s.Target = float64(s1.Target)
return nil
}

View file

@ -0,0 +1,89 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "getwithoutbody:v1",
"name": "getwithoutbody",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates a GET with a request.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"ListMetricRequest": {
"id": "ListMetricRequest",
"type": "object",
"description": "The request of getwithoutbody.metricDescriptors.list.",
"properties": {
"kind": {
"type": "string",
"description": "Identifies what kind of resource this is. Value: the fixed string \"getwithoutbody#listMetricRequest\".",
"default": "getwithoutbody#listMetricRequest"
}
}
},
"ListMetricResponse": {
"id": "ListMetricResponse",
"type": "object",
"description": "The response of getwithoutbody.metricDescriptors.list.",
"properties": {
"kind": {
"type": "string",
"description": "Identifies what kind of resource this is. Value: the fixed string \"getwithoutbody#listMetricResponse\".",
"default": "getwithoutbody#listMetricResponse"
},
"nextPageToken": {
"type": "string",
"description": "Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, set this value to the pageToken query parameter."
}
}
}
},
"resources": {
"metricDescriptors": {
"methods": {
"list": {
"id": "getwithoutbody.metricDescriptors.list",
"path": "{project}/metricDescriptors",
"httpMethod": "GET",
"description": "List all of the available metric descriptors. Large number of metric descriptors will be paginated, use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.",
"parameters": {
"count": {
"type": "integer",
"description": "Maximum number of metric descriptors per page. Used for pagination. If not specified, count = 100.",
"default": "100",
"format": "int32",
"minimum": "1",
"maximum": "1000",
"location": "query"
},
"pageToken": {
"type": "string",
"description": "The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.",
"location": "query"
},
"project": {
"type": "string",
"description": "The project id. The value can be the numeric project ID or string-based project name.",
"required": true,
"location": "path"
}
},
"parameterOrder": [
"project"
],
"request": {
"$ref": "ListMetricRequest"
},
"response": {
"$ref": "ListMetricResponse"
},
"scopes": [
"https://www.googleapis.com/auth/getwithoutbody.readonly"
]
}
}
}
}
}

View file

@ -0,0 +1,344 @@
// Package getwithoutbody provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/getwithoutbody/v1"
// ...
// getwithoutbodyService, err := getwithoutbody.New(oauthHttpClient)
package getwithoutbody // import "google.golang.org/api/getwithoutbody/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "getwithoutbody:v1"
const apiName = "getwithoutbody"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.MetricDescriptors = NewMetricDescriptorsService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
MetricDescriptors *MetricDescriptorsService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewMetricDescriptorsService(s *Service) *MetricDescriptorsService {
rs := &MetricDescriptorsService{s: s}
return rs
}
type MetricDescriptorsService struct {
s *Service
}
// ListMetricRequest: The request of
// getwithoutbody.metricDescriptors.list.
type ListMetricRequest struct {
// Kind: Identifies what kind of resource this is. Value: the fixed
// string "getwithoutbody#listMetricRequest".
Kind string `json:"kind,omitempty"`
// ForceSendFields is a list of field names (e.g. "Kind") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Kind") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *ListMetricRequest) MarshalJSON() ([]byte, error) {
type noMethod ListMetricRequest
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// ListMetricResponse: The response of
// getwithoutbody.metricDescriptors.list.
type ListMetricResponse struct {
// Kind: Identifies what kind of resource this is. Value: the fixed
// string "getwithoutbody#listMetricResponse".
Kind string `json:"kind,omitempty"`
// NextPageToken: Pagination token. If present, indicates that
// additional results are available for retrieval. To access the results
// past the pagination limit, set this value to the pageToken query
// parameter.
NextPageToken string `json:"nextPageToken,omitempty"`
// ServerResponse contains the HTTP response code and headers from the
// server.
googleapi.ServerResponse `json:"-"`
// ForceSendFields is a list of field names (e.g. "Kind") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Kind") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *ListMetricResponse) MarshalJSON() ([]byte, error) {
type noMethod ListMetricResponse
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// method id "getwithoutbody.metricDescriptors.list":
type MetricDescriptorsListCall struct {
s *Service
project string
listmetricrequest *ListMetricRequest
urlParams_ gensupport.URLParams
ifNoneMatch_ string
ctx_ context.Context
header_ http.Header
}
// List: List all of the available metric descriptors. Large number of
// metric descriptors will be paginated, use the nextPageToken returned
// in the response to request subsequent pages of results by setting the
// pageToken query parameter to the value of the nextPageToken.
func (r *MetricDescriptorsService) List(project string, listmetricrequest *ListMetricRequest) *MetricDescriptorsListCall {
c := &MetricDescriptorsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
c.project = project
c.listmetricrequest = listmetricrequest
return c
}
// Count sets the optional parameter "count": Maximum number of metric
// descriptors per page. Used for pagination. If not specified, count =
// 100.
func (c *MetricDescriptorsListCall) Count(count int64) *MetricDescriptorsListCall {
c.urlParams_.Set("count", fmt.Sprint(count))
return c
}
// PageToken sets the optional parameter "pageToken": The pagination
// token, which is used to page through large result sets. Set this
// value to the value of the nextPageToken to retrieve the next page of
// results.
func (c *MetricDescriptorsListCall) PageToken(pageToken string) *MetricDescriptorsListCall {
c.urlParams_.Set("pageToken", pageToken)
return c
}
// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *MetricDescriptorsListCall) Fields(s ...googleapi.Field) *MetricDescriptorsListCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
return c
}
// IfNoneMatch sets the optional parameter which makes the operation
// fail if the object's ETag matches the given value. This is useful for
// getting updates only after the object has changed since the last
// request. Use googleapi.IsNotModified to check whether the response
// error from Do is the result of In-None-Match.
func (c *MetricDescriptorsListCall) IfNoneMatch(entityTag string) *MetricDescriptorsListCall {
c.ifNoneMatch_ = entityTag
return c
}
// Context sets the context to be used in this call's Do method. Any
// pending HTTP request will be aborted if the provided context is
// canceled.
func (c *MetricDescriptorsListCall) Context(ctx context.Context) *MetricDescriptorsListCall {
c.ctx_ = ctx
return c
}
// Header returns an http.Header that can be modified by the caller to
// add HTTP headers to the request.
func (c *MetricDescriptorsListCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *MetricDescriptorsListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
for k, v := range c.header_ {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/metricDescriptors")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("GET", urls, body)
req.Header = reqHeaders
googleapi.Expand(req.URL, map[string]string{
"project": c.project,
})
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "getwithoutbody.metricDescriptors.list" call.
// Exactly one of *ListMetricResponse or error will be non-nil. Any
// non-2xx status code is an error. Response headers are in either
// *ListMetricResponse.ServerResponse.Header or (if a response was
// returned at all) in error.(*googleapi.Error).Header. Use
// googleapi.IsNotModified to check whether the returned error was
// because http.StatusNotModified was returned.
func (c *MetricDescriptorsListCall) Do(opts ...googleapi.CallOption) (*ListMetricResponse, error) {
gensupport.SetOptions(c.urlParams_, opts...)
res, err := c.doRequest("json")
if res != nil && res.StatusCode == http.StatusNotModified {
if res.Body != nil {
res.Body.Close()
}
return nil, &googleapi.Error{
Code: res.StatusCode,
Header: res.Header,
}
}
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
ret := &ListMetricResponse{
ServerResponse: googleapi.ServerResponse{
Header: res.Header,
HTTPStatusCode: res.StatusCode,
},
}
target := &ret
if err := json.NewDecoder(res.Body).Decode(target); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "List all of the available metric descriptors. Large number of metric descriptors will be paginated, use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.",
// "httpMethod": "GET",
// "id": "getwithoutbody.metricDescriptors.list",
// "parameterOrder": [
// "project"
// ],
// "parameters": {
// "count": {
// "default": "100",
// "description": "Maximum number of metric descriptors per page. Used for pagination. If not specified, count = 100.",
// "format": "int32",
// "location": "query",
// "maximum": "1000",
// "minimum": "1",
// "type": "integer"
// },
// "pageToken": {
// "description": "The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.",
// "location": "query",
// "type": "string"
// },
// "project": {
// "description": "The project id. The value can be the numeric project ID or string-based project name.",
// "location": "path",
// "required": true,
// "type": "string"
// }
// },
// "path": "{project}/metricDescriptors",
// "request": {
// "$ref": "ListMetricRequest"
// },
// "response": {
// "$ref": "ListMetricResponse"
// },
// "scopes": [
// "https://www.googleapis.com/auth/getwithoutbody.readonly"
// ]
// }
}
// Pages invokes f for each page of results.
// A non-nil error returned from f will halt the iteration.
// The provided context supersedes any context provided to the Context method.
func (c *MetricDescriptorsListCall) Pages(ctx context.Context, f func(*ListMetricResponse) error) error {
c.ctx_ = ctx
defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
for {
x, err := c.Do()
if err != nil {
return err
}
if err := f(x); err != nil {
return err
}
if x.NextPageToken == "" {
return nil
}
c.PageToken(x.NextPageToken)
}
}

View file

@ -0,0 +1,51 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "mapofany:v1",
"name": "mapofany",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an associative array.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"TableDataInsertAllRequest": {
"id": "TableDataInsertAllRequest",
"type": "object",
"properties": {
"kind": {
"type": "string",
"description": "The resource type of the response.",
"default": "bigquery#tableDataInsertAllRequest"
},
"rows": {
"type": "array",
"description": "The rows to insert.",
"items": {
"type": "object",
"properties": {
"json": {
"$ref": "JsonObject",
"description": "[Required] A JSON object that contains a row of data. The object's properties and values must match the destination table's schema."
}
}
}
}
}
},
"JsonObject": {
"id": "JsonObject",
"type": "object",
"description": "Represents a single JSON object.",
"additionalProperties": {
"$ref": "JsonValue"
}
},
"JsonValue": {
"id": "JsonValue",
"type": "any"
}
}
}

View file

@ -0,0 +1,126 @@
// Package mapofany provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/mapofany/v1"
// ...
// mapofanyService, err := mapofany.New(oauthHttpClient)
package mapofany // import "google.golang.org/api/mapofany/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "mapofany:v1"
const apiName = "mapofany"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
type JsonValue interface{}
type TableDataInsertAllRequest struct {
// Kind: The resource type of the response.
Kind string `json:"kind,omitempty"`
// Rows: The rows to insert.
Rows []*TableDataInsertAllRequestRows `json:"rows,omitempty"`
// ForceSendFields is a list of field names (e.g. "Kind") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Kind") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *TableDataInsertAllRequest) MarshalJSON() ([]byte, error) {
type noMethod TableDataInsertAllRequest
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type TableDataInsertAllRequestRows struct {
// Json: [Required] A JSON object that contains a row of data. The
// object's properties and values must match the destination table's
// schema.
Json map[string]JsonValue `json:"json,omitempty"`
// ForceSendFields is a list of field names (e.g. "Json") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Json") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *TableDataInsertAllRequestRows) MarshalJSON() ([]byte, error) {
type noMethod TableDataInsertAllRequestRows
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

View file

@ -0,0 +1,76 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "additionalprops:v1",
"name": "additionalprops",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an associative array.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"TimeseriesDescriptor": {
"id": "TimeseriesDescriptor",
"type": "object",
"description": "The descriptions of a time series.",
"properties": {
"labels": {
"type": "object",
"description": "The set of key-value pairs that describe this time series, including target-specific labels and metric-specific labels.",
"additionalProperties": {
"type": "string",
"description": "The label's name."
}
},
"metric": {
"type": "string",
"description": "The name of the metric."
},
"project": {
"type": "string",
"description": "The project ID to which this time series belongs."
},
"tags": {
"type": "object",
"description": "A map of additional information.",
"additionalProperties": {
"type": "array",
"description": "A string which maps to an array of values.",
"items": {
"$ref": "Property"
}
}
}
}
},
"GetMapResponse": {
"id": "GetMapResponse",
"type": "object",
"description": "Response of getting a map.",
"additionalProperties": {
"type": "string"
}
},
"Property": {
"id": "Property",
"type": "object"
}
},
"resources": {
"atlas": {
"methods": {
"getMap": {
"id": "mapofstrings.getMap",
"path": "map",
"httpMethod": "GET",
"description": "Get a map.",
"response": {
"$ref": "GetMapResponse"
}
}
}
}
}
}

View file

@ -0,0 +1,216 @@
// Package additionalprops provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/additionalprops/v1"
// ...
// additionalpropsService, err := additionalprops.New(oauthHttpClient)
package additionalprops // import "google.golang.org/api/additionalprops/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "additionalprops:v1"
const apiName = "additionalprops"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Atlas = NewAtlasService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
Atlas *AtlasService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewAtlasService(s *Service) *AtlasService {
rs := &AtlasService{s: s}
return rs
}
type AtlasService struct {
s *Service
}
type Property struct {
}
// TimeseriesDescriptor: The descriptions of a time series.
type TimeseriesDescriptor struct {
// Labels: The set of key-value pairs that describe this time series,
// including target-specific labels and metric-specific labels.
Labels map[string]string `json:"labels,omitempty"`
// Metric: The name of the metric.
Metric string `json:"metric,omitempty"`
// Project: The project ID to which this time series belongs.
Project string `json:"project,omitempty"`
// Tags: A map of additional information.
Tags map[string][]Property `json:"tags,omitempty"`
// ForceSendFields is a list of field names (e.g. "Labels") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Labels") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *TimeseriesDescriptor) MarshalJSON() ([]byte, error) {
type noMethod TimeseriesDescriptor
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// method id "mapofstrings.getMap":
type AtlasGetMapCall struct {
s *Service
urlParams_ gensupport.URLParams
ifNoneMatch_ string
ctx_ context.Context
header_ http.Header
}
// GetMap: Get a map.
func (r *AtlasService) GetMap() *AtlasGetMapCall {
c := &AtlasGetMapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
return c
}
// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *AtlasGetMapCall) Fields(s ...googleapi.Field) *AtlasGetMapCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
return c
}
// IfNoneMatch sets the optional parameter which makes the operation
// fail if the object's ETag matches the given value. This is useful for
// getting updates only after the object has changed since the last
// request. Use googleapi.IsNotModified to check whether the response
// error from Do is the result of In-None-Match.
func (c *AtlasGetMapCall) IfNoneMatch(entityTag string) *AtlasGetMapCall {
c.ifNoneMatch_ = entityTag
return c
}
// Context sets the context to be used in this call's Do method. Any
// pending HTTP request will be aborted if the provided context is
// canceled.
func (c *AtlasGetMapCall) Context(ctx context.Context) *AtlasGetMapCall {
c.ctx_ = ctx
return c
}
// Header returns an http.Header that can be modified by the caller to
// add HTTP headers to the request.
func (c *AtlasGetMapCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *AtlasGetMapCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
for k, v := range c.header_ {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "map")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("GET", urls, body)
req.Header = reqHeaders
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "mapofstrings.getMap" call.
func (c *AtlasGetMapCall) Do(opts ...googleapi.CallOption) (map[string]string, error) {
gensupport.SetOptions(c.urlParams_, opts...)
res, err := c.doRequest("json")
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret map[string]string
target := &ret
if err := json.NewDecoder(res.Body).Decode(target); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Get a map.",
// "httpMethod": "GET",
// "id": "mapofstrings.getMap",
// "path": "map",
// "response": {
// "$ref": "GetMapResponse"
// }
// }
}

View file

@ -0,0 +1,34 @@
{
"kind": "discovery#restDescription",
"discoveryVersion": "v1",
"id": "androidbuildinternal:v1",
"name": "androidbuildinternal",
"version": "v1",
"description": "proper handling of a map of int64s in string format",
"protocol": "rest",
"schemas": {
"TestResultSummaryToolGroupTestSuite": {
"id": "TestResultSummaryToolGroupTestSuite",
"type": "object",
"properties": {
"passed": {
"type": "boolean"
},
"passedTestTags": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "int64"
}
},
"testTags": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "int64"
}
}
}
}
}
}

View file

@ -0,0 +1,95 @@
// Package androidbuildinternal provides access to the .
//
// Usage example:
//
// import "google.golang.org/api/androidbuildinternal/v1"
// ...
// androidbuildinternalService, err := androidbuildinternal.New(oauthHttpClient)
package androidbuildinternal // import "google.golang.org/api/androidbuildinternal/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "androidbuildinternal:v1"
const apiName = "androidbuildinternal"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
type TestResultSummaryToolGroupTestSuite struct {
Passed bool `json:"passed,omitempty"`
PassedTestTags map[string]string `json:"passedTestTags,omitempty"`
TestTags map[string]string `json:"testTags,omitempty"`
// ForceSendFields is a list of field names (e.g. "Passed") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Passed") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *TestResultSummaryToolGroupTestSuite) MarshalJSON() ([]byte, error) {
type noMethod TestResultSummaryToolGroupTestSuite
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

View file

@ -0,0 +1,35 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "additionalpropsobjs:v1",
"name": "additionalpropsobjs",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an associative array.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"Entity": {
"id": "Entity",
"type": "object",
"externalTypeName": "apphosting.client.datastoreservice.proto.Entity",
"properties": {
"properties": {
"type": "object",
"description": "The entity's properties.",
"additionalProperties": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the property. Properties with names matching regex \"__.*__\" are reserved. A reserved property name is forbidden in certain documented contexts. The name cannot be \"\"."
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,121 @@
// Package additionalpropsobjs provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/additionalpropsobjs/v1"
// ...
// additionalpropsobjsService, err := additionalpropsobjs.New(oauthHttpClient)
package additionalpropsobjs // import "google.golang.org/api/additionalpropsobjs/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "additionalpropsobjs:v1"
const apiName = "additionalpropsobjs"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
type Entity struct {
// Properties: The entity's properties.
Properties map[string]EntityProperties `json:"properties,omitempty"`
// ForceSendFields is a list of field names (e.g. "Properties") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Properties") to include in
// API requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Entity) MarshalJSON() ([]byte, error) {
type noMethod Entity
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type EntityProperties struct {
// Name: The name of the property. Properties with names matching regex
// "__.*__" are reserved. A reserved property name is forbidden in
// certain documented contexts. The name cannot be "".
Name string `json:"name,omitempty"`
// ForceSendFields is a list of field names (e.g. "Name") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Name") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *EntityProperties) MarshalJSON() ([]byte, error) {
type noMethod EntityProperties
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

View file

@ -0,0 +1,72 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "additionalprops:v1",
"name": "additionalprops",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an associative array.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"TimeseriesDescriptor": {
"id": "TimeseriesDescriptor",
"type": "object",
"description": "The descriptions of a time series.",
"properties": {
"labels": {
"type": "object",
"description": "The set of key-value pairs that describe this time series, including target-specific labels and metric-specific labels.",
"additionalProperties": {
"type": "string",
"description": "The label's name."
}
},
"metric": {
"type": "string",
"description": "The name of the metric."
},
"project": {
"type": "string",
"description": "The project ID to which this time series belongs."
},
"tags": {
"type": "object",
"description": "A map of additional information.",
"additionalProperties": {
"type": "array",
"description": "A string which maps to an array of values.",
"items": {
"type": "string"
}
}
}
}
},
"GetMapResponse": {
"id": "GetMapResponse",
"type": "object",
"description": "Response of getting a map.",
"additionalProperties": {
"type": "string"
}
}
},
"resources": {
"atlas": {
"methods": {
"getMap": {
"id": "mapofstrings.getMap",
"path": "map",
"httpMethod": "GET",
"description": "Get a map.",
"response": {
"$ref": "GetMapResponse"
}
}
}
}
}
}

View file

@ -0,0 +1,213 @@
// Package additionalprops provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/additionalprops/v1"
// ...
// additionalpropsService, err := additionalprops.New(oauthHttpClient)
package additionalprops // import "google.golang.org/api/additionalprops/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "additionalprops:v1"
const apiName = "additionalprops"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Atlas = NewAtlasService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
Atlas *AtlasService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewAtlasService(s *Service) *AtlasService {
rs := &AtlasService{s: s}
return rs
}
type AtlasService struct {
s *Service
}
// TimeseriesDescriptor: The descriptions of a time series.
type TimeseriesDescriptor struct {
// Labels: The set of key-value pairs that describe this time series,
// including target-specific labels and metric-specific labels.
Labels map[string]string `json:"labels,omitempty"`
// Metric: The name of the metric.
Metric string `json:"metric,omitempty"`
// Project: The project ID to which this time series belongs.
Project string `json:"project,omitempty"`
// Tags: A map of additional information.
Tags map[string][]string `json:"tags,omitempty"`
// ForceSendFields is a list of field names (e.g. "Labels") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Labels") to include in API
// requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *TimeseriesDescriptor) MarshalJSON() ([]byte, error) {
type noMethod TimeseriesDescriptor
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// method id "mapofstrings.getMap":
type AtlasGetMapCall struct {
s *Service
urlParams_ gensupport.URLParams
ifNoneMatch_ string
ctx_ context.Context
header_ http.Header
}
// GetMap: Get a map.
func (r *AtlasService) GetMap() *AtlasGetMapCall {
c := &AtlasGetMapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
return c
}
// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *AtlasGetMapCall) Fields(s ...googleapi.Field) *AtlasGetMapCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
return c
}
// IfNoneMatch sets the optional parameter which makes the operation
// fail if the object's ETag matches the given value. This is useful for
// getting updates only after the object has changed since the last
// request. Use googleapi.IsNotModified to check whether the response
// error from Do is the result of In-None-Match.
func (c *AtlasGetMapCall) IfNoneMatch(entityTag string) *AtlasGetMapCall {
c.ifNoneMatch_ = entityTag
return c
}
// Context sets the context to be used in this call's Do method. Any
// pending HTTP request will be aborted if the provided context is
// canceled.
func (c *AtlasGetMapCall) Context(ctx context.Context) *AtlasGetMapCall {
c.ctx_ = ctx
return c
}
// Header returns an http.Header that can be modified by the caller to
// add HTTP headers to the request.
func (c *AtlasGetMapCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *AtlasGetMapCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
for k, v := range c.header_ {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "map")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("GET", urls, body)
req.Header = reqHeaders
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "mapofstrings.getMap" call.
func (c *AtlasGetMapCall) Do(opts ...googleapi.CallOption) (map[string]string, error) {
gensupport.SetOptions(c.urlParams_, opts...)
res, err := c.doRequest("json")
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret map[string]string
target := &ret
if err := json.NewDecoder(res.Body).Decode(target); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Get a map.",
// "httpMethod": "GET",
// "id": "mapofstrings.getMap",
// "path": "map",
// "response": {
// "$ref": "GetMapResponse"
// }
// }
}

View file

@ -0,0 +1,149 @@
{
"id": "cloudresourcemanager:v1",
"name": "cloudresourcemanager",
"canonicalName": "Cloud Resource Manager",
"version": "v1",
"revision": "20160927",
"title": "Google Cloud Resource Manager API",
"documentationLink": "https://cloud.google.com/resource-manager",
"protocol": "rest",
"baseUrl": "https://cloudresourcemanager.googleapis.com/",
"basePath": "",
"rootUrl": "https://cloudresourcemanager.googleapis.com/",
"servicePath": "",
"schemas": {
"Operation": {
"id": "Operation",
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"SearchOrganizationsRequest": {
"id": "SearchOrganizationsRequest",
"type": "object",
"properties": {
"pageSize": {
"type": "integer",
"description": "The maximum number of Organizations to return in the response. This field is optional.",
"format": "int32"
},
"pageToken": {
"type": "string"
},
"filter": {
"type": "string"
}
}
},
"SearchOrganizationsResponse": {
"id": "SearchOrganizationsResponse",
"type": "object",
"properties": {
"organizations": {
"type": "array",
"items": {
"$ref": "Organization"
}
},
"nextPageToken": {
"type": "string"
}
}
},
"Organization": {
"id": "Organization",
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"Project": {
"id": "Project",
"type": "object",
"properties": {
"projectId": {
"type": "string"
}
}
},
"ListProjectsResponse": {
"id": "ListProjectsResponse",
"type": "object",
"properties": {
"projects": {
"type": "array",
"items": {
"$ref": "Project"
}
},
"nextPageToken": {
"type": "string"
}
}
}
},
"resources": {
"projects": {
"methods": {
"yes1": {
"id": "cloudresourcemanager.organizations.search",
"path": "v1/organizations:search",
"httpMethod": "POST",
"request": {
"$ref": "SearchOrganizationsRequest"
},
"response": {
"$ref": "SearchOrganizationsResponse"
}
},
"yes2": {
"id": "cloudresourcemanager.projects.list",
"path": "v1/projects",
"httpMethod": "GET",
"parameters": {
"pageToken": {
"type": "string",
"location": "query"
},
"pageSize": {
"type": "integer",
"format": "int32",
"location": "query"
},
"filter": {
"type": "string",
"location": "query"
}
},
"response": {
"$ref": "ListProjectsResponse"
}
},
"no": {
"id": "cloudresourcemanager.operations.get",
"path": "v1/{+name}",
"httpMethod": "GET",
"parameters": {
"name": {
"type": "string",
"required": true,
"pattern": "^operations/.*$",
"location": "path"
}
},
"parameterOrder": [
"name"
],
"response": {
"$ref": "Operation"
}
}
}
}
}
}

View file

@ -0,0 +1,94 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "paramrename:v1",
"name": "paramrename",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates parameter renaming.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"Event": {
"id": "Event",
"type": "string"
},
"ResultTable": {
"id": "ResultTable",
"type": "string"
}
},
"resources": {
"events": {
"methods": {
"move": {
"id": "calendar.events.move",
"path": "calendars/{calendarId}/events/{eventId}/move",
"httpMethod": "POST",
"description": "Moves an event to another calendar, i.e. changes an event's organizer.",
"parameters": {
"destination": {
"type": "string",
"description": "Calendar identifier of the target calendar where the event is to be moved to.",
"required": true,
"location": "query"
},
"source-param": {
"type": "string",
"description": "Some parameter.",
"required": false,
"location": "query"
},
"right-string": {
"type": "string",
"description": "Yet another parameter.",
"required": true,
"location": "path"
}
},
"parameterOrder": [
"destination",
"right-string"
],
"response": {
"$ref": "Event"
},
"scopes": [
"https://www.googleapis.com/auth/calendar"
]
}
}
},
"reports": {
"methods": {
"query": {
"id": "youtubeAnalytics.reports.query",
"path": "reports",
"httpMethod": "GET",
"description": "Retrieve your YouTube Analytics reports.",
"parameters": {
"start-date": {
"type": "string",
"description": "The start date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.",
"required": true,
"pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
"location": "query"
}
},
"parameterOrder": [
"start-date"
],
"response": {
"$ref": "ResultTable"
},
"scopes": [
"https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
"https://www.googleapis.com/auth/yt-analytics.readonly"
]
}
}
}
}
}

View file

@ -0,0 +1,373 @@
// Package paramrename provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/paramrename/v1"
// ...
// paramrenameService, err := paramrename.New(oauthHttpClient)
package paramrename // import "google.golang.org/api/paramrename/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "paramrename:v1"
const apiName = "paramrename"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Events = NewEventsService(s)
s.Reports = NewReportsService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
Events *EventsService
Reports *ReportsService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewEventsService(s *Service) *EventsService {
rs := &EventsService{s: s}
return rs
}
type EventsService struct {
s *Service
}
func NewReportsService(s *Service) *ReportsService {
rs := &ReportsService{s: s}
return rs
}
type ReportsService struct {
s *Service
}
type Event string
type ResultTable string
// method id "calendar.events.move":
type EventsMoveCall struct {
s *Service
rightString string
urlParams_ gensupport.URLParams
ctx_ context.Context
header_ http.Header
}
// Move: Moves an event to another calendar, i.e. changes an event's
// organizer.
func (r *EventsService) Move(destinationid string, rightString string) *EventsMoveCall {
c := &EventsMoveCall{s: r.s, urlParams_: make(gensupport.URLParams)}
c.urlParams_.Set("destination", destinationid)
c.rightString = rightString
return c
}
// SourceParam sets the optional parameter "source-param": Some
// parameter.
func (c *EventsMoveCall) SourceParam(sourceParam string) *EventsMoveCall {
c.urlParams_.Set("source-param", sourceParam)
return c
}
// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *EventsMoveCall) Fields(s ...googleapi.Field) *EventsMoveCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
return c
}
// Context sets the context to be used in this call's Do method. Any
// pending HTTP request will be aborted if the provided context is
// canceled.
func (c *EventsMoveCall) Context(ctx context.Context) *EventsMoveCall {
c.ctx_ = ctx
return c
}
// Header returns an http.Header that can be modified by the caller to
// add HTTP headers to the request.
func (c *EventsMoveCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *EventsMoveCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
for k, v := range c.header_ {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "calendars/{calendarId}/events/{eventId}/move")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("POST", urls, body)
req.Header = reqHeaders
googleapi.Expand(req.URL, map[string]string{
"right-string": c.rightString,
})
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "calendar.events.move" call.
// Exactly one of *Event or error will be non-nil. Any non-2xx status
// code is an error. Response headers are in either
// *Event.ServerResponse.Header or (if a response was returned at all)
// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
// check whether the returned error was because http.StatusNotModified
// was returned.
func (c *EventsMoveCall) Do(opts ...googleapi.CallOption) (*Event, error) {
gensupport.SetOptions(c.urlParams_, opts...)
res, err := c.doRequest("json")
if res != nil && res.StatusCode == http.StatusNotModified {
if res.Body != nil {
res.Body.Close()
}
return nil, &googleapi.Error{
Code: res.StatusCode,
Header: res.Header,
}
}
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
ret := &Event{
ServerResponse: googleapi.ServerResponse{
Header: res.Header,
HTTPStatusCode: res.StatusCode,
},
}
target := &ret
if err := json.NewDecoder(res.Body).Decode(target); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Moves an event to another calendar, i.e. changes an event's organizer.",
// "httpMethod": "POST",
// "id": "calendar.events.move",
// "parameterOrder": [
// "destination",
// "right-string"
// ],
// "parameters": {
// "destination": {
// "description": "Calendar identifier of the target calendar where the event is to be moved to.",
// "location": "query",
// "required": true,
// "type": "string"
// },
// "right-string": {
// "description": "Yet another parameter.",
// "location": "path",
// "required": true,
// "type": "string"
// },
// "source-param": {
// "description": "Some parameter.",
// "location": "query",
// "required": false,
// "type": "string"
// }
// },
// "path": "calendars/{calendarId}/events/{eventId}/move",
// "response": {
// "$ref": "Event"
// },
// "scopes": [
// "https://www.googleapis.com/auth/calendar"
// ]
// }
}
// method id "youtubeAnalytics.reports.query":
type ReportsQueryCall struct {
s *Service
urlParams_ gensupport.URLParams
ifNoneMatch_ string
ctx_ context.Context
header_ http.Header
}
// Query: Retrieve your YouTube Analytics reports.
func (r *ReportsService) Query(startDate string) *ReportsQueryCall {
c := &ReportsQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
c.urlParams_.Set("start-date", startDate)
return c
}
// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *ReportsQueryCall) Fields(s ...googleapi.Field) *ReportsQueryCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
return c
}
// IfNoneMatch sets the optional parameter which makes the operation
// fail if the object's ETag matches the given value. This is useful for
// getting updates only after the object has changed since the last
// request. Use googleapi.IsNotModified to check whether the response
// error from Do is the result of In-None-Match.
func (c *ReportsQueryCall) IfNoneMatch(entityTag string) *ReportsQueryCall {
c.ifNoneMatch_ = entityTag
return c
}
// Context sets the context to be used in this call's Do method. Any
// pending HTTP request will be aborted if the provided context is
// canceled.
func (c *ReportsQueryCall) Context(ctx context.Context) *ReportsQueryCall {
c.ctx_ = ctx
return c
}
// Header returns an http.Header that can be modified by the caller to
// add HTTP headers to the request.
func (c *ReportsQueryCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *ReportsQueryCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
for k, v := range c.header_ {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "reports")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("GET", urls, body)
req.Header = reqHeaders
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "youtubeAnalytics.reports.query" call.
// Exactly one of *ResultTable or error will be non-nil. Any non-2xx
// status code is an error. Response headers are in either
// *ResultTable.ServerResponse.Header or (if a response was returned at
// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
// to check whether the returned error was because
// http.StatusNotModified was returned.
func (c *ReportsQueryCall) Do(opts ...googleapi.CallOption) (*ResultTable, error) {
gensupport.SetOptions(c.urlParams_, opts...)
res, err := c.doRequest("json")
if res != nil && res.StatusCode == http.StatusNotModified {
if res.Body != nil {
res.Body.Close()
}
return nil, &googleapi.Error{
Code: res.StatusCode,
Header: res.Header,
}
}
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
ret := &ResultTable{
ServerResponse: googleapi.ServerResponse{
Header: res.Header,
HTTPStatusCode: res.StatusCode,
},
}
target := &ret
if err := json.NewDecoder(res.Body).Decode(target); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Retrieve your YouTube Analytics reports.",
// "httpMethod": "GET",
// "id": "youtubeAnalytics.reports.query",
// "parameterOrder": [
// "start-date"
// ],
// "parameters": {
// "start-date": {
// "description": "The start date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.",
// "location": "query",
// "pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
// "required": true,
// "type": "string"
// }
// },
// "path": "reports",
// "response": {
// "$ref": "ResultTable"
// },
// "scopes": [
// "https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
// "https://www.googleapis.com/auth/yt-analytics.readonly"
// ]
// }
}

View file

@ -0,0 +1,94 @@
{
"kind": "discovery#restDescription",
"etag": "\"DGgqtFnjgu83tuwvvVNNUhOiHWk/1UCG4CqfTBrxPN0MRjUm7GaLJ7Y\"",
"discoveryVersion": "v1",
"id": "adexchangebuyer:v1.1",
"name": "adexchangebuyer",
"version": "v1.1",
"title": "Ad Exchange Buyer API",
"description": "Lets you manage your Ad Exchange Buyer account.",
"ownerDomain": "google.com",
"ownerName": "Google",
"icons": {
"x16": "http://www.google.com/images/icons/product/doubleclick-16.gif",
"x32": "http://www.google.com/images/icons/product/doubleclick-32.gif"
},
"documentationLink": "https://developers.google.com/ad-exchange/buyer-rest",
"protocol": "rest",
"baseUrl": "https://www.googleapis.com/adexchangebuyer/v1.1/",
"basePath": "/adexchangebuyer/v1.1/",
"rootUrl": "https://www.googleapis.com/",
"servicePath": "adexchangebuyer/v1.1/",
"batchPath": "batch",
"parameters": {
"alt": {
"type": "string",
"description": "Data format for the response.",
"default": "json",
"enum": [
"json"
],
"enumDescriptions": [
"Responses with Content-Type of application/json"
],
"location": "query"
},
"fields": {
"type": "string",
"description": "Selector specifying which fields to include in a partial response.",
"location": "query"
},
"key": {
"type": "string",
"description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.",
"location": "query"
},
"oauth_token": {
"type": "string",
"description": "OAuth 2.0 token for the current user.",
"location": "query"
},
"prettyPrint": {
"type": "boolean",
"description": "Returns response with indentations and line breaks.",
"default": "true",
"location": "query"
},
"quotaUser": {
"type": "string",
"description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.",
"location": "query"
},
"userIp": {
"type": "string",
"description": "IP address of the site where the request originates. Use this if you want to enforce per-user limits.",
"location": "query"
}
},
"auth": {
"oauth2": {
"scopes": {
"https://www.googleapis.com/auth/adexchange.buyer": {
"description": "Manage your Ad Exchange buyer account configuration"
}
}
}
},
"schemas": {
"Creative": {
"id": "Creative",
"type": "object",
"description": "A creative and its classification data.",
"properties": {
"advertiserId": {
"type": "array",
"description": "Detected advertiser id, if any. Read-only. This field should not be set in requests.",
"items": {
"type": "string",
"format": "int64"
}
}
}
}
}
}

View file

@ -0,0 +1,102 @@
// Package adexchangebuyer provides access to the Ad Exchange Buyer API.
//
// See https://developers.google.com/ad-exchange/buyer-rest
//
// Usage example:
//
// import "google.golang.org/api/adexchangebuyer/v1.1"
// ...
// adexchangebuyerService, err := adexchangebuyer.New(oauthHttpClient)
package adexchangebuyer // import "google.golang.org/api/adexchangebuyer/v1.1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "adexchangebuyer:v1.1"
const apiName = "adexchangebuyer"
const apiVersion = "v1.1"
const basePath = "https://www.googleapis.com/adexchangebuyer/v1.1/"
// OAuth2 scopes used by this API.
const (
// Manage your Ad Exchange buyer account configuration
AdexchangeBuyerScope = "https://www.googleapis.com/auth/adexchange.buyer"
)
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
// Creative: A creative and its classification data.
type Creative struct {
// AdvertiserId: Detected advertiser id, if any. Read-only. This field
// should not be set in requests.
AdvertiserId googleapi.Int64s `json:"advertiserId,omitempty"`
// ForceSendFields is a list of field names (e.g. "AdvertiserId") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "AdvertiserId") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Creative) MarshalJSON() ([]byte, error) {
type noMethod Creative
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

View file

@ -0,0 +1,65 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "repeated:v1",
"name": "repeated",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates repeated fields.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
},
"resources": {
"accounts": {
"resources": {
"reports": {
"methods": {
"generate": {
"id": "adsense.accounts.reports.generate",
"path": "accounts/{accountId}/reports",
"httpMethod": "GET",
"description": "Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify \"alt=csv\" as a query parameter.",
"parameters": {
"accountId": {
"type": "string",
"description": "Account upon which to report.",
"required": true,
"location": "path"
},
"currency": {
"type": "string",
"description": "Optional currency to use when reporting on monetary metrics. Defaults to the account's currency if not set.",
"pattern": "[a-zA-Z]+",
"location": "query"
},
"ids": {
"type": "string",
"description": "Select only user profiles with these IDs.",
"format": "int64",
"repeated": true,
"location": "query"
},
"dimension": {
"type": "string",
"description": "Dimensions to base the report on.",
"pattern": "[a-zA-Z_]+",
"repeated": true,
"location": "query"
}
},
"parameterOrder": [
"ids",
"currency",
"accountId",
"dimension"
]
}
}
}
}
}
}
}

View file

@ -0,0 +1,253 @@
// Package repeated provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/repeated/v1"
// ...
// repeatedService, err := repeated.New(oauthHttpClient)
package repeated // import "google.golang.org/api/repeated/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "repeated:v1"
const apiName = "repeated"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Accounts = NewAccountsService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
Accounts *AccountsService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewAccountsService(s *Service) *AccountsService {
rs := &AccountsService{s: s}
rs.Reports = NewAccountsReportsService(s)
return rs
}
type AccountsService struct {
s *Service
Reports *AccountsReportsService
}
func NewAccountsReportsService(s *Service) *AccountsReportsService {
rs := &AccountsReportsService{s: s}
return rs
}
type AccountsReportsService struct {
s *Service
}
// method id "adsense.accounts.reports.generate":
type AccountsReportsGenerateCall struct {
s *Service
accountId string
urlParams_ gensupport.URLParams
ifNoneMatch_ string
ctx_ context.Context
header_ http.Header
}
// Generate: Generate an AdSense report based on the report request sent
// in the query parameters. Returns the result as JSON; to retrieve
// output in CSV format specify "alt=csv" as a query parameter.
func (r *AccountsReportsService) Generate(ids []int64, currency string, accountId string, dimension []string) *AccountsReportsGenerateCall {
c := &AccountsReportsGenerateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
var ids_ []string
for _, v := range ids {
ids_ = append(ids_, fmt.Sprint(v))
}
c.urlParams_.SetMulti("ids", ids_)
c.urlParams_.Set("currency", currency)
c.accountId = accountId
c.urlParams_.SetMulti("dimension", append([]string{}, dimension...))
return c
}
// Currency sets the optional parameter "currency": Optional currency to
// use when reporting on monetary metrics. Defaults to the account's
// currency if not set.
func (c *AccountsReportsGenerateCall) Currency(currency string) *AccountsReportsGenerateCall {
c.urlParams_.Set("currency", currency)
return c
}
// Dimension sets the optional parameter "dimension": Dimensions to base
// the report on.
func (c *AccountsReportsGenerateCall) Dimension(dimension ...string) *AccountsReportsGenerateCall {
c.urlParams_.SetMulti("dimension", append([]string{}, dimension...))
return c
}
// Ids sets the optional parameter "ids": Select only user profiles with
// these IDs.
func (c *AccountsReportsGenerateCall) Ids(ids ...int64) *AccountsReportsGenerateCall {
var ids_ []string
for _, v := range ids {
ids_ = append(ids_, fmt.Sprint(v))
}
c.urlParams_.SetMulti("ids", ids_)
return c
}
// Fields allows partial responses to be retrieved. See
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *AccountsReportsGenerateCall) Fields(s ...googleapi.Field) *AccountsReportsGenerateCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
return c
}
// IfNoneMatch sets the optional parameter which makes the operation
// fail if the object's ETag matches the given value. This is useful for
// getting updates only after the object has changed since the last
// request. Use googleapi.IsNotModified to check whether the response
// error from Do is the result of In-None-Match.
func (c *AccountsReportsGenerateCall) IfNoneMatch(entityTag string) *AccountsReportsGenerateCall {
c.ifNoneMatch_ = entityTag
return c
}
// Context sets the context to be used in this call's Do method. Any
// pending HTTP request will be aborted if the provided context is
// canceled.
func (c *AccountsReportsGenerateCall) Context(ctx context.Context) *AccountsReportsGenerateCall {
c.ctx_ = ctx
return c
}
// Header returns an http.Header that can be modified by the caller to
// add HTTP headers to the request.
func (c *AccountsReportsGenerateCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *AccountsReportsGenerateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
for k, v := range c.header_ {
reqHeaders[k] = v
}
reqHeaders.Set("User-Agent", c.s.userAgent())
if c.ifNoneMatch_ != "" {
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
}
var body io.Reader = nil
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{accountId}/reports")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("GET", urls, body)
req.Header = reqHeaders
googleapi.Expand(req.URL, map[string]string{
"accountId": c.accountId,
})
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "adsense.accounts.reports.generate" call.
func (c *AccountsReportsGenerateCall) Do(opts ...googleapi.CallOption) error {
gensupport.SetOptions(c.urlParams_, opts...)
res, err := c.doRequest("json")
if err != nil {
return err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return err
}
return nil
// {
// "description": "Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify \"alt=csv\" as a query parameter.",
// "httpMethod": "GET",
// "id": "adsense.accounts.reports.generate",
// "parameterOrder": [
// "ids",
// "currency",
// "accountId",
// "dimension"
// ],
// "parameters": {
// "accountId": {
// "description": "Account upon which to report.",
// "location": "path",
// "required": true,
// "type": "string"
// },
// "currency": {
// "description": "Optional currency to use when reporting on monetary metrics. Defaults to the account's currency if not set.",
// "location": "query",
// "pattern": "[a-zA-Z]+",
// "type": "string"
// },
// "dimension": {
// "description": "Dimensions to base the report on.",
// "location": "query",
// "pattern": "[a-zA-Z_]+",
// "repeated": true,
// "type": "string"
// },
// "ids": {
// "description": "Select only user profiles with these IDs.",
// "format": "int64",
// "location": "query",
// "repeated": true,
// "type": "string"
// }
// },
// "path": "accounts/{accountId}/reports"
// }
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,158 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "wrapnewlines:v1",
"name": "wrapnewlines",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates wrapping of descriptions containing newlines.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"Thing": {
"id": "Thing",
"type": "object",
"description": "don't care",
"properties": {
"bool_empty_default_a":{
"type": "boolean",
"description": "\nNonempty default: no\nUnfortunate default: no",
"default": "false"
},
"bool_empty_default_b":{
"type": "boolean",
"description": "\nNonempty default: no\nUnfortunate default: no"
},
"bool_nonempty_default":{
"type": "boolean",
"description": "\nNonempty default: yes\nUnfortunate default: yes",
"default": "true"
},
"string_nonempty_default_doesnt_accept_empty": {
"type": "string",
"description": "\nNonempty default: yes\nAccepts empty value: no\nUnfortunate default: no",
"default": "nonempty"
},
"string_nonempty_default_enum_accepts_empty": {
"type": "string",
"description": "\nNonempty default: yes\nAccepts empty value: yes (enum)\nUnfortunate default: yes",
"default": "nonempty",
"enum": [
"",
"nonempty",
"aaa"
],
"enumDescriptions": [
"",
""
]
},
"string_nonempty_default_enum_doesnt_accept_empty": {
"type": "string",
"description": "\nNonempty default: yes\nAccepts empty value: no (enum)\nUnfortunate default: no",
"default": "nonempty",
"enum": [
"nonempty",
"aaa"
],
"enumDescriptions": [
""
]
},
"string_nonempty_default_pattern_accepts_empty": {
"type": "string",
"description": "\nNonempty default: yes\nAccepts empty value: yes (pattern)\nUnfortunate default: yes",
"default": "nonempty",
"pattern": ".?"
},
"string_nonempty_default_pattern_doesnt_accept_empty": {
"type": "string",
"description": "\nNonempty default: yes\nAccepts empty value: no (pattern)\nUnfortunate default: no",
"default": "nonempty",
"pattern": "."
},
"string_empty_default_doesnt_accept_empty": {
"type": "string",
"description": "\nNonempty default: no\nAccepts empty value: no\nUnfortunate default: no",
"default": ""
},
"string_empty_default_enum_accepts_empty": {
"type": "string",
"description": "\nNonempty default: no\nAccepts empty value: yes (enum)\nUnfortunate default: no",
"default": "",
"enum": [
"",
"value"
],
"enumDescriptions": [
"",
""
]
},
"string_empty_default_enum_doesnt_accept_empty": {
"type": "string",
"description": "\nNonempty default: no\nAccepts empty value: no (enum)\nUnfortunate default: no",
"default": "",
"enum": [
"value"
],
"enumDescriptions": [
""
]
},
"string_empty_default_pattern_accepts_empty": {
"type": "string",
"description": "\nNonempty default: no\nAccepts empty value: yes (pattern)\nUnfortunate default: no",
"default": "",
"pattern": ".?"
},
"string_empty_default_pattern_doesnt_accept_empty": {
"type": "string",
"description": "\nNonempty default: no\nAccepts empty value: no (pattern)\nUnfortunate default: no",
"default": "",
"pattern": "."
},
"numeric_empty_default_a":{
"type": "string",
"format": "int64",
"description": "\nNonempty default: no\nUnfortunate default: no",
"default": ""
},
"numeric_empty_default_b":{
"type": "string",
"format": "int64",
"description": "\nNonempty default: no\nUnfortunate default: no"
},
"numeric_empty_default_c":{
"type": "string",
"format": "int64",
"description": "\nNonempty default: no\nUnfortunate default: no",
"default": "0"
},
"numeric_empty_default_d":{
"type": "number",
"description": "\nNonempty default: no\nUnfortunate default: no",
"default": "0.0"
},
"numeric_empty_default_e":{
"type": "number",
"description": "\nNonempty default: no\nUnfortunate default: no",
"default": "-0.0"
},
"numeric_nonempty_default_a":{
"type": "string",
"format": "int64",
"description": "\nNonempty default: yes\nUnfortunate default: yes\nstring encoded, so will not be represented as pointer.",
"default": "1"
},
"numeric_nonempty_default_b":{
"type": "number",
"description": "\nNonempty default: yes\nUnfortunate default: yes",
"default": "0.001"
}
}
}
}
}

View file

@ -0,0 +1,246 @@
// Package wrapnewlines provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/wrapnewlines/v1"
// ...
// wrapnewlinesService, err := wrapnewlines.New(oauthHttpClient)
package wrapnewlines // import "google.golang.org/api/wrapnewlines/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "wrapnewlines:v1"
const apiName = "wrapnewlines"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
// Thing: don't care
type Thing struct {
// BoolEmptyDefaultA:
// Nonempty default: no
// Unfortunate default: no
BoolEmptyDefaultA bool `json:"bool_empty_default_a,omitempty"`
// BoolEmptyDefaultB:
// Nonempty default: no
// Unfortunate default: no
BoolEmptyDefaultB bool `json:"bool_empty_default_b,omitempty"`
// BoolNonemptyDefault:
// Nonempty default: yes
// Unfortunate default: yes
//
// Default: true
BoolNonemptyDefault *bool `json:"bool_nonempty_default,omitempty"`
// NumericEmptyDefaultA:
// Nonempty default: no
// Unfortunate default: no
NumericEmptyDefaultA int64 `json:"numeric_empty_default_a,omitempty,string"`
// NumericEmptyDefaultB:
// Nonempty default: no
// Unfortunate default: no
NumericEmptyDefaultB int64 `json:"numeric_empty_default_b,omitempty,string"`
// NumericEmptyDefaultC:
// Nonempty default: no
// Unfortunate default: no
NumericEmptyDefaultC int64 `json:"numeric_empty_default_c,omitempty,string"`
// NumericEmptyDefaultD:
// Nonempty default: no
// Unfortunate default: no
NumericEmptyDefaultD float64 `json:"numeric_empty_default_d,omitempty"`
// NumericEmptyDefaultE:
// Nonempty default: no
// Unfortunate default: no
NumericEmptyDefaultE float64 `json:"numeric_empty_default_e,omitempty"`
// NumericNonemptyDefaultA:
// Nonempty default: yes
// Unfortunate default: yes
// string encoded, so will not be represented as pointer.
//
// Default: 1
NumericNonemptyDefaultA *int64 `json:"numeric_nonempty_default_a,omitempty,string"`
// NumericNonemptyDefaultB:
// Nonempty default: yes
// Unfortunate default: yes
//
// Default: 0.001
NumericNonemptyDefaultB *float64 `json:"numeric_nonempty_default_b,omitempty"`
// StringEmptyDefaultDoesntAcceptEmpty:
// Nonempty default: no
// Accepts empty value: no
// Unfortunate default: no
StringEmptyDefaultDoesntAcceptEmpty string `json:"string_empty_default_doesnt_accept_empty,omitempty"`
// StringEmptyDefaultEnumAcceptsEmpty:
// Nonempty default: no
// Accepts empty value: yes (enum)
// Unfortunate default: no
//
// Possible values:
// "" (default)
// "value"
StringEmptyDefaultEnumAcceptsEmpty string `json:"string_empty_default_enum_accepts_empty,omitempty"`
// StringEmptyDefaultEnumDoesntAcceptEmpty:
// Nonempty default: no
// Accepts empty value: no (enum)
// Unfortunate default: no
//
// Possible values:
// "value"
StringEmptyDefaultEnumDoesntAcceptEmpty string `json:"string_empty_default_enum_doesnt_accept_empty,omitempty"`
// StringEmptyDefaultPatternAcceptsEmpty:
// Nonempty default: no
// Accepts empty value: yes (pattern)
// Unfortunate default: no
StringEmptyDefaultPatternAcceptsEmpty string `json:"string_empty_default_pattern_accepts_empty,omitempty"`
// StringEmptyDefaultPatternDoesntAcceptEmpty:
// Nonempty default: no
// Accepts empty value: no (pattern)
// Unfortunate default: no
StringEmptyDefaultPatternDoesntAcceptEmpty string `json:"string_empty_default_pattern_doesnt_accept_empty,omitempty"`
// StringNonemptyDefaultDoesntAcceptEmpty:
// Nonempty default: yes
// Accepts empty value: no
// Unfortunate default: no
StringNonemptyDefaultDoesntAcceptEmpty string `json:"string_nonempty_default_doesnt_accept_empty,omitempty"`
// StringNonemptyDefaultEnumAcceptsEmpty:
// Nonempty default: yes
// Accepts empty value: yes (enum)
// Unfortunate default: yes
//
// Possible values:
// ""
// "nonempty" (default)
// "aaa"
StringNonemptyDefaultEnumAcceptsEmpty *string `json:"string_nonempty_default_enum_accepts_empty,omitempty"`
// StringNonemptyDefaultEnumDoesntAcceptEmpty:
// Nonempty default: yes
// Accepts empty value: no (enum)
// Unfortunate default: no
//
// Possible values:
// "nonempty" (default)
// "aaa"
StringNonemptyDefaultEnumDoesntAcceptEmpty string `json:"string_nonempty_default_enum_doesnt_accept_empty,omitempty"`
// StringNonemptyDefaultPatternAcceptsEmpty:
// Nonempty default: yes
// Accepts empty value: yes (pattern)
// Unfortunate default: yes
//
// Default: nonempty
StringNonemptyDefaultPatternAcceptsEmpty *string `json:"string_nonempty_default_pattern_accepts_empty,omitempty"`
// StringNonemptyDefaultPatternDoesntAcceptEmpty:
// Nonempty default: yes
// Accepts empty value: no (pattern)
// Unfortunate default: no
StringNonemptyDefaultPatternDoesntAcceptEmpty string `json:"string_nonempty_default_pattern_doesnt_accept_empty,omitempty"`
// ForceSendFields is a list of field names (e.g. "BoolEmptyDefaultA")
// to unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "BoolEmptyDefaultA") to
// include in API requests with the JSON null value. By default, fields
// with empty values are omitted from API requests. However, any field
// with an empty value appearing in NullFields will be sent to the
// server as null. It is an error if a field in this list has a
// non-empty value. This may be used to include null fields in Patch
// requests.
NullFields []string `json:"-"`
}
func (s *Thing) MarshalJSON() ([]byte, error) {
type noMethod Thing
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
func (s *Thing) UnmarshalJSON(data []byte) error {
type noMethod Thing
var s1 struct {
NumericEmptyDefaultD gensupport.JSONFloat64 `json:"numeric_empty_default_d"`
NumericEmptyDefaultE gensupport.JSONFloat64 `json:"numeric_empty_default_e"`
NumericNonemptyDefaultB *gensupport.JSONFloat64 `json:"numeric_nonempty_default_b"`
*noMethod
}
s1.noMethod = (*noMethod)(s)
if err := json.Unmarshal(data, &s1); err != nil {
return err
}
s.NumericEmptyDefaultD = float64(s1.NumericEmptyDefaultD)
s.NumericEmptyDefaultE = float64(s1.NumericEmptyDefaultE)
if s1.NumericNonemptyDefaultB != nil {
s.NumericNonemptyDefaultB = (*float64)(s1.NumericNonemptyDefaultB)
}
return nil
}

View file

@ -0,0 +1,418 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "additionalpropsobjs:v1",
"name": "additionalpropsobjs",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates an associative array.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"GeoJsonGeometry": {
"id": "GeoJsonGeometry",
"type": "object",
"variant": {
"discriminant": "type",
"map": [
{
"type_value": "GeometryCollection",
"$ref": "GeoJsonGeometryCollection"
},
{
"type_value": "LineString",
"$ref": "GeoJsonLineString"
},
{
"type_value": "MultiLineString",
"$ref": "GeoJsonMultiLineString"
},
{
"type_value": "MultiPoint",
"$ref": "GeoJsonMultiPoint"
},
{
"type_value": "MultiPolygon",
"$ref": "GeoJsonMultiPolygon"
},
{
"type_value": "Point",
"$ref": "GeoJsonPoint"
},
{
"type_value": "Polygon",
"$ref": "GeoJsonPolygon"
}
]
}
},
"GeoJsonGeometryCollection": {
"id": "GeoJsonGeometryCollection",
"type": "object",
"description": "A heterogenous collection of GeoJsonGeometry objects.",
"properties": {
"geometries": {
"type": "array",
"description": "An array of geometry objects. There must be at least 2 different types of geometries in the array.",
"items": {
"$ref": "GeoJsonGeometry"
}
},
"type": {
"type": "string",
"description": "Identifies this object as a GeoJsonGeometryCollection.",
"enum": [
"GeometryCollection"
],
"enumDescriptions": [
""
]
}
}
},
"GeoJsonLineString": {
"id": "GeoJsonLineString",
"type": "object",
"properties": {
"coordinates": {
"type": "array",
"description": "An array of two or more positions, representing a line.",
"items": {
"$ref": "GeoJsonPosition"
}
},
"type": {
"type": "string",
"description": "Identifies this object as a GeoJsonLineString.",
"enum": [
"LineString"
],
"enumDescriptions": [
""
]
}
}
},
"GeoJsonMultiLineString": {
"id": "GeoJsonMultiLineString",
"type": "object",
"description": "Multi Line String",
"properties": {
"coordinates": {
"type": "array",
"description": "An array of at least two GeoJsonLineString coordinate arrays.",
"items": {
"type": "array",
"items": {
"$ref": "GeoJsonPosition"
}
}
},
"type": {
"type": "string",
"description": "Identifies this object as a GeoJsonMultiLineString.",
"enum": [
"MultiLineString"
],
"enumDescriptions": [
""
]
}
}
},
"GeoJsonMultiPoint": {
"id": "GeoJsonMultiPoint",
"type": "object",
"properties": {
"coordinates": {
"type": "array",
"description": "An array of at least two GeoJsonPoint coordinate arrays.",
"items": {
"$ref": "GeoJsonPosition"
}
},
"type": {
"type": "string",
"description": "Identifies this object as a GeoJsonMultiPoint.",
"enum": [
"MultiPoint"
],
"enumDescriptions": [
""
]
}
}
},
"GeoJsonMultiPolygon": {
"id": "GeoJsonMultiPolygon",
"type": "object",
"properties": {
"coordinates": {
"type": "array",
"description": "An array of at least two GeoJsonPolygon coordinate arrays.",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"$ref": "GeoJsonPosition"
}
}
}
},
"type": {
"type": "string",
"description": "Identifies this object as a GeoJsonMultiPolygon.",
"enum": [
"MultiPolygon"
],
"enumDescriptions": [
""
]
}
}
},
"GeoJsonPoint": {
"id": "GeoJsonPoint",
"type": "object",
"properties": {
"coordinates": {
"$ref": "GeoJsonPosition",
"description": "A single GeoJsonPosition, specifying the location of the point."
},
"type": {
"type": "string",
"description": "Identifies this object as a GeoJsonPoint.",
"enum": [
"Point"
],
"enumDescriptions": [
""
]
}
}
},
"GeoJsonPolygon": {
"id": "GeoJsonPolygon",
"type": "object",
"properties": {
"coordinates": {
"type": "array",
"description": "An array of LinearRings, each of which is an array of four or more GeoJsonPositions. The first and last coordinates in each LinearRing must be the same. For polygons with multiple rings, the first LinearRing is the external ring, with subsequent rings being interior rings (i.e. hole). All LinearRings must contain GeoJsonPositions in counter-clockwise order.",
"items": {
"type": "array",
"items": {
"$ref": "GeoJsonPosition"
}
}
},
"type": {
"type": "string",
"description": "Identifies this object as a GeoJsonPolygon.",
"enum": [
"Polygon"
],
"enumDescriptions": [
""
]
}
}
},
"GeoJsonPosition": {
"id": "GeoJsonPosition",
"type": "array",
"description": "A position represents a geographical position as an array containing a longitude and a latitude, and optionally an altitude, in that order. All Geometry objects make use of positions to represent geometries as nested arrays. The structure of the array is governed by the type of the geometry.",
"items": {
"type": "number",
"format": "double"
}
},
"MapFolder": {
"id": "MapFolder",
"type": "object",
"properties": {
"contents": {
"type": "array",
"items": {
"$ref": "MapItem"
}
},
"defaultViewport": {
"type": "array",
"description": "An array of four numbers (west, south, east, north) which defines the rectangular bounding box of the default viewport. The numbers represent latitude and longitude in decimal degrees.",
"items": {
"type": "number",
"format": "double"
}
},
"expandable": {
"type": "boolean",
"description": "The expandability setting of this MapFolder. If true, the folder can be expanded."
},
"key": {
"type": "string",
"description": "A user defined alias for this MapFolder, specific to this Map."
},
"name": {
"type": "string",
"description": "The name of this MapFolder.",
"annotations": {
"required": [
"mapsengine.maps.create",
"mapsengine.maps.patch"
]
}
},
"type": {
"type": "string",
"description": "Identifies this object as a MapFolder.",
"enum": [
"folder"
],
"enumDescriptions": [
""
],
"annotations": {
"required": [
"mapsengine.maps.create",
"mapsengine.maps.patch"
]
}
},
"visibility": {
"type": "string",
"description": "The visibility setting of this MapFolder. One of \"defaultOn\" or \"defaultOff\"."
}
}
},
"MapItem": {
"id": "MapItem",
"type": "object",
"variant": {
"discriminant": "type",
"map": [
{
"type_value": "folder",
"$ref": "MapFolder"
},
{
"type_value": "kmlLink",
"$ref": "MapKmlLink"
},
{
"type_value": "layer",
"$ref": "MapLayer"
}
]
}
},
"MapKmlLink": {
"id": "MapKmlLink",
"type": "object",
"properties": {
"defaultViewport": {
"type": "array",
"description": "An array of four numbers (west, south, east, north) which defines the rectangular bounding box of the default viewport. The numbers represent latitude and longitude in decimal degrees.",
"items": {
"type": "number",
"format": "double"
}
},
"kmlUrl": {
"type": "string",
"description": "The URL to the KML file represented by this MapKmlLink.",
"annotations": {
"required": [
"mapsengine.maps.create",
"mapsengine.maps.patch"
]
}
},
"name": {
"type": "string",
"description": "The name of this MapKmlLink.",
"annotations": {
"required": [
"mapsengine.maps.create",
"mapsengine.maps.patch"
]
}
},
"type": {
"type": "string",
"description": "Identifies this object as a MapKmlLink.",
"enum": [
"kmlLink"
],
"enumDescriptions": [
""
],
"annotations": {
"required": [
"mapsengine.maps.create",
"mapsengine.maps.patch"
]
}
},
"visibility": {
"type": "string",
"description": "The visibility setting of this MapKmlLink. One of \"defaultOn\" or \"defaultOff\"."
}
}
},
"MapLayer": {
"id": "MapLayer",
"type": "object",
"properties": {
"defaultViewport": {
"type": "array",
"description": "An array of four numbers (west, south, east, north) which defines the rectangular bounding box of the default viewport. The numbers represent latitude and longitude in decimal degrees.",
"items": {
"type": "number",
"format": "double"
}
},
"id": {
"type": "string",
"description": "The ID of this MapLayer. This ID can be used to request more details about the layer.",
"annotations": {
"required": [
"mapsengine.maps.create",
"mapsengine.maps.patch"
]
}
},
"key": {
"type": "string",
"description": "A user defined alias for this MapLayer, specific to this Map."
},
"name": {
"type": "string",
"description": "The name of this MapLayer."
},
"type": {
"type": "string",
"description": "Identifies this object as a MapLayer.",
"enum": [
"layer"
],
"enumDescriptions": [
""
],
"annotations": {
"required": [
"mapsengine.maps.create",
"mapsengine.maps.patch"
]
}
},
"visibility": {
"type": "string",
"description": "The visibility setting of this MapLayer. One of \"defaultOn\" or \"defaultOff\"."
}
}
}
}
}

View file

@ -0,0 +1,547 @@
// Package additionalpropsobjs provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/additionalpropsobjs/v1"
// ...
// additionalpropsobjsService, err := additionalpropsobjs.New(oauthHttpClient)
package additionalpropsobjs // import "google.golang.org/api/additionalpropsobjs/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "additionalpropsobjs:v1"
const apiName = "additionalpropsobjs"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
type GeoJsonGeometry map[string]interface{}
func (t GeoJsonGeometry) Type() string {
return googleapi.VariantType(t)
}
func (t GeoJsonGeometry) GeometryCollection() (r GeoJsonGeometryCollection, ok bool) {
if t.Type() != "GeometryCollection" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t GeoJsonGeometry) LineString() (r GeoJsonLineString, ok bool) {
if t.Type() != "LineString" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t GeoJsonGeometry) MultiLineString() (r GeoJsonMultiLineString, ok bool) {
if t.Type() != "MultiLineString" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t GeoJsonGeometry) MultiPoint() (r GeoJsonMultiPoint, ok bool) {
if t.Type() != "MultiPoint" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t GeoJsonGeometry) MultiPolygon() (r GeoJsonMultiPolygon, ok bool) {
if t.Type() != "MultiPolygon" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t GeoJsonGeometry) Point() (r GeoJsonPoint, ok bool) {
if t.Type() != "Point" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t GeoJsonGeometry) Polygon() (r GeoJsonPolygon, ok bool) {
if t.Type() != "Polygon" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
// GeoJsonGeometryCollection: A heterogenous collection of
// GeoJsonGeometry objects.
type GeoJsonGeometryCollection struct {
// Geometries: An array of geometry objects. There must be at least 2
// different types of geometries in the array.
Geometries []GeoJsonGeometry `json:"geometries,omitempty"`
// Type: Identifies this object as a GeoJsonGeometryCollection.
//
// Possible values:
// "GeometryCollection"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Geometries") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Geometries") to include in
// API requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonGeometryCollection) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonGeometryCollection
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type GeoJsonLineString struct {
// Coordinates: An array of two or more positions, representing a line.
Coordinates [][]float64 `json:"coordinates,omitempty"`
// Type: Identifies this object as a GeoJsonLineString.
//
// Possible values:
// "LineString"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Coordinates") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Coordinates") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonLineString) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonLineString
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// GeoJsonMultiLineString: Multi Line String
type GeoJsonMultiLineString struct {
// Coordinates: An array of at least two GeoJsonLineString coordinate
// arrays.
Coordinates [][][]float64 `json:"coordinates,omitempty"`
// Type: Identifies this object as a GeoJsonMultiLineString.
//
// Possible values:
// "MultiLineString"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Coordinates") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Coordinates") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonMultiLineString) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonMultiLineString
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type GeoJsonMultiPoint struct {
// Coordinates: An array of at least two GeoJsonPoint coordinate arrays.
Coordinates [][]float64 `json:"coordinates,omitempty"`
// Type: Identifies this object as a GeoJsonMultiPoint.
//
// Possible values:
// "MultiPoint"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Coordinates") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Coordinates") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonMultiPoint) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonMultiPoint
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type GeoJsonMultiPolygon struct {
// Coordinates: An array of at least two GeoJsonPolygon coordinate
// arrays.
Coordinates [][][][]float64 `json:"coordinates,omitempty"`
// Type: Identifies this object as a GeoJsonMultiPolygon.
//
// Possible values:
// "MultiPolygon"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Coordinates") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Coordinates") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonMultiPolygon) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonMultiPolygon
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type GeoJsonPoint struct {
// Coordinates: A single GeoJsonPosition, specifying the location of the
// point.
Coordinates []float64 `json:"coordinates,omitempty"`
// Type: Identifies this object as a GeoJsonPoint.
//
// Possible values:
// "Point"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Coordinates") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Coordinates") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonPoint) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonPoint
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type GeoJsonPolygon struct {
// Coordinates: An array of LinearRings, each of which is an array of
// four or more GeoJsonPositions. The first and last coordinates in each
// LinearRing must be the same. For polygons with multiple rings, the
// first LinearRing is the external ring, with subsequent rings being
// interior rings (i.e. hole). All LinearRings must contain
// GeoJsonPositions in counter-clockwise order.
Coordinates [][][]float64 `json:"coordinates,omitempty"`
// Type: Identifies this object as a GeoJsonPolygon.
//
// Possible values:
// "Polygon"
Type string `json:"type,omitempty"`
// ForceSendFields is a list of field names (e.g. "Coordinates") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Coordinates") to include
// in API requests with the JSON null value. By default, fields with
// empty values are omitted from API requests. However, any field with
// an empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *GeoJsonPolygon) MarshalJSON() ([]byte, error) {
type noMethod GeoJsonPolygon
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type MapFolder struct {
Contents []MapItem `json:"contents,omitempty"`
// DefaultViewport: An array of four numbers (west, south, east, north)
// which defines the rectangular bounding box of the default viewport.
// The numbers represent latitude and longitude in decimal degrees.
DefaultViewport []float64 `json:"defaultViewport,omitempty"`
// Expandable: The expandability setting of this MapFolder. If true, the
// folder can be expanded.
Expandable bool `json:"expandable,omitempty"`
// Key: A user defined alias for this MapFolder, specific to this Map.
Key string `json:"key,omitempty"`
// Name: The name of this MapFolder.
Name string `json:"name,omitempty"`
// Type: Identifies this object as a MapFolder.
//
// Possible values:
// "folder"
Type string `json:"type,omitempty"`
// Visibility: The visibility setting of this MapFolder. One of
// "defaultOn" or "defaultOff".
Visibility string `json:"visibility,omitempty"`
// ForceSendFields is a list of field names (e.g. "Contents") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Contents") to include in
// API requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *MapFolder) MarshalJSON() ([]byte, error) {
type noMethod MapFolder
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type MapItem map[string]interface{}
func (t MapItem) Type() string {
return googleapi.VariantType(t)
}
func (t MapItem) Folder() (r MapFolder, ok bool) {
if t.Type() != "Folder" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t MapItem) KmlLink() (r MapKmlLink, ok bool) {
if t.Type() != "KmlLink" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
func (t MapItem) Layer() (r MapLayer, ok bool) {
if t.Type() != "Layer" {
return r, false
}
ok = googleapi.ConvertVariant(map[string]interface{}(t), &r)
return r, ok
}
type MapKmlLink struct {
// DefaultViewport: An array of four numbers (west, south, east, north)
// which defines the rectangular bounding box of the default viewport.
// The numbers represent latitude and longitude in decimal degrees.
DefaultViewport []float64 `json:"defaultViewport,omitempty"`
// KmlUrl: The URL to the KML file represented by this MapKmlLink.
KmlUrl string `json:"kmlUrl,omitempty"`
// Name: The name of this MapKmlLink.
Name string `json:"name,omitempty"`
// Type: Identifies this object as a MapKmlLink.
//
// Possible values:
// "kmlLink"
Type string `json:"type,omitempty"`
// Visibility: The visibility setting of this MapKmlLink. One of
// "defaultOn" or "defaultOff".
Visibility string `json:"visibility,omitempty"`
// ForceSendFields is a list of field names (e.g. "DefaultViewport") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "DefaultViewport") to
// include in API requests with the JSON null value. By default, fields
// with empty values are omitted from API requests. However, any field
// with an empty value appearing in NullFields will be sent to the
// server as null. It is an error if a field in this list has a
// non-empty value. This may be used to include null fields in Patch
// requests.
NullFields []string `json:"-"`
}
func (s *MapKmlLink) MarshalJSON() ([]byte, error) {
type noMethod MapKmlLink
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
type MapLayer struct {
// DefaultViewport: An array of four numbers (west, south, east, north)
// which defines the rectangular bounding box of the default viewport.
// The numbers represent latitude and longitude in decimal degrees.
DefaultViewport []float64 `json:"defaultViewport,omitempty"`
// Id: The ID of this MapLayer. This ID can be used to request more
// details about the layer.
Id string `json:"id,omitempty"`
// Key: A user defined alias for this MapLayer, specific to this Map.
Key string `json:"key,omitempty"`
// Name: The name of this MapLayer.
Name string `json:"name,omitempty"`
// Type: Identifies this object as a MapLayer.
//
// Possible values:
// "layer"
Type string `json:"type,omitempty"`
// Visibility: The visibility setting of this MapLayer. One of
// "defaultOn" or "defaultOff".
Visibility string `json:"visibility,omitempty"`
// ForceSendFields is a list of field names (e.g. "DefaultViewport") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "DefaultViewport") to
// include in API requests with the JSON null value. By default, fields
// with empty values are omitted from API requests. However, any field
// with an empty value appearing in NullFields will be sent to the
// server as null. It is an error if a field in this list has a
// non-empty value. This may be used to include null fields in Patch
// requests.
NullFields []string `json:"-"`
}
func (s *MapLayer) MarshalJSON() ([]byte, error) {
type noMethod MapLayer
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}

View file

@ -0,0 +1,30 @@
{
"kind": "discovery#restDescription",
"etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"",
"discoveryVersion": "v1",
"id": "wrapnewlines:v1",
"name": "wrapnewlines",
"version": "v1",
"title": "Example API",
"description": "The Example API demonstrates wrapping of descriptions containing newlines.",
"ownerDomain": "google.com",
"ownerName": "Google",
"protocol": "rest",
"schemas": {
"Thing": {
"id": "Thing",
"type": "object",
"description": "don't care",
"properties": {
"oneline": {
"type": "string",
"description": "First sentence. Second sentence. Description is long enough to be wrapped."
},
"twoline": {
"type": "string",
"description": "First sentence.\nSecond sentence. Description is long enough to be wrapped."
}
}
}
}
}

View file

@ -0,0 +1,98 @@
// Package wrapnewlines provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/wrapnewlines/v1"
// ...
// wrapnewlinesService, err := wrapnewlines.New(oauthHttpClient)
package wrapnewlines // import "google.golang.org/api/wrapnewlines/v1"
import (
"bytes"
"encoding/json"
"errors"
"fmt"
context "golang.org/x/net/context"
ctxhttp "golang.org/x/net/context/ctxhttp"
gensupport "google.golang.org/api/gensupport"
googleapi "google.golang.org/api/googleapi"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = gensupport.MarshalJSON
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = context.Canceled
var _ = ctxhttp.Do
const apiId = "wrapnewlines:v1"
const apiName = "wrapnewlines"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
// Thing: don't care
type Thing struct {
// Oneline: First sentence. Second sentence. Description is long enough
// to be wrapped.
Oneline string `json:"oneline,omitempty"`
// Twoline: First sentence.
// Second sentence. Description is long enough to be wrapped.
Twoline string `json:"twoline,omitempty"`
// ForceSendFields is a list of field names (e.g. "Oneline") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
// NullFields is a list of field names (e.g. "Oneline") to include in
// API requests with the JSON null value. By default, fields with empty
// values are omitted from API requests. However, any field with an
// empty value appearing in NullFields will be sent to the server as
// null. It is an error if a field in this list has a non-empty value.
// This may be used to include null fields in Patch requests.
NullFields []string `json:"-"`
}
func (s *Thing) MarshalJSON() ([]byte, error) {
type noMethod Thing
raw := noMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}