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>
191 files changed
tree: f81b9b1ca5095c506b16f4f2124b04058a4f9fe5
  1. acceleratedmobilepageurl/
  2. adexchangebuyer/
  3. adexchangebuyer2/
  4. adexchangeseller/
  5. admin/
  6. adsense/
  7. adsensehost/
  8. analytics/
  9. analyticsreporting/
  10. androidenterprise/
  11. androidpublisher/
  12. appengine/
  13. appsactivity/
  14. appstate/
  15. autoscaler/
  16. bigquery/
  17. blogger/
  18. books/
  19. calendar/
  20. civicinfo/
  21. classroom/
  22. cloudbilling/
  23. cloudbuild/
  24. clouddebugger/
  25. clouderrorreporting/
  26. cloudlatencytest/
  27. cloudmonitoring/
  28. cloudresourcemanager/
  29. cloudtrace/
  30. clouduseraccounts/
  31. compute/
  32. consumersurveys/
  33. container/
  34. content/
  35. coordinate/
  36. customsearch/
  37. dataflow/
  38. dataproc/
  39. datastore/
  40. deploymentmanager/
  41. dfareporting/
  42. discovery/
  43. dns/
  44. doubleclickbidmanager/
  45. doubleclicksearch/
  46. drive/
  47. examples/
  48. firebasedynamiclinks/
  49. firebaserules/
  50. fitness/
  51. freebase/
  52. fusiontables/
  53. games/
  54. gamesconfiguration/
  55. gamesmanagement/
  56. gan/
  57. genomics/
  58. gensupport/
  59. gmail/
  60. google-api-go-generator/
  61. googleapi/
  62. groupsmigration/
  63. groupssettings/
  64. iam/
  65. identitytoolkit/
  66. integration-tests/
  67. internal/
  68. iterator/
  69. kgsearch/
  70. language/
  71. lib/
  72. licensing/
  73. logging/
  74. manager/
  75. mapsengine/
  76. mirror/
  77. ml/
  78. monitoring/
  79. oauth2/
  80. option/
  81. pagespeedonline/
  82. partners/
  83. people/
  84. playmoviespartner/
  85. plus/
  86. plusdomains/
  87. prediction/
  88. proximitybeacon/
  89. pubsub/
  90. qpxexpress/
  91. replicapool/
  92. replicapoolupdater/
  93. reseller/
  94. resourceviews/
  95. runtimeconfig/
  96. safebrowsing/
  97. script/
  98. servicecontrol/
  99. servicemanagement/
  100. serviceregistry/
  101. sheets/
  102. siteverification/
  103. spectrum/
  104. speech/
  105. sqladmin/
  106. storage/
  107. storagetransfer/
  108. tagmanager/
  109. taskqueue/
  110. tasks/
  111. toolresults/
  112. translate/
  113. transport/
  114. urlshortener/
  115. vision/
  116. webfonts/
  117. webmasters/
  118. youtube/
  119. youtubeanalytics/
  120. youtubereporting/
  121. .hgignore
  122. .hgtags
  123. .travis.yml
  124. api-list.json
  125. AUTHORS
  126. CONTRIBUTING.md
  127. CONTRIBUTORS
  128. GettingStarted.md
  129. key.json.enc
  130. LICENSE
  131. Makefile
  132. NOTES
  133. README.md
  134. TODO
README.md

Google APIs Client Library for Go

Status

Build Status

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 Example

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.