google-cloud-storage 0.20.2 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,10 +23,9 @@ module Google
23
23
  # Represents a Bucket's Access Control List.
24
24
  #
25
25
  # @example
26
- # require "google/cloud"
26
+ # require "google/cloud/storage"
27
27
  #
28
- # gcloud = Google::Cloud.new
29
- # storage = gcloud.storage
28
+ # storage = Google::Cloud::Storage.new
30
29
  #
31
30
  # bucket = storage.bucket "my-bucket"
32
31
  #
@@ -64,10 +63,9 @@ module Google
64
63
  # Reloads all Access Control List data for the bucket.
65
64
  #
66
65
  # @example
67
- # require "google/cloud"
66
+ # require "google/cloud/storage"
68
67
  #
69
- # gcloud = Google::Cloud.new
70
- # storage = gcloud.storage
68
+ # storage = Google::Cloud::Storage.new
71
69
  #
72
70
  # bucket = storage.bucket "my-bucket"
73
71
  #
@@ -88,10 +86,9 @@ module Google
88
86
  # @return [Array<String>]
89
87
  #
90
88
  # @example
91
- # require "google/cloud"
89
+ # require "google/cloud/storage"
92
90
  #
93
- # gcloud = Google::Cloud.new
94
- # storage = gcloud.storage
91
+ # storage = Google::Cloud::Storage.new
95
92
  #
96
93
  # bucket = storage.bucket "my-bucket"
97
94
  #
@@ -108,10 +105,9 @@ module Google
108
105
  # @return [Array<String>]
109
106
  #
110
107
  # @example
111
- # require "google/cloud"
108
+ # require "google/cloud/storage"
112
109
  #
113
- # gcloud = Google::Cloud.new
114
- # storage = gcloud.storage
110
+ # storage = Google::Cloud::Storage.new
115
111
  #
116
112
  # bucket = storage.bucket "my-bucket"
117
113
  #
@@ -128,10 +124,9 @@ module Google
128
124
  # @return [Array<String>]
129
125
  #
130
126
  # @example
131
- # require "google/cloud"
127
+ # require "google/cloud/storage"
132
128
  #
133
- # gcloud = Google::Cloud.new
134
- # storage = gcloud.storage
129
+ # storage = Google::Cloud::Storage.new
135
130
  #
136
131
  # bucket = storage.bucket "my-bucket"
137
132
  #
@@ -158,10 +153,9 @@ module Google
158
153
  # * allAuthenticatedUsers
159
154
  #
160
155
  # @example Grant access to a user by prepending `"user-"` to an email:
161
- # require "google/cloud"
156
+ # require "google/cloud/storage"
162
157
  #
163
- # gcloud = Google::Cloud.new
164
- # storage = gcloud.storage
158
+ # storage = Google::Cloud::Storage.new
165
159
  #
166
160
  # bucket = storage.bucket "my-bucket"
167
161
  #
@@ -169,10 +163,9 @@ module Google
169
163
  # bucket.acl.add_owner "user-#{email}"
170
164
  #
171
165
  # @example Grant access to a group by prepending `"group-"` to email:
172
- # require "google/cloud"
166
+ # require "google/cloud/storage"
173
167
  #
174
- # gcloud = Google::Cloud.new
175
- # storage = gcloud.storage
168
+ # storage = Google::Cloud::Storage.new
176
169
  #
177
170
  # bucket = storage.bucket "my-bucket"
178
171
  #
@@ -202,10 +195,9 @@ module Google
202
195
  # * allAuthenticatedUsers
203
196
  #
204
197
  # @example Grant access to a user by prepending `"user-"` to an email:
205
- # require "google/cloud"
198
+ # require "google/cloud/storage"
206
199
  #
207
- # gcloud = Google::Cloud.new
208
- # storage = gcloud.storage
200
+ # storage = Google::Cloud::Storage.new
209
201
  #
210
202
  # bucket = storage.bucket "my-bucket"
211
203
  #
@@ -213,10 +205,9 @@ module Google
213
205
  # bucket.acl.add_writer "user-#{email}"
214
206
  #
215
207
  # @example Grant access to a group by prepending `"group-"` to email:
216
- # require "google/cloud"
208
+ # require "google/cloud/storage"
217
209
  #
218
- # gcloud = Google::Cloud.new
219
- # storage = gcloud.storage
210
+ # storage = Google::Cloud::Storage.new
220
211
  #
221
212
  # bucket = storage.bucket "my-bucket"
222
213
  #
@@ -246,10 +237,9 @@ module Google
246
237
  # * allAuthenticatedUsers
247
238
  #
248
239
  # @example Grant access to a user by prepending `"user-"` to an email:
249
- # require "google/cloud"
240
+ # require "google/cloud/storage"
250
241
  #
251
- # gcloud = Google::Cloud.new
252
- # storage = gcloud.storage
242
+ # storage = Google::Cloud::Storage.new
253
243
  #
254
244
  # bucket = storage.bucket "my-bucket"
255
245
  #
@@ -257,10 +247,9 @@ module Google
257
247
  # bucket.acl.add_reader "user-#{email}"
258
248
  #
259
249
  # @example Grant access to a group by prepending `"group-"` to email:
260
- # require "google/cloud"
250
+ # require "google/cloud/storage"
261
251
  #
262
- # gcloud = Google::Cloud.new
263
- # storage = gcloud.storage
252
+ # storage = Google::Cloud::Storage.new
264
253
  #
265
254
  # bucket = storage.bucket "my-bucket"
266
255
  #
@@ -291,10 +280,9 @@ module Google
291
280
  # * allAuthenticatedUsers
292
281
  #
293
282
  # @example
294
- # require "google/cloud"
283
+ # require "google/cloud/storage"
295
284
  #
296
- # gcloud = Google::Cloud.new
297
- # storage = gcloud.storage
285
+ # storage = Google::Cloud::Storage.new
298
286
  #
299
287
  # bucket = storage.bucket "my-bucket"
300
288
  #
@@ -321,10 +309,9 @@ module Google
321
309
  # rule to the bucket.
322
310
  #
323
311
  # @example
324
- # require "google/cloud"
312
+ # require "google/cloud/storage"
325
313
  #
326
- # gcloud = Google::Cloud.new
327
- # storage = gcloud.storage
314
+ # storage = Google::Cloud::Storage.new
328
315
  #
329
316
  # bucket = storage.bucket "my-bucket"
330
317
  #
@@ -343,10 +330,9 @@ module Google
343
330
  # rule to the bucket.
344
331
  #
345
332
  # @example
346
- # require "google/cloud"
333
+ # require "google/cloud/storage"
347
334
  #
348
- # gcloud = Google::Cloud.new
349
- # storage = gcloud.storage
335
+ # storage = Google::Cloud::Storage.new
350
336
  #
351
337
  # bucket = storage.bucket "my-bucket"
352
338
  #
@@ -361,10 +347,9 @@ module Google
361
347
  # rule to the bucket.
362
348
  #
363
349
  # @example
364
- # require "google/cloud"
350
+ # require "google/cloud/storage"
365
351
  #
366
- # gcloud = Google::Cloud.new
367
- # storage = gcloud.storage
352
+ # storage = Google::Cloud::Storage.new
368
353
  #
369
354
  # bucket = storage.bucket "my-bucket"
370
355
  #
@@ -380,10 +365,9 @@ module Google
380
365
  # rule to the bucket.
381
366
  #
382
367
  # @example
383
- # require "google/cloud"
368
+ # require "google/cloud/storage"
384
369
  #
385
- # gcloud = Google::Cloud.new
386
- # storage = gcloud.storage
370
+ # storage = Google::Cloud::Storage.new
387
371
  #
388
372
  # bucket = storage.bucket "my-bucket"
389
373
  #
@@ -399,10 +383,9 @@ module Google
399
383
  # rule to the bucket.
400
384
  #
401
385
  # @example
402
- # require "google/cloud"
386
+ # require "google/cloud/storage"
403
387
  #
404
- # gcloud = Google::Cloud.new
405
- # storage = gcloud.storage
388
+ # storage = Google::Cloud::Storage.new
406
389
  #
407
390
  # bucket = storage.bucket "my-bucket"
408
391
  #
@@ -440,10 +423,9 @@ module Google
440
423
  # Represents a Bucket's Default Access Control List.
441
424
  #
442
425
  # @example
443
- # require "google/cloud"
426
+ # require "google/cloud/storage"
444
427
  #
445
- # gcloud = Google::Cloud.new
446
- # storage = gcloud.storage
428
+ # storage = Google::Cloud::Storage.new
447
429
  #
448
430
  # bucket = storage.bucket "my-bucket"
449
431
  #
@@ -481,10 +463,9 @@ module Google
481
463
  # Reloads all Default Access Control List data for the bucket.
482
464
  #
483
465
  # @example
484
- # require "google/cloud"
466
+ # require "google/cloud/storage"
485
467
  #
486
- # gcloud = Google::Cloud.new
487
- # storage = gcloud.storage
468
+ # storage = Google::Cloud::Storage.new
488
469
  #
489
470
  # bucket = storage.bucket "my-bucket"
490
471
  #
@@ -493,9 +474,7 @@ module Google
493
474
  def reload!
494
475
  gapi = @service.list_default_acls @bucket
495
476
  acls = Array(gapi.items).map do |acl|
496
- if acl.is_a? Google::Apis::StorageV1::ObjectAccessControl
497
- return acl
498
- end
477
+ next acl if acl.is_a? Google::Apis::StorageV1::ObjectAccessControl
499
478
  fail "Unknown ACL format: #{acl.class}" unless acl.is_a? Hash
500
479
  Google::Apis::StorageV1::ObjectAccessControl.from_json acl.to_json
501
480
  end
@@ -510,10 +489,9 @@ module Google
510
489
  # @return [Array<String>]
511
490
  #
512
491
  # @example
513
- # require "google/cloud"
492
+ # require "google/cloud/storage"
514
493
  #
515
- # gcloud = Google::Cloud.new
516
- # storage = gcloud.storage
494
+ # storage = Google::Cloud::Storage.new
517
495
  #
518
496
  # bucket = storage.bucket "my-bucket"
519
497
  #
@@ -530,10 +508,9 @@ module Google
530
508
  # @return [Array<String>]
531
509
  #
532
510
  # @example
533
- # require "google/cloud"
511
+ # require "google/cloud/storage"
534
512
  #
535
- # gcloud = Google::Cloud.new
536
- # storage = gcloud.storage
513
+ # storage = Google::Cloud::Storage.new
537
514
  #
538
515
  # bucket = storage.bucket "my-bucket"
539
516
  #
@@ -560,10 +537,9 @@ module Google
560
537
  # * allAuthenticatedUsers
561
538
  #
562
539
  # @example Grant access to a user by prepending `"user-"` to an email:
563
- # require "google/cloud"
540
+ # require "google/cloud/storage"
564
541
  #
565
- # gcloud = Google::Cloud.new
566
- # storage = gcloud.storage
542
+ # storage = Google::Cloud::Storage.new
567
543
  #
568
544
  # bucket = storage.bucket "my-bucket"
569
545
  #
@@ -571,10 +547,9 @@ module Google
571
547
  # bucket.default_acl.add_owner "user-#{email}"
572
548
  #
573
549
  # @example Grant access to a group by prepending `"group-"` to email:
574
- # require "google/cloud"
550
+ # require "google/cloud/storage"
575
551
  #
576
- # gcloud = Google::Cloud.new
577
- # storage = gcloud.storage
552
+ # storage = Google::Cloud::Storage.new
578
553
  #
579
554
  # bucket = storage.bucket "my-bucket"
580
555
  #
@@ -604,10 +579,9 @@ module Google
604
579
  # * allAuthenticatedUsers
605
580
  #
606
581
  # @example Grant access to a user by prepending `"user-"` to an email:
607
- # require "google/cloud"
582
+ # require "google/cloud/storage"
608
583
  #
609
- # gcloud = Google::Cloud.new
610
- # storage = gcloud.storage
584
+ # storage = Google::Cloud::Storage.new
611
585
  #
612
586
  # bucket = storage.bucket "my-bucket"
613
587
  #
@@ -615,10 +589,9 @@ module Google
615
589
  # bucket.default_acl.add_reader "user-#{email}"
616
590
  #
617
591
  # @example Grant access to a group by prepending `"group-"` to email:
618
- # require "google/cloud"
592
+ # require "google/cloud/storage"
619
593
  #
620
- # gcloud = Google::Cloud.new
621
- # storage = gcloud.storage
594
+ # storage = Google::Cloud::Storage.new
622
595
  #
623
596
  # bucket = storage.bucket "my-bucket"
624
597
  #
@@ -649,10 +622,9 @@ module Google
649
622
  # * allAuthenticatedUsers
650
623
  #
651
624
  # @example
652
- # require "google/cloud"
625
+ # require "google/cloud/storage"
653
626
  #
654
- # gcloud = Google::Cloud.new
655
- # storage = gcloud.storage
627
+ # storage = Google::Cloud::Storage.new
656
628
  #
657
629
  # bucket = storage.bucket "my-bucket"
658
630
  #
@@ -678,10 +650,9 @@ module Google
678
650
  # predefined ACL rule to files in the bucket.
679
651
  #
680
652
  # @example
681
- # require "google/cloud"
653
+ # require "google/cloud/storage"
682
654
  #
683
- # gcloud = Google::Cloud.new
684
- # storage = gcloud.storage
655
+ # storage = Google::Cloud::Storage.new
685
656
  #
686
657
  # bucket = storage.bucket "my-bucket"
687
658
  #
@@ -700,10 +671,9 @@ module Google
700
671
  # predefined ACL rule to files in the bucket.
701
672
  #
702
673
  # @example
703
- # require "google/cloud"
674
+ # require "google/cloud/storage"
704
675
  #
705
- # gcloud = Google::Cloud.new
706
- # storage = gcloud.storage
676
+ # storage = Google::Cloud::Storage.new
707
677
  #
708
678
  # bucket = storage.bucket "my-bucket"
709
679
  #
@@ -719,10 +689,9 @@ module Google
719
689
  # predefined ACL rule to files in the bucket.
720
690
  #
721
691
  # @example
722
- # require "google/cloud"
692
+ # require "google/cloud/storage"
723
693
  #
724
- # gcloud = Google::Cloud.new
725
- # storage = gcloud.storage
694
+ # storage = Google::Cloud::Storage.new
726
695
  #
727
696
  # bucket = storage.bucket "my-bucket"
728
697
  #
@@ -738,10 +707,9 @@ module Google
738
707
  # predefined ACL rule to files in the bucket.
739
708
  #
740
709
  # @example
741
- # require "google/cloud"
710
+ # require "google/cloud/storage"
742
711
  #
743
- # gcloud = Google::Cloud.new
744
- # storage = gcloud.storage
712
+ # storage = Google::Cloud::Storage.new
745
713
  #
746
714
  # bucket = storage.bucket "my-bucket"
747
715
  #
@@ -756,10 +724,9 @@ module Google
756
724
  # predefined ACL rule to files in the bucket.
757
725
  #
758
726
  # @example
759
- # require "google/cloud"
727
+ # require "google/cloud/storage"
760
728
  #
761
- # gcloud = Google::Cloud.new
762
- # storage = gcloud.storage
729
+ # storage = Google::Cloud::Storage.new
763
730
  #
764
731
  # bucket = storage.bucket "my-bucket"
765
732
  #
@@ -775,10 +742,9 @@ module Google
775
742
  # predefined ACL rule to files in the bucket.
776
743
  #
777
744
  # @example
778
- # require "google/cloud"
745
+ # require "google/cloud/storage"
779
746
  #
780
- # gcloud = Google::Cloud.new
781
- # storage = gcloud.storage
747
+ # storage = Google::Cloud::Storage.new
782
748
  #
783
749
  # bucket = storage.bucket "my-bucket"
784
750
  #
@@ -29,10 +29,9 @@ module Google
29
29
  # Resource Sharing (CORS)
30
30
  #
31
31
  # @example
32
- # require "google/cloud"
32
+ # require "google/cloud/storage"
33
33
  #
34
- # gcloud = Google::Cloud.new
35
- # storage = gcloud.storage
34
+ # storage = Google::Cloud::Storage.new
36
35
  # bucket = storage.bucket "my-todo-app"
37
36
  #
38
37
  # bucket = storage.bucket "my-bucket"
@@ -87,10 +86,9 @@ module Google
87
86
  # minutes.)
88
87
  #
89
88
  # @example
90
- # require "google/cloud"
89
+ # require "google/cloud/storage"
91
90
  #
92
- # gcloud = Google::Cloud.new
93
- # storage = gcloud.storage
91
+ # storage = Google::Cloud::Storage.new
94
92
  #
95
93
  # bucket = storage.create_bucket "my-bucket" do |c|
96
94
  # c.add_rule ["http://example.org", "https://example.org"],
@@ -40,10 +40,9 @@ module Google
40
40
  # @return [Boolean]
41
41
  #
42
42
  # @example
43
- # require "google/cloud"
43
+ # require "google/cloud/storage"
44
44
  #
45
- # gcloud = Google::Cloud.new
46
- # storage = gcloud.storage
45
+ # storage = Google::Cloud::Storage.new
47
46
  #
48
47
  # buckets = storage.buckets
49
48
  # if buckets.next?
@@ -60,10 +59,9 @@ module Google
60
59
  # @return [Bucket::List]
61
60
  #
62
61
  # @example
63
- # require "google/cloud"
62
+ # require "google/cloud/storage"
64
63
  #
65
- # gcloud = Google::Cloud.new
66
- # storage = gcloud.storage
64
+ # storage = Google::Cloud::Storage.new
67
65
  #
68
66
  # buckets = storage.buckets
69
67
  # if buckets.next?
@@ -97,10 +95,9 @@ module Google
97
95
  # @return [Enumerator]
98
96
  #
99
97
  # @example Iterating each bucket by passing a block:
100
- # require "google/cloud"
98
+ # require "google/cloud/storage"
101
99
  #
102
- # gcloud = Google::Cloud.new
103
- # storage = gcloud.storage
100
+ # storage = Google::Cloud::Storage.new
104
101
  #
105
102
  # buckets = storage.buckets
106
103
  # buckets.all do |bucket|
@@ -108,10 +105,9 @@ module Google
108
105
  # end
109
106
  #
110
107
  # @example Using the enumerator by not passing a block:
111
- # require "google/cloud"
108
+ # require "google/cloud/storage"
112
109
  #
113
- # gcloud = Google::Cloud.new
114
- # storage = gcloud.storage
110
+ # storage = Google::Cloud::Storage.new
115
111
  #
116
112
  # buckets = storage.buckets
117
113
  # all_names = buckets.all.map do |bucket|
@@ -119,10 +115,9 @@ module Google
119
115
  # end
120
116
  #
121
117
  # @example Limit the number of API calls made:
122
- # require "google/cloud"
118
+ # require "google/cloud/storage"
123
119
  #
124
- # gcloud = Google::Cloud.new
125
- # storage = gcloud.storage
120
+ # storage = Google::Cloud::Storage.new
126
121
  #
127
122
  # buckets = storage.buckets
128
123
  # buckets.all(request_limit: 10) do |bucket|