google-cloud-storage 1.32.0 → 1.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/google/cloud/storage/bucket.rb +137 -3
- data/lib/google/cloud/storage/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b25b270d900a20eeef47726ae61ddbaf11457d3cdab25c1d8b2169d4537f0047
|
4
|
+
data.tar.gz: 4cdc04bbe927ada1e58ee895889c210d1a3afebfadb7917e8dfd8db7218bcd4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3afb0f705f9592631928e5f4645513b273d729067578f333052e0dc51da38d8aa4951ba2778aaeb3e6799680fa783a2ce6426d6abaf5e9c796029977ce3ecaea
|
7
|
+
data.tar.gz: 750da06b028394f5018431945ba86a44733414b334cc9677f81031fd6f0271df47ae74612047487f077ec27c06f645b27b0ab4e6bb875134610c197ac3fd446a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.34.0 / 2021-06-30
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Add support for automatic crc32c and md5 upload verification
|
8
|
+
* Add checksum to Bucket#create_file
|
9
|
+
|
10
|
+
### 1.33.0 / 2021-06-29
|
11
|
+
|
12
|
+
#### Features
|
13
|
+
|
14
|
+
* Add support for PublicAccessPrevention
|
15
|
+
* Add Bucket#public_access_prevention
|
16
|
+
* Add Bucket#public_access_prevention=
|
17
|
+
* Add Bucket#public_access_prevention_enforced?
|
18
|
+
* Add Bucket#public_access_prevention_unspecified?
|
19
|
+
* Add samples for PublicAccessPrevention
|
20
|
+
|
3
21
|
### 1.32.0 / 2021-06-22
|
4
22
|
|
5
23
|
#### Features
|
@@ -931,6 +931,108 @@ module Google
|
|
931
931
|
uniform_bucket_level_access_locked_at
|
932
932
|
end
|
933
933
|
|
934
|
+
##
|
935
|
+
# The value for Public Access Prevention in the bucket's IAM configuration. Currently, `unspecified` and
|
936
|
+
# `enforced` are supported. When set to `enforced`, Public Access Prevention is enforced in the bucket's IAM
|
937
|
+
# configuration. This value can be modified by calling {#public_access_prevention=}.
|
938
|
+
#
|
939
|
+
# @return [String, nil] Currently, `unspecified` and `enforced` are supported. Returns `nil` if the bucket has
|
940
|
+
# no IAM configuration.
|
941
|
+
#
|
942
|
+
# @example
|
943
|
+
# require "google/cloud/storage"
|
944
|
+
#
|
945
|
+
# storage = Google::Cloud::Storage.new
|
946
|
+
#
|
947
|
+
# bucket = storage.bucket "my-bucket"
|
948
|
+
#
|
949
|
+
# bucket.public_access_prevention = :enforced
|
950
|
+
# bucket.public_access_prevention #=> "enforced"
|
951
|
+
#
|
952
|
+
def public_access_prevention
|
953
|
+
@gapi.iam_configuration&.public_access_prevention
|
954
|
+
end
|
955
|
+
|
956
|
+
##
|
957
|
+
# Sets the value for Public Access Prevention in the bucket's IAM configuration. This value can be queried by
|
958
|
+
# calling {#public_access_prevention}.
|
959
|
+
#
|
960
|
+
# @param [Symbol, String] new_public_access_prevention The bucket's new Public Access Prevention configuration.
|
961
|
+
# Currently, `unspecified` and `enforced` are supported. When set to `enforced`, Public Access
|
962
|
+
# Prevention is enforced in the bucket's IAM configuration.
|
963
|
+
#
|
964
|
+
# @example Set Public Access Prevention to enforced:
|
965
|
+
# require "google/cloud/storage"
|
966
|
+
#
|
967
|
+
# storage = Google::Cloud::Storage.new
|
968
|
+
#
|
969
|
+
# bucket = storage.bucket "my-bucket"
|
970
|
+
#
|
971
|
+
# bucket.public_access_prevention = :enforced
|
972
|
+
# bucket.public_access_prevention #=> "enforced"
|
973
|
+
#
|
974
|
+
# @example Set Public Access Prevention to unspecified:
|
975
|
+
# require "google/cloud/storage"
|
976
|
+
#
|
977
|
+
# storage = Google::Cloud::Storage.new
|
978
|
+
#
|
979
|
+
# bucket = storage.bucket "my-bucket"
|
980
|
+
#
|
981
|
+
# bucket.public_access_prevention = :unspecified
|
982
|
+
# bucket.public_access_prevention #=> "unspecified"
|
983
|
+
#
|
984
|
+
def public_access_prevention= new_public_access_prevention
|
985
|
+
@gapi.iam_configuration ||= API::Bucket::IamConfiguration.new
|
986
|
+
@gapi.iam_configuration.public_access_prevention = new_public_access_prevention.to_s
|
987
|
+
patch_gapi! :iam_configuration
|
988
|
+
end
|
989
|
+
|
990
|
+
##
|
991
|
+
# Whether the bucket's file IAM configuration enforces Public Access Prevention. The default is `false`. This
|
992
|
+
# value can be modified by calling {Bucket#public_access_prevention=}.
|
993
|
+
#
|
994
|
+
# @return [Boolean] Returns `false` if the bucket has no IAM configuration or if Public Access Prevention is
|
995
|
+
# not `enforced` in the IAM configuration. Returns `true` if Public Access Prevention is `enforced` in the IAM
|
996
|
+
# configuration.
|
997
|
+
#
|
998
|
+
# @example
|
999
|
+
# require "google/cloud/storage"
|
1000
|
+
#
|
1001
|
+
# storage = Google::Cloud::Storage.new
|
1002
|
+
#
|
1003
|
+
# bucket = storage.bucket "my-bucket"
|
1004
|
+
#
|
1005
|
+
# bucket.public_access_prevention = :enforced
|
1006
|
+
# bucket.public_access_prevention_enforced? # true
|
1007
|
+
#
|
1008
|
+
def public_access_prevention_enforced?
|
1009
|
+
return false unless @gapi.iam_configuration&.public_access_prevention
|
1010
|
+
@gapi.iam_configuration.public_access_prevention.to_s == "enforced"
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
##
|
1014
|
+
# Whether the value for Public Access Prevention in the bucket's IAM configuration is `unspecified`. The default
|
1015
|
+
# is `false`. This value can be modified by calling {Bucket#public_access_prevention=}.
|
1016
|
+
#
|
1017
|
+
# @return [Boolean] Returns `false` if the bucket has no IAM configuration or if Public Access Prevention is
|
1018
|
+
# not `unspecified` in the IAM configuration. Returns `true` if Public Access Prevention is `unspecified` in
|
1019
|
+
# the IAM configuration.
|
1020
|
+
#
|
1021
|
+
# @example
|
1022
|
+
# require "google/cloud/storage"
|
1023
|
+
#
|
1024
|
+
# storage = Google::Cloud::Storage.new
|
1025
|
+
#
|
1026
|
+
# bucket = storage.bucket "my-bucket"
|
1027
|
+
#
|
1028
|
+
# bucket.public_access_prevention = :unspecified
|
1029
|
+
# bucket.public_access_prevention_unspecified? # true
|
1030
|
+
#
|
1031
|
+
def public_access_prevention_unspecified?
|
1032
|
+
return false unless @gapi.iam_configuration&.public_access_prevention
|
1033
|
+
@gapi.iam_configuration.public_access_prevention.to_s == "unspecified"
|
1034
|
+
end
|
1035
|
+
|
934
1036
|
##
|
935
1037
|
# Updates the bucket with changes made in the given block in a single
|
936
1038
|
# PATCH request. The following attributes may be set: {#cors},
|
@@ -1230,16 +1332,34 @@ module Google
|
|
1230
1332
|
# changed to a time in the future. If custom_time must be unset, you
|
1231
1333
|
# must either perform a rewrite operation, or upload the data again
|
1232
1334
|
# and create a new file.
|
1335
|
+
# @param [Symbol, nil] checksum The type of checksum for the client to
|
1336
|
+
# automatically calculate and send with the create request to verify
|
1337
|
+
# the integrity of the object. If provided, Cloud Storage will only
|
1338
|
+
# create the file if the value calculated by the client matches the
|
1339
|
+
# value calculated by the service.
|
1340
|
+
#
|
1341
|
+
# Acceptable values are:
|
1342
|
+
#
|
1343
|
+
# * `md5` - Calculate and provide a checksum using the MD5 hash.
|
1344
|
+
# * `crc32c` - Calculate and provide a checksum using the CRC32c hash.
|
1345
|
+
# * `all` - Calculate and provide checksums for all available verifications.
|
1346
|
+
#
|
1347
|
+
# Optional. The default is `nil`. Do not provide if also providing a
|
1348
|
+
# corresponding `crc32c` or `md5` argument. See
|
1349
|
+
# [Validation](https://cloud.google.com/storage/docs/hashes-etags)
|
1350
|
+
# for more information.
|
1233
1351
|
# @param [String] crc32c The CRC32c checksum of the file data, as
|
1234
1352
|
# described in [RFC 4960, Appendix
|
1235
1353
|
# B](http://tools.ietf.org/html/rfc4960#appendix-B).
|
1236
1354
|
# If provided, Cloud Storage will only create the file if the value
|
1237
|
-
# matches the value calculated by the service.
|
1355
|
+
# matches the value calculated by the service. Do not provide if also
|
1356
|
+
# providing a `checksum: :crc32c` or `checksum: :all` argument. See
|
1238
1357
|
# [Validation](https://cloud.google.com/storage/docs/hashes-etags)
|
1239
1358
|
# for more information.
|
1240
1359
|
# @param [String] md5 The MD5 hash of the file data. If provided, Cloud
|
1241
1360
|
# Storage will only create the file if the value matches the value
|
1242
|
-
# calculated by the service.
|
1361
|
+
# calculated by the service. Do not provide if also providing a
|
1362
|
+
# `checksum: :md5` or `checksum: :all` argument. See
|
1243
1363
|
# [Validation](https://cloud.google.com/storage/docs/hashes-etags) for
|
1244
1364
|
# more information.
|
1245
1365
|
# @param [Hash] metadata A hash of custom, user-provided web-safe keys
|
@@ -1371,6 +1491,7 @@ module Google
|
|
1371
1491
|
content_language: nil,
|
1372
1492
|
content_type: nil,
|
1373
1493
|
custom_time: nil,
|
1494
|
+
checksum: nil,
|
1374
1495
|
crc32c: nil,
|
1375
1496
|
md5: nil,
|
1376
1497
|
metadata: nil,
|
@@ -1388,7 +1509,8 @@ module Google
|
|
1388
1509
|
path ||= file.path if file.respond_to? :path
|
1389
1510
|
path ||= file if file.is_a? String
|
1390
1511
|
raise ArgumentError, "must provide path" if path.nil?
|
1391
|
-
|
1512
|
+
crc32c = crc32c_for file, checksum, crc32c
|
1513
|
+
md5 = md5_for file, checksum, md5
|
1392
1514
|
|
1393
1515
|
gapi = service.insert_file name,
|
1394
1516
|
file,
|
@@ -2719,6 +2841,18 @@ module Google
|
|
2719
2841
|
raise ArgumentError, "cannot find file #{file}"
|
2720
2842
|
end
|
2721
2843
|
|
2844
|
+
def crc32c_for source, checksum, crc32c
|
2845
|
+
return crc32c unless [:crc32c, :all].include? checksum
|
2846
|
+
raise ArgumentError, "'checksum: :crc32c' or 'checksum: :all' is present with 'crc32c' arg" if crc32c
|
2847
|
+
File::Verifier.crc32c_for source
|
2848
|
+
end
|
2849
|
+
|
2850
|
+
def md5_for source, checksum, md5
|
2851
|
+
return md5 unless [:md5, :all].include? checksum
|
2852
|
+
raise ArgumentError, "'checksum: :md5' or 'checksum: :all' is present with 'md5' arg" if md5
|
2853
|
+
File::Verifier.md5_for source
|
2854
|
+
end
|
2855
|
+
|
2722
2856
|
##
|
2723
2857
|
# Yielded to a block to accumulate changes for a patch request.
|
2724
2858
|
class Updater < Bucket
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.34.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-06-
|
12
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|