From 8295bd8983ecc3e795bce453ceb9794e0b0b0acb Mon Sep 17 00:00:00 2001 From: Ed Rooth Date: Thu, 11 Dec 2014 16:31:17 -0800 Subject: [PATCH] *: update google golang api package locations --- api/serialization.go | 2 +- client/http.go | 2 +- schema/v1-gen.go | 85 +++++++++++++++++++++++++++--- scripts/schema-generator | 6 +-- scripts/schema_generator_import.go | 2 +- 5 files changed, 83 insertions(+), 14 deletions(-) diff --git a/api/serialization.go b/api/serialization.go index e4255808a..52f9e0230 100644 --- a/api/serialization.go +++ b/api/serialization.go @@ -62,7 +62,7 @@ func sendResponse(rw http.ResponseWriter, code int, resp interface{}) { } } -// errorEntity is a fork of "code.google.com/p/google-api-go-client/googleapi".Error +// errorEntity is a fork of "google.golang.org/api/googleapi".Error type errorEntity struct { // Code is the HTTP response status code and will always be populated. Code int `json:"code"` diff --git a/client/http.go b/client/http.go index 7eb7885c1..b0b5afad7 100644 --- a/client/http.go +++ b/client/http.go @@ -21,7 +21,7 @@ import ( "net/url" "path" - "github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/google-api-go-client/googleapi" + "github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/googleapi" "github.com/coreos/fleet/machine" "github.com/coreos/fleet/schema" diff --git a/schema/v1-gen.go b/schema/v1-gen.go index 3cebe9d3a..24a215e3d 100644 --- a/schema/v1-gen.go +++ b/schema/v1-gen.go @@ -4,7 +4,7 @@ // // Usage example: // -// import "github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/google-api-go-client/schema/v1" +// import "github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/schema/v1" // ... // schemaService, err := schema.New(oauthHttpClient) package schema @@ -20,7 +20,7 @@ import ( "strconv" "strings" - "github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/google-api-go-client/googleapi" + "github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/googleapi" ) // Always reference these packages, just in case the auto-generated code @@ -168,6 +168,14 @@ func (c *MachinesListCall) NextPageToken(nextPageToken string) *MachinesListCall 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 *MachinesListCall) Fields(s ...googleapi.Field) *MachinesListCall { + c.opt_["fields"] = googleapi.CombineFields(s) + return c +} + func (c *MachinesListCall) Do() (*MachinePage, error) { var body io.Reader = nil params := make(url.Values) @@ -175,6 +183,9 @@ func (c *MachinesListCall) Do() (*MachinePage, error) { if v, ok := c.opt_["nextPageToken"]; ok { params.Set("nextPageToken", fmt.Sprintf("%v", v)) } + if v, ok := c.opt_["fields"]; ok { + params.Set("fields", fmt.Sprintf("%v", v)) + } urls := googleapi.ResolveRelative(c.s.BasePath, "machines") urls += "?" + params.Encode() req, _ := http.NewRequest("GET", urls, body) @@ -242,6 +253,14 @@ func (c *UnitStateListCall) UnitName(unitName string) *UnitStateListCall { 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 *UnitStateListCall) Fields(s ...googleapi.Field) *UnitStateListCall { + c.opt_["fields"] = googleapi.CombineFields(s) + return c +} + func (c *UnitStateListCall) Do() (*UnitStatePage, error) { var body io.Reader = nil params := make(url.Values) @@ -255,6 +274,9 @@ func (c *UnitStateListCall) Do() (*UnitStatePage, error) { if v, ok := c.opt_["unitName"]; ok { params.Set("unitName", fmt.Sprintf("%v", v)) } + if v, ok := c.opt_["fields"]; ok { + params.Set("fields", fmt.Sprintf("%v", v)) + } urls := googleapi.ResolveRelative(c.s.BasePath, "state") urls += "?" + params.Encode() req, _ := http.NewRequest("GET", urls, body) @@ -314,15 +336,27 @@ func (r *UnitsService) Delete(unitName string) *UnitsDeleteCall { 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 *UnitsDeleteCall) Fields(s ...googleapi.Field) *UnitsDeleteCall { + c.opt_["fields"] = googleapi.CombineFields(s) + return c +} + func (c *UnitsDeleteCall) Do() error { var body io.Reader = nil params := make(url.Values) params.Set("alt", "json") + if v, ok := c.opt_["fields"]; ok { + params.Set("fields", fmt.Sprintf("%v", v)) + } urls := googleapi.ResolveRelative(c.s.BasePath, "units/{unitName}") urls += "?" + params.Encode() req, _ := http.NewRequest("DELETE", urls, body) - req.URL.Path = strings.Replace(req.URL.Path, "{unitName}", url.QueryEscape(c.unitName), 1) - googleapi.SetOpaque(req.URL) + googleapi.Expand(req.URL, map[string]string{ + "unitName": c.unitName, + }) req.Header.Set("User-Agent", "google-api-go-client/0.5") res, err := c.s.client.Do(req) if err != nil { @@ -367,15 +401,27 @@ func (r *UnitsService) Get(unitName string) *UnitsGetCall { 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 *UnitsGetCall) Fields(s ...googleapi.Field) *UnitsGetCall { + c.opt_["fields"] = googleapi.CombineFields(s) + return c +} + func (c *UnitsGetCall) Do() (*Unit, error) { var body io.Reader = nil params := make(url.Values) params.Set("alt", "json") + if v, ok := c.opt_["fields"]; ok { + params.Set("fields", fmt.Sprintf("%v", v)) + } urls := googleapi.ResolveRelative(c.s.BasePath, "units/{unitName}") urls += "?" + params.Encode() req, _ := http.NewRequest("GET", urls, body) - req.URL.Path = strings.Replace(req.URL.Path, "{unitName}", url.QueryEscape(c.unitName), 1) - googleapi.SetOpaque(req.URL) + googleapi.Expand(req.URL, map[string]string{ + "unitName": c.unitName, + }) req.Header.Set("User-Agent", "google-api-go-client/0.5") res, err := c.s.client.Do(req) if err != nil { @@ -431,6 +477,14 @@ func (c *UnitsListCall) NextPageToken(nextPageToken string) *UnitsListCall { 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 *UnitsListCall) Fields(s ...googleapi.Field) *UnitsListCall { + c.opt_["fields"] = googleapi.CombineFields(s) + return c +} + func (c *UnitsListCall) Do() (*UnitPage, error) { var body io.Reader = nil params := make(url.Values) @@ -438,6 +492,9 @@ func (c *UnitsListCall) Do() (*UnitPage, error) { if v, ok := c.opt_["nextPageToken"]; ok { params.Set("nextPageToken", fmt.Sprintf("%v", v)) } + if v, ok := c.opt_["fields"]; ok { + params.Set("fields", fmt.Sprintf("%v", v)) + } urls := googleapi.ResolveRelative(c.s.BasePath, "units") urls += "?" + params.Encode() req, _ := http.NewRequest("GET", urls, body) @@ -491,6 +548,14 @@ func (r *UnitsService) Set(unitName string, unit *Unit) *UnitsSetCall { 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 *UnitsSetCall) Fields(s ...googleapi.Field) *UnitsSetCall { + c.opt_["fields"] = googleapi.CombineFields(s) + return c +} + func (c *UnitsSetCall) Do() error { var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.unit) @@ -500,11 +565,15 @@ func (c *UnitsSetCall) Do() error { ctype := "application/json" params := make(url.Values) params.Set("alt", "json") + if v, ok := c.opt_["fields"]; ok { + params.Set("fields", fmt.Sprintf("%v", v)) + } urls := googleapi.ResolveRelative(c.s.BasePath, "units/{unitName}") urls += "?" + params.Encode() req, _ := http.NewRequest("PUT", urls, body) - req.URL.Path = strings.Replace(req.URL.Path, "{unitName}", url.QueryEscape(c.unitName), 1) - googleapi.SetOpaque(req.URL) + googleapi.Expand(req.URL, map[string]string{ + "unitName": c.unitName, + }) req.Header.Set("Content-Type", ctype) req.Header.Set("User-Agent", "google-api-go-client/0.5") res, err := c.s.client.Do(req) diff --git a/scripts/schema-generator b/scripts/schema-generator index 8b9b1e091..3a61a0aaa 100755 --- a/scripts/schema-generator +++ b/scripts/schema-generator @@ -5,7 +5,7 @@ OUT="schema/v1-json.go" GEN="schema/v1-gen.go" # See scripts/schema_generator_import.go for instructions on updating the dependency -PKG="code.google.com/p/google-api-go-client/google-api-go-generator" +PKG="google.golang.org/api/google-api-go-generator" # First, write the discovery document into a go file so it can be served statically by the API cat << 'EOF' > "${OUT}" @@ -29,11 +29,11 @@ fi # Build the bindings GOPATH=${PWD}/gopath ./bin/google-api-go-generator \ - -googleapi_pkg "code.google.com/p/google-api-go-client/googleapi" \ + -googleapi_pkg "google.golang.org/api/googleapi" \ -api_json_file "${IN}" \ -output "${GEN}" # Finally, fix the import in the bindings to refer to the vendored google-api package -sed -i -e "s%code.google.com%github.com/coreos/fleet/Godeps/_workspace/src/code.google.com%" "${GEN}" +sed -i -e "s%google.golang.org%github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org%" "${GEN}" goimports -w ${GEN} diff --git a/scripts/schema_generator_import.go b/scripts/schema_generator_import.go index 3056c32df..20b792bdf 100644 --- a/scripts/schema_generator_import.go +++ b/scripts/schema_generator_import.go @@ -28,4 +28,4 @@ package scripts // 4. Run `godep save` as usual across the entire project (e.g. `godep save -r ./...`) // 5. Revert this file (i.e. comment the line again, and revert to the original import) as it will not build properly // -// import _ "code.google.com/p/google-api-go-client/google-api-go-generator" +// import _ "google.golang.org/api/google-api-go-generator"