google-cloud-storage 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/lib/google-cloud-storage.rb +27 -2
- data/lib/google/cloud/storage.rb +101 -11
- data/lib/google/cloud/storage/bucket.rb +53 -21
- data/lib/google/cloud/storage/bucket/acl.rb +24 -24
- data/lib/google/cloud/storage/bucket/cors.rb +3 -3
- data/lib/google/cloud/storage/bucket/list.rb +3 -3
- data/lib/google/cloud/storage/credentials.rb +9 -8
- data/lib/google/cloud/storage/errors.rb +2 -2
- data/lib/google/cloud/storage/file.rb +74 -15
- data/lib/google/cloud/storage/file/acl.rb +13 -13
- data/lib/google/cloud/storage/file/list.rb +3 -3
- data/lib/google/cloud/storage/file/signer.rb +12 -8
- data/lib/google/cloud/storage/file/verifier.rb +12 -10
- data/lib/google/cloud/storage/notification.rb +3 -3
- data/lib/google/cloud/storage/policy.rb +3 -3
- data/lib/google/cloud/storage/post_object.rb +2 -2
- data/lib/google/cloud/storage/project.rb +5 -15
- data/lib/google/cloud/storage/service.rb +187 -22
- data/lib/google/cloud/storage/version.rb +3 -3
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa3b7db1df4e7dfaf4f531dc12faf2245d7d9d18107e9dbad1877520df131939
|
4
|
+
data.tar.gz: 5ff65a195b17e9a52eccd0787cba142153fb24347984b3453cd2ce2e295b6b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c372dc40320fa3ac1561b804c3cafc591ce51e3c6fb299709b30282a7f13e2bceb34fa30cbe913a39d723cbdbce8ef77b4adeaea9f40971a4cff1993912144f9
|
7
|
+
data.tar.gz: 3122a76ab51e4604fcb44e53cf1e784bacbabbfd5086448493c1a1a48416cdf43f37bad23517ac369d67e465734e66f864510b6302d9b8f129c6259e40cb6583
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Apache License
|
2
2
|
Version 2.0, January 2004
|
3
|
-
|
3
|
+
https://www.apache.org/licenses/
|
4
4
|
|
5
5
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
6
|
|
@@ -192,7 +192,7 @@
|
|
192
192
|
you may not use this file except in compliance with the License.
|
193
193
|
You may obtain a copy of the License at
|
194
194
|
|
195
|
-
|
195
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
196
196
|
|
197
197
|
Unless required by applicable law or agreed to in writing, software
|
198
198
|
distributed under the License is distributed on an "AS IS" BASIS,
|
data/lib/google-cloud-storage.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# Copyright 2016 Google
|
1
|
+
# Copyright 2016 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
5
5
|
# You may obtain a copy of the License at
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
8
|
#
|
9
9
|
# Unless required by applicable law or agreed to in writing, software
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -20,6 +20,8 @@
|
|
20
20
|
|
21
21
|
gem "google-cloud-core"
|
22
22
|
require "google/cloud"
|
23
|
+
require "google/cloud/config"
|
24
|
+
require "googleauth"
|
23
25
|
|
24
26
|
module Google
|
25
27
|
module Cloud
|
@@ -114,3 +116,26 @@ module Google
|
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
119
|
+
|
120
|
+
# Set the default storage configuration
|
121
|
+
Google::Cloud.configure.add_config! :storage do |config|
|
122
|
+
default_project = Google::Cloud::Config.deferred do
|
123
|
+
ENV["STORAGE_PROJECT"]
|
124
|
+
end
|
125
|
+
default_creds = Google::Cloud::Config.deferred do
|
126
|
+
Google::Cloud::Config.credentials_from_env(
|
127
|
+
"STORAGE_CREDENTIALS", "STORAGE_CREDENTIALS_JSON",
|
128
|
+
"STORAGE_KEYFILE", "STORAGE_KEYFILE_JSON"
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
config.add_field! :project_id, default_project, match: String, allow_nil: true
|
133
|
+
config.add_alias! :project, :project_id
|
134
|
+
config.add_field! :credentials, default_creds,
|
135
|
+
match: [String, Hash, Google::Auth::Credentials],
|
136
|
+
allow_nil: true
|
137
|
+
config.add_alias! :keyfile, :credentials
|
138
|
+
config.add_field! :scope, nil, match: [String, Array]
|
139
|
+
config.add_field! :retries, nil, match: Integer
|
140
|
+
config.add_field! :timeout, nil, match: Integer
|
141
|
+
end
|
data/lib/google/cloud/storage.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# Copyright 2014 Google
|
1
|
+
# Copyright 2014 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
5
5
|
# You may obtain a copy of the License at
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
8
|
#
|
9
9
|
# Unless required by applicable law or agreed to in writing, software
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -15,6 +15,8 @@
|
|
15
15
|
|
16
16
|
require "google-cloud-storage"
|
17
17
|
require "google/cloud/storage/project"
|
18
|
+
require "google/cloud/config"
|
19
|
+
require "google/cloud/env"
|
18
20
|
|
19
21
|
module Google
|
20
22
|
module Cloud
|
@@ -27,11 +29,14 @@ module Google
|
|
27
29
|
# networking infrastructure to perform data operations in a cost effective
|
28
30
|
# manner.
|
29
31
|
#
|
30
|
-
# The goal of google-cloud is to provide
|
31
|
-
# Rubyists.
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
32
|
+
# The goal of google-cloud is to provide an API that is comfortable to
|
33
|
+
# Rubyists. Your authentication credentials are detected automatically in
|
34
|
+
# Google Cloud Platform environments such as Google Compute Engine, Google
|
35
|
+
# App Engine and Google Kubernetes Engine. In other environments you can
|
36
|
+
# configure authentication easily, either directly in your code or via
|
37
|
+
# environment variables. Read more about the options for connecting in the
|
38
|
+
# [Authentication
|
39
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
35
40
|
#
|
36
41
|
# ```ruby
|
37
42
|
# require "google/cloud/storage"
|
@@ -334,6 +339,44 @@ module Google
|
|
334
339
|
# downloaded.read #=> "Hello world!"
|
335
340
|
# ```
|
336
341
|
#
|
342
|
+
# ## Creating and downloading gzip-encoded files
|
343
|
+
#
|
344
|
+
# When uploading a gzip-compressed file, you should pass
|
345
|
+
# `content_encoding: "gzip"` if you want the file to be eligible for
|
346
|
+
# [decompressive transcoding](https://cloud.google.com/storage/docs/transcoding)
|
347
|
+
# when it is later downloaded. In addition, giving the gzip-compressed file
|
348
|
+
# a name containing the original file extension (for example, `.txt`) will
|
349
|
+
# ensure that the file's `Content-Type` metadata is set correctly. (You can
|
350
|
+
# also set the file's `Content-Type` metadata explicitly with the
|
351
|
+
# `content_type` option.)
|
352
|
+
#
|
353
|
+
# ```ruby
|
354
|
+
# require "zlib"
|
355
|
+
# require "google/cloud/storage"
|
356
|
+
#
|
357
|
+
# storage = Google::Cloud::Storage.new
|
358
|
+
#
|
359
|
+
# gz = StringIO.new ""
|
360
|
+
# z = Zlib::GzipWriter.new gz
|
361
|
+
# z.write "Hello world!"
|
362
|
+
# z.close
|
363
|
+
# data = StringIO.new gz.string
|
364
|
+
#
|
365
|
+
# bucket = storage.bucket "my-bucket"
|
366
|
+
#
|
367
|
+
# bucket.create_file data, "path/to/gzipped.txt",
|
368
|
+
# content_encoding: "gzip"
|
369
|
+
#
|
370
|
+
# file = bucket.file "path/to/gzipped.txt"
|
371
|
+
#
|
372
|
+
# # The downloaded data is decompressed by default.
|
373
|
+
# file.download "path/to/downloaded/hello.txt"
|
374
|
+
#
|
375
|
+
# # The downloaded data remains compressed with skip_decompress.
|
376
|
+
# file.download "path/to/downloaded/gzipped.txt",
|
377
|
+
# skip_decompress: true
|
378
|
+
# ```
|
379
|
+
#
|
337
380
|
# ## Using Signed URLs
|
338
381
|
#
|
339
382
|
# Access without authentication can be granted to a file for a specified
|
@@ -604,18 +647,23 @@ module Google
|
|
604
647
|
#
|
605
648
|
def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
|
606
649
|
timeout: nil, project: nil, keyfile: nil
|
607
|
-
project_id ||= (project ||
|
650
|
+
project_id ||= (project || default_project_id)
|
608
651
|
project_id = project_id.to_s # Always cast to a string
|
609
|
-
|
652
|
+
raise ArgumentError, "project_id is missing" if project_id.empty?
|
610
653
|
|
611
|
-
|
654
|
+
scope ||= configure.scope
|
655
|
+
retries ||= configure.retries
|
656
|
+
timeout ||= configure.timeout
|
657
|
+
credentials ||= (keyfile || default_credentials(scope: scope))
|
612
658
|
unless credentials.is_a? Google::Auth::Credentials
|
613
659
|
credentials = Storage::Credentials.new credentials, scope: scope
|
614
660
|
end
|
615
661
|
|
616
662
|
Storage::Project.new(
|
617
663
|
Storage::Service.new(
|
618
|
-
project_id, credentials, retries: retries, timeout: timeout
|
664
|
+
project_id, credentials, retries: retries, timeout: timeout
|
665
|
+
)
|
666
|
+
)
|
619
667
|
end
|
620
668
|
|
621
669
|
##
|
@@ -645,6 +693,48 @@ module Google
|
|
645
693
|
Storage::Service.new(nil, nil, retries: retries, timeout: timeout)
|
646
694
|
)
|
647
695
|
end
|
696
|
+
|
697
|
+
##
|
698
|
+
# Configure the Google Cloud Storage library.
|
699
|
+
#
|
700
|
+
# The following Storage configuration parameters are supported:
|
701
|
+
#
|
702
|
+
# * `project_id` - (String) Identifier for a Storage project. (The
|
703
|
+
# parameter `project` is considered deprecated, but may also be used.)
|
704
|
+
# * `credentials` - (String, Hash, Google::Auth::Credentials) The path to
|
705
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
706
|
+
# Google::Auth::Credentials object. (See {Storage::Credentials}) (The
|
707
|
+
# parameter `keyfile` is considered deprecated, but may also be used.)
|
708
|
+
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
|
709
|
+
# the set of resources and operations that the connection can access.
|
710
|
+
# * `retries` - (Integer) Number of times to retry requests on server
|
711
|
+
# error.
|
712
|
+
# * `timeout` - (Integer) Default timeout to use in requests.
|
713
|
+
#
|
714
|
+
# @return [Google::Cloud::Config] The configuration object the
|
715
|
+
# Google::Cloud::Storage library uses.
|
716
|
+
#
|
717
|
+
def self.configure
|
718
|
+
yield Google::Cloud.configure.storage if block_given?
|
719
|
+
|
720
|
+
Google::Cloud.configure.storage
|
721
|
+
end
|
722
|
+
|
723
|
+
##
|
724
|
+
# @private Default project.
|
725
|
+
def self.default_project_id
|
726
|
+
Google::Cloud.configure.storage.project_id ||
|
727
|
+
Google::Cloud.configure.project_id ||
|
728
|
+
Google::Cloud.env.project_id
|
729
|
+
end
|
730
|
+
|
731
|
+
##
|
732
|
+
# @private Default credentials.
|
733
|
+
def self.default_credentials scope: nil
|
734
|
+
Google::Cloud.configure.storage.credentials ||
|
735
|
+
Google::Cloud.configure.credentials ||
|
736
|
+
Storage::Credentials.default(scope: scope)
|
737
|
+
end
|
648
738
|
end
|
649
739
|
end
|
650
740
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# Copyright 2014 Google
|
1
|
+
# Copyright 2014 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
5
5
|
# You may obtain a copy of the License at
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
8
|
#
|
9
9
|
# Unless required by applicable law or agreed to in writing, software
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -349,7 +349,7 @@ module Google
|
|
349
349
|
def requester_pays
|
350
350
|
@gapi.billing.requester_pays if @gapi.billing
|
351
351
|
end
|
352
|
-
|
352
|
+
alias requester_pays? requester_pays
|
353
353
|
|
354
354
|
##
|
355
355
|
# Enables requester pays for the bucket. If enabled, a client accessing
|
@@ -508,7 +508,7 @@ module Google
|
|
508
508
|
File::List.from_gapi gapi, service, name, prefix, delimiter, max,
|
509
509
|
versions, user_project: user_project
|
510
510
|
end
|
511
|
-
|
511
|
+
alias find_files files
|
512
512
|
|
513
513
|
##
|
514
514
|
# Retrieves a file matching the path.
|
@@ -557,7 +557,7 @@ module Google
|
|
557
557
|
rescue Google::Cloud::NotFoundError
|
558
558
|
nil
|
559
559
|
end
|
560
|
-
|
560
|
+
alias find_file file
|
561
561
|
|
562
562
|
##
|
563
563
|
# Creates a new {File} object by providing a path to a local file (or
|
@@ -608,7 +608,12 @@ module Google
|
|
608
608
|
# response header to be returned when the file is downloaded.
|
609
609
|
# @param [String] content_encoding The [Content-Encoding
|
610
610
|
# ](https://tools.ietf.org/html/rfc7231#section-3.1.2.2) response
|
611
|
-
# header to be returned when the file is downloaded.
|
611
|
+
# header to be returned when the file is downloaded. For example,
|
612
|
+
# `content_encoding: "gzip"` can indicate to clients that the uploaded
|
613
|
+
# data is gzip-compressed. However, there is no check to guarantee the
|
614
|
+
# specified `Content-Encoding` has actually been applied to the file
|
615
|
+
# data, and incorrectly specifying the file's encoding could lead
|
616
|
+
# to unintended behavior on subsequent download requests.
|
612
617
|
# @param [String] content_language The
|
613
618
|
# [Content-Language](http://tools.ietf.org/html/bcp47) response
|
614
619
|
# header to be returned when the file is downloaded.
|
@@ -682,6 +687,32 @@ module Google
|
|
682
687
|
# file = bucket.file "destination/path/file.ext",
|
683
688
|
# encryption_key: key
|
684
689
|
#
|
690
|
+
# @example Create a file with gzip-encoded data.
|
691
|
+
# require "zlib"
|
692
|
+
# require "google/cloud/storage"
|
693
|
+
#
|
694
|
+
# storage = Google::Cloud::Storage.new
|
695
|
+
#
|
696
|
+
# gz = StringIO.new ""
|
697
|
+
# z = Zlib::GzipWriter.new gz
|
698
|
+
# z.write "Hello world!"
|
699
|
+
# z.close
|
700
|
+
# data = StringIO.new gz.string
|
701
|
+
#
|
702
|
+
# bucket = storage.bucket "my-bucket"
|
703
|
+
#
|
704
|
+
# bucket.create_file data, "path/to/gzipped.txt",
|
705
|
+
# content_encoding: "gzip"
|
706
|
+
#
|
707
|
+
# file = bucket.file "path/to/gzipped.txt"
|
708
|
+
#
|
709
|
+
# # The downloaded data is decompressed by default.
|
710
|
+
# file.download "path/to/downloaded/hello.txt"
|
711
|
+
#
|
712
|
+
# # The downloaded data remains compressed with skip_decompress.
|
713
|
+
# file.download "path/to/downloaded/gzipped.txt",
|
714
|
+
# skip_decompress: true
|
715
|
+
#
|
685
716
|
def create_file file, path = nil, acl: nil, cache_control: nil,
|
686
717
|
content_disposition: nil, content_encoding: nil,
|
687
718
|
content_language: nil, content_type: nil,
|
@@ -698,13 +729,13 @@ module Google
|
|
698
729
|
ensure_io_or_file_exists! file
|
699
730
|
path ||= file.path if file.respond_to? :path
|
700
731
|
path ||= file if file.is_a? String
|
701
|
-
|
732
|
+
raise ArgumentError, "must provide path" if path.nil?
|
702
733
|
|
703
734
|
gapi = service.insert_file name, file, path, options
|
704
735
|
File.from_gapi gapi, service, user_project: user_project
|
705
736
|
end
|
706
|
-
|
707
|
-
|
737
|
+
alias upload_file create_file
|
738
|
+
alias new_file create_file
|
708
739
|
|
709
740
|
##
|
710
741
|
# Concatenates a list of existing files in the bucket into a new file in
|
@@ -796,7 +827,7 @@ module Google
|
|
796
827
|
ensure_service!
|
797
828
|
sources = Array sources
|
798
829
|
if sources.size < 2
|
799
|
-
|
830
|
+
raise ArgumentError, "must provide at least two source files"
|
800
831
|
end
|
801
832
|
|
802
833
|
options = { acl: File::Acl.predefined_rule_for(acl),
|
@@ -813,8 +844,8 @@ module Google
|
|
813
844
|
destination_gapi, options
|
814
845
|
File.from_gapi gapi, service, user_project: user_project
|
815
846
|
end
|
816
|
-
|
817
|
-
|
847
|
+
alias compose_file compose
|
848
|
+
alias combine compose
|
818
849
|
|
819
850
|
##
|
820
851
|
# Access without authentication can be granted to a File for a specified
|
@@ -1166,7 +1197,7 @@ module Google
|
|
1166
1197
|
policy = Policy.from_gapi gapi
|
1167
1198
|
return policy unless block_given?
|
1168
1199
|
yield policy
|
1169
|
-
|
1200
|
+
update_policy policy
|
1170
1201
|
end
|
1171
1202
|
|
1172
1203
|
##
|
@@ -1199,14 +1230,15 @@ module Google
|
|
1199
1230
|
#
|
1200
1231
|
# policy.add "roles/owner", "user:owner@example.com"
|
1201
1232
|
#
|
1202
|
-
# bucket.
|
1233
|
+
# bucket.update_policy policy # API call
|
1203
1234
|
#
|
1204
|
-
def
|
1235
|
+
def update_policy new_policy
|
1205
1236
|
ensure_service!
|
1206
1237
|
gapi = service.set_bucket_policy name, new_policy.to_gapi,
|
1207
1238
|
user_project: user_project
|
1208
1239
|
Policy.from_gapi gapi
|
1209
1240
|
end
|
1241
|
+
alias policy= update_policy
|
1210
1242
|
|
1211
1243
|
##
|
1212
1244
|
# Tests the specified permissions against the [Cloud
|
@@ -1270,7 +1302,7 @@ module Google
|
|
1270
1302
|
user_project: user_project
|
1271
1303
|
end
|
1272
1304
|
end
|
1273
|
-
|
1305
|
+
alias find_notifications notifications
|
1274
1306
|
|
1275
1307
|
##
|
1276
1308
|
# Retrieves a Pub/Sub notification subscription for the bucket.
|
@@ -1300,7 +1332,7 @@ module Google
|
|
1300
1332
|
rescue Google::Cloud::NotFoundError
|
1301
1333
|
nil
|
1302
1334
|
end
|
1303
|
-
|
1335
|
+
alias find_notification notification
|
1304
1336
|
|
1305
1337
|
|
1306
1338
|
##
|
@@ -1381,7 +1413,7 @@ module Google
|
|
1381
1413
|
gapi = service.insert_notification name, topic, options
|
1382
1414
|
Notification.from_gapi name, gapi, service, user_project: user_project
|
1383
1415
|
end
|
1384
|
-
|
1416
|
+
alias new_notification create_notification
|
1385
1417
|
|
1386
1418
|
##
|
1387
1419
|
# Reloads the bucket with current data from the Storage service.
|
@@ -1392,7 +1424,7 @@ module Google
|
|
1392
1424
|
@lazy = nil
|
1393
1425
|
self
|
1394
1426
|
end
|
1395
|
-
|
1427
|
+
alias refresh! reload!
|
1396
1428
|
|
1397
1429
|
##
|
1398
1430
|
# Determines whether the bucket exists in the Storage service.
|
@@ -1442,7 +1474,7 @@ module Google
|
|
1442
1474
|
##
|
1443
1475
|
# Raise an error unless an active service is available.
|
1444
1476
|
def ensure_service!
|
1445
|
-
|
1477
|
+
raise "Must have active connection" unless service
|
1446
1478
|
end
|
1447
1479
|
|
1448
1480
|
##
|
@@ -1472,7 +1504,7 @@ module Google
|
|
1472
1504
|
def ensure_io_or_file_exists! file
|
1473
1505
|
return if file.respond_to?(:read) && file.respond_to?(:rewind)
|
1474
1506
|
return if ::File.file? file
|
1475
|
-
|
1507
|
+
raise ArgumentError, "cannot find file #{file}"
|
1476
1508
|
end
|
1477
1509
|
|
1478
1510
|
def storage_class_for str
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# Copyright 2015 Google
|
1
|
+
# Copyright 2015 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
5
5
|
# You may obtain a copy of the License at
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
8
|
#
|
9
9
|
# Unless required by applicable law or agreed to in writing, software
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -46,7 +46,7 @@ module Google
|
|
46
46
|
"public" => "publicRead",
|
47
47
|
"public_read" => "publicRead",
|
48
48
|
"publicReadWrite" => "publicReadWrite",
|
49
|
-
"public_write" => "publicReadWrite" }
|
49
|
+
"public_write" => "publicReadWrite" }.freeze
|
50
50
|
|
51
51
|
##
|
52
52
|
# A boolean value or a project ID string to indicate the project to
|
@@ -98,7 +98,7 @@ module Google
|
|
98
98
|
@writers = entities_from_acls acls, "WRITER"
|
99
99
|
@readers = entities_from_acls acls, "READER"
|
100
100
|
end
|
101
|
-
|
101
|
+
alias refresh! reload!
|
102
102
|
|
103
103
|
##
|
104
104
|
# Lists the owners of the bucket.
|
@@ -344,10 +344,10 @@ module Google
|
|
344
344
|
def auth!
|
345
345
|
update_predefined_acl! "authenticatedRead"
|
346
346
|
end
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
347
|
+
alias authenticatedRead! auth!
|
348
|
+
alias auth_read! auth!
|
349
|
+
alias authenticated! auth!
|
350
|
+
alias authenticated_read! auth!
|
351
351
|
|
352
352
|
##
|
353
353
|
# Convenience method to apply the `private` predefined ACL
|
@@ -382,7 +382,7 @@ module Google
|
|
382
382
|
def project_private!
|
383
383
|
update_predefined_acl! "projectPrivate"
|
384
384
|
end
|
385
|
-
|
385
|
+
alias projectPrivate! project_private!
|
386
386
|
|
387
387
|
##
|
388
388
|
# Convenience method to apply the `publicRead` predefined ACL
|
@@ -400,8 +400,8 @@ module Google
|
|
400
400
|
def public!
|
401
401
|
update_predefined_acl! "publicRead"
|
402
402
|
end
|
403
|
-
|
404
|
-
|
403
|
+
alias publicRead! public!
|
404
|
+
alias public_read! public!
|
405
405
|
|
406
406
|
# Convenience method to apply the `publicReadWrite` predefined ACL
|
407
407
|
# rule to the bucket.
|
@@ -418,7 +418,7 @@ module Google
|
|
418
418
|
def public_write!
|
419
419
|
update_predefined_acl! "publicReadWrite"
|
420
420
|
end
|
421
|
-
|
421
|
+
alias publicReadWrite! public_write!
|
422
422
|
|
423
423
|
protected
|
424
424
|
|
@@ -472,7 +472,7 @@ module Google
|
|
472
472
|
"project_private" => "projectPrivate",
|
473
473
|
"publicRead" => "publicRead",
|
474
474
|
"public" => "publicRead",
|
475
|
-
"public_read" => "publicRead" }
|
475
|
+
"public_read" => "publicRead" }.freeze
|
476
476
|
|
477
477
|
##
|
478
478
|
# A boolean value or a project ID string to indicate the project to
|
@@ -521,13 +521,13 @@ module Google
|
|
521
521
|
user_project: user_project
|
522
522
|
acls = Array(gapi.items).map do |acl|
|
523
523
|
next acl if acl.is_a? Google::Apis::StorageV1::ObjectAccessControl
|
524
|
-
|
524
|
+
raise "Unknown ACL format: #{acl.class}" unless acl.is_a? Hash
|
525
525
|
Google::Apis::StorageV1::ObjectAccessControl.from_json acl.to_json
|
526
526
|
end
|
527
527
|
@owners = entities_from_acls acls, "OWNER"
|
528
528
|
@readers = entities_from_acls acls, "READER"
|
529
529
|
end
|
530
|
-
|
530
|
+
alias refresh! reload!
|
531
531
|
|
532
532
|
##
|
533
533
|
# Lists the default owners for files in the bucket.
|
@@ -710,10 +710,10 @@ module Google
|
|
710
710
|
def auth!
|
711
711
|
update_predefined_default_acl! "authenticatedRead"
|
712
712
|
end
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
713
|
+
alias authenticatedRead! auth!
|
714
|
+
alias auth_read! auth!
|
715
|
+
alias authenticated! auth!
|
716
|
+
alias authenticated_read! auth!
|
717
717
|
|
718
718
|
##
|
719
719
|
# Convenience method to apply the default `bucketOwnerFullControl`
|
@@ -731,7 +731,7 @@ module Google
|
|
731
731
|
def owner_full!
|
732
732
|
update_predefined_default_acl! "bucketOwnerFullControl"
|
733
733
|
end
|
734
|
-
|
734
|
+
alias bucketOwnerFullControl! owner_full!
|
735
735
|
|
736
736
|
##
|
737
737
|
# Convenience method to apply the default `bucketOwnerRead`
|
@@ -749,7 +749,7 @@ module Google
|
|
749
749
|
def owner_read!
|
750
750
|
update_predefined_default_acl! "bucketOwnerRead"
|
751
751
|
end
|
752
|
-
|
752
|
+
alias bucketOwnerRead! owner_read!
|
753
753
|
|
754
754
|
##
|
755
755
|
# Convenience method to apply the default `private`
|
@@ -784,7 +784,7 @@ module Google
|
|
784
784
|
def project_private!
|
785
785
|
update_predefined_default_acl! "projectPrivate"
|
786
786
|
end
|
787
|
-
|
787
|
+
alias projectPrivate! project_private!
|
788
788
|
|
789
789
|
##
|
790
790
|
# Convenience method to apply the default `publicRead`
|
@@ -802,8 +802,8 @@ module Google
|
|
802
802
|
def public!
|
803
803
|
update_predefined_default_acl! "publicRead"
|
804
804
|
end
|
805
|
-
|
806
|
-
|
805
|
+
alias publicRead! public!
|
806
|
+
alias public_read! public!
|
807
807
|
|
808
808
|
protected
|
809
809
|
|