transport: Add dialer with tcp user timeout

The new dialer is only supported by go1.11+, and is only used when
GOOGLE_CLOUD_ENABLE_DIRECT_PATH contains specific services. e.g.
GOOGLE_CLOUD_ENABLE_DIRECT_PATH=spanner,bigtable means only spanner and
bigtable will be using this dialer.

Note that currently this socketopt dialer will overwrite user defined
dialer if any. I will update this logic once we have a way to introspect
the dialoptions(https://github.com/grpc/grpc-go/issues/2795).

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