commit | 1ba8c3c8628c255599cf16f4dbbbb79499f4e307 | [log] [tgz] |
---|---|---|
author | Jonathan Amsterdam <jba@google.com> | Sat Oct 01 12:54:39 2016 -0400 |
committer | Jonathan Amsterdam <jba@google.com> | Thu Oct 06 16:40:32 2016 +0000 |
tree | f81b9b1ca5095c506b16f4f2124b04058a4f9fe5 | |
parent | 74c274bf66fc9ff1193915913a3370bcc79dba51 [diff] |
generator: support nulls in JSON ForceSendFields doesn't quite cover all the cases needed to correctly patch a resource. Sometimes you have to send a JSON null to clear a value; the zero value won't do. Two examples from storage/v1.Objects.Patch: - It is an error to send "" as the value of ContentLanguage. - Sending the empty JSON map `{}` for Metadata is a no-op. In both these cases, to clear the value you must send a null. This CL: - Adds a NullFields field to each resource, to complement ForceSendFields. - Modifies the custom JSON marshalling logic to send null for any field in NullFields (and return an error for a non-empty field in NullFields). - Regenerates all the clients. - Updates the goldens in testdata. Change-Id: I748921ae83e2df6fb2f168a87075615955fcc656 Reviewed-on: https://code-review.googlesource.com/8010 Reviewed-by: Jonathan Amsterdam <jba@google.com>
These are auto-generated Go libraries from the Google Discovery Service's JSON description files of the available “new style” Google APIs.
Due to the auto-generated nature of this collection of libraries, complete APIs or specific versions can appear or go away without notice. As a result, you should always locally vendor any API(s) that your code relies upon.
Announcement email:
Getting started documentation:
In summary:
$ go get google.golang.org/api/storage/v1 $ go get google.golang.org/api/tasks/v1 $ go get google.golang.org/api/moderator/v1 ... etc ...
For docs, see e.g.:
The package of a given import is the second-to-last component, before the version number.
For examples, see:
For support, use the golang-nuts@ mailing list:
Application Default Credentials provide a simplified way to obtain credentials for authenticating with Google APIs.
The Application Default Credentials authenticate as the application itself, which make them great for working with Google Cloud APIs like Storage or Datastore. They are the recommended form of authentication when building applications that run on Google Compute Engine or Google App Engine.
Default credentials are provided by the golang.org/x/oauth2/google
package. To use them, add the following import:
import "golang.org/x/oauth2/google"
Some credentials types require you to specify scopes, and service entry points may not inject them. If you encounter this situation you may need to specify scopes as follows:
import ( "golang.org/x/net/context" "golang.org/x/oauth2/google" "google.golang.org/api/compute/v1" ) func main() { // Use oauth2.NoContext if there isn't a good context to pass in. ctx := context.Background() client, err := google.DefaultClient(ctx, compute.ComputeScope) if err != nil { //... } computeService, err := compute.New(client) if err != nil { //... } }
If you need a oauth2.TokenSource
, use the DefaultTokenSource
function:
ts, err := google.DefaultTokenSource(ctx, scope1, scope2, ...) if err != nil { //... } client := oauth2.NewClient(ctx, ts)
See also: golang.org/x/oauth2/google package documentation.