gcloud 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +8 -8
  2. data/AUTHENTICATION.md +3 -3
  3. data/CHANGELOG.md +92 -0
  4. data/OVERVIEW.md +3 -3
  5. data/lib/gcloud.rb +75 -25
  6. data/lib/gcloud/backoff.rb +5 -1
  7. data/lib/gcloud/bigquery.rb +25 -43
  8. data/lib/gcloud/bigquery/copy_job.rb +13 -13
  9. data/lib/gcloud/bigquery/data.rb +20 -16
  10. data/lib/gcloud/bigquery/dataset.rb +202 -177
  11. data/lib/gcloud/bigquery/dataset/access.rb +118 -104
  12. data/lib/gcloud/bigquery/dataset/list.rb +14 -18
  13. data/lib/gcloud/bigquery/extract_job.rb +12 -12
  14. data/lib/gcloud/bigquery/insert_response.rb +12 -14
  15. data/lib/gcloud/bigquery/job.rb +45 -57
  16. data/lib/gcloud/bigquery/job/list.rb +18 -24
  17. data/lib/gcloud/bigquery/load_job.rb +35 -27
  18. data/lib/gcloud/bigquery/project.rb +53 -73
  19. data/lib/gcloud/bigquery/query_data.rb +28 -35
  20. data/lib/gcloud/bigquery/query_job.rb +18 -18
  21. data/lib/gcloud/bigquery/schema.rb +359 -0
  22. data/lib/gcloud/bigquery/service.rb +506 -0
  23. data/lib/gcloud/bigquery/table.rb +185 -266
  24. data/lib/gcloud/bigquery/table/list.rb +15 -19
  25. data/lib/gcloud/bigquery/view.rb +126 -81
  26. data/lib/gcloud/datastore.rb +39 -27
  27. data/lib/gcloud/datastore/commit.rb +2 -2
  28. data/lib/gcloud/datastore/dataset.rb +8 -19
  29. data/lib/gcloud/datastore/dataset/lookup_results.rb +2 -4
  30. data/lib/gcloud/datastore/dataset/query_results.rb +0 -2
  31. data/lib/gcloud/datastore/entity.rb +7 -1
  32. data/lib/gcloud/datastore/errors.rb +5 -27
  33. data/lib/gcloud/datastore/grpc_utils.rb +4 -3
  34. data/lib/gcloud/datastore/key.rb +6 -0
  35. data/lib/gcloud/datastore/service.rb +18 -12
  36. data/lib/gcloud/datastore/transaction.rb +0 -10
  37. data/lib/gcloud/dns.rb +29 -19
  38. data/lib/gcloud/dns/change.rb +10 -15
  39. data/lib/gcloud/dns/change/list.rb +4 -4
  40. data/lib/gcloud/dns/importer.rb +1 -1
  41. data/lib/gcloud/dns/project.rb +32 -49
  42. data/lib/gcloud/dns/record.rb +8 -2
  43. data/lib/gcloud/dns/record/list.rb +4 -4
  44. data/lib/gcloud/dns/service.rb +167 -0
  45. data/lib/gcloud/dns/zone.rb +33 -52
  46. data/lib/gcloud/dns/zone/list.rb +12 -16
  47. data/lib/gcloud/errors.rb +31 -19
  48. data/lib/gcloud/logging.rb +50 -39
  49. data/lib/gcloud/logging/entry.rb +197 -24
  50. data/lib/gcloud/logging/entry/list.rb +0 -2
  51. data/lib/gcloud/logging/logger.rb +1 -1
  52. data/lib/gcloud/logging/metric.rb +3 -9
  53. data/lib/gcloud/logging/metric/list.rb +0 -2
  54. data/lib/gcloud/logging/project.rb +58 -54
  55. data/lib/gcloud/logging/resource_descriptor.rb +2 -2
  56. data/lib/gcloud/logging/resource_descriptor/list.rb +0 -2
  57. data/lib/gcloud/logging/service.rb +32 -23
  58. data/lib/gcloud/logging/sink.rb +8 -14
  59. data/lib/gcloud/logging/sink/list.rb +0 -2
  60. data/lib/gcloud/pubsub.rb +21 -16
  61. data/lib/gcloud/pubsub/policy.rb +204 -0
  62. data/lib/gcloud/pubsub/project.rb +26 -38
  63. data/lib/gcloud/pubsub/service.rb +39 -31
  64. data/lib/gcloud/pubsub/subscription.rb +56 -59
  65. data/lib/gcloud/pubsub/subscription/list.rb +4 -4
  66. data/lib/gcloud/pubsub/topic.rb +69 -66
  67. data/lib/gcloud/pubsub/topic/list.rb +0 -2
  68. data/lib/gcloud/pubsub/topic/{batch.rb → publisher.rb} +15 -2
  69. data/lib/gcloud/resource_manager.rb +27 -26
  70. data/lib/gcloud/resource_manager/manager.rb +19 -39
  71. data/lib/gcloud/resource_manager/policy.rb +211 -0
  72. data/lib/gcloud/resource_manager/project.rb +97 -121
  73. data/lib/gcloud/resource_manager/project/list.rb +7 -7
  74. data/lib/gcloud/resource_manager/project/updater.rb +4 -9
  75. data/lib/gcloud/resource_manager/service.rb +127 -0
  76. data/lib/gcloud/storage.rb +24 -42
  77. data/lib/gcloud/storage/bucket.rb +104 -192
  78. data/lib/gcloud/storage/bucket/acl.rb +47 -143
  79. data/lib/gcloud/storage/bucket/cors.rb +55 -11
  80. data/lib/gcloud/storage/bucket/list.rb +14 -14
  81. data/lib/gcloud/storage/errors.rb +3 -43
  82. data/lib/gcloud/storage/file.rb +114 -111
  83. data/lib/gcloud/storage/file/acl.rb +27 -113
  84. data/lib/gcloud/storage/file/list.rb +21 -21
  85. data/lib/gcloud/storage/project.rb +49 -59
  86. data/lib/gcloud/storage/service.rb +347 -0
  87. data/lib/gcloud/translate.rb +24 -14
  88. data/lib/gcloud/translate/api.rb +12 -21
  89. data/lib/gcloud/translate/detection.rb +5 -5
  90. data/lib/gcloud/translate/language.rb +1 -1
  91. data/lib/gcloud/translate/service.rb +80 -0
  92. data/lib/gcloud/translate/translation.rb +6 -6
  93. data/lib/gcloud/version.rb +1 -1
  94. data/lib/gcloud/vision.rb +24 -15
  95. data/lib/gcloud/vision/annotate.rb +24 -21
  96. data/lib/gcloud/vision/annotation.rb +9 -9
  97. data/lib/gcloud/vision/annotation/entity.rb +11 -11
  98. data/lib/gcloud/vision/annotation/face.rb +25 -25
  99. data/lib/gcloud/vision/annotation/properties.rb +8 -8
  100. data/lib/gcloud/vision/annotation/safe_search.rb +4 -4
  101. data/lib/gcloud/vision/annotation/text.rb +7 -7
  102. data/lib/gcloud/vision/annotation/vertex.rb +1 -1
  103. data/lib/gcloud/vision/image.rb +11 -11
  104. data/lib/gcloud/vision/location.rb +5 -2
  105. data/lib/gcloud/vision/project.rb +14 -16
  106. data/lib/gcloud/vision/service.rb +66 -0
  107. data/lib/google/api_client.rb +0 -0
  108. metadata +27 -24
  109. data/lib/gcloud/bigquery/connection.rb +0 -624
  110. data/lib/gcloud/bigquery/errors.rb +0 -68
  111. data/lib/gcloud/bigquery/table/schema.rb +0 -234
  112. data/lib/gcloud/dns/connection.rb +0 -173
  113. data/lib/gcloud/dns/errors.rb +0 -68
  114. data/lib/gcloud/resource_manager/connection.rb +0 -134
  115. data/lib/gcloud/resource_manager/errors.rb +0 -68
  116. data/lib/gcloud/storage/connection.rb +0 -444
  117. data/lib/gcloud/translate/connection.rb +0 -85
  118. data/lib/gcloud/translate/errors.rb +0 -68
  119. data/lib/gcloud/upload.rb +0 -95
  120. data/lib/gcloud/vision/connection.rb +0 -63
  121. data/lib/gcloud/vision/errors.rb +0 -69
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTIzYjc5OWY0M2E1MGJkMTVlNWI5NmM4YTdkZDM3ZWRmZTgyZDRiZQ==
4
+ MTdmZDU0OTY4YzZmZjM4OTJkZTVmMDVkODg2NmVmNjIyZTdhNjY4ZA==
5
5
  data.tar.gz: !binary |-
6
- Nzg1ZTExY2RhMDRlMDUzMzkyY2FkYTI4ODUyMDc3NTEyMjIzM2QyMw==
6
+ ZDFjMWNhZGJkMDNlM2YzODZhNWU2MGJmZGZjYWQ4YjU5N2ZkMzRjNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmFjZmQyMjU4NjRhZGM0Zjc4NDYxYmVjYTQyNzhhZGI1ZTAyZjBhYTBjMDZm
10
- N2U5OWZkOTYzZDk1NjEyNzk0MjJiMTU1OTVlYjZiN2Q1MjhjMTMwYjg2M2U3
11
- OWI2NWYxMjlmZGE2NDM2MDZjOWExYzIyNDhiMjEzOTE4ZWRjMjY=
9
+ ZDgwNjM1ZjNmYjg3YjI3NjJiYTA2NmNjN2JiYzU5MDllYzY3NGMzYTY0Yjg1
10
+ YTM4M2FkODM3MTNmYWUxZDViNTE0MTQzYjk5NTFmMGMzN2EyOWIzZmFmODVk
11
+ OTVjNTkzOWY2NGIzM2RmMzhiMDFlOGYzYjk2ZTA2ZjBjNDIyMzk=
12
12
  data.tar.gz: !binary |-
13
- ZjgzNWI3NjA3ZWFkNmJjZWUxYWM1M2M3MGIxMzdmOTcxMTdlZjIzZjRiOGU3
14
- Yzk1MWQ0ZDQzYjg0N2Y1MDI2MzhmM2VlNTA0NWY2NWYyMDAzMjU3YmE5YzM3
15
- ZWI3MTkyMDU2M2YyYzMyYWQ0MTg0YWMwYzc4NWNlNTBmMThlNzU=
13
+ OGZmNGE2ODE4MDViM2MzNzc0ZjQ4YzZmNGRjZjUyZmViNjE1ZWY1OThlZmQx
14
+ Y2ZmOGEyZjVlMzFhMzZjODNlNDNhMjVmYzQ1ZGY3ZDQ2ZTBjZTRjMjQ5ODRk
15
+ NmY5YmQ0NWZiZDk1YzZlZjU0MmJlZGQzZWRhODRlMGQzOWI1ZWY=
data/AUTHENTICATION.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Creating a Service Account
4
4
 
5
- Gcloud aims to make authentication as simple as possible. Google Cloud requires a **Project ID** and **Service Account Credentials** to connect to the APIs. To create a service account:
5
+ The gcloud-ruby library aims to make authentication as simple as possible. Google Cloud requires a **Project ID** and **Service Account Credentials** to connect to the APIs. To create a service account:
6
6
 
7
7
  1. Visit the [Google Developers Console Projects page](https://console.developers.google.com/project).
8
8
  1. Create a new project or click on an existing project that you wish to use.
@@ -18,11 +18,11 @@ Gcloud aims to make authentication as simple as possible. Google Cloud requires
18
18
  1. Under **New credentials**, select **Service account key**.
19
19
  1. If you want to create a new service account, under **Service account**, select **New service account**. Otherwise, select an existing service account. Submit the form to download a JSON type key. Save the downloaded JSON key file to authorize your requests.
20
20
 
21
- You will use the **Project ID** and **JSON file** to connect to services with gcloud.
21
+ You will use the **Project ID** and **JSON file** to connect to services with gcloud-ruby.
22
22
 
23
23
  ## Project and Credential Lookup
24
24
 
25
- Gcloud aims to make authentication as simple as possible, and provides several mechanisms to configure your system without providing **Project ID** and **Service Account Credentials** directly in code.
25
+ The gcloud-ruby library aims to make authentication as simple as possible, and provides several mechanisms to configure your system without providing **Project ID** and **Service Account Credentials** directly in code.
26
26
 
27
27
  **Project ID** is discovered in the following order:
28
28
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,97 @@
1
1
  # Release History
2
2
 
3
+ ### 0.12.0 / 2016-07-25
4
+
5
+ In addition to upgrading the `google-api-client` dependency to the latest version (a significant change in the HTTP stack), this release makes a number of small, breaking changes in anticipation of gcloud-ruby `1.0`.
6
+
7
+ #### Changes
8
+
9
+ * Core
10
+ * Upgrade Google API Client dependency to `0.9`
11
+ * Upgrade gRPC dependency to `1.0.0.pre1`
12
+ * Add optional arguments `retries` and `timeout` to service factories
13
+ * Remove `Gcloud::Error#inner`, use `#cause` instead
14
+ * Remove `Gcloud::Backoff`
15
+ * Remove `Gcloud::Upload`
16
+ * BigQuery
17
+ * Replace `Bigquery::Error` and `Bigquery::ApiError` classes with `Gcloud::Error` classes
18
+ * Update `Dataset#access` to return a frozen `Dataset::Access` object (was array of hashes)
19
+ * Remove `Dataset#access=`, use `Dataset#access` with a block to make changes
20
+ * Update `Dataset#create_table` method
21
+ * Remove `schema` optional argument
22
+ * Add `fields` optional argument
23
+ * Yield `Table::Updater` instead of `Table::Schema`
24
+ * Remove erroneous `Dataset::Access` methods
25
+ * `Dataset::Access#add_owner_view`
26
+ * `Dataset::Access#add_writer_view`
27
+ * `Dataset::Access#remove_writer_view`
28
+ * `Dataset::Access#remove_owner_view`
29
+ * `Dataset::Access#writer_view?`
30
+ * `Dataset::Access#owner_view?`
31
+ * Remove erroneous `Job::List#total` accessor
32
+ * Remove erroneous `Project#access` method
33
+ * Move `Table::Schema` to `Schema`
34
+ * Update `Table#schema` to return a frozen `Schema` object (was hash)
35
+ * Remove `Table#schema=`, use `Table#schema` with a block to make changes
36
+ * Add `Schema::Field`
37
+ * Add `View#id` and `#query_id` methods, to match `Table`
38
+ * Add `Dataset::Updater` class
39
+ * Add `Table::Updater` class
40
+ * Remove `Table#load` optional argument `chunk_size`
41
+ * Datastore
42
+ * Replace `Datastore::Error` and `Datastore::KeyfileError` classes with `Gcloud::Error` classes
43
+ * Add `KeyError` class
44
+ * Remove `TransactionError#commit_error` and `#transaction_error` methods, use `#cause` instead
45
+ * Add `Entity#serialized_size` method
46
+ * Add `Key#serialized_size` method
47
+ * Update documentation for emulator (pcostell)
48
+ * DNS
49
+ * Replace `Dns::Error` and `Dns::ApiError` classes with `Gcloud::Error` classes
50
+ * Logging
51
+ * Update `Project#entry` with convenient optional arguments
52
+ * Add `Entry#resource=` method
53
+ * Add `Entry` severity convenience methods
54
+ * `Entry#default!`
55
+ * `Entry#debug!`
56
+ * `Entry#info!`
57
+ * `Entry#notice!`
58
+ * `Entry#warning!`
59
+ * `Entry#error!`
60
+ * `Entry#critical!`
61
+ * `Entry#alert!`
62
+ * `Entry#emergency!`
63
+ * Pub/Sub
64
+ * Add `Policy` class
65
+ * Update `Topic#policy` to yield a `Policy` object to be updated
66
+ * Update `Topic#policy`/`#policy=` to return/receive `Policy` object (was hash)
67
+ * Update `Subscription#policy` to yield a `Policy` object to be updated
68
+ * Update `Subscription#policy`/`#policy=` to return/receive `Policy` object (was hash)
69
+ * Rename `Topic::Batch` to `Topic::Publisher`
70
+ * Resource Manager
71
+ * Upgrade to `V1` API
72
+ * Add `Policy` class
73
+ * Update `Project#policy` to yield a `Policy` object to be updated
74
+ * Update `Project#policy`/`#policy=` to return/receive `Policy` object (was hash)
75
+ * Storage
76
+ * Replace `Storage::Error` and `Storage::ApiError` classes with `Gcloud::Error` classes
77
+ * Update `Project#create_bucket`
78
+ * Yield `Bucket::Updater` object instead of a `Bucket::Cors` object
79
+ * Remove `cors` optional argument
80
+ * Remove `Bucket#create_file` optional argument `chunk_size`
81
+ * Remove `Bucket#cors=`, use `Bucket#cors` with a block to make changes
82
+ * Add `Bucket::Cors::Rule` class
83
+ * Remove erroneous `Bucket::DefaultAcl` methods
84
+ * `Bucket::DefaultAcl#writers`
85
+ * `Bucket::DefaultAcl#add_writer`
86
+ * Remove erroneous `File::Acl` methods
87
+ * `File::Acl#writers`
88
+ * `File::Acl#add_writer`
89
+ * Translate
90
+ * Replace `Translate::Error` and `Translate::ApiError` classes with `Gcloud::Error` classes
91
+ * Vision
92
+ * Replace `Vision::Error` and `Vision::ApiError` classes with `Gcloud::Error` classes
93
+
94
+
3
95
  ### 0.11.0 / 2016-06-13
4
96
 
5
97
  #### Changes
data/OVERVIEW.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Getting started
2
2
 
3
- The `gcloud` library is installable through rubygems:
3
+ The gcloud-ruby library is installable through rubygems:
4
4
 
5
5
  ```sh
6
6
  $ gem install gcloud
7
7
  ```
8
8
 
9
- Gcloud aims to make authentication as simple as possible. Google Cloud requires a **Project ID** and **Service Account Credentials** to connect to the APIs. You can learn more about various options for connection on the [Authentication Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
9
+ The gcloud-ruby library aims to make authentication as simple as possible. Google Cloud requires a **Project ID** and **Service Account Credentials** to connect to the APIs. You can learn more about various options for connection on the [Authentication Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
10
10
 
11
11
  # BigQuery
12
12
 
@@ -99,7 +99,7 @@ end
99
99
 
100
100
  # Logging
101
101
 
102
- [Google Cloud Logging](https://cloud.google.com/logging/) collects and stores logs from applications and services on the Google Cloud Platform, giving you fine-grained, programmatic control over your projects' logs. With this API you can do the following:
102
+ [Stackdriver Logging](https://cloud.google.com/logging/) collects and stores logs from applications and services on the Google Cloud Platform, giving you fine-grained, programmatic control over your projects' logs. With this API you can do the following:
103
103
 
104
104
  * Read and filter log entries
105
105
  * Export your log entries to Cloud Storage,
data/lib/gcloud.rb CHANGED
@@ -18,12 +18,13 @@ require "gcloud/version"
18
18
  ##
19
19
  # # Google Cloud
20
20
  #
21
- # Gcloud is the official library for interacting with the Google Cloud Platform.
22
- # Google Cloud Platform is a set of modular cloud-based services that allow
23
- # you to create anything from simple websites to complex applications.
21
+ # The gcloud-ruby library is the official library for interacting with Google
22
+ # Cloud Platform. Google Cloud Platform is a set of modular cloud-based services
23
+ # that allow you to create anything from simple websites to complex
24
+ # applications.
24
25
  #
25
- # Gcloud's goal is to provide a API that is familiar and comfortable to
26
- # Rubyists. Authentication is handled by providing project and credential
26
+ # The goal of gcloud-ruby is to provide a API that is familiar and comfortable
27
+ # to Rubyists. Authentication is handled by providing project and credential
27
28
  # information, or if you are running on Google Compute Engine this configuration
28
29
  # is taken care of for you.
29
30
  #
@@ -41,6 +42,9 @@ module Gcloud
41
42
  # connecting to.
42
43
  # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
43
44
  # path the file must be readable.
45
+ # @param [Integer] retries Number of times to retry requests on server error.
46
+ # The default value is `3`. Optional.
47
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
44
48
  #
45
49
  # @return [Gcloud]
46
50
  #
@@ -52,10 +56,12 @@ module Gcloud
52
56
  # pubsub = gcloud.pubsub
53
57
  # storage = gcloud.storage
54
58
  #
55
- def self.new project = nil, keyfile = nil
59
+ def self.new project = nil, keyfile = nil, retries: nil, timeout: nil
56
60
  gcloud = Object.new
57
61
  gcloud.instance_variable_set "@project", project
58
62
  gcloud.instance_variable_set "@keyfile", keyfile
63
+ gcloud.instance_variable_set "@retries", retries
64
+ gcloud.instance_variable_set "@timeout", timeout
59
65
  gcloud.extend Gcloud
60
66
  gcloud
61
67
  end
@@ -75,6 +81,9 @@ module Gcloud
75
81
  # The default scope is:
76
82
  #
77
83
  # * `https://www.googleapis.com/auth/datastore`
84
+ # @param [Integer] retries Number of times to retry requests on server error.
85
+ # The default value is `3`. Optional.
86
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
78
87
  #
79
88
  # @return [Gcloud::Datastore::Dataset]
80
89
  #
@@ -100,9 +109,11 @@ module Gcloud
100
109
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
101
110
  # datastore = gcloud.datastore scope: platform_scope
102
111
  #
103
- def datastore scope: nil
112
+ def datastore scope: nil, retries: nil, timeout: nil
104
113
  require "gcloud/datastore"
105
- Gcloud.datastore @project, @keyfile, scope: scope
114
+ Gcloud.datastore @project, @keyfile, scope: scope,
115
+ retries: (retries || @retries),
116
+ timeout: (timeout || @timeout)
106
117
  end
107
118
 
108
119
  ##
@@ -123,6 +134,9 @@ module Gcloud
123
134
  # The default scope is:
124
135
  #
125
136
  # * `https://www.googleapis.com/auth/devstorage.full_control`
137
+ # @param [Integer] retries Number of times to retry requests on server error.
138
+ # The default value is `3`. Optional.
139
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
126
140
  #
127
141
  # @return [Gcloud::Storage::Project]
128
142
  #
@@ -141,9 +155,11 @@ module Gcloud
141
155
  # readonly_scope = "https://www.googleapis.com/auth/devstorage.read_only"
142
156
  # readonly_storage = gcloud.storage scope: readonly_scope
143
157
  #
144
- def storage scope: nil
158
+ def storage scope: nil, retries: nil, timeout: nil
145
159
  require "gcloud/storage"
146
- Gcloud.storage @project, @keyfile, scope: scope
160
+ Gcloud.storage @project, @keyfile, scope: scope,
161
+ retries: (retries || @retries),
162
+ timeout: (timeout || @timeout)
147
163
  end
148
164
 
149
165
  ##
@@ -161,6 +177,9 @@ module Gcloud
161
177
  # The default scope is:
162
178
  #
163
179
  # * `https://www.googleapis.com/auth/pubsub`
180
+ # @param [Integer] retries Number of times to retry requests on server error.
181
+ # The default value is `3`. Optional.
182
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
164
183
  #
165
184
  # @return [Gcloud::Pubsub::Project]
166
185
  #
@@ -179,9 +198,11 @@ module Gcloud
179
198
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
180
199
  # pubsub = gcloud.pubsub scope: platform_scope
181
200
  #
182
- def pubsub scope: nil
201
+ def pubsub scope: nil, retries: nil, timeout: nil
183
202
  require "gcloud/pubsub"
184
- Gcloud.pubsub @project, @keyfile, scope: scope
203
+ Gcloud.pubsub @project, @keyfile, scope: scope,
204
+ retries: (retries || @retries),
205
+ timeout: (timeout || @timeout)
185
206
  end
186
207
 
187
208
  ##
@@ -199,6 +220,9 @@ module Gcloud
199
220
  # The default scope is:
200
221
  #
201
222
  # * `https://www.googleapis.com/auth/bigquery`
223
+ # @param [Integer] retries Number of times to retry requests on server error.
224
+ # The default value is `3`. Optional.
225
+ # @param [Integer] timeout Default request timeout in seconds. Optional.
202
226
  #
203
227
  # @return [Gcloud::Bigquery::Project]
204
228
  #
@@ -220,9 +244,11 @@ module Gcloud
220
244
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
221
245
  # bigquery = gcloud.bigquery scope: platform_scope
222
246
  #
223
- def bigquery scope: nil
247
+ def bigquery scope: nil, retries: nil, timeout: nil
224
248
  require "gcloud/bigquery"
225
- Gcloud.bigquery @project, @keyfile, scope: scope
249
+ Gcloud.bigquery @project, @keyfile, scope: scope,
250
+ retries: (retries || @retries),
251
+ timeout: (timeout || @timeout)
226
252
  end
227
253
 
228
254
  ##
@@ -240,6 +266,9 @@ module Gcloud
240
266
  # The default scope is:
241
267
  #
242
268
  # * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
269
+ # @param [Integer] retries Number of times to retry requests on server error.
270
+ # The default value is `3`. Optional.
271
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
243
272
  #
244
273
  # @return [Gcloud::Dns::Project]
245
274
  #
@@ -260,9 +289,11 @@ module Gcloud
260
289
  # readonly_scope = "https://www.googleapis.com/auth/ndev.clouddns.readonly"
261
290
  # dns = gcloud.dns scope: readonly_scope
262
291
  #
263
- def dns scope: nil
292
+ def dns scope: nil, retries: nil, timeout: nil
264
293
  require "gcloud/dns"
265
- Gcloud.dns @project, @keyfile, scope: scope
294
+ Gcloud.dns @project, @keyfile, scope: scope,
295
+ retries: (retries || @retries),
296
+ timeout: (timeout || @timeout)
266
297
  end
267
298
 
268
299
  # rubocop:disable Metrics/LineLength
@@ -284,6 +315,9 @@ module Gcloud
284
315
  # The default scope is:
285
316
  #
286
317
  # * `https://www.googleapis.com/auth/cloud-platform`
318
+ # @param [Integer] retries Number of times to retry requests on server error.
319
+ # The default value is `3`. Optional.
320
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
287
321
  #
288
322
  # @return [Gcloud::ResourceManager::Manager]
289
323
  #
@@ -303,15 +337,17 @@ module Gcloud
303
337
  # readonly_scope = "https://www.googleapis.com/auth/cloudresourcemanager.readonly"
304
338
  # resource_manager = gcloud.resource_manager scope: readonly_scope
305
339
  #
306
- def resource_manager scope: nil
340
+ def resource_manager scope: nil, retries: nil, timeout: nil
307
341
  require "gcloud/resource_manager"
308
- Gcloud.resource_manager @keyfile, scope: scope
342
+ Gcloud.resource_manager @keyfile, scope: scope,
343
+ retries: (retries || @retries),
344
+ timeout: (timeout || @timeout)
309
345
  end
310
346
 
311
347
  # rubocop:enable Metrics/LineLength
312
348
 
313
349
  ##
314
- # Creates a new object for connecting to the Logging service.
350
+ # Creates a new object for connecting to the Stackdriver Logging service.
315
351
  # Each call creates a new connection.
316
352
  #
317
353
  # For more information on connecting to Google Cloud see the [Authentication
@@ -325,6 +361,9 @@ module Gcloud
325
361
  # The default scope is:
326
362
  #
327
363
  # * `https://www.googleapis.com/auth/logging.admin`
364
+ # @param [Integer] retries Number of times to retry requests on server error.
365
+ # The default value is `3`. Optional.
366
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
328
367
  #
329
368
  # @return [Gcloud::Logging::Project]
330
369
  #
@@ -342,9 +381,11 @@ module Gcloud
342
381
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
343
382
  # logging = gcloud.logging scope: platform_scope
344
383
  #
345
- def logging scope: nil
384
+ def logging scope: nil, retries: nil, timeout: nil
346
385
  require "gcloud/logging"
347
- Gcloud.logging @project, @keyfile, scope: scope
386
+ Gcloud.logging @project, @keyfile, scope: scope,
387
+ retries: (retries || @retries),
388
+ timeout: (timeout || @timeout)
348
389
  end
349
390
 
350
391
  ##
@@ -360,6 +401,9 @@ module Gcloud
360
401
  # keys](https://cloud.google.com/translate/v2/using_rest#creating-server-api-keys).
361
402
  #
362
403
  # @param [String] key a public API access key (not an OAuth 2.0 token)
404
+ # @param [Integer] retries Number of times to retry requests on server error.
405
+ # The default value is `3`. Optional.
406
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
363
407
  #
364
408
  # @return [Gcloud::Translate::Api]
365
409
  #
@@ -383,9 +427,10 @@ module Gcloud
383
427
  # translation = translate.translate "Hello world!", to: "la"
384
428
  # translation.text #=> "Salve mundi!"
385
429
  #
386
- def translate key = nil
430
+ def translate key = nil, retries: nil, timeout: nil
387
431
  require "gcloud/translate"
388
- Gcloud.translate key
432
+ Gcloud.translate key, retries: (retries || @retries),
433
+ timeout: (timeout || @timeout)
389
434
  end
390
435
 
391
436
  ##
@@ -400,6 +445,9 @@ module Gcloud
400
445
  # The default scope is:
401
446
  #
402
447
  # * `https://www.googleapis.com/auth/cloud-platform`
448
+ # @param [Integer] retries Number of times to retry requests on server error.
449
+ # The default value is `3`. Optional.
450
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
403
451
  #
404
452
  # @return [Gcloud::Vision::Project]
405
453
  #
@@ -421,8 +469,10 @@ module Gcloud
421
469
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
422
470
  # vision = gcloud.vision scope: platform_scope
423
471
  #
424
- def vision scope: nil
472
+ def vision scope: nil, retries: nil, timeout: nil
425
473
  require "gcloud/vision"
426
- Gcloud.vision @project, @keyfile, scope: scope
474
+ Gcloud.vision @project, @keyfile, scope: scope,
475
+ retries: (retries || @retries),
476
+ timeout: (timeout || @timeout)
427
477
  end
428
478
  end
@@ -15,6 +15,7 @@
15
15
 
16
16
  module Gcloud
17
17
  ##
18
+ # @private
18
19
  # Backoff allows users to control how Google API calls are retried.
19
20
  # If an API call fails the response will be checked to see if the
20
21
  # call can be retried. If the response matches the criteria, then it
@@ -34,7 +35,10 @@ module Gcloud
34
35
  # The number of times a retriable API call should be retried.
35
36
  #
36
37
  # The default value is `3`.
37
- attr_accessor :retries
38
+ attr_reader :retries
39
+ def retries= new_retries
40
+ @retries = new_retries
41
+ end
38
42
 
39
43
  ##
40
44
  # The GRPC Status Codes that should be retried.
@@ -36,6 +36,9 @@ module Gcloud
36
36
  # The default scope is:
37
37
  #
38
38
  # * `https://www.googleapis.com/auth/bigquery`
39
+ # @param [Integer] retries Number of times to retry requests on server error.
40
+ # The default value is `3`. Optional.
41
+ # @param [Integer] timeout Default timeout to use in requests. Optional.
39
42
  #
40
43
  # @return [Gcloud::Bigquery::Project]
41
44
  #
@@ -46,14 +49,21 @@ module Gcloud
46
49
  # dataset = bigquery.dataset "my_dataset"
47
50
  # table = dataset.table "my_table"
48
51
  #
49
- def self.bigquery project = nil, keyfile = nil, scope: nil
52
+ def self.bigquery project = nil, keyfile = nil, scope: nil, retries: nil,
53
+ timeout: nil
50
54
  project ||= Gcloud::Bigquery::Project.default_project
55
+ project = project.to_s # Always cast to a string
56
+ fail ArgumentError, "project is missing" if project.empty?
57
+
51
58
  if keyfile.nil?
52
59
  credentials = Gcloud::Bigquery::Credentials.default scope: scope
53
60
  else
54
61
  credentials = Gcloud::Bigquery::Credentials.new keyfile, scope: scope
55
62
  end
56
- Gcloud::Bigquery::Project.new project, credentials
63
+
64
+ Gcloud::Bigquery::Project.new(
65
+ Gcloud::Bigquery::Service.new(
66
+ project, credentials, retries: retries, timeout: timeout))
57
67
  end
58
68
 
59
69
  ##
@@ -64,8 +74,8 @@ module Gcloud
64
74
  # more, read [What is
65
75
  # BigQuery?](https://cloud.google.com/bigquery/what-is-bigquery).
66
76
  #
67
- # Gcloud's goal is to provide an API that is familiar and comfortable to
68
- # Rubyists. Authentication is handled by {Gcloud#bigquery}. You can provide
77
+ # The goal of gcloud-ruby is to provide an API that is comfortable
78
+ # to Rubyists. Authentication is handled by {Gcloud#bigquery}. You can provide
69
79
  # the project and credential information to connect to the BigQuery service,
70
80
  # or if you are running on Google Compute Engine this configuration is taken
71
81
  # care of for you. You can read more about the options for connecting in the
@@ -311,33 +321,6 @@ module Gcloud
311
321
  # default format for load operations, the option is not actually necessary.
312
322
  # For JSON saved with a `.txt` extension, however, it would be.
313
323
  #
314
- # ### A note about large uploads
315
- #
316
- # You may encounter a Broken pipe (`Errno::EPIPE`) error when attempting to
317
- # upload large files. To avoid this problem, add the
318
- # [httpclient](https://rubygems.org/gems/httpclient) gem to your project, and
319
- # the line (or lines) of configuration shown below. These lines must execute
320
- # after you require gcloud but before you make your first gcloud connection.
321
- # The first statement configures [Faraday](https://rubygems.org/gems/faraday)
322
- # to use httpclient. The second statement, which should only be added if you
323
- # are using a version of Faraday at or above 0.9.2, is a workaround for [this
324
- # gzip issue](https://github.com/GoogleCloudPlatform/gcloud-ruby/issues/367).
325
- #
326
- # ```ruby
327
- # require "gcloud"
328
- #
329
- # # Use httpclient to avoid broken pipe errors with large uploads
330
- # Faraday.default_adapter = :httpclient
331
- #
332
- # # Only add the following statement if using Faraday >= 0.9.2
333
- # # Override gzip middleware with no-op for httpclient
334
- # Faraday::Response.register_middleware :gzip =>
335
- # Faraday::Response::Middleware
336
- #
337
- # gcloud = Gcloud.new
338
- # bigquery = gcloud.bigquery
339
- # ```
340
- #
341
324
  # ## Exporting query results to Google Cloud Storage
342
325
  #
343
326
  # The example below shows how to pass the `table` option with a query in order
@@ -386,24 +369,23 @@ module Gcloud
386
369
  # BigQuery](https://cloud.google.com/bigquery/exporting-data-from-bigquery)
387
370
  # for details.
388
371
  #
389
- # ## Configuring Backoff
372
+ # ## Configuring retries and timeout
390
373
  #
391
- # The {Gcloud::Backoff} class allows users to globally configure how Cloud API
392
- # requests are automatically retried in the case of some errors, such as a
393
- # `500` or `503` status code, or a specific internal error code such as
394
- # `rateLimitExceeded`.
374
+ # You can configure how many times API requests may be automatically retried.
375
+ # When an API request fails, the response will be inspected to see if the
376
+ # request meets criteria indicating that it may succeed on retry, such as
377
+ # `500` and `503` status codes or a specific internal error code such as
378
+ # `rateLimitExceeded`. If it meets the criteria, the request will be retried
379
+ # after a delay. If another error occurs, the delay will be increased before a
380
+ # subsequent attempt, until the `retries` limit is reached.
395
381
  #
396
- # If an API call fails, the response will be inspected to see if the call
397
- # should be retried. If the response matches the criteria, then the request
398
- # will be retried after a delay. If another error occurs, the delay will be
399
- # increased incrementally before a subsequent attempt. The first retry will be
400
- # delayed one second, the second retry two seconds, and so on.
382
+ # You can also set the request `timeout` value in seconds.
401
383
  #
402
384
  # ```ruby
403
385
  # require "gcloud"
404
- # require "gcloud/backoff"
405
386
  #
406
- # Gcloud::Backoff.retries = 5 # Raise the maximum number of retries from 3
387
+ # gcloud = Gcloud.new
388
+ # bigquery = gcloud.bigquery retries: 10, timeout: 120
407
389
  # ```
408
390
  #
409
391
  # See the [BigQuery error