Simplify per-call API by factoring common cross-API parameters.

This introduces googleapi.CallOption to replace the QuotaUser and UserIP
methods that are attached to many Call types.

Instead of
	type AclDeleteCall
	func (c *AclDeleteCall) Do() error
	func (c *AclDeleteCall) QuotaUser(quotaUser string) *AclDeleteCall
	func (c *AclDeleteCall) UserIP(userIP string) *AclDeleteCall
we now generate
	type AclDeleteCall
	func (c *AclDeleteCall) Do(...googleapi.CallOption) error
and supply in package googleapi
	type CallOption
	func QuotaUser(u string) CallOption
	func UserIP(ip string) CallOption

Change-Id: I41518390cfd9d13150aaf35b5fe703e812e3643e
Reviewed-on: https://code-review.googlesource.com/3992
Reviewed-by: Michael McGreevy <mcgreevy@golang.org>
144 files changed
tree: 1520c734cb2e7af353e05ca8e4106cd821514898
  1. adexchangebuyer/
  2. adexchangeseller/
  3. admin/
  4. adsense/
  5. adsensehost/
  6. analytics/
  7. androidenterprise/
  8. androidpublisher/
  9. appengine/
  10. appsactivity/
  11. appstate/
  12. autoscaler/
  13. bigquery/
  14. blogger/
  15. books/
  16. calendar/
  17. civicinfo/
  18. classroom/
  19. cloudbilling/
  20. clouddebugger/
  21. cloudlatencytest/
  22. cloudmonitoring/
  23. cloudresourcemanager/
  24. cloudtrace/
  25. clouduseraccounts/
  26. compute/
  27. container/
  28. content/
  29. coordinate/
  30. customsearch/
  31. dataflow/
  32. dataproc/
  33. datastore/
  34. deploymentmanager/
  35. dfareporting/
  36. discovery/
  37. dns/
  38. doubleclickbidmanager/
  39. doubleclicksearch/
  40. drive/
  41. examples/
  42. fitness/
  43. freebase/
  44. fusiontables/
  45. games/
  46. gamesconfiguration/
  47. gamesmanagement/
  48. gan/
  49. genomics/
  50. gensupport/
  51. gmail/
  52. google-api-go-generator/
  53. googleapi/
  54. groupsmigration/
  55. groupssettings/
  56. identitytoolkit/
  57. integration-tests/
  58. kgsearch/
  59. lib/
  60. licensing/
  61. logging/
  62. manager/
  63. mapsengine/
  64. mirror/
  65. oauth2/
  66. pagespeedonline/
  67. partners/
  68. playmoviespartner/
  69. plus/
  70. plusdomains/
  71. prediction/
  72. proximitybeacon/
  73. pubsub/
  74. qpxexpress/
  75. replicapool/
  76. replicapoolupdater/
  77. reseller/
  78. resourceviews/
  79. script/
  80. siteverification/
  81. spectrum/
  82. sqladmin/
  83. storage/
  84. storagetransfer/
  85. tagmanager/
  86. taskqueue/
  87. tasks/
  88. translate/
  89. urlshortener/
  90. webfonts/
  91. webmasters/
  92. youtube/
  93. youtubeanalytics/
  94. youtubereporting/
  95. .hgignore
  96. .hgtags
  97. .travis.yml
  98. api-list.json
  99. AUTHORS
  100. CONTRIBUTING.md
  101. CONTRIBUTORS
  102. GettingStarted.md
  103. key.json.enc
  104. LICENSE
  105. Makefile
  106. NOTES
  107. README.md
  108. 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.