google-cloud-storage 1.28.0 → 1.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +52 -0
- data/CONTRIBUTING.md +2 -2
- data/lib/google-cloud-storage.rb +1 -0
- data/lib/google/cloud/storage.rb +2 -1
- data/lib/google/cloud/storage/bucket.rb +56 -31
- data/lib/google/cloud/storage/bucket/acl.rb +12 -14
- data/lib/google/cloud/storage/bucket/cors.rb +4 -1
- data/lib/google/cloud/storage/bucket/lifecycle.rb +11 -11
- data/lib/google/cloud/storage/bucket/list.rb +3 -3
- data/lib/google/cloud/storage/credentials.rb +16 -14
- data/lib/google/cloud/storage/file.rb +7 -5
- data/lib/google/cloud/storage/file/acl.rb +5 -6
- data/lib/google/cloud/storage/file/list.rb +3 -3
- data/lib/google/cloud/storage/file/signer_v2.rb +2 -4
- data/lib/google/cloud/storage/file/signer_v4.rb +12 -12
- data/lib/google/cloud/storage/hmac_key/list.rb +3 -3
- data/lib/google/cloud/storage/policy.rb +2 -2
- data/lib/google/cloud/storage/policy/binding.rb +5 -3
- data/lib/google/cloud/storage/policy/bindings.rb +2 -2
- data/lib/google/cloud/storage/policy/condition.rb +4 -2
- data/lib/google/cloud/storage/post_object.rb +2 -1
- data/lib/google/cloud/storage/service.rb +2 -1
- data/lib/google/cloud/storage/version.rb +1 -1
- metadata +23 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1b17e5256dade278dacc588b1dd5483769f352fa6a44075f8984c9b98e6951b
|
4
|
+
data.tar.gz: 9a17da5e7e0f0da605e290e4a17ad75d6d89c2d2c83549d6a70378f77b86c8c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33b1ad115cb14c993607c4c173a8d117b19ebbe1515c7fbbaf6f7f38650dfcef0219b68e404a02a785f1092d6c1b04ffdab273c5546370569134b5fdbf596cc4
|
7
|
+
data.tar.gz: 8f4595aa9df9901462e1a2d522f35fd9b84ab2d96bbaf765e78582b4378c6270324efb3b43b037aa99e38377a5ed410c2dbe63c8ab34daf4b81004c0318a1edf
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,57 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.31.0 / 2021-03-10
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0
|
8
|
+
|
9
|
+
### 1.30.0 / 2021-01-13
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* Replace google-api-client with specific client gems
|
14
|
+
* Remove google-api-client
|
15
|
+
* Add google-apis-iamcredentials_v1
|
16
|
+
* Add google-apis-storage_v1
|
17
|
+
|
18
|
+
#### Documentation
|
19
|
+
|
20
|
+
* Update Bucket#generate_signed_post_policy_v4 documentation
|
21
|
+
|
22
|
+
### 1.29.2 / 2020-12-14
|
23
|
+
|
24
|
+
#### Bug Fixes
|
25
|
+
|
26
|
+
* Fix support for #generate_signed_post_policy_v4 conditions
|
27
|
+
|
28
|
+
### 1.29.1 / 2020-10-05
|
29
|
+
|
30
|
+
#### Bug Fixes
|
31
|
+
|
32
|
+
* Fix encoding of space characters in file names in signed_url v4
|
33
|
+
|
34
|
+
#### Documentation
|
35
|
+
|
36
|
+
* Update Bucket#default_kms_key= docs
|
37
|
+
* Demonstrate deleting the Cloud KMS encryption key
|
38
|
+
* Update customer-supplied encryption key docs and examples ([#7851](https://www.github.com/googleapis/google-cloud-ruby/issues/7851))
|
39
|
+
|
40
|
+
### 1.29.0 / 2020-09-22
|
41
|
+
|
42
|
+
#### Features
|
43
|
+
|
44
|
+
* quota_project can be set via library configuration ([#7656](https://www.github.com/googleapis/google-cloud-ruby/issues/7656))
|
45
|
+
|
46
|
+
#### Bug Fixes
|
47
|
+
|
48
|
+
* Fix encoding of space characters in #signed_url version: :v4
|
49
|
+
* Fix encoding of space characters to use percent encoding (%20) instead of plus sign (+).
|
50
|
+
|
51
|
+
#### Documentation
|
52
|
+
|
53
|
+
* Add custom time to file metadata sample
|
54
|
+
|
3
55
|
### 1.28.0 / 2020-08-26
|
4
56
|
|
5
57
|
* Add Object Lifecycle Management fields
|
data/CONTRIBUTING.md
CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
|
|
24
24
|
In order to use the google-cloud-storage console and run the project's tests,
|
25
25
|
there is a small amount of setup:
|
26
26
|
|
27
|
-
1. Install Ruby. google-cloud-storage requires Ruby 2.
|
27
|
+
1. Install Ruby. google-cloud-storage requires Ruby 2.5+. You may choose to
|
28
28
|
manage your Ruby and gem installations with [RVM](https://rvm.io/),
|
29
29
|
[rbenv](https://github.com/rbenv/rbenv), or
|
30
30
|
[chruby](https://github.com/postmodern/chruby).
|
@@ -45,7 +45,7 @@ there is a small amount of setup:
|
|
45
45
|
|
46
46
|
```sh
|
47
47
|
$ cd google-cloud-storage/
|
48
|
-
$ bundle
|
48
|
+
$ bundle install
|
49
49
|
```
|
50
50
|
|
51
51
|
## Console
|
data/lib/google-cloud-storage.rb
CHANGED
@@ -136,6 +136,7 @@ Google::Cloud.configure.add_config! :storage do |config|
|
|
136
136
|
allow_nil: true
|
137
137
|
config.add_alias! :keyfile, :credentials
|
138
138
|
config.add_field! :scope, nil, match: [String, Array]
|
139
|
+
config.add_field! :quota_project, nil, match: String
|
139
140
|
config.add_field! :retries, nil, match: Integer
|
140
141
|
config.add_field! :timeout, nil, match: Integer
|
141
142
|
# TODO: Remove once discovery document is updated.
|
data/lib/google/cloud/storage.rb
CHANGED
@@ -93,7 +93,8 @@ module Google
|
|
93
93
|
Storage::Project.new(
|
94
94
|
Storage::Service.new(
|
95
95
|
project_id, credentials,
|
96
|
-
retries: retries, timeout: timeout, host: endpoint
|
96
|
+
retries: retries, timeout: timeout, host: endpoint,
|
97
|
+
quota_project: configure.quota_project
|
97
98
|
)
|
98
99
|
)
|
99
100
|
end
|
@@ -309,7 +309,7 @@ module Google
|
|
309
309
|
# @see https://cloud.google.com/storage/docs/access-logs Access Logs
|
310
310
|
#
|
311
311
|
def logging_bucket
|
312
|
-
@gapi.logging
|
312
|
+
@gapi.logging&.log_bucket
|
313
313
|
end
|
314
314
|
|
315
315
|
##
|
@@ -333,7 +333,7 @@ module Google
|
|
333
333
|
# @return [String]
|
334
334
|
#
|
335
335
|
def logging_prefix
|
336
|
-
@gapi.logging
|
336
|
+
@gapi.logging&.log_object_prefix
|
337
337
|
end
|
338
338
|
|
339
339
|
##
|
@@ -392,7 +392,7 @@ module Google
|
|
392
392
|
# @return [Boolean]
|
393
393
|
#
|
394
394
|
def versioning?
|
395
|
-
@gapi.versioning
|
395
|
+
@gapi.versioning&.enabled?
|
396
396
|
end
|
397
397
|
|
398
398
|
##
|
@@ -422,7 +422,7 @@ module Google
|
|
422
422
|
# @return [String] The main page suffix.
|
423
423
|
#
|
424
424
|
def website_main
|
425
|
-
@gapi.website
|
425
|
+
@gapi.website&.main_page_suffix
|
426
426
|
end
|
427
427
|
|
428
428
|
##
|
@@ -449,7 +449,7 @@ module Google
|
|
449
449
|
# @return [String]
|
450
450
|
#
|
451
451
|
def website_404
|
452
|
-
@gapi.website
|
452
|
+
@gapi.website&.not_found_page
|
453
453
|
end
|
454
454
|
|
455
455
|
##
|
@@ -498,7 +498,7 @@ module Google
|
|
498
498
|
# the bucket.
|
499
499
|
#
|
500
500
|
def requester_pays
|
501
|
-
@gapi.billing
|
501
|
+
@gapi.billing&.requester_pays
|
502
502
|
end
|
503
503
|
alias requester_pays? requester_pays
|
504
504
|
|
@@ -550,14 +550,15 @@ module Google
|
|
550
550
|
# bucket.default_kms_key #=> kms_key_name
|
551
551
|
#
|
552
552
|
def default_kms_key
|
553
|
-
@gapi.encryption
|
553
|
+
@gapi.encryption&.default_kms_key_name
|
554
554
|
end
|
555
555
|
|
556
556
|
##
|
557
557
|
# Set the Cloud KMS encryption key that will be used to protect files.
|
558
558
|
# For example: `projects/a/locations/b/keyRings/c/cryptoKeys/d`
|
559
559
|
#
|
560
|
-
# @param [String] new_default_kms_key New Cloud KMS key name
|
560
|
+
# @param [String, nil] new_default_kms_key New Cloud KMS key name, or
|
561
|
+
# `nil` to delete the Cloud KMS encryption key.
|
561
562
|
#
|
562
563
|
# @example
|
563
564
|
# require "google/cloud/storage"
|
@@ -571,6 +572,15 @@ module Google
|
|
571
572
|
#
|
572
573
|
# bucket.default_kms_key = kms_key_name
|
573
574
|
#
|
575
|
+
# @example Delete the default Cloud KMS encryption key:
|
576
|
+
# require "google/cloud/storage"
|
577
|
+
#
|
578
|
+
# storage = Google::Cloud::Storage.new
|
579
|
+
#
|
580
|
+
# bucket = storage.bucket "my-bucket"
|
581
|
+
#
|
582
|
+
# bucket.default_kms_key = nil
|
583
|
+
#
|
574
584
|
def default_kms_key= new_default_kms_key
|
575
585
|
@gapi.encryption = API::Bucket::Encryption.new \
|
576
586
|
default_kms_key_name: new_default_kms_key
|
@@ -589,7 +599,7 @@ module Google
|
|
589
599
|
# retention policy exists for the bucket.
|
590
600
|
#
|
591
601
|
def retention_period
|
592
|
-
@gapi.retention_policy
|
602
|
+
@gapi.retention_policy&.retention_period
|
593
603
|
end
|
594
604
|
|
595
605
|
##
|
@@ -648,7 +658,7 @@ module Google
|
|
648
658
|
# policy, if a policy exists.
|
649
659
|
#
|
650
660
|
def retention_effective_at
|
651
|
-
@gapi.retention_policy
|
661
|
+
@gapi.retention_policy&.effective_time
|
652
662
|
end
|
653
663
|
|
654
664
|
##
|
@@ -798,7 +808,7 @@ module Google
|
|
798
808
|
# bucket.uniform_bucket_level_access? # true
|
799
809
|
#
|
800
810
|
def uniform_bucket_level_access?
|
801
|
-
return false unless @gapi.iam_configuration
|
811
|
+
return false unless @gapi.iam_configuration&.uniform_bucket_level_access
|
802
812
|
!@gapi.iam_configuration.uniform_bucket_level_access.enabled.nil? &&
|
803
813
|
@gapi.iam_configuration.uniform_bucket_level_access.enabled
|
804
814
|
end
|
@@ -860,7 +870,7 @@ module Google
|
|
860
870
|
# puts bucket.uniform_bucket_level_access_locked_at
|
861
871
|
#
|
862
872
|
def uniform_bucket_level_access_locked_at
|
863
|
-
return nil unless @gapi.iam_configuration
|
873
|
+
return nil unless @gapi.iam_configuration&.uniform_bucket_level_access
|
864
874
|
@gapi.iam_configuration.uniform_bucket_level_access.locked_time
|
865
875
|
end
|
866
876
|
|
@@ -1637,8 +1647,8 @@ module Google
|
|
1637
1647
|
end
|
1638
1648
|
|
1639
1649
|
##
|
1640
|
-
# Generate a PostObject that includes the fields and
|
1641
|
-
# upload objects via
|
1650
|
+
# Generate a PostObject that includes the fields and URL to
|
1651
|
+
# upload objects via HTML forms.
|
1642
1652
|
#
|
1643
1653
|
# Generating a PostObject requires service account credentials,
|
1644
1654
|
# either by connecting with a service account when calling
|
@@ -1684,7 +1694,7 @@ module Google
|
|
1684
1694
|
# Proc should return a signature created using a RPC call to the
|
1685
1695
|
# [Service Account Credentials signBlob](https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob)
|
1686
1696
|
# method as shown in the example below.
|
1687
|
-
# @return [PostObject] An object containing the URL, fields, and values needed to upload files via
|
1697
|
+
# @return [PostObject] An object containing the URL, fields, and values needed to upload files via HTML forms.
|
1688
1698
|
#
|
1689
1699
|
# @raise [SignedUrlUnavailable] If the service account credentials
|
1690
1700
|
# are missing. Service account credentials are acquired by following the
|
@@ -1807,10 +1817,14 @@ module Google
|
|
1807
1817
|
end
|
1808
1818
|
|
1809
1819
|
##
|
1810
|
-
# Generate a PostObject that includes the fields and
|
1811
|
-
# upload objects via
|
1820
|
+
# Generate a `PostObject` that includes the fields and URL to
|
1821
|
+
# upload objects via HTML forms. The resulting `PostObject` is
|
1822
|
+
# based on a policy document created from the method arguments.
|
1823
|
+
# This policy provides authorization to ensure that the HTML
|
1824
|
+
# form can upload files into the bucket. See [Signatures -
|
1825
|
+
# Policy document](https://cloud.google.com/storage/docs/authentication/signatures#policy-document).
|
1812
1826
|
#
|
1813
|
-
# Generating a PostObject requires service account credentials,
|
1827
|
+
# Generating a `PostObject` requires service account credentials,
|
1814
1828
|
# either by connecting with a service account when calling
|
1815
1829
|
# {Google::Cloud.storage}, or by passing in the service account
|
1816
1830
|
# `issuer` and `signing_key` values. Although the private key can
|
@@ -1823,6 +1837,8 @@ module Google
|
|
1823
1837
|
# steps in [Service Account Authentication](
|
1824
1838
|
# https://cloud.google.com/iam/docs/service-accounts).
|
1825
1839
|
#
|
1840
|
+
# @see https://cloud.google.com/storage/docs/authentication/signatures#policy-document Signatures -
|
1841
|
+
# Policy document
|
1826
1842
|
# @see https://cloud.google.com/storage/docs/xml-api/post-object
|
1827
1843
|
#
|
1828
1844
|
# @param [String] path Path to the file in Google Cloud Storage.
|
@@ -1846,9 +1862,14 @@ module Google
|
|
1846
1862
|
# method as shown in the example below.
|
1847
1863
|
# @param [Integer] expires The number of seconds until the URL expires.
|
1848
1864
|
# The default is 604800 (7 days).
|
1849
|
-
# @param [Hash] fields User-supplied form fields such as `acl`,
|
1865
|
+
# @param [Hash{String => String}] fields User-supplied form fields such as `acl`,
|
1850
1866
|
# `cache-control`, `success_action_status`, and `success_action_redirect`.
|
1851
|
-
#
|
1867
|
+
# Optional. See [Upload an object with HTML forms - Form
|
1868
|
+
# fields](https://cloud.google.com/storage/docs/xml-api/post-object-forms#form_fields).
|
1869
|
+
# @param [Array<Hash{String => String}|Array<String>>] conditions An array of
|
1870
|
+
# policy conditions that every upload must satisfy. For example:
|
1871
|
+
# `[["eq", "$Content-Type", "image/jpeg"]]`. Optional. See [Signatures - Policy
|
1872
|
+
# document](https://cloud.google.com/storage/docs/authentication/signatures#policy-document).
|
1852
1873
|
# @param [String] scheme The URL scheme. The default value is `HTTPS`.
|
1853
1874
|
# @param [Boolean] virtual_hosted_style Whether to use a virtual hosted-style
|
1854
1875
|
# hostname, which adds the bucket into the host portion of the URI rather
|
@@ -1861,12 +1882,12 @@ module Google
|
|
1861
1882
|
# Cloud Load Balancer which routes to a bucket you own, e.g.
|
1862
1883
|
# `my-load-balancer-domain.tld`.
|
1863
1884
|
#
|
1864
|
-
# @return [PostObject] An object containing the URL, fields, and values needed to
|
1885
|
+
# @return [PostObject] An object containing the URL, fields, and values needed to
|
1886
|
+
# upload files via HTML forms.
|
1865
1887
|
#
|
1866
|
-
# @raise [SignedUrlUnavailable] If the service account credentials
|
1867
|
-
#
|
1868
|
-
#
|
1869
|
-
# https://cloud.google.com/iam/docs/service-accounts).
|
1888
|
+
# @raise [SignedUrlUnavailable] If the service account credentials are missing.
|
1889
|
+
# Service account credentials are acquired by following the steps in [Service
|
1890
|
+
# Account Authentication](https://cloud.google.com/iam/docs/service-accounts).
|
1870
1891
|
#
|
1871
1892
|
# @example
|
1872
1893
|
# require "google/cloud/storage"
|
@@ -1876,8 +1897,9 @@ module Google
|
|
1876
1897
|
# bucket = storage.bucket "my-todo-app"
|
1877
1898
|
#
|
1878
1899
|
# conditions = [["starts-with", "$acl","public"]]
|
1879
|
-
# post = bucket.generate_signed_post_policy_v4 "avatars/heidi/400x400.png",
|
1880
|
-
#
|
1900
|
+
# post = bucket.generate_signed_post_policy_v4 "avatars/heidi/400x400.png",
|
1901
|
+
# expires: 10,
|
1902
|
+
# conditions: conditions
|
1881
1903
|
#
|
1882
1904
|
# post.url #=> "https://storage.googleapis.com/my-todo-app/"
|
1883
1905
|
# post.fields["key"] #=> "my-todo-app/avatars/heidi/400x400.png"
|
@@ -1918,10 +1940,11 @@ module Google
|
|
1918
1940
|
#
|
1919
1941
|
# bucket = storage.bucket "my-todo-app"
|
1920
1942
|
# conditions = [["starts-with", "$acl","public"]]
|
1921
|
-
# post = bucket.generate_signed_post_policy_v4
|
1922
|
-
#
|
1923
|
-
#
|
1924
|
-
#
|
1943
|
+
# post = bucket.generate_signed_post_policy_v4 "avatars/heidi/400x400.png",
|
1944
|
+
# expires: 10,
|
1945
|
+
# conditions: conditions,
|
1946
|
+
# issuer: issuer,
|
1947
|
+
# signer: signer
|
1925
1948
|
#
|
1926
1949
|
# post.url #=> "https://storage.googleapis.com/my-todo-app/"
|
1927
1950
|
# post.fields["key"] #=> "my-todo-app/avatars/heidi/400x400.png"
|
@@ -2549,9 +2572,11 @@ module Google
|
|
2549
2572
|
# Yielded to a block to accumulate changes for a patch request.
|
2550
2573
|
class Updater < Bucket
|
2551
2574
|
attr_reader :updates
|
2575
|
+
|
2552
2576
|
##
|
2553
2577
|
# Create an Updater object.
|
2554
2578
|
def initialize gapi
|
2579
|
+
super()
|
2555
2580
|
@updates = []
|
2556
2581
|
@gapi = gapi
|
2557
2582
|
@labels = @gapi.labels.to_h.dup
|
@@ -198,7 +198,7 @@ module Google
|
|
198
198
|
gapi = @service.insert_bucket_acl @bucket, entity, "OWNER",
|
199
199
|
user_project: user_project
|
200
200
|
entity = gapi.entity
|
201
|
-
@owners
|
201
|
+
@owners&.push entity
|
202
202
|
entity
|
203
203
|
end
|
204
204
|
|
@@ -243,7 +243,7 @@ module Google
|
|
243
243
|
gapi = @service.insert_bucket_acl @bucket, entity, "WRITER",
|
244
244
|
user_project: user_project
|
245
245
|
entity = gapi.entity
|
246
|
-
@writers
|
246
|
+
@writers&.push entity
|
247
247
|
entity
|
248
248
|
end
|
249
249
|
|
@@ -288,7 +288,7 @@ module Google
|
|
288
288
|
gapi = @service.insert_bucket_acl @bucket, entity, "READER",
|
289
289
|
user_project: user_project
|
290
290
|
entity = gapi.entity
|
291
|
-
@readers
|
291
|
+
@readers&.push entity
|
292
292
|
entity
|
293
293
|
end
|
294
294
|
|
@@ -323,9 +323,9 @@ module Google
|
|
323
323
|
def delete entity
|
324
324
|
@service.delete_bucket_acl @bucket, entity,
|
325
325
|
user_project: user_project
|
326
|
-
@owners
|
327
|
-
@writers
|
328
|
-
@readers
|
326
|
+
@owners&.delete entity
|
327
|
+
@writers&.delete entity
|
328
|
+
@readers&.delete entity
|
329
329
|
true
|
330
330
|
end
|
331
331
|
|
@@ -445,8 +445,7 @@ module Google
|
|
445
445
|
|
446
446
|
def entities_from_acls acls, role
|
447
447
|
selected = acls.select { |acl| acl.role == role }
|
448
|
-
|
449
|
-
entities
|
448
|
+
selected.map(&:entity)
|
450
449
|
end
|
451
450
|
end
|
452
451
|
|
@@ -614,7 +613,7 @@ module Google
|
|
614
613
|
gapi = @service.insert_default_acl @bucket, entity, "OWNER",
|
615
614
|
user_project: user_project
|
616
615
|
entity = gapi.entity
|
617
|
-
@owners
|
616
|
+
@owners&.push entity
|
618
617
|
entity
|
619
618
|
end
|
620
619
|
|
@@ -657,7 +656,7 @@ module Google
|
|
657
656
|
gapi = @service.insert_default_acl @bucket, entity, "READER",
|
658
657
|
user_project: user_project
|
659
658
|
entity = gapi.entity
|
660
|
-
@readers
|
659
|
+
@readers&.push entity
|
661
660
|
entity
|
662
661
|
end
|
663
662
|
|
@@ -690,8 +689,8 @@ module Google
|
|
690
689
|
def delete entity
|
691
690
|
@service.delete_default_acl @bucket, entity,
|
692
691
|
user_project: user_project
|
693
|
-
@owners
|
694
|
-
@readers
|
692
|
+
@owners&.delete entity
|
693
|
+
@readers&.delete entity
|
695
694
|
true
|
696
695
|
end
|
697
696
|
|
@@ -829,8 +828,7 @@ module Google
|
|
829
828
|
|
830
829
|
def entities_from_acls acls, role
|
831
830
|
selected = acls.select { |acl| acl.role == role }
|
832
|
-
|
833
|
-
entities
|
831
|
+
selected.map(&:entity)
|
834
832
|
end
|
835
833
|
end
|
836
834
|
end
|
@@ -172,7 +172,10 @@ module Google
|
|
172
172
|
# rule.max_age #=> 3600
|
173
173
|
#
|
174
174
|
class Rule
|
175
|
-
attr_accessor :origin
|
175
|
+
attr_accessor :origin
|
176
|
+
attr_accessor :methods
|
177
|
+
attr_accessor :headers
|
178
|
+
attr_accessor :max_age
|
176
179
|
|
177
180
|
# @private
|
178
181
|
def initialize origin, methods, headers: nil, max_age: nil
|
@@ -371,17 +371,17 @@ module Google
|
|
371
371
|
# end
|
372
372
|
#
|
373
373
|
class Rule
|
374
|
-
attr_accessor :action
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
374
|
+
attr_accessor :action
|
375
|
+
attr_accessor :storage_class
|
376
|
+
attr_accessor :age
|
377
|
+
attr_accessor :created_before
|
378
|
+
attr_accessor :custom_time_before
|
379
|
+
attr_accessor :days_since_custom_time
|
380
|
+
attr_accessor :days_since_noncurrent_time
|
381
|
+
attr_accessor :is_live
|
382
|
+
attr_accessor :matches_storage_class
|
383
|
+
attr_accessor :noncurrent_time_before
|
384
|
+
attr_accessor :num_newer_versions
|
385
385
|
|
386
386
|
# @private
|
387
387
|
def initialize action,
|
@@ -125,17 +125,17 @@ module Google
|
|
125
125
|
# puts bucket.name
|
126
126
|
# end
|
127
127
|
#
|
128
|
-
def all request_limit: nil
|
128
|
+
def all request_limit: nil, &block
|
129
129
|
request_limit = request_limit.to_i if request_limit
|
130
130
|
unless block_given?
|
131
131
|
return enum_for :all, request_limit: request_limit
|
132
132
|
end
|
133
133
|
results = self
|
134
134
|
loop do
|
135
|
-
results.each
|
135
|
+
results.each(&block)
|
136
136
|
if request_limit
|
137
137
|
request_limit -= 1
|
138
|
-
break if request_limit
|
138
|
+
break if request_limit.negative?
|
139
139
|
end
|
140
140
|
break unless results.next?
|
141
141
|
results = results.next
|
@@ -38,20 +38,22 @@ module Google
|
|
38
38
|
# storage.project_id #=> "my-project"
|
39
39
|
#
|
40
40
|
class Credentials < Google::Auth::Credentials
|
41
|
-
SCOPE =
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
41
|
+
SCOPE = ["https://www.googleapis.com/auth/devstorage.full_control"].freeze
|
42
|
+
PATH_ENV_VARS = [
|
43
|
+
"STORAGE_CREDENTIALS",
|
44
|
+
"STORAGE_KEYFILE",
|
45
|
+
"GOOGLE_CLOUD_CREDENTIALS",
|
46
|
+
"GOOGLE_CLOUD_KEYFILE",
|
47
|
+
"GCLOUD_KEYFILE"
|
48
|
+
].freeze
|
49
|
+
JSON_ENV_VARS = [
|
50
|
+
"STORAGE_CREDENTIALS_JSON",
|
51
|
+
"STORAGE_KEYFILE_JSON",
|
52
|
+
"GOOGLE_CLOUD_CREDENTIALS_JSON",
|
53
|
+
"GOOGLE_CLOUD_KEYFILE_JSON",
|
54
|
+
"GCLOUD_KEYFILE_JSON"
|
55
|
+
].freeze
|
56
|
+
DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"].freeze
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -191,7 +191,7 @@ module Google
|
|
191
191
|
# @return [Integer]
|
192
192
|
#
|
193
193
|
def size
|
194
|
-
@gapi.size
|
194
|
+
@gapi.size&.to_i
|
195
195
|
end
|
196
196
|
|
197
197
|
##
|
@@ -412,7 +412,8 @@ module Google
|
|
412
412
|
# You can use this SHA256 hash to uniquely identify the AES-256
|
413
413
|
# encryption key required to decrypt this file.
|
414
414
|
#
|
415
|
-
# @return [String]
|
415
|
+
# @return [String, nil] The encoded SHA256 hash, or `nil` if there is
|
416
|
+
# no customer-supplied encryption key for this file.
|
416
417
|
#
|
417
418
|
def encryption_key_sha256
|
418
419
|
return nil unless @gapi.customer_encryption
|
@@ -1229,7 +1230,7 @@ module Google
|
|
1229
1230
|
# cipher.encrypt
|
1230
1231
|
# new_key = cipher.random_key
|
1231
1232
|
#
|
1232
|
-
# file = bucket.file "path/to/my-file.ext"
|
1233
|
+
# file = bucket.file "path/to/my-file.ext", encryption_key: old_key
|
1233
1234
|
# file.rewrite "new-destination-bucket",
|
1234
1235
|
# "path/to/destination/file.ext",
|
1235
1236
|
# encryption_key: old_key,
|
@@ -1250,7 +1251,7 @@ module Google
|
|
1250
1251
|
# # Old customer-supplied key was stored securely for later use.
|
1251
1252
|
# old_key = "y\x03\"\x0E\xB6\xD3\x9B\x0E\xAB*\x19\xFAv\xDEY\xBEI..."
|
1252
1253
|
#
|
1253
|
-
# file = bucket.file "path/to/my-file.ext"
|
1254
|
+
# file = bucket.file "path/to/my-file.ext", encryption_key: old_key
|
1254
1255
|
# file.rewrite "new-destination-bucket",
|
1255
1256
|
# "path/to/destination/file.ext",
|
1256
1257
|
# encryption_key: old_key,
|
@@ -1872,7 +1873,7 @@ module Google
|
|
1872
1873
|
|
1873
1874
|
ensure_service!
|
1874
1875
|
|
1875
|
-
rewrite_attrs =
|
1876
|
+
rewrite_attrs = [:storage_class, :kms_key_name]
|
1876
1877
|
@gapi = if attributes.any? { |a| rewrite_attrs.include? a }
|
1877
1878
|
rewrite_gapi \
|
1878
1879
|
bucket, name, update_gapi, user_project: user_project
|
@@ -1971,6 +1972,7 @@ module Google
|
|
1971
1972
|
##
|
1972
1973
|
# @private Create an Updater object.
|
1973
1974
|
def initialize gapi
|
1975
|
+
super()
|
1974
1976
|
@updates = []
|
1975
1977
|
@gapi = gapi
|
1976
1978
|
@metadata ||= @gapi.metadata.to_h.dup
|
@@ -190,7 +190,7 @@ module Google
|
|
190
190
|
generation: generation,
|
191
191
|
user_project: user_project
|
192
192
|
entity = gapi.entity
|
193
|
-
@owners
|
193
|
+
@owners&.push entity
|
194
194
|
entity
|
195
195
|
end
|
196
196
|
|
@@ -241,7 +241,7 @@ module Google
|
|
241
241
|
generation: generation,
|
242
242
|
user_project: user_project
|
243
243
|
entity = gapi.entity
|
244
|
-
@readers
|
244
|
+
@readers&.push entity
|
245
245
|
entity
|
246
246
|
end
|
247
247
|
|
@@ -281,8 +281,8 @@ module Google
|
|
281
281
|
@service.delete_file_acl \
|
282
282
|
@bucket, @file, entity,
|
283
283
|
generation: generation, user_project: user_project
|
284
|
-
@owners
|
285
|
-
@readers
|
284
|
+
@owners&.delete entity
|
285
|
+
@readers&.delete entity
|
286
286
|
true
|
287
287
|
end
|
288
288
|
|
@@ -428,8 +428,7 @@ module Google
|
|
428
428
|
|
429
429
|
def entities_from_acls acls, role
|
430
430
|
selected = acls.select { |acl| acl.role == role }
|
431
|
-
|
432
|
-
entities
|
431
|
+
selected.map(&:entity)
|
433
432
|
end
|
434
433
|
end
|
435
434
|
end
|
@@ -141,17 +141,17 @@ module Google
|
|
141
141
|
# puts file.name
|
142
142
|
# end
|
143
143
|
#
|
144
|
-
def all request_limit: nil
|
144
|
+
def all request_limit: nil, &block
|
145
145
|
request_limit = request_limit.to_i if request_limit
|
146
146
|
unless block_given?
|
147
147
|
return enum_for :all, request_limit: request_limit
|
148
148
|
end
|
149
149
|
results = self
|
150
150
|
loop do
|
151
|
-
results.each
|
151
|
+
results.each(&block)
|
152
152
|
if request_limit
|
153
153
|
request_limit -= 1
|
154
|
-
break if request_limit
|
154
|
+
break if request_limit.negative?
|
155
155
|
end
|
156
156
|
break unless results.next?
|
157
157
|
results = results.next
|
@@ -147,10 +147,8 @@ module Google
|
|
147
147
|
"&Expires=#{expires}" \
|
148
148
|
"&Signature=#{url_escape signed_string}"
|
149
149
|
|
150
|
-
|
151
|
-
|
152
|
-
url << "&#{url_escape name}=#{url_escape value}"
|
153
|
-
end
|
150
|
+
query&.each do |name, value|
|
151
|
+
url << "&#{url_escape name}=#{url_escape value}"
|
154
152
|
end
|
155
153
|
|
156
154
|
url
|
@@ -60,7 +60,7 @@ module Google
|
|
60
60
|
|
61
61
|
p = {}
|
62
62
|
p["conditions"] = policy_conditions base_fields, conditions, fields
|
63
|
-
expires ||= 60*60*24
|
63
|
+
expires ||= 60 * 60 * 24
|
64
64
|
p["expiration"] = (now + expires).strftime "%Y-%m-%dT%H:%M:%SZ"
|
65
65
|
|
66
66
|
policy_str = escape_characters p.to_json
|
@@ -100,7 +100,7 @@ module Google
|
|
100
100
|
|
101
101
|
algorithm = "GOOG4-RSA-SHA256"
|
102
102
|
expires = determine_expires expires
|
103
|
-
credential = issuer
|
103
|
+
credential = "#{issuer}/#{scope}"
|
104
104
|
canonical_query_str = canonical_query query, algorithm, credential, goog_date, expires, signed_headers_str
|
105
105
|
|
106
106
|
# From AWS: You don't include a payload hash in the Canonical
|
@@ -131,9 +131,7 @@ module Google
|
|
131
131
|
# methods below are public visibility only for unit testing
|
132
132
|
def escape_characters str
|
133
133
|
str.split("").map do |s|
|
134
|
-
if
|
135
|
-
escape_special_unicode s
|
136
|
-
else
|
134
|
+
if s.ascii_only?
|
137
135
|
case s
|
138
136
|
when "\\"
|
139
137
|
'\\'
|
@@ -152,12 +150,14 @@ module Google
|
|
152
150
|
else
|
153
151
|
s
|
154
152
|
end
|
153
|
+
else
|
154
|
+
escape_special_unicode s
|
155
155
|
end
|
156
156
|
end.join
|
157
157
|
end
|
158
158
|
|
159
159
|
def escape_special_unicode str
|
160
|
-
str.unpack("U*").map { |i|
|
160
|
+
str.unpack("U*").map { |i| "\\u#{i.to_s(16).rjust(4, '0')}" }.join
|
161
161
|
end
|
162
162
|
|
163
163
|
protected
|
@@ -177,7 +177,7 @@ module Google
|
|
177
177
|
# Add the bucket to the head of the base_fields. This is not returned in the PostObject fields.
|
178
178
|
conditions.unshift "bucket" => @bucket_name
|
179
179
|
# Add user-provided conditions to the head of the conditions array.
|
180
|
-
conditions
|
180
|
+
conditions = user_conditions + conditions if user_conditions
|
181
181
|
if user_fields
|
182
182
|
# Convert each pair in fields hash to a single-entry hash and add it to the head of the conditions array.
|
183
183
|
user_fields.to_a.reverse.each { |f| conditions.unshift Hash[*f] }
|
@@ -212,14 +212,14 @@ module Google
|
|
212
212
|
if signer.is_a? Proc
|
213
213
|
lambda do |string_to_sign|
|
214
214
|
sig = signer.call string_to_sign
|
215
|
-
sig.
|
215
|
+
sig.unpack1 "H*"
|
216
216
|
end
|
217
217
|
else
|
218
218
|
signer = OpenSSL::PKey::RSA.new signer unless signer.respond_to? :sign
|
219
219
|
# Sign string to sign
|
220
220
|
lambda do |string_to_sign|
|
221
221
|
sig = signer.sign OpenSSL::Digest::SHA256.new, string_to_sign
|
222
|
-
sig.
|
222
|
+
sig.unpack1 "H*"
|
223
223
|
end
|
224
224
|
end
|
225
225
|
end
|
@@ -273,7 +273,7 @@ module Google
|
|
273
273
|
# Only the characters in the regex set [A-Za-z0-9.~_-] must be left un-escaped; all others must be
|
274
274
|
# percent-encoded using %XX UTF-8 style.
|
275
275
|
def escape_query_param str
|
276
|
-
CGI.escape(str.to_s).gsub("%7E", "~")
|
276
|
+
CGI.escape(str.to_s).gsub("%7E", "~").gsub "+", "%20"
|
277
277
|
end
|
278
278
|
|
279
279
|
def host_name virtual_hosted_style, bucket_bound_hostname
|
@@ -287,7 +287,7 @@ module Google
|
|
287
287
|
path = []
|
288
288
|
path << "/#{@bucket_name}" if path_style
|
289
289
|
path << "/#{String(@file_name)}" if @file_name && !@file_name.empty?
|
290
|
-
CGI.escape(path.join).gsub
|
290
|
+
CGI.escape(path.join).gsub("%2F", "/").gsub "+", "%20"
|
291
291
|
end
|
292
292
|
|
293
293
|
##
|
@@ -359,7 +359,7 @@ module Google
|
|
359
359
|
end
|
360
360
|
packed_signature = signing_key.sign OpenSSL::Digest::SHA256.new, data
|
361
361
|
end
|
362
|
-
packed_signature.
|
362
|
+
packed_signature.unpack1("H*").force_encoding "utf-8"
|
363
363
|
end
|
364
364
|
end
|
365
365
|
end
|
@@ -131,17 +131,17 @@ module Google
|
|
131
131
|
# puts key.access_id
|
132
132
|
# end
|
133
133
|
#
|
134
|
-
def all request_limit: nil
|
134
|
+
def all request_limit: nil, &block
|
135
135
|
request_limit = request_limit.to_i if request_limit
|
136
136
|
unless block_given?
|
137
137
|
return enum_for :all, request_limit: request_limit
|
138
138
|
end
|
139
139
|
results = self
|
140
140
|
loop do
|
141
|
-
results.each
|
141
|
+
results.each(&block)
|
142
142
|
if request_limit
|
143
143
|
request_limit -= 1
|
144
|
-
break if request_limit
|
144
|
+
break if request_limit.negative?
|
145
145
|
end
|
146
146
|
break unless results.next?
|
147
147
|
results = results.next
|
@@ -212,8 +212,8 @@ module Google
|
|
212
212
|
def deep_dup
|
213
213
|
warn "DEPRECATED: Storage::PolicyV1#deep_dup"
|
214
214
|
dup.tap do |p|
|
215
|
-
roles_dup = p.roles.
|
216
|
-
|
215
|
+
roles_dup = p.roles.transform_values do |v|
|
216
|
+
v.dup rescue value
|
217
217
|
end
|
218
218
|
p.instance_variable_set :@roles, roles_dup
|
219
219
|
end
|
@@ -89,7 +89,9 @@ module Google
|
|
89
89
|
# end
|
90
90
|
#
|
91
91
|
class Binding
|
92
|
-
attr_reader :role
|
92
|
+
attr_reader :role
|
93
|
+
attr_reader :members
|
94
|
+
attr_reader :condition
|
93
95
|
|
94
96
|
##
|
95
97
|
# Creates a Binding object.
|
@@ -128,8 +130,8 @@ module Google
|
|
128
130
|
raise ArgumentError, "members is empty, must be provided" if @members.empty?
|
129
131
|
|
130
132
|
condition = Condition.new(**condition) if condition.is_a? Hash
|
131
|
-
if condition
|
132
|
-
raise ArgumentError, "expected Condition, not #{condition.inspect}"
|
133
|
+
if condition && !(condition.is_a? Condition)
|
134
|
+
raise ArgumentError, "expected Condition, not #{condition.inspect}"
|
133
135
|
end
|
134
136
|
@condition = condition
|
135
137
|
end
|
@@ -70,7 +70,9 @@ module Google
|
|
70
70
|
# end
|
71
71
|
#
|
72
72
|
class Condition
|
73
|
-
attr_reader :title
|
73
|
+
attr_reader :title
|
74
|
+
attr_reader :description
|
75
|
+
attr_reader :expression
|
74
76
|
|
75
77
|
##
|
76
78
|
# Creates a Condition object.
|
@@ -83,7 +85,7 @@ module Google
|
|
83
85
|
# one attributes, and statements are combined using logic operators,
|
84
86
|
# following CEL language specification. Required.
|
85
87
|
#
|
86
|
-
def initialize title:, description: nil
|
88
|
+
def initialize title:, expression:, description: nil
|
87
89
|
@title = String title
|
88
90
|
@description = String description
|
89
91
|
@expression = String expression
|
@@ -39,7 +39,7 @@ module Google
|
|
39
39
|
##
|
40
40
|
# Creates a new Service instance.
|
41
41
|
def initialize project, credentials,
|
42
|
-
retries: nil, timeout: nil, host: nil
|
42
|
+
retries: nil, timeout: nil, host: nil, quota_project: nil
|
43
43
|
@project = project
|
44
44
|
@credentials = credentials
|
45
45
|
@service = API::StorageService.new
|
@@ -55,6 +55,7 @@ module Google
|
|
55
55
|
@service.request_options.header["x-goog-api-client"] = \
|
56
56
|
"gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::Storage::VERSION}"
|
57
57
|
@service.request_options.header["Accept-Encoding"] = "gzip"
|
58
|
+
@service.request_options.quota_project = quota_project if quota_project
|
58
59
|
@service.authorization = @credentials.client if @credentials
|
59
60
|
@service.root_url = host if host
|
60
61
|
end
|
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.31.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:
|
12
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -26,19 +26,33 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.2'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name: google-
|
29
|
+
name: google-apis-iamcredentials_v1
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '0.
|
34
|
+
version: '0.1'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0.
|
41
|
+
version: '0.1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: google-apis-storage_v1
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.1'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.1'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: googleauth
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,14 +115,14 @@ dependencies:
|
|
101
115
|
requirements:
|
102
116
|
- - "~>"
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version: 1.
|
118
|
+
version: 1.25.1
|
105
119
|
type: :development
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
123
|
- - "~>"
|
110
124
|
- !ruby/object:Gem::Version
|
111
|
-
version: 1.
|
125
|
+
version: 1.25.1
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: minitest
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -291,15 +305,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
291
305
|
requirements:
|
292
306
|
- - ">="
|
293
307
|
- !ruby/object:Gem::Version
|
294
|
-
version: '2.
|
308
|
+
version: '2.5'
|
295
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
296
310
|
requirements:
|
297
311
|
- - ">="
|
298
312
|
- !ruby/object:Gem::Version
|
299
313
|
version: '0'
|
300
314
|
requirements: []
|
301
|
-
|
302
|
-
rubygems_version: 2.6.14.4
|
315
|
+
rubygems_version: 3.2.13
|
303
316
|
signing_key:
|
304
317
|
specification_version: 4
|
305
318
|
summary: API Client library for Google Cloud Storage
|