google-cloud-storage 1.27.0 → 1.30.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 +55 -0
- data/CONTRIBUTING.md +1 -1
- data/lib/google-cloud-storage.rb +1 -0
- data/lib/google/cloud/storage.rb +2 -1
- data/lib/google/cloud/storage/bucket.rb +50 -21
- data/lib/google/cloud/storage/bucket/lifecycle.rb +160 -26
- data/lib/google/cloud/storage/file.rb +31 -5
- data/lib/google/cloud/storage/file/signer_v4.rb +3 -3
- data/lib/google/cloud/storage/service.rb +4 -3
- data/lib/google/cloud/storage/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b78945de5adc36366ded346357d71f954327a48b11d9d909ad5b8443f51c95
|
4
|
+
data.tar.gz: adcc876f70b87130ca732a591a9f1d6aa278e03a0356ea012620f30650c3b25e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e46be5fe50420e4a674add04d12a06243dba3438aafedc9356246ac8e5fa66aa0db547d9264a70b940cd46133aed1b7256cdad02397c93b0eeb73d312fffdd48
|
7
|
+
data.tar.gz: 0a89f487726406d8865b1c675d43f1153e3cf78d0e5b8df1ebc4eb1f09a051f9dd45c328503d500dda6aee4bcd60c3693104d0371755154263eb52ccceaf3b1b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,60 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.30.0 / 2021-01-13
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Replace google-api-client with specific client gems
|
8
|
+
* Remove google-api-client
|
9
|
+
* Add google-apis-iamcredentials_v1
|
10
|
+
* Add google-apis-storage_v1
|
11
|
+
|
12
|
+
#### Documentation
|
13
|
+
|
14
|
+
* Update Bucket#generate_signed_post_policy_v4 documentation
|
15
|
+
|
16
|
+
### 1.29.2 / 2020-12-14
|
17
|
+
|
18
|
+
#### Bug Fixes
|
19
|
+
|
20
|
+
* Fix support for #generate_signed_post_policy_v4 conditions
|
21
|
+
|
22
|
+
### 1.29.1 / 2020-10-05
|
23
|
+
|
24
|
+
#### Bug Fixes
|
25
|
+
|
26
|
+
* Fix encoding of space characters in file names in signed_url v4
|
27
|
+
|
28
|
+
#### Documentation
|
29
|
+
|
30
|
+
* Update Bucket#default_kms_key= docs
|
31
|
+
* Demonstrate deleting the Cloud KMS encryption key
|
32
|
+
* Update customer-supplied encryption key docs and examples ([#7851](https://www.github.com/googleapis/google-cloud-ruby/issues/7851))
|
33
|
+
|
34
|
+
### 1.29.0 / 2020-09-22
|
35
|
+
|
36
|
+
#### Features
|
37
|
+
|
38
|
+
* quota_project can be set via library configuration ([#7656](https://www.github.com/googleapis/google-cloud-ruby/issues/7656))
|
39
|
+
|
40
|
+
#### Bug Fixes
|
41
|
+
|
42
|
+
* Fix encoding of space characters in #signed_url version: :v4
|
43
|
+
* Fix encoding of space characters to use percent encoding (%20) instead of plus sign (+).
|
44
|
+
|
45
|
+
#### Documentation
|
46
|
+
|
47
|
+
* Add custom time to file metadata sample
|
48
|
+
|
49
|
+
### 1.28.0 / 2020-08-26
|
50
|
+
|
51
|
+
* Add Object Lifecycle Management fields
|
52
|
+
* Add custom_time_before to Lifecycle::Rule
|
53
|
+
* Add days_since_custom_time to Lifecycle::Rule
|
54
|
+
* Add days_since_noncurrent_time to Lifecycle::Rule
|
55
|
+
* Add noncurrent_time_before to Lifecycle::Rule
|
56
|
+
* Add File#custom_time and #custom_time=
|
57
|
+
|
3
58
|
### 1.27.0 / 2020-07-29
|
4
59
|
|
5
60
|
#### Features
|
data/CONTRIBUTING.md
CHANGED
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
|
@@ -557,7 +557,8 @@ module Google
|
|
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
|
@@ -1128,6 +1138,11 @@ module Google
|
|
1128
1138
|
# @param [String] content_type The
|
1129
1139
|
# [Content-Type](https://tools.ietf.org/html/rfc2616#section-14.17)
|
1130
1140
|
# response header to be returned when the file is downloaded.
|
1141
|
+
# @param [DateTime] custom_time A custom time specified by the user for
|
1142
|
+
# the file. Once set, custom_time can't be unset, and it can only be
|
1143
|
+
# changed to a time in the future. If custom_time must be unset, you
|
1144
|
+
# must either perform a rewrite operation, or upload the data again
|
1145
|
+
# and create a new file.
|
1131
1146
|
# @param [String] crc32c The CRC32c checksum of the file data, as
|
1132
1147
|
# described in [RFC 4960, Appendix
|
1133
1148
|
# B](http://tools.ietf.org/html/rfc4960#appendix-B).
|
@@ -1249,7 +1264,7 @@ module Google
|
|
1249
1264
|
#
|
1250
1265
|
def create_file file, path = nil, acl: nil, cache_control: nil,
|
1251
1266
|
content_disposition: nil, content_encoding: nil,
|
1252
|
-
content_language: nil, content_type: nil,
|
1267
|
+
content_language: nil, content_type: nil, custom_time: nil,
|
1253
1268
|
crc32c: nil, md5: nil, metadata: nil,
|
1254
1269
|
storage_class: nil, encryption_key: nil, kms_key: nil,
|
1255
1270
|
temporary_hold: nil, event_based_hold: nil
|
@@ -1264,6 +1279,7 @@ module Google
|
|
1264
1279
|
md5: md5,
|
1265
1280
|
cache_control: cache_control,
|
1266
1281
|
content_type: content_type,
|
1282
|
+
custom_time: custom_time,
|
1267
1283
|
content_disposition: content_disposition,
|
1268
1284
|
crc32c: crc32c,
|
1269
1285
|
content_encoding: content_encoding,
|
@@ -1631,8 +1647,8 @@ module Google
|
|
1631
1647
|
end
|
1632
1648
|
|
1633
1649
|
##
|
1634
|
-
# Generate a PostObject that includes the fields and
|
1635
|
-
# upload objects via
|
1650
|
+
# Generate a PostObject that includes the fields and URL to
|
1651
|
+
# upload objects via HTML forms.
|
1636
1652
|
#
|
1637
1653
|
# Generating a PostObject requires service account credentials,
|
1638
1654
|
# either by connecting with a service account when calling
|
@@ -1678,7 +1694,7 @@ module Google
|
|
1678
1694
|
# Proc should return a signature created using a RPC call to the
|
1679
1695
|
# [Service Account Credentials signBlob](https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob)
|
1680
1696
|
# method as shown in the example below.
|
1681
|
-
# @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.
|
1682
1698
|
#
|
1683
1699
|
# @raise [SignedUrlUnavailable] If the service account credentials
|
1684
1700
|
# are missing. Service account credentials are acquired by following the
|
@@ -1801,10 +1817,14 @@ module Google
|
|
1801
1817
|
end
|
1802
1818
|
|
1803
1819
|
##
|
1804
|
-
# Generate a PostObject that includes the fields and
|
1805
|
-
# 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).
|
1806
1826
|
#
|
1807
|
-
# Generating a PostObject requires service account credentials,
|
1827
|
+
# Generating a `PostObject` requires service account credentials,
|
1808
1828
|
# either by connecting with a service account when calling
|
1809
1829
|
# {Google::Cloud.storage}, or by passing in the service account
|
1810
1830
|
# `issuer` and `signing_key` values. Although the private key can
|
@@ -1817,6 +1837,8 @@ module Google
|
|
1817
1837
|
# steps in [Service Account Authentication](
|
1818
1838
|
# https://cloud.google.com/iam/docs/service-accounts).
|
1819
1839
|
#
|
1840
|
+
# @see https://cloud.google.com/storage/docs/authentication/signatures#policy-document Signatures -
|
1841
|
+
# Policy document
|
1820
1842
|
# @see https://cloud.google.com/storage/docs/xml-api/post-object
|
1821
1843
|
#
|
1822
1844
|
# @param [String] path Path to the file in Google Cloud Storage.
|
@@ -1840,9 +1862,14 @@ module Google
|
|
1840
1862
|
# method as shown in the example below.
|
1841
1863
|
# @param [Integer] expires The number of seconds until the URL expires.
|
1842
1864
|
# The default is 604800 (7 days).
|
1843
|
-
# @param [Hash] fields User-supplied form fields such as `acl`,
|
1865
|
+
# @param [Hash{String => String}] fields User-supplied form fields such as `acl`,
|
1844
1866
|
# `cache-control`, `success_action_status`, and `success_action_redirect`.
|
1845
|
-
#
|
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).
|
1846
1873
|
# @param [String] scheme The URL scheme. The default value is `HTTPS`.
|
1847
1874
|
# @param [Boolean] virtual_hosted_style Whether to use a virtual hosted-style
|
1848
1875
|
# hostname, which adds the bucket into the host portion of the URI rather
|
@@ -1855,12 +1882,12 @@ module Google
|
|
1855
1882
|
# Cloud Load Balancer which routes to a bucket you own, e.g.
|
1856
1883
|
# `my-load-balancer-domain.tld`.
|
1857
1884
|
#
|
1858
|
-
# @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.
|
1859
1887
|
#
|
1860
|
-
# @raise [SignedUrlUnavailable] If the service account credentials
|
1861
|
-
#
|
1862
|
-
#
|
1863
|
-
# 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).
|
1864
1891
|
#
|
1865
1892
|
# @example
|
1866
1893
|
# require "google/cloud/storage"
|
@@ -1870,8 +1897,9 @@ module Google
|
|
1870
1897
|
# bucket = storage.bucket "my-todo-app"
|
1871
1898
|
#
|
1872
1899
|
# conditions = [["starts-with", "$acl","public"]]
|
1873
|
-
# post = bucket.generate_signed_post_policy_v4 "avatars/heidi/400x400.png",
|
1874
|
-
#
|
1900
|
+
# post = bucket.generate_signed_post_policy_v4 "avatars/heidi/400x400.png",
|
1901
|
+
# expires: 10,
|
1902
|
+
# conditions: conditions
|
1875
1903
|
#
|
1876
1904
|
# post.url #=> "https://storage.googleapis.com/my-todo-app/"
|
1877
1905
|
# post.fields["key"] #=> "my-todo-app/avatars/heidi/400x400.png"
|
@@ -1912,10 +1940,11 @@ module Google
|
|
1912
1940
|
#
|
1913
1941
|
# bucket = storage.bucket "my-todo-app"
|
1914
1942
|
# conditions = [["starts-with", "$acl","public"]]
|
1915
|
-
# post = bucket.generate_signed_post_policy_v4
|
1916
|
-
#
|
1917
|
-
#
|
1918
|
-
#
|
1943
|
+
# post = bucket.generate_signed_post_policy_v4 "avatars/heidi/400x400.png",
|
1944
|
+
# expires: 10,
|
1945
|
+
# conditions: conditions,
|
1946
|
+
# issuer: issuer,
|
1947
|
+
# signer: signer
|
1919
1948
|
#
|
1920
1949
|
# post.url #=> "https://storage.googleapis.com/my-todo-app/"
|
1921
1950
|
# post.fields["key"] #=> "my-todo-app/avatars/heidi/400x400.png"
|
@@ -105,6 +105,21 @@ module Google
|
|
105
105
|
# only the date part (for instance, "2013-01-15"). This condition is
|
106
106
|
# satisfied when a file is created before midnight of the specified
|
107
107
|
# date in UTC.
|
108
|
+
# @param [String,Date] custom_time_before A date in RFC 3339 format with
|
109
|
+
# only the date part (for instance, "2013-01-15"). This condition is
|
110
|
+
# satisfied when the custom time on an object is before this date in UTC.
|
111
|
+
# @param [Integer] days_since_custom_time Represents the number of
|
112
|
+
# days elapsed since the user-specified timestamp set on an object.
|
113
|
+
# The condition is satisfied if the days elapsed is at least this
|
114
|
+
# number. If no custom timestamp is specified on an object, the
|
115
|
+
# condition does not apply.
|
116
|
+
# @param [Integer] days_since_noncurrent_time Represents the number of
|
117
|
+
# days elapsed since the noncurrent timestamp of an object. The
|
118
|
+
# condition is satisfied if the days elapsed is at least this number.
|
119
|
+
# The value of the field must be a nonnegative integer. If it's zero,
|
120
|
+
# the object version will become eligible for Lifecycle action as
|
121
|
+
# soon as it becomes noncurrent. Relevant only for versioning-enabled
|
122
|
+
# buckets. (See {Bucket#versioning?})
|
108
123
|
# @param [Boolean] is_live Relevant only for versioned files. If the
|
109
124
|
# value is `true`, this condition matches live files; if the value
|
110
125
|
# is `false`, it matches archived files.
|
@@ -115,6 +130,10 @@ module Google
|
|
115
130
|
# `DURABLE_REDUCED_AVAILABILITY` are supported as legacy storage
|
116
131
|
# classes. Arguments will be converted from symbols and lower-case
|
117
132
|
# to upper-case strings.
|
133
|
+
# @param [String,Date] noncurrent_time_before A date in RFC 3339 format
|
134
|
+
# with only the date part (for instance, "2013-01-15"). This condition
|
135
|
+
# is satisfied when the noncurrent time on an object is before this
|
136
|
+
# date in UTC. This condition is relevant only for versioned objects.
|
118
137
|
# @param [Integer] num_newer_versions Relevant only for versioned
|
119
138
|
# files. If the value is N, this condition is satisfied when there
|
120
139
|
# are at least N versions (including the live version) newer than
|
@@ -129,16 +148,29 @@ module Google
|
|
129
148
|
# b.lifecycle.add_set_storage_class_rule "COLDLINE", age: 10
|
130
149
|
# end
|
131
150
|
#
|
132
|
-
def add_set_storage_class_rule storage_class,
|
133
|
-
|
151
|
+
def add_set_storage_class_rule storage_class,
|
152
|
+
age: nil,
|
153
|
+
created_before: nil,
|
154
|
+
custom_time_before: nil,
|
155
|
+
days_since_custom_time: nil,
|
156
|
+
days_since_noncurrent_time: nil,
|
157
|
+
is_live: nil,
|
134
158
|
matches_storage_class: nil,
|
159
|
+
noncurrent_time_before: nil,
|
135
160
|
num_newer_versions: nil
|
136
|
-
push Rule.new
|
161
|
+
push Rule.new(
|
137
162
|
"SetStorageClass",
|
138
163
|
storage_class: storage_class_for(storage_class),
|
139
|
-
age: age,
|
164
|
+
age: age,
|
165
|
+
created_before: created_before,
|
166
|
+
custom_time_before: custom_time_before,
|
167
|
+
days_since_custom_time: days_since_custom_time,
|
168
|
+
days_since_noncurrent_time: days_since_noncurrent_time,
|
169
|
+
is_live: is_live,
|
140
170
|
matches_storage_class: storage_class_for(matches_storage_class),
|
171
|
+
noncurrent_time_before: noncurrent_time_before,
|
141
172
|
num_newer_versions: num_newer_versions
|
173
|
+
)
|
142
174
|
end
|
143
175
|
|
144
176
|
##
|
@@ -156,6 +188,21 @@ module Google
|
|
156
188
|
# only the date part (for instance, "2013-01-15"). This condition is
|
157
189
|
# satisfied when a file is created before midnight of the specified
|
158
190
|
# date in UTC.
|
191
|
+
# @param [String,Date] custom_time_before A date in RFC 3339 format with
|
192
|
+
# only the date part (for instance, "2013-01-15"). This condition is
|
193
|
+
# satisfied when the custom time on an object is before this date in UTC.
|
194
|
+
# @param [Integer] days_since_custom_time Represents the number of
|
195
|
+
# days elapsed since the user-specified timestamp set on an object.
|
196
|
+
# The condition is satisfied if the days elapsed is at least this
|
197
|
+
# number. If no custom timestamp is specified on an object, the
|
198
|
+
# condition does not apply.
|
199
|
+
# @param [Integer] days_since_noncurrent_time Represents the number of
|
200
|
+
# days elapsed since the noncurrent timestamp of an object. The
|
201
|
+
# condition is satisfied if the days elapsed is at least this number.
|
202
|
+
# The value of the field must be a nonnegative integer. If it's zero,
|
203
|
+
# the object version will become eligible for Lifecycle action as
|
204
|
+
# soon as it becomes noncurrent. Relevant only for versioning-enabled
|
205
|
+
# buckets. (See {Bucket#versioning?})
|
159
206
|
# @param [Boolean] is_live Relevant only for versioned files. If the
|
160
207
|
# value is `true`, this condition matches live files; if the value
|
161
208
|
# is `false`, it matches archived files.
|
@@ -166,6 +213,10 @@ module Google
|
|
166
213
|
# `DURABLE_REDUCED_AVAILABILITY` are supported as legacy storage
|
167
214
|
# classes. Arguments will be converted from symbols and lower-case
|
168
215
|
# to upper-case strings.
|
216
|
+
# @param [String,Date] noncurrent_time_before A date in RFC 3339 format
|
217
|
+
# with only the date part (for instance, "2013-01-15"). This condition
|
218
|
+
# is satisfied when the noncurrent time on an object is before this
|
219
|
+
# date in UTC. This condition is relevant only for versioned objects.
|
169
220
|
# @param [Integer] num_newer_versions Relevant only for versioned
|
170
221
|
# files. If the value is N, this condition is satisfied when there
|
171
222
|
# are at least N versions (including the live version) newer than
|
@@ -180,14 +231,27 @@ module Google
|
|
180
231
|
# b.lifecycle.add_delete_rule age: 30, is_live: false
|
181
232
|
# end
|
182
233
|
#
|
183
|
-
def add_delete_rule age: nil,
|
234
|
+
def add_delete_rule age: nil,
|
235
|
+
created_before: nil,
|
236
|
+
custom_time_before: nil,
|
237
|
+
days_since_custom_time: nil,
|
238
|
+
days_since_noncurrent_time: nil,
|
239
|
+
is_live: nil,
|
184
240
|
matches_storage_class: nil,
|
241
|
+
noncurrent_time_before: nil,
|
185
242
|
num_newer_versions: nil
|
186
|
-
push Rule.new
|
243
|
+
push Rule.new(
|
187
244
|
"Delete",
|
188
|
-
age: age,
|
245
|
+
age: age,
|
246
|
+
created_before: created_before,
|
247
|
+
custom_time_before: custom_time_before,
|
248
|
+
days_since_custom_time: days_since_custom_time,
|
249
|
+
days_since_noncurrent_time: days_since_noncurrent_time,
|
250
|
+
is_live: is_live,
|
189
251
|
matches_storage_class: storage_class_for(matches_storage_class),
|
252
|
+
noncurrent_time_before: noncurrent_time_before,
|
190
253
|
num_newer_versions: num_newer_versions
|
254
|
+
)
|
191
255
|
end
|
192
256
|
|
193
257
|
# @private
|
@@ -231,10 +295,26 @@ module Google
|
|
231
295
|
# action. Required only if the action is `SetStorageClass`.
|
232
296
|
# @attr [Integer] age The age of a file (in days). This condition is
|
233
297
|
# satisfied when a file reaches the specified age.
|
234
|
-
# @attr [String,Date] created_before A date in RFC 3339 format with
|
298
|
+
# @attr [String,Date,nil] created_before A date in RFC 3339 format with
|
235
299
|
# only the date part (for instance, "2013-01-15"). This condition is
|
236
300
|
# satisfied when a file is created before midnight of the specified
|
237
|
-
# date in UTC.
|
301
|
+
# date in UTC. When returned by the service, a non-empty value will
|
302
|
+
# always be a Date object.
|
303
|
+
# @attr [String,Date,nil] custom_time_before A date in RFC 3339 format with
|
304
|
+
# only the date part (for instance, "2013-01-15"). This condition is
|
305
|
+
# satisfied when the custom time on an object is before this date in UTC.
|
306
|
+
# @attr [Integer,nil] days_since_custom_time Represents the number of
|
307
|
+
# days elapsed since the user-specified timestamp set on an object.
|
308
|
+
# The condition is satisfied if the days elapsed is at least this
|
309
|
+
# number. If no custom timestamp is specified on an object, the
|
310
|
+
# condition does not apply.
|
311
|
+
# @attr [Integer] days_since_noncurrent_time Represents the number of
|
312
|
+
# days elapsed since the noncurrent timestamp of an object. The
|
313
|
+
# condition is satisfied if the days elapsed is at least this number.
|
314
|
+
# The value of the field must be a nonnegative integer. If it's zero,
|
315
|
+
# the object version will become eligible for Lifecycle action as
|
316
|
+
# soon as it becomes noncurrent. Relevant only for versioning-enabled
|
317
|
+
# buckets. (See {Bucket#versioning?})
|
238
318
|
# @attr [Boolean] is_live Relevant only for versioned files. If the
|
239
319
|
# value is `true`, this condition matches live files; if the value
|
240
320
|
# is `false`, it matches archived files.
|
@@ -243,6 +323,12 @@ module Google
|
|
243
323
|
# Values include `STANDARD`, `NEARLINE`, `COLDLINE`, and `ARCHIVE`.
|
244
324
|
# `REGIONAL`, `MULTI_REGIONAL`, and `DURABLE_REDUCED_AVAILABILITY`
|
245
325
|
# are supported as legacy storage classes.
|
326
|
+
# @attr [String,Date,nil] noncurrent_time_before A date in RFC 3339 format
|
327
|
+
# with only the date part (for instance, "2013-01-15"). This condition
|
328
|
+
# is satisfied when the noncurrent time on an object is before this
|
329
|
+
# date in UTC. This condition is relevant only for versioned objects.
|
330
|
+
# When returned by the service, a non-empty value will always be a
|
331
|
+
# Date object.
|
246
332
|
# @attr [Integer] num_newer_versions Relevant only for versioned
|
247
333
|
# files. If the value is N, this condition is satisfied when there
|
248
334
|
# are at least N versions (including the live version) newer than
|
@@ -285,28 +371,57 @@ module Google
|
|
285
371
|
# end
|
286
372
|
#
|
287
373
|
class Rule
|
288
|
-
attr_accessor :action,
|
289
|
-
:
|
374
|
+
attr_accessor :action,
|
375
|
+
:storage_class,
|
376
|
+
:age,
|
377
|
+
:created_before,
|
378
|
+
:custom_time_before,
|
379
|
+
:days_since_custom_time,
|
380
|
+
:days_since_noncurrent_time,
|
381
|
+
:is_live,
|
382
|
+
:matches_storage_class,
|
383
|
+
:noncurrent_time_before,
|
384
|
+
:num_newer_versions
|
290
385
|
|
291
386
|
# @private
|
292
|
-
def initialize action,
|
293
|
-
|
294
|
-
|
387
|
+
def initialize action,
|
388
|
+
storage_class: nil,
|
389
|
+
age: nil,
|
390
|
+
created_before: nil,
|
391
|
+
custom_time_before: nil,
|
392
|
+
days_since_custom_time: nil,
|
393
|
+
days_since_noncurrent_time: nil,
|
394
|
+
is_live: nil,
|
395
|
+
matches_storage_class: nil,
|
396
|
+
noncurrent_time_before: nil,
|
397
|
+
num_newer_versions: nil
|
295
398
|
@action = action
|
296
399
|
@storage_class = storage_class
|
297
400
|
@age = age
|
298
401
|
@created_before = created_before
|
402
|
+
@custom_time_before = custom_time_before
|
403
|
+
@days_since_custom_time = days_since_custom_time
|
404
|
+
@days_since_noncurrent_time = days_since_noncurrent_time
|
299
405
|
@is_live = is_live
|
300
406
|
@matches_storage_class = Array(matches_storage_class)
|
407
|
+
@noncurrent_time_before = noncurrent_time_before
|
301
408
|
@num_newer_versions = num_newer_versions
|
302
409
|
end
|
303
410
|
|
304
411
|
# @private
|
305
412
|
# @return [Google::Apis::StorageV1::Bucket::Lifecycle]
|
306
413
|
def to_gapi
|
307
|
-
condition = condition_gapi(
|
308
|
-
|
309
|
-
|
414
|
+
condition = condition_gapi(
|
415
|
+
age,
|
416
|
+
created_before,
|
417
|
+
custom_time_before,
|
418
|
+
days_since_custom_time,
|
419
|
+
days_since_noncurrent_time,
|
420
|
+
is_live,
|
421
|
+
matches_storage_class,
|
422
|
+
noncurrent_time_before,
|
423
|
+
num_newer_versions
|
424
|
+
)
|
310
425
|
Google::Apis::StorageV1::Bucket::Lifecycle::Rule.new(
|
311
426
|
action: action_gapi(action, storage_class),
|
312
427
|
condition: condition
|
@@ -316,18 +431,30 @@ module Google
|
|
316
431
|
# @private
|
317
432
|
def action_gapi action, storage_class
|
318
433
|
Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Action.new(
|
319
|
-
type: action,
|
434
|
+
type: action,
|
435
|
+
storage_class: storage_class
|
320
436
|
)
|
321
437
|
end
|
322
438
|
|
323
439
|
# @private
|
324
|
-
def condition_gapi age,
|
325
|
-
|
440
|
+
def condition_gapi age,
|
441
|
+
created_before,
|
442
|
+
custom_time_before,
|
443
|
+
days_since_custom_time,
|
444
|
+
days_since_noncurrent_time,
|
445
|
+
is_live,
|
446
|
+
matches_storage_class,
|
447
|
+
noncurrent_time_before,
|
448
|
+
num_newer_versions
|
326
449
|
Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Condition.new(
|
327
450
|
age: age,
|
328
451
|
created_before: created_before,
|
452
|
+
custom_time_before: custom_time_before,
|
453
|
+
days_since_custom_time: days_since_custom_time,
|
454
|
+
days_since_noncurrent_time: days_since_noncurrent_time,
|
329
455
|
is_live: is_live,
|
330
456
|
matches_storage_class: Array(matches_storage_class),
|
457
|
+
noncurrent_time_before: noncurrent_time_before,
|
331
458
|
num_newer_versions: num_newer_versions
|
332
459
|
)
|
333
460
|
end
|
@@ -337,12 +464,19 @@ module Google
|
|
337
464
|
def self.from_gapi gapi
|
338
465
|
action = gapi.action
|
339
466
|
c = gapi.condition
|
340
|
-
new
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
467
|
+
new(
|
468
|
+
action.type,
|
469
|
+
storage_class: action.storage_class,
|
470
|
+
age: c.age,
|
471
|
+
created_before: c.created_before,
|
472
|
+
custom_time_before: c.custom_time_before,
|
473
|
+
days_since_custom_time: c.days_since_custom_time,
|
474
|
+
days_since_noncurrent_time: c.days_since_noncurrent_time,
|
475
|
+
is_live: c.is_live,
|
476
|
+
matches_storage_class: c.matches_storage_class,
|
477
|
+
noncurrent_time_before: c.noncurrent_time_before,
|
478
|
+
num_newer_versions: c.num_newer_versions
|
479
|
+
)
|
346
480
|
end
|
347
481
|
|
348
482
|
# @private
|
@@ -355,6 +355,29 @@ module Google
|
|
355
355
|
update_gapi! :content_type
|
356
356
|
end
|
357
357
|
|
358
|
+
##
|
359
|
+
# A custom time specified by the user for the file, or `nil`.
|
360
|
+
#
|
361
|
+
# @return [DateTime, nil]
|
362
|
+
#
|
363
|
+
def custom_time
|
364
|
+
@gapi.custom_time
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# Updates the custom time specified by the user for the file. Once set,
|
369
|
+
# custom_time can't be unset, and it can only be changed to a time in the
|
370
|
+
# future. If custom_time must be unset, you must either perform a rewrite
|
371
|
+
# operation, or upload the data again and create a new file.
|
372
|
+
#
|
373
|
+
# @param [DateTime] custom_time A custom time specified by the user
|
374
|
+
# for the file.
|
375
|
+
#
|
376
|
+
def custom_time= custom_time
|
377
|
+
@gapi.custom_time = custom_time
|
378
|
+
update_gapi! :custom_time
|
379
|
+
end
|
380
|
+
|
358
381
|
##
|
359
382
|
# A hash of custom, user-provided web-safe keys and arbitrary string
|
360
383
|
# values that will returned with requests for the file as "x-goog-meta-"
|
@@ -389,7 +412,8 @@ module Google
|
|
389
412
|
# You can use this SHA256 hash to uniquely identify the AES-256
|
390
413
|
# encryption key required to decrypt this file.
|
391
414
|
#
|
392
|
-
# @return [String]
|
415
|
+
# @return [String, nil] The encoded SHA256 hash, or `nil` if there is
|
416
|
+
# no customer-supplied encryption key for this file.
|
393
417
|
#
|
394
418
|
def encryption_key_sha256
|
395
419
|
return nil unless @gapi.customer_encryption
|
@@ -746,8 +770,9 @@ module Google
|
|
746
770
|
# Updates the file with changes made in the given block in a single
|
747
771
|
# PATCH request. The following attributes may be set: {#cache_control=},
|
748
772
|
# {#content_disposition=}, {#content_encoding=}, {#content_language=},
|
749
|
-
# {#content_type=}, and {#metadata=}. The {#metadata} hash
|
750
|
-
# the block is completely mutable and will be included in the
|
773
|
+
# {#content_type=}, {#custom_time=} and {#metadata=}. The {#metadata} hash
|
774
|
+
# accessible in the block is completely mutable and will be included in the
|
775
|
+
# request.
|
751
776
|
#
|
752
777
|
# @yield [file] a block yielding a delegate object for updating the file
|
753
778
|
#
|
@@ -766,6 +791,7 @@ module Google
|
|
766
791
|
# f.content_encoding = "deflate"
|
767
792
|
# f.content_language = "de"
|
768
793
|
# f.content_type = "application/json"
|
794
|
+
# f.custom_time = DateTime.new 2025, 12, 31
|
769
795
|
# f.metadata["player"] = "Bob"
|
770
796
|
# f.metadata["score"] = "10"
|
771
797
|
# end
|
@@ -1204,7 +1230,7 @@ module Google
|
|
1204
1230
|
# cipher.encrypt
|
1205
1231
|
# new_key = cipher.random_key
|
1206
1232
|
#
|
1207
|
-
# file = bucket.file "path/to/my-file.ext"
|
1233
|
+
# file = bucket.file "path/to/my-file.ext", encryption_key: old_key
|
1208
1234
|
# file.rewrite "new-destination-bucket",
|
1209
1235
|
# "path/to/destination/file.ext",
|
1210
1236
|
# encryption_key: old_key,
|
@@ -1225,7 +1251,7 @@ module Google
|
|
1225
1251
|
# # Old customer-supplied key was stored securely for later use.
|
1226
1252
|
# old_key = "y\x03\"\x0E\xB6\xD3\x9B\x0E\xAB*\x19\xFAv\xDEY\xBEI..."
|
1227
1253
|
#
|
1228
|
-
# file = bucket.file "path/to/my-file.ext"
|
1254
|
+
# file = bucket.file "path/to/my-file.ext", encryption_key: old_key
|
1229
1255
|
# file.rewrite "new-destination-bucket",
|
1230
1256
|
# "path/to/destination/file.ext",
|
1231
1257
|
# encryption_key: old_key,
|
@@ -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] }
|
@@ -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
|
##
|
@@ -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
|
@@ -292,12 +293,12 @@ module Google
|
|
292
293
|
def insert_file bucket_name, source, path = nil, acl: nil,
|
293
294
|
cache_control: nil, content_disposition: nil,
|
294
295
|
content_encoding: nil, content_language: nil,
|
295
|
-
content_type: nil, crc32c: nil, md5: nil, metadata: nil,
|
296
|
+
content_type: nil, custom_time: nil, crc32c: nil, md5: nil, metadata: nil,
|
296
297
|
storage_class: nil, key: nil, kms_key: nil,
|
297
298
|
temporary_hold: nil, event_based_hold: nil,
|
298
299
|
user_project: nil
|
299
300
|
params =
|
300
|
-
{ cache_control: cache_control, content_type: content_type,
|
301
|
+
{ cache_control: cache_control, content_type: content_type, custom_time: custom_time,
|
301
302
|
content_disposition: content_disposition, md5_hash: md5,
|
302
303
|
content_encoding: content_encoding, crc32c: crc32c,
|
303
304
|
content_language: content_language, metadata: metadata,
|
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.30.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-01-13 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
|
@@ -298,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
298
312
|
- !ruby/object:Gem::Version
|
299
313
|
version: '0'
|
300
314
|
requirements: []
|
301
|
-
rubygems_version: 3.1.
|
315
|
+
rubygems_version: 3.1.4
|
302
316
|
signing_key:
|
303
317
|
specification_version: 4
|
304
318
|
summary: API Client library for Google Cloud Storage
|