option: support system parameters

- Support system parameters in both gRPC and Http
- For HTTP, we added an http.transport wrapper named as parameterTransport
  to inject the parameters into HTTP headers.
- For gRPC, we added an implementation of credentials.PerRPCCredentials which
  embeds grpc.TokenSource to inject the parameters into the request metadata.
- X-Goog-IAM-Authorization-Token is not supported since it is not
implemented yet at the server-side.
- For more information please read: https://cloud.google.com/apis/docs/system-parameters

Change-Id: I8a6dc00bb7dcd43cb6ac1899d1f55847264dc019
Reviewed-on: https://code-review.googlesource.com/c/37870
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jean de Klerk <deklerk@google.com>
Reviewed-by: Chris Broadfoot <cbro@google.com>
6 files changed
tree: 4cc5e1db3c0474fe12bc5d946798b717c78b1583
  1. .gitignore
  2. .hgtags
  3. AUTHORS
  4. CONTRIBUTING.md
  5. CONTRIBUTORS
  6. GettingStarted.md
  7. LICENSE
  8. NOTES
  9. README.md
  10. TODO
  11. abusiveexperiencereport/
  12. acceleratedmobilepageurl/
  13. accesscontextmanager/
  14. adexchangebuyer/
  15. adexchangebuyer2/
  16. adexchangeseller/
  17. adexperiencereport/
  18. admin/
  19. adsense/
  20. adsensehost/
  21. alertcenter/
  22. analytics/
  23. analyticsreporting/
  24. androiddeviceprovisioning/
  25. androidenterprise/
  26. androidmanagement/
  27. androidpublisher/
  28. api-list.json
  29. appengine/
  30. appsactivity/
  31. appstate/
  32. bigquery/
  33. bigquerydatatransfer/
  34. bigtableadmin/
  35. binaryauthorization/
  36. blogger/
  37. books/
  38. calendar/
  39. chat/
  40. civicinfo/
  41. classroom/
  42. cloudasset/
  43. cloudbilling/
  44. cloudbuild/
  45. clouddebugger/
  46. clouderrorreporting/
  47. cloudfunctions/
  48. cloudidentity/
  49. cloudiot/
  50. cloudkms/
  51. cloudprofiler/
  52. cloudresourcemanager/
  53. cloudscheduler/
  54. cloudsearch/
  55. cloudshell/
  56. cloudtasks/
  57. cloudtrace/
  58. composer/
  59. compute/
  60. consumersurveys/
  61. container/
  62. containeranalysis/
  63. content/
  64. customsearch/
  65. dataflow/
  66. dataproc/
  67. datastore/
  68. deploymentmanager/
  69. dfareporting/
  70. dialogflow/
  71. digitalassetlinks/
  72. discovery/
  73. dlp/
  74. dns/
  75. docs/
  76. doubleclickbidmanager/
  77. doubleclicksearch/
  78. drive/
  79. driveactivity/
  80. examples/
  81. file/
  82. firebasedynamiclinks/
  83. firebasehosting/
  84. firebaseremoteconfig/
  85. firebaserules/
  86. firestore/
  87. fitness/
  88. fusiontables/
  89. games/
  90. gamesconfiguration/
  91. gamesmanagement/
  92. genomics/
  93. gensupport/
  94. gmail/
  95. go.mod
  96. go.sum
  97. google-api-go-generator/
  98. googleapi/
  99. groupsmigration/
  100. groupssettings/
  101. healthcare/
  102. iam/
  103. iamcredentials/
  104. iap/
  105. identitytoolkit/
  106. indexing/
  107. integration-tests/
  108. internal/
  109. iterator/
  110. jobs/
  111. key.json.enc
  112. kgsearch/
  113. language/
  114. lib/
  115. libraryagent/
  116. licensing/
  117. logging/
  118. manufacturers/
  119. mirror/
  120. ml/
  121. monitoring/
  122. oauth2/
  123. option/
  124. oslogin/
  125. pagespeedonline/
  126. partners/
  127. people/
  128. photoslibrary/
  129. playcustomapp/
  130. playmoviespartner/
  131. plus/
  132. plusdomains/
  133. poly/
  134. prediction/
  135. proximitybeacon/
  136. pubsub/
  137. qpxexpress/
  138. redis/
  139. remotebuildexecution/
  140. replicapool/
  141. replicapoolupdater/
  142. reseller/
  143. runtimeconfig/
  144. safebrowsing/
  145. script/
  146. searchconsole/
  147. servicebroker/
  148. serviceconsumermanagement/
  149. servicecontrol/
  150. servicemanagement/
  151. servicenetworking/
  152. serviceusage/
  153. serviceuser/
  154. sheets/
  155. siteverification/
  156. slides/
  157. sourcerepo/
  158. spanner/
  159. spectrum/
  160. speech/
  161. sqladmin/
  162. storage/
  163. storagetransfer/
  164. streetviewpublish/
  165. support/
  166. surveys/
  167. tagmanager/
  168. tasks/
  169. testing/
  170. texttospeech/
  171. toolresults/
  172. tpu/
  173. tracing/
  174. translate/
  175. transport/
  176. urlshortener/
  177. vault/
  178. videointelligence/
  179. vision/
  180. webfonts/
  181. webmasters/
  182. websecurityscanner/
  183. youtube/
  184. youtubeanalytics/
  185. youtubereporting/
README.md

Google APIs Client Library for Go

Getting Started

$ go get google.golang.org/api/tasks/v1
$ go get google.golang.org/api/moderator/v1
$ go get google.golang.org/api/urlshortener/v1
... etc ...

and using:

package main

import (
	"net/http"

	"google.golang.org/api/urlshortener/v1"
)

func main() {
	svc, err := urlshortener.New(http.DefaultClient)
	// ...
}

Status

GoDoc

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.

These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.

If you're working with Google Cloud Platform APIs such as Datastore or Pub/Sub, consider using the Cloud Client Libraries for Go instead. These are the new and idiomatic Go libraries targeted specifically at Google Cloud Platform Services.

The generator itself and the code it produces are beta. Some APIs are alpha/beta, and indicated as such in the import path (e.g., “google.golang.org/api/someapi/v1alpha”).

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 (
        "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.