google-api-go-client: add If-None-Match support

Fixes #86.

Note that examples/storage.go demonstrates the use of the new
If-None-Match support.

Additionally, this change allows the headers of all responses
to be inspected so that "ETag", for example, could be extracted
from the response. This could be especially useful for the
Compute API and other APIs that do not explicitly return ETag
within the body of their responses.

Note also that examples/compute.go now demonstrates the use of the
new googleapi.ServiceResponse and "ETag" extraction from the header.

Change-Id: Ic6fc35c6bdd4aca87ba0ee51b59f94b8de34d5ea
Reviewed-on: https://code-review.googlesource.com/3375
Reviewed-by: Glenn Lewis <gmlewis@google.com>
143 files changed
tree: 7951824545c7a4d844e261ccd1ccf69d1fb8f69d
  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. clouduseraccounts/
  25. compute/
  26. container/
  27. content/
  28. coordinate/
  29. customsearch/
  30. dataflow/
  31. datastore/
  32. deploymentmanager/
  33. dfareporting/
  34. discovery/
  35. dns/
  36. doubleclickbidmanager/
  37. doubleclicksearch/
  38. drive/
  39. examples/
  40. fitness/
  41. freebase/
  42. fusiontables/
  43. games/
  44. gamesconfiguration/
  45. gamesmanagement/
  46. gan/
  47. genomics/
  48. gmail/
  49. google-api-go-generator/
  50. googleapi/
  51. groupsmigration/
  52. groupssettings/
  53. identitytoolkit/
  54. internal/
  55. lib/
  56. licensing/
  57. logging/
  58. manager/
  59. mapsengine/
  60. mirror/
  61. oauth2/
  62. pagespeedonline/
  63. partners/
  64. playmoviespartner/
  65. plus/
  66. plusdomains/
  67. prediction/
  68. proximitybeacon/
  69. pubsub/
  70. qpxexpress/
  71. replicapool/
  72. replicapoolupdater/
  73. reseller/
  74. resourceviews/
  75. script/
  76. siteverification/
  77. spectrum/
  78. sqladmin/
  79. storage/
  80. storagetransfer/
  81. tagmanager/
  82. taskqueue/
  83. tasks/
  84. translate/
  85. urlshortener/
  86. webfonts/
  87. webmasters/
  88. youtube/
  89. youtubeanalytics/
  90. .hgignore
  91. .hgtags
  92. .travis.yml
  93. api-list.json
  94. AUTHORS
  95. CONTRIBUTING.md
  96. CONTRIBUTORS
  97. GettingStarted.md
  98. LICENSE
  99. Makefile
  100. NOTES
  101. README.md
  102. 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.