gcloud 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +8 -8
  2. data/AUTHENTICATION.md +13 -9
  3. data/CHANGELOG.md +8 -3
  4. data/OVERVIEW.md +46 -8
  5. data/lib/gcloud.rb +123 -117
  6. data/lib/gcloud/backoff.rb +43 -15
  7. data/lib/gcloud/bigquery.rb +211 -195
  8. data/lib/gcloud/bigquery/connection.rb +9 -9
  9. data/lib/gcloud/bigquery/copy_job.rb +15 -16
  10. data/lib/gcloud/bigquery/credentials.rb +3 -3
  11. data/lib/gcloud/bigquery/data.rb +12 -11
  12. data/lib/gcloud/bigquery/dataset.rb +162 -216
  13. data/lib/gcloud/bigquery/dataset/access.rb +59 -43
  14. data/lib/gcloud/bigquery/dataset/list.rb +3 -3
  15. data/lib/gcloud/bigquery/errors.rb +9 -5
  16. data/lib/gcloud/bigquery/extract_job.rb +18 -18
  17. data/lib/gcloud/bigquery/insert_response.rb +7 -4
  18. data/lib/gcloud/bigquery/job.rb +48 -44
  19. data/lib/gcloud/bigquery/job/list.rb +3 -3
  20. data/lib/gcloud/bigquery/load_job.rb +24 -25
  21. data/lib/gcloud/bigquery/project.rb +145 -204
  22. data/lib/gcloud/bigquery/query_data.rb +10 -9
  23. data/lib/gcloud/bigquery/query_job.rb +23 -32
  24. data/lib/gcloud/bigquery/table.rb +238 -280
  25. data/lib/gcloud/bigquery/table/list.rb +3 -3
  26. data/lib/gcloud/bigquery/table/schema.rb +79 -87
  27. data/lib/gcloud/bigquery/view.rb +69 -82
  28. data/lib/gcloud/credentials.rb +3 -9
  29. data/lib/gcloud/datastore.rb +194 -170
  30. data/lib/gcloud/datastore/connection.rb +12 -8
  31. data/lib/gcloud/datastore/credentials.rb +6 -4
  32. data/lib/gcloud/datastore/dataset.rb +74 -141
  33. data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
  34. data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
  35. data/lib/gcloud/datastore/entity.rb +81 -76
  36. data/lib/gcloud/datastore/errors.rb +10 -8
  37. data/lib/gcloud/datastore/key.rb +41 -77
  38. data/lib/gcloud/datastore/properties.rb +3 -3
  39. data/lib/gcloud/datastore/proto.rb +7 -4
  40. data/lib/gcloud/datastore/query.rb +26 -3
  41. data/lib/gcloud/datastore/transaction.rb +12 -8
  42. data/lib/gcloud/dns.rb +180 -152
  43. data/lib/gcloud/dns/change.rb +16 -16
  44. data/lib/gcloud/dns/change/list.rb +3 -3
  45. data/lib/gcloud/dns/connection.rb +9 -10
  46. data/lib/gcloud/dns/credentials.rb +3 -3
  47. data/lib/gcloud/dns/errors.rb +9 -5
  48. data/lib/gcloud/dns/importer.rb +17 -23
  49. data/lib/gcloud/dns/project.rb +42 -64
  50. data/lib/gcloud/dns/record.rb +58 -46
  51. data/lib/gcloud/dns/record/list.rb +6 -7
  52. data/lib/gcloud/dns/zone.rb +198 -289
  53. data/lib/gcloud/dns/zone/list.rb +3 -3
  54. data/lib/gcloud/dns/zone/transaction.rb +56 -72
  55. data/lib/gcloud/errors.rb +174 -3
  56. data/lib/gcloud/gce.rb +3 -4
  57. data/lib/gcloud/grpc_utils.rb +76 -0
  58. data/lib/gcloud/logging.rb +308 -0
  59. data/lib/gcloud/logging/credentials.rb +29 -0
  60. data/lib/gcloud/logging/entry.rb +303 -0
  61. data/lib/gcloud/logging/entry/http_request.rb +141 -0
  62. data/lib/gcloud/logging/entry/list.rb +111 -0
  63. data/lib/gcloud/logging/entry/operation.rb +90 -0
  64. data/lib/gcloud/logging/logger.rb +307 -0
  65. data/lib/gcloud/logging/metric.rb +175 -0
  66. data/lib/gcloud/logging/metric/list.rb +98 -0
  67. data/lib/gcloud/logging/project.rb +650 -0
  68. data/lib/gcloud/logging/resource.rb +95 -0
  69. data/lib/gcloud/logging/resource_descriptor.rb +140 -0
  70. data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
  71. data/lib/gcloud/logging/service.rb +258 -0
  72. data/lib/gcloud/logging/sink.rb +233 -0
  73. data/lib/gcloud/logging/sink/list.rb +97 -0
  74. data/lib/gcloud/pubsub.rb +241 -199
  75. data/lib/gcloud/pubsub/credentials.rb +3 -3
  76. data/lib/gcloud/pubsub/message.rb +26 -20
  77. data/lib/gcloud/pubsub/project.rb +166 -233
  78. data/lib/gcloud/pubsub/received_message.rb +28 -38
  79. data/lib/gcloud/pubsub/service.rb +323 -0
  80. data/lib/gcloud/pubsub/subscription.rb +172 -242
  81. data/lib/gcloud/pubsub/subscription/list.rb +11 -9
  82. data/lib/gcloud/pubsub/topic.rb +152 -271
  83. data/lib/gcloud/pubsub/topic/batch.rb +66 -0
  84. data/lib/gcloud/pubsub/topic/list.rb +9 -7
  85. data/lib/gcloud/resource_manager.rb +158 -138
  86. data/lib/gcloud/resource_manager/connection.rb +6 -5
  87. data/lib/gcloud/resource_manager/credentials.rb +3 -3
  88. data/lib/gcloud/resource_manager/errors.rb +9 -5
  89. data/lib/gcloud/resource_manager/manager.rb +54 -86
  90. data/lib/gcloud/resource_manager/project.rb +69 -88
  91. data/lib/gcloud/resource_manager/project/list.rb +4 -5
  92. data/lib/gcloud/resource_manager/project/updater.rb +12 -14
  93. data/lib/gcloud/search.rb +158 -135
  94. data/lib/gcloud/search/api_client.rb +7 -7
  95. data/lib/gcloud/search/connection.rb +8 -8
  96. data/lib/gcloud/search/credentials.rb +3 -3
  97. data/lib/gcloud/search/document.rb +64 -87
  98. data/lib/gcloud/search/document/list.rb +5 -5
  99. data/lib/gcloud/search/errors.rb +9 -5
  100. data/lib/gcloud/search/field_value.rb +32 -38
  101. data/lib/gcloud/search/field_values.rb +50 -80
  102. data/lib/gcloud/search/fields.rb +44 -65
  103. data/lib/gcloud/search/index.rb +163 -204
  104. data/lib/gcloud/search/index/list.rb +5 -5
  105. data/lib/gcloud/search/project.rb +31 -47
  106. data/lib/gcloud/search/result.rb +27 -31
  107. data/lib/gcloud/search/result/list.rb +6 -6
  108. data/lib/gcloud/storage.rb +224 -190
  109. data/lib/gcloud/storage/bucket.rb +202 -227
  110. data/lib/gcloud/storage/bucket/acl.rb +83 -170
  111. data/lib/gcloud/storage/bucket/cors.rb +31 -34
  112. data/lib/gcloud/storage/bucket/list.rb +3 -3
  113. data/lib/gcloud/storage/connection.rb +11 -7
  114. data/lib/gcloud/storage/credentials.rb +3 -3
  115. data/lib/gcloud/storage/errors.rb +11 -8
  116. data/lib/gcloud/storage/file.rb +129 -171
  117. data/lib/gcloud/storage/file/acl.rb +51 -99
  118. data/lib/gcloud/storage/file/list.rb +3 -3
  119. data/lib/gcloud/storage/file/verifier.rb +3 -2
  120. data/lib/gcloud/storage/project.rb +111 -132
  121. data/lib/gcloud/upload.rb +4 -7
  122. data/lib/gcloud/version.rb +2 -4
  123. data/lib/google/api/annotations.rb +14 -0
  124. data/lib/google/api/http.rb +30 -0
  125. data/lib/google/api/label.rb +24 -0
  126. data/lib/google/api/monitored_resource.rb +25 -0
  127. data/lib/google/datastore/v1beta3/datastore.rb +115 -0
  128. data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
  129. data/lib/google/datastore/v1beta3/entity.rb +63 -0
  130. data/lib/google/datastore/v1beta3/query.rb +128 -0
  131. data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
  132. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
  133. data/lib/google/example/library/v1/library.rb +91 -0
  134. data/lib/google/example/library/v1/library_services.rb +40 -0
  135. data/lib/google/iam/v1/iam_policy.rb +33 -0
  136. data/lib/google/iam/v1/iam_policy_services.rb +30 -0
  137. data/lib/google/iam/v1/policy.rb +25 -0
  138. data/lib/google/logging/type/http_request.rb +28 -0
  139. data/lib/google/logging/type/log_severity.rb +27 -0
  140. data/lib/google/logging/v2/log_entry.rb +44 -0
  141. data/lib/google/logging/v2/logging.rb +56 -0
  142. data/lib/google/logging/v2/logging_config.rb +59 -0
  143. data/lib/google/logging/v2/logging_config_services.rb +32 -0
  144. data/lib/google/logging/v2/logging_metrics.rb +51 -0
  145. data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
  146. data/lib/google/logging/v2/logging_services.rb +31 -0
  147. data/lib/google/longrunning/operations.rb +50 -0
  148. data/lib/google/longrunning/operations_services.rb +29 -0
  149. data/lib/google/protobuf/any.rb +17 -0
  150. data/lib/google/protobuf/api.rb +31 -0
  151. data/lib/google/protobuf/descriptor.rb +0 -0
  152. data/lib/google/protobuf/duration.rb +17 -0
  153. data/lib/google/protobuf/empty.rb +15 -0
  154. data/lib/google/protobuf/field_mask.rb +16 -0
  155. data/lib/google/protobuf/source_context.rb +16 -0
  156. data/lib/google/protobuf/struct.rb +35 -0
  157. data/lib/google/protobuf/timestamp.rb +17 -0
  158. data/lib/google/protobuf/type.rb +79 -0
  159. data/lib/google/protobuf/wrappers.rb +48 -0
  160. data/lib/google/pubsub/v1/pubsub.rb +129 -0
  161. data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
  162. data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
  163. data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
  164. data/lib/google/rpc/code.rb +32 -0
  165. data/lib/google/rpc/error_details.rb +61 -0
  166. data/lib/google/rpc/status.rb +19 -0
  167. data/lib/google/type/color.rb +20 -0
  168. data/lib/google/type/date.rb +18 -0
  169. data/lib/google/type/dayofweek.rb +23 -0
  170. data/lib/google/type/latlng.rb +17 -0
  171. data/lib/google/type/money.rb +18 -0
  172. data/lib/google/type/timeofday.rb +19 -0
  173. metadata +101 -4
  174. data/lib/gcloud/pubsub/connection.rb +0 -295
  175. data/lib/gcloud/pubsub/errors.rb +0 -93
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,14 +12,16 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  module Gcloud
17
17
  module Storage
18
18
  class File
19
19
  ##
20
- # = File Access Control List
20
+ # # File Access Control List
21
21
  #
22
22
  # Represents a File's Access Control List.
23
23
  #
24
+ # @example
24
25
  # require "gcloud"
25
26
  #
26
27
  # gcloud = Gcloud.new
@@ -32,6 +33,7 @@ module Gcloud
32
33
  # file.acl.readers.each { |reader| puts reader }
33
34
  #
34
35
  class Acl
36
+ # @private
35
37
  RULES = { "authenticatedRead" => "authenticatedRead",
36
38
  "auth" => "authenticatedRead",
37
39
  "auth_read" => "authenticatedRead",
@@ -46,12 +48,12 @@ module Gcloud
46
48
  "project_private" => "projectPrivate",
47
49
  "publicRead" => "publicRead",
48
50
  "public" => "publicRead",
49
- "public_read" => "publicRead" } #:nodoc:
51
+ "public_read" => "publicRead" }
50
52
 
51
53
  ##
52
- # Initialized a new Acl object.
54
+ # @private Initialized a new Acl object.
53
55
  # Must provide a valid Bucket object.
54
- def initialize file #:nodoc:
56
+ def initialize file
55
57
  @bucket = file.bucket
56
58
  @file = file.name
57
59
  @connection = file.connection
@@ -63,8 +65,7 @@ module Gcloud
63
65
  ##
64
66
  # Reloads all Access Control List data for the file.
65
67
  #
66
- # === Example
67
- #
68
+ # @example
68
69
  # require "gcloud"
69
70
  #
70
71
  # gcloud = Gcloud.new
@@ -87,12 +88,9 @@ module Gcloud
87
88
  ##
88
89
  # Lists the owners of the file.
89
90
  #
90
- # === Returns
91
- #
92
- # Array of Strings
93
- #
94
- # === Example
91
+ # @return [Array<String>]
95
92
  #
93
+ # @example
96
94
  # require "gcloud"
97
95
  #
98
96
  # gcloud = Gcloud.new
@@ -111,12 +109,9 @@ module Gcloud
111
109
  ##
112
110
  # Lists the owners of the file.
113
111
  #
114
- # === Returns
115
- #
116
- # Array of Strings
117
- #
118
- # === Example
112
+ # @return [Array<String>]
119
113
  #
114
+ # @example
120
115
  # require "gcloud"
121
116
  #
122
117
  # gcloud = Gcloud.new
@@ -135,12 +130,9 @@ module Gcloud
135
130
  ##
136
131
  # Lists the readers of the file.
137
132
  #
138
- # === Returns
139
- #
140
- # Array of Strings
141
- #
142
- # === Example
133
+ # @return [Array<String>]
143
134
  #
135
+ # @example
144
136
  # require "gcloud"
145
137
  #
146
138
  # gcloud = Gcloud.new
@@ -159,11 +151,8 @@ module Gcloud
159
151
  ##
160
152
  # Grants owner permission to the file.
161
153
  #
162
- # === Parameters
163
- #
164
- # +entity+::
165
- # The entity holding the permission, in one of the following forms:
166
- # (+String+)
154
+ # @param [String] entity The entity holding the permission, in one of
155
+ # the following forms:
167
156
  #
168
157
  # * user-userId
169
158
  # * user-email
@@ -174,15 +163,10 @@ module Gcloud
174
163
  # * allUsers
175
164
  # * allAuthenticatedUsers
176
165
  #
177
- # +generation+::
178
- # When present, selects a specific revision of this object.
179
- # Default is the latest version. (+Integer+)
180
- #
181
- # === Examples
182
- #
183
- # Access to a file can be granted to a user by appending +"user-"+ to
184
- # the email address:
166
+ # @param [Integer] generation When present, selects a specific revision
167
+ # of this object. Default is the latest version.
185
168
  #
169
+ # @example Grant access to a user by pre-pending `"user-"` to an email:
186
170
  # require "gcloud"
187
171
  #
188
172
  # gcloud = Gcloud.new
@@ -194,9 +178,7 @@ module Gcloud
194
178
  # email = "heidi@example.net"
195
179
  # file.acl.add_owner "user-#{email}"
196
180
  #
197
- # Access to a file can be granted to a group by appending +"group-"+ to
198
- # the email address:
199
- #
181
+ # @example Grant access to a group by pre-pending `"group-"` to an email
200
182
  # require "gcloud"
201
183
  #
202
184
  # gcloud = Gcloud.new
@@ -223,11 +205,8 @@ module Gcloud
223
205
  ##
224
206
  # Grants writer permission to the file.
225
207
  #
226
- # === Parameters
227
- #
228
- # +entity+::
229
- # The entity holding the permission, in one of the following forms:
230
- # (+String+)
208
+ # @param [String] entity The entity holding the permission, in one of
209
+ # the following forms:
231
210
  #
232
211
  # * user-userId
233
212
  # * user-email
@@ -238,15 +217,10 @@ module Gcloud
238
217
  # * allUsers
239
218
  # * allAuthenticatedUsers
240
219
  #
241
- # +generation+::
242
- # When present, selects a specific revision of this object.
243
- # Default is the latest version. (+Integer+)
244
- #
245
- # === Examples
246
- #
247
- # Access to a file can be granted to a user by appending +"user-"+ to
248
- # the email address:
220
+ # @param [Integer] generation When present, selects a specific revision
221
+ # of this object. Default is the latest version.
249
222
  #
223
+ # @example Grant access to a user by pre-pending `"user-"` to an email:
250
224
  # require "gcloud"
251
225
  #
252
226
  # gcloud = Gcloud.new
@@ -258,9 +232,7 @@ module Gcloud
258
232
  # email = "heidi@example.net"
259
233
  # file.acl.add_writer "user-#{email}"
260
234
  #
261
- # Access to a file can be granted to a group by appending +"group-"+ to
262
- # the email address:
263
- #
235
+ # @example Grant access to a group by pre-pending `"group-"` to an email
264
236
  # require "gcloud"
265
237
  #
266
238
  # gcloud = Gcloud.new
@@ -287,11 +259,8 @@ module Gcloud
287
259
  ##
288
260
  # Grants reader permission to the file.
289
261
  #
290
- # === Parameters
291
- #
292
- # +entity+::
293
- # The entity holding the permission, in one of the following forms:
294
- # (+String+)
262
+ # @param [String] entity The entity holding the permission, in one of
263
+ # the following forms:
295
264
  #
296
265
  # * user-userId
297
266
  # * user-email
@@ -302,15 +271,10 @@ module Gcloud
302
271
  # * allUsers
303
272
  # * allAuthenticatedUsers
304
273
  #
305
- # +generation+::
306
- # When present, selects a specific revision of this object.
307
- # Default is the latest version. (+Integer+)
308
- #
309
- # === Examples
310
- #
311
- # Access to a file can be granted to a user by appending +"user-"+ to
312
- # the email address:
274
+ # @param [Integer] generation When present, selects a specific revision
275
+ # of this object. Default is the latest version.
313
276
  #
277
+ # @example Grant access to a user by pre-pending `"user-"` to an email:
314
278
  # require "gcloud"
315
279
  #
316
280
  # gcloud = Gcloud.new
@@ -322,9 +286,7 @@ module Gcloud
322
286
  # email = "heidi@example.net"
323
287
  # file.acl.add_reader "user-#{email}"
324
288
  #
325
- # Access to a file can be granted to a group by appending +"group-"+ to
326
- # the email address:
327
- #
289
+ # @example Grant access to a group by pre-pending `"group-"` to an email
328
290
  # require "gcloud"
329
291
  #
330
292
  # gcloud = Gcloud.new
@@ -351,11 +313,8 @@ module Gcloud
351
313
  ##
352
314
  # Permanently deletes the entity from the file's access control list.
353
315
  #
354
- # === Parameters
355
- #
356
- # +entity+::
357
- # The entity holding the permission, in one of the following forms:
358
- # (+String+)
316
+ # @param [String] entity The entity holding the permission, in one of
317
+ # the following forms:
359
318
  #
360
319
  # * user-userId
361
320
  # * user-email
@@ -366,12 +325,10 @@ module Gcloud
366
325
  # * allUsers
367
326
  # * allAuthenticatedUsers
368
327
  #
369
- # +generation+::
370
- # When present, selects a specific revision of this object.
371
- # Default is the latest version. (+Integer+)
372
- #
373
- # === Example
328
+ # @param [Integer] generation When present, selects a specific revision
329
+ # of this object. Default is the latest version.
374
330
  #
331
+ # @example
375
332
  # require "gcloud"
376
333
  #
377
334
  # gcloud = Gcloud.new
@@ -395,18 +352,18 @@ module Gcloud
395
352
  false
396
353
  end
397
354
 
398
- def self.predefined_rule_for rule_name #:nodoc:
355
+ # @private
356
+ def self.predefined_rule_for rule_name
399
357
  RULES[rule_name.to_s]
400
358
  end
401
359
 
402
360
  # Predefined ACL helpers
403
361
 
404
362
  ##
405
- # Convenience method to apply the +authenticatedRead+ predefined ACL
363
+ # Convenience method to apply the `authenticatedRead` predefined ACL
406
364
  # rule to the file.
407
365
  #
408
- # === Example
409
- #
366
+ # @example
410
367
  # require "gcloud"
411
368
  #
412
369
  # gcloud = Gcloud.new
@@ -426,11 +383,10 @@ module Gcloud
426
383
  alias_method :authenticated_read!, :auth!
427
384
 
428
385
  ##
429
- # Convenience method to apply the +bucketOwnerFullControl+ predefined
386
+ # Convenience method to apply the `bucketOwnerFullControl` predefined
430
387
  # ACL rule to the file.
431
388
  #
432
- # === Example
433
- #
389
+ # @example
434
390
  # require "gcloud"
435
391
  #
436
392
  # gcloud = Gcloud.new
@@ -447,11 +403,10 @@ module Gcloud
447
403
  alias_method :bucketOwnerFullControl!, :owner_full!
448
404
 
449
405
  ##
450
- # Convenience method to apply the +bucketOwnerRead+ predefined ACL
406
+ # Convenience method to apply the `bucketOwnerRead` predefined ACL
451
407
  # rule to the file.
452
408
  #
453
- # === Example
454
- #
409
+ # @example
455
410
  # require "gcloud"
456
411
  #
457
412
  # gcloud = Gcloud.new
@@ -468,11 +423,10 @@ module Gcloud
468
423
  alias_method :bucketOwnerRead!, :owner_read!
469
424
 
470
425
  ##
471
- # Convenience method to apply the +private+ predefined ACL
426
+ # Convenience method to apply the `private` predefined ACL
472
427
  # rule to the file.
473
428
  #
474
- # === Example
475
- #
429
+ # @example
476
430
  # require "gcloud"
477
431
  #
478
432
  # gcloud = Gcloud.new
@@ -488,11 +442,10 @@ module Gcloud
488
442
  end
489
443
 
490
444
  ##
491
- # Convenience method to apply the +projectPrivate+ predefined ACL
445
+ # Convenience method to apply the `projectPrivate` predefined ACL
492
446
  # rule to the file.
493
447
  #
494
- # === Example
495
- #
448
+ # @example
496
449
  # require "gcloud"
497
450
  #
498
451
  # gcloud = Gcloud.new
@@ -509,11 +462,10 @@ module Gcloud
509
462
  alias_method :projectPrivate!, :project_private!
510
463
 
511
464
  ##
512
- # Convenience method to apply the +publicRead+ predefined ACL
465
+ # Convenience method to apply the `publicRead` predefined ACL
513
466
  # rule to the file.
514
467
  #
515
- # === Example
516
- #
468
+ # @example
517
469
  # require "gcloud"
518
470
  #
519
471
  # gcloud = Gcloud.new
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "delegate"
17
17
 
18
18
  module Gcloud
@@ -40,8 +40,8 @@ module Gcloud
40
40
  end
41
41
 
42
42
  ##
43
- # New File::List from a response object.
44
- def self.from_response resp, conn #:nodoc:
43
+ # @private New File::List from a response object.
44
+ def self.from_response resp, conn
45
45
  buckets = Array(resp.data["items"]).map do |gapi_object|
46
46
  File.from_gapi gapi_object, conn
47
47
  end
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2014 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "pathname"
17
17
  require "digest/md5"
18
18
  require "digest/crc32c"
@@ -22,9 +22,10 @@ module Gcloud
22
22
  module Storage
23
23
  class File
24
24
  ##
25
+ # @private
25
26
  # Verifies downloaded files by creating an MD5 or CRC32c hash digest
26
27
  # and comparing the value to the one from the Storage API.
27
- module Verifier #:nodoc:
28
+ module Verifier
28
29
  def self.verify_md5! gcloud_file, local_file
29
30
  gcloud_digest = gcloud_file.md5
30
31
  local_digest = md5_for local_file
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2014 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "gcloud/gce"
17
17
  require "gcloud/storage/errors"
18
18
  require "gcloud/storage/connection"
@@ -24,7 +24,7 @@ require "gcloud/storage/file"
24
24
  module Gcloud
25
25
  module Storage
26
26
  ##
27
- # = Project
27
+ # # Project
28
28
  #
29
29
  # Represents the project that storage buckets and files belong to.
30
30
  # All data in Google Cloud Storage belongs inside a project.
@@ -32,9 +32,12 @@ module Gcloud
32
32
  # authentication, and monitoring settings for those APIs.
33
33
  #
34
34
  # Gcloud::Storage::Project is the main object for interacting with
35
- # Google Storage. Gcloud::Storage::Bucket objects are created,
35
+ # Google Storage. {Gcloud::Storage::Bucket} objects are created,
36
36
  # read, updated, and deleted by Gcloud::Storage::Project.
37
37
  #
38
+ # See {Gcloud#storage}
39
+ #
40
+ # @example
38
41
  # require "gcloud"
39
42
  #
40
43
  # gcloud = Gcloud.new
@@ -43,17 +46,16 @@ module Gcloud
43
46
  # bucket = storage.bucket "my-bucket"
44
47
  # file = bucket.file "path/to/my-file.ext"
45
48
  #
46
- # See Gcloud#storage
47
49
  class Project
48
50
  ##
49
- # The Connection object.
50
- attr_accessor :connection #:nodoc:
51
+ # @private The Connection object.
52
+ attr_accessor :connection
51
53
 
52
54
  ##
53
- # Creates a new Project instance.
55
+ # @private Creates a new Project instance.
54
56
  #
55
- # See Gcloud#storage
56
- def initialize project, credentials #:nodoc:
57
+ # See {Gcloud#storage}
58
+ def initialize project, credentials
57
59
  project = project.to_s # Always cast to a string
58
60
  fail ArgumentError, "project is missing" if project.empty?
59
61
  @connection = Connection.new project, credentials
@@ -62,8 +64,7 @@ module Gcloud
62
64
  ##
63
65
  # The Storage project connected to.
64
66
  #
65
- # === Example
66
- #
67
+ # @example
67
68
  # require "gcloud"
68
69
  #
69
70
  # gcloud = Gcloud.new "my-todo-project",
@@ -77,8 +78,8 @@ module Gcloud
77
78
  end
78
79
 
79
80
  ##
80
- # Default project.
81
- def self.default_project #:nodoc:
81
+ # @private Default project.
82
+ def self.default_project
82
83
  ENV["STORAGE_PROJECT"] ||
83
84
  ENV["GCLOUD_PROJECT"] ||
84
85
  ENV["GOOGLE_CLOUD_PROJECT"] ||
@@ -88,23 +89,16 @@ module Gcloud
88
89
  ##
89
90
  # Retrieves a list of buckets for the given project.
90
91
  #
91
- # === Parameters
92
- #
93
- # +prefix+::
94
- # Filter results to buckets whose names begin with this prefix.
95
- # (+String+)
96
- # +token+::
97
- # A previously-returned page token representing part of the larger set
98
- # of results to view. (+String+)
99
- # +max+::
100
- # Maximum number of buckets to return. (+Integer+)
101
- #
102
- # === Returns
103
- #
104
- # Array of Gcloud::Storage::Bucket (See Gcloud::Storage::Bucket::List)
92
+ # @param [String] prefix Filter results to buckets whose names begin with
93
+ # this prefix.
94
+ # @param [String] token A previously-returned page token representing part
95
+ # of the larger set of results to view.
96
+ # @param [Integer] max Maximum number of buckets to return.
105
97
  #
106
- # === Examples
98
+ # @return [Array<Gcloud::Storage::Bucket>] (See
99
+ # {Gcloud::Storage::Bucket::List})
107
100
  #
101
+ # @example
108
102
  # require "gcloud"
109
103
  #
110
104
  # gcloud = Gcloud.new
@@ -115,9 +109,7 @@ module Gcloud
115
109
  # puts bucket.name
116
110
  # end
117
111
  #
118
- # You can also retrieve all buckets whose names begin with a prefix using
119
- # the +:prefix+ option:
120
- #
112
+ # @example Retrieve all buckets with names that begin with a given prefix:
121
113
  # require "gcloud"
122
114
  #
123
115
  # gcloud = Gcloud.new
@@ -125,9 +117,7 @@ module Gcloud
125
117
  #
126
118
  # user_buckets = storage.buckets prefix: "user-"
127
119
  #
128
- # If you have a significant number of buckets, you may need to paginate
129
- # through them: (See Bucket::List#token)
130
- #
120
+ # @example With pagination: (See {Bucket::List#token})
131
121
  # require "gcloud"
132
122
  #
133
123
  # gcloud = Gcloud.new
@@ -159,17 +149,12 @@ module Gcloud
159
149
  ##
160
150
  # Retrieves bucket by name.
161
151
  #
162
- # === Parameters
163
- #
164
- # +bucket_name+::
165
- # Name of a bucket. (+String+)
166
- #
167
- # === Returns
168
- #
169
- # Gcloud::Storage::Bucket or nil if bucket does not exist
152
+ # @param [String] bucket_name Name of a bucket.
170
153
  #
171
- # === Example
154
+ # @return [Gcloud::Storage::Bucket, nil] Returns nil if bucket does not
155
+ # exist
172
156
  #
157
+ # @example
173
158
  # require "gcloud"
174
159
  #
175
160
  # gcloud = Gcloud.new
@@ -192,101 +177,102 @@ module Gcloud
192
177
  ##
193
178
  # Creates a new bucket with optional attributes. Also accepts a block for
194
179
  # defining the CORS configuration for a static website served from the
195
- # bucket. See Bucket::Cors for details. For more information about
196
- # configuring buckets as static websites, see {How to Host a Static
197
- # Website }[https://cloud.google.com/storage/docs/website-configuration].
198
- # For more information about CORS, see {Cross-Origin Resource Sharing
199
- # (CORS)}[https://cloud.google.com/storage/docs/cross-origin].
180
+ # bucket. See {Bucket::Cors} for details.
200
181
  #
201
- # === Parameters
182
+ # The API call to create the bucket may be retried under certain
183
+ # conditions. See {Gcloud::Backoff} to control this behavior, or
184
+ # specify the wanted behavior in the call with the `:retries:` option.
185
+ #
186
+ # You can pass [website
187
+ # settings](https://cloud.google.com/storage/docs/website-configuration)
188
+ # for the bucket, including a block that defines CORS rule. See
189
+ # {Bucket::Cors} for details.
202
190
  #
203
- # +bucket_name+::
204
- # Name of a bucket. (+String+)
205
- # +acl+::
206
- # Apply a predefined set of access controls to this bucket. (+String+)
191
+ # @see https://cloud.google.com/storage/docs/cross-origin Cross-Origin
192
+ # Resource Sharing (CORS)
193
+ # @see https://cloud.google.com/storage/docs/website-configuration How to
194
+ # Host a Static Website
195
+ #
196
+ # @param [String] bucket_name Name of a bucket.
197
+ # @param [String] acl Apply a predefined set of access controls to this
198
+ # bucket.
207
199
  #
208
200
  # Acceptable values are:
209
- # * +auth+, +auth_read+, +authenticated+, +authenticated_read+,
210
- # +authenticatedRead+ - Project team owners get OWNER access, and
201
+ #
202
+ # * `auth`, `auth_read`, `authenticated`, `authenticated_read`,
203
+ # `authenticatedRead` - Project team owners get OWNER access, and
211
204
  # allAuthenticatedUsers get READER access.
212
- # * +private+ - Project team owners get OWNER access.
213
- # * +project_private+, +projectPrivate+ - Project team members get
205
+ # * `private` - Project team owners get OWNER access.
206
+ # * `project_private`, `projectPrivate` - Project team members get
214
207
  # access according to their roles.
215
- # * +public+, +public_read+, +publicRead+ - Project team owners get
208
+ # * `public`, `public_read`, `publicRead` - Project team owners get
216
209
  # OWNER access, and allUsers get READER access.
217
- # * +public_write+, +publicReadWrite+ - Project team owners get OWNER
210
+ # * `public_write`, `publicReadWrite` - Project team owners get OWNER
218
211
  # access, and allUsers get WRITER access.
219
- # +default_acl+::
220
- # Apply a predefined set of default object access controls to this
221
- # bucket. (+String+)
212
+ # @param [String] default_acl Apply a predefined set of default object
213
+ # access controls to this bucket.
222
214
  #
223
215
  # Acceptable values are:
224
- # * +auth+, +auth_read+, +authenticated+, +authenticated_read+,
225
- # +authenticatedRead+ - File owner gets OWNER access, and
216
+ #
217
+ # * `auth`, `auth_read`, `authenticated`, `authenticated_read`,
218
+ # `authenticatedRead` - File owner gets OWNER access, and
226
219
  # allAuthenticatedUsers get READER access.
227
- # * +owner_full+, +bucketOwnerFullControl+ - File owner gets OWNER
220
+ # * `owner_full`, `bucketOwnerFullControl` - File owner gets OWNER
228
221
  # access, and project team owners get OWNER access.
229
- # * +owner_read+, +bucketOwnerRead+ - File owner gets OWNER access, and
222
+ # * `owner_read`, `bucketOwnerRead` - File owner gets OWNER access, and
230
223
  # project team owners get READER access.
231
- # * +private+ - File owner gets OWNER access.
232
- # * +project_private+, +projectPrivate+ - File owner gets OWNER access,
224
+ # * `private` - File owner gets OWNER access.
225
+ # * `project_private`, `projectPrivate` - File owner gets OWNER access,
233
226
  # and project team members get access according to their roles.
234
- # * +public+, +public_read+, +publicRead+ - File owner gets OWNER
227
+ # * `public`, `public_read`, `publicRead` - File owner gets OWNER
235
228
  # access, and allUsers get READER access.
236
- # +cors+::
237
- # The CORS rules for the bucket. Accepts an array of hashes containing
238
- # the attributes specified for the {resource description of
239
- # cors}[https://cloud.google.com/storage/docs/json_api/v1/buckets#cors].
240
- # +location+::
241
- # The location of the bucket. Object data for objects in the bucket
242
- # resides in physical storage within this region. Possible values
243
- # include +ASIA+, +EU+, and +US+.(See the {developer's
244
- # guide}[https://cloud.google.com/storage/docs/bucket-locations] for the
245
- # authoritative list. The default value is +US+. (+String+)
246
- # +logging_bucket+::
247
- # The destination bucket for the bucket's logs. For more information,
248
- # see {Access
249
- # Logs}[https://cloud.google.com/storage/docs/access-logs]. (+String+)
250
- # +logging_prefix+::
251
- # The prefix used to create log object names for the bucket. It can be
252
- # at most 900 characters and must be a {valid object
253
- # name}[https://cloud.google.com/storage/docs/bucket-naming#objectnames]
254
- # . By default, the object prefix is the name
255
- # of the bucket for which the logs are enabled. For more information,
256
- # see {Access Logs}[https://cloud.google.com/storage/docs/access-logs].
257
- # (+String+)
258
- # +retries+::
259
- # The number of times the API call should be retried.
260
- # Default is Gcloud::Backoff.retries. (+Integer+)
261
- # +storage_class+::
262
- # Defines how objects in the bucket are stored and determines the SLA
263
- # and the cost of storage. Values include +:standard+, +:nearline+, and
264
- # +:dra+ (Durable Reduced Availability), as well as the strings returned
265
- # by Bucket#storage_class. For more information, see {Storage
266
- # Classes}[https://cloud.google.com/storage/docs/storage-classes].
267
- # The default value is +:standard+. (+Symbol+ or +String+)
268
- # +versioning+::
269
- # Whether {Object
270
- # Versioning}[https://cloud.google.com/storage/docs/object-versioning]
271
- # is to be enabled for the bucket. The default value is +false+.
272
- # (+Boolean+)
273
- # +website_main+::
274
- # The index page returned from a static website served from the bucket
275
- # when a site visitor requests the top level directory. For more
276
- # information, see {How to Host a Static Website
277
- # }[https://cloud.google.com/storage/docs/website-configuration#step4].
278
- # +website_404+::
279
- # The page returned from a static website served from the bucket when a
280
- # site visitor requests a resource that does not exist. For more
281
- # information, see {How to Host a Static Website
282
- # }[https://cloud.google.com/storage/docs/website-configuration#step4].
283
- #
284
- # === Returns
285
- #
286
- # Gcloud::Storage::Bucket
287
- #
288
- # === Examples
289
- #
229
+ # @param [String] cors The CORS rules for the bucket. Accepts an array of
230
+ # hashes containing the attributes specified for the [resource
231
+ # description of
232
+ # cors](https://cloud.google.com/storage/docs/json_api/v1/buckets#cors).
233
+ # @param [String] location The location of the bucket. Object data for
234
+ # objects in the bucket resides in physical storage within this region.
235
+ # Possible values include `ASIA`, `EU`, and `US`. (See the [developer's
236
+ # guide](https://cloud.google.com/storage/docs/bucket-locations) for the
237
+ # authoritative list. The default value is `US`.
238
+ # @param [String] logging_bucket The destination bucket for the bucket's
239
+ # logs. For more information, see [Access
240
+ # Logs](https://cloud.google.com/storage/docs/access-logs).
241
+ # @param [String] logging_prefix The prefix used to create log object
242
+ # names for the bucket. It can be at most 900 characters and must be a
243
+ # [valid object
244
+ # name](https://cloud.google.com/storage/docs/bucket-naming#objectnames)
245
+ # . By default, the object prefix is the name of the bucket for which
246
+ # the logs are enabled. For more information, see [Access
247
+ # Logs](https://cloud.google.com/storage/docs/access-logs).
248
+ # @param [Integer] retries The number of times the API call should be
249
+ # retried. Default is {Gcloud::Backoff.retries}.
250
+ # @param [Symbol, String] storage_class Defines how objects in the bucket
251
+ # are stored and determines the SLA and the cost of storage. Values
252
+ # include `:standard`, `:nearline`, and `:dra` (Durable Reduced
253
+ # Availability), as well as the strings returned by
254
+ # Bucket#storage_class. For more information, see [Storage
255
+ # Classes](https://cloud.google.com/storage/docs/storage-classes). The
256
+ # default value is `:standard`.
257
+ # @param [Boolean] versioning Whether [Object
258
+ # Versioning](https://cloud.google.com/storage/docs/object-versioning)
259
+ # is to be enabled for the bucket. The default value is `false`.
260
+ # @param [String] website_main The index page returned from a static
261
+ # website served from the bucket when a site visitor requests the top
262
+ # level directory. For more information, see [How to Host a Static
263
+ # Website
264
+ # ](https://cloud.google.com/storage/docs/website-configuration#step4).
265
+ # @param [String] website_404 The page returned from a static website
266
+ # served from the bucket when a site visitor requests a resource that
267
+ # does not exist. For more information, see [How to Host a Static
268
+ # Website
269
+ # ](https://cloud.google.com/storage/docs/website-configuration#step4).
270
+ # @yield [cors] a block for setting CORS rules
271
+ # @yieldparam [Bucket::Cors] cors the object accepting CORS rules
272
+ #
273
+ # @return [Gcloud::Storage::Bucket]
274
+ #
275
+ # @example
290
276
  # require "gcloud"
291
277
  #
292
278
  # gcloud = Gcloud.new
@@ -294,10 +280,7 @@ module Gcloud
294
280
  #
295
281
  # bucket = storage.create_bucket "my-bucket"
296
282
  #
297
- # The API call to create the bucket may be retried under certain
298
- # conditions. See Gcloud::Backoff to control this behavior, or
299
- # specify the wanted behavior in the call with the +:retries:+ option:
300
- #
283
+ # @example Specify the number of retries to attempt:
301
284
  # require "gcloud"
302
285
  #
303
286
  # gcloud = Gcloud.new
@@ -305,11 +288,7 @@ module Gcloud
305
288
  #
306
289
  # bucket = storage.create_bucket "my-bucket", retries: 5
307
290
  #
308
- # You can pass {website
309
- # settings}[https://cloud.google.com/storage/docs/website-configuration]
310
- # for the bucket, including a block that defines CORS rule. See
311
- # Bucket::Cors for details.
312
- #
291
+ # @example Add CORS rules in a block:
313
292
  # require "gcloud"
314
293
  #
315
294
  # gcloud = Gcloud.new