google-cloud-storage 1.45.0 → 1.56.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a00be88dfffe243057e1ffe70891fabb483caadc76a7a37e8b82dcdb5f95395
4
- data.tar.gz: 2190d664457e1419b26b95266d8911728a612647d404790b35f37586dfe59e02
3
+ metadata.gz: 37d818583b06d396a9b237a24187b677bb5261c31e3a139714ef4f8fd868e4ec
4
+ data.tar.gz: d8ed3812b144e20a747c79147fd26642a7f8d4c9a5e017e925144f9e33afa717
5
5
  SHA512:
6
- metadata.gz: e5b129dba88921e6aeec6476d60bb17ee603f0cb641194bbeb09531aff568c2290e17ab3f0f290d87976a0b0f35d4f10674dab8fea6deef70d424738a4ce767c
7
- data.tar.gz: 87e4411cda889bb7bdbf0ccddc2a343ae475614c5cab19d8461bcd646ac78016b6be35975255e14c1af1efcd3c5087c9b769b674260a82f936ef4c0456566a19
6
+ metadata.gz: 519fe7bc2cf869c804bbfac6ce300b300f99f065a594673d36cf344b3cacff1ff1fb4eec086903ddcbc4a4be108c66082f05d539ef9508570d43ec9c678893be
7
+ data.tar.gz: a82b8ddd47b64d71c5035491a87021912419213538a0b2105de3facf4a09aac927379b1c980e5612629426cc7e0ec5de3590480fcdc265fb1bdf172f28d1be05
data/CHANGELOG.md CHANGED
@@ -1,5 +1,84 @@
1
1
  # Release History
2
2
 
3
+ ### 1.56.0 (2025-04-21)
4
+
5
+ #### Features
6
+
7
+ * move_object within hns bucket ([#29391](https://github.com/googleapis/google-cloud-ruby/issues/29391))
8
+
9
+ ### 1.55.0 (2025-02-13)
10
+
11
+ #### Features
12
+
13
+ * Soft deleted Bucket Restore ([#28138](https://github.com/googleapis/google-cloud-ruby/issues/28138))
14
+ #### Documentation
15
+
16
+ * updating the encryption key GCS sample ([#28815](https://github.com/googleapis/google-cloud-ruby/issues/28815))
17
+
18
+ ### 1.54.0 (2024-12-11)
19
+
20
+ #### Features
21
+
22
+ * Updated required Ruby version to 3.0 or later ([#27599](https://github.com/googleapis/google-cloud-ruby/issues/27599))
23
+
24
+ ### 1.53.0 (2024-12-04)
25
+
26
+ #### Features
27
+
28
+ * add integration test for universe domain ([#27384](https://github.com/googleapis/google-cloud-ruby/issues/27384))
29
+ * fetch file and bucket details from url ([#27322](https://github.com/googleapis/google-cloud-ruby/issues/27322))
30
+
31
+ ### 1.52.0 (2024-05-31)
32
+
33
+ #### Features
34
+
35
+ * support for hierarchical namespace (folders) ([#25967](https://github.com/googleapis/google-cloud-ruby/issues/25967))
36
+
37
+ ### 1.51.0 (2024-04-25)
38
+
39
+ #### Features
40
+
41
+ * Respect custom endpoint for signed_url ([#25469](https://github.com/googleapis/google-cloud-ruby/issues/25469))
42
+
43
+ ### 1.50.0 (2024-04-19)
44
+
45
+ #### Features
46
+
47
+ * Add support for soft deletion ([#25340](https://github.com/googleapis/google-cloud-ruby/issues/25340))
48
+ #### Bug Fixes
49
+
50
+ * Set configured univer_domain and endpoint when initializing through Service ([#25665](https://github.com/googleapis/google-cloud-ruby/issues/25665))
51
+
52
+ ### 1.49.0 (2024-02-21)
53
+
54
+ #### Features
55
+
56
+ * Support of Managed Folders ([#24809](https://github.com/googleapis/google-cloud-ruby/issues/24809))
57
+
58
+ ### 1.48.1 (2024-01-26)
59
+
60
+ #### Bug Fixes
61
+
62
+ * Raise an error on mismatching universe domain ([#24486](https://github.com/googleapis/google-cloud-ruby/issues/24486))
63
+
64
+ ### 1.48.0 (2024-01-25)
65
+
66
+ #### Features
67
+
68
+ * Support for universe_domain ([#24449](https://github.com/googleapis/google-cloud-ruby/issues/24449))
69
+
70
+ ### 1.47.0 (2024-01-09)
71
+
72
+ #### Features
73
+
74
+ * support for object lock / retention ([#23732](https://github.com/googleapis/google-cloud-ruby/issues/23732))
75
+
76
+ ### 1.46.0 (2024-01-08)
77
+
78
+ #### Features
79
+
80
+ * support match_glob for Object.list
81
+
3
82
  ### 1.45.0 (2023-11-06)
4
83
 
5
84
  #### Features
@@ -182,7 +182,7 @@ module Google
182
182
  @origin = Array(origin)
183
183
  @methods = Array(methods)
184
184
  @headers = Array(headers)
185
- @max_age = (max_age || 1800)
185
+ @max_age = max_age || 1800
186
186
  end
187
187
 
188
188
  # @private
@@ -195,7 +195,7 @@ module Google
195
195
 
196
196
  # @private
197
197
  def self.from_gapi gapi
198
- new gapi.origin.dup, gapi.http_method.dup, \
198
+ new gapi.origin.dup, gapi.http_method.dup,
199
199
  headers: gapi.response_header.dup,
200
200
  max_age: gapi.max_age_seconds
201
201
  end
@@ -72,7 +72,8 @@ module Google
72
72
  return nil unless next?
73
73
  ensure_service!
74
74
  gapi = @service.list_buckets prefix: @prefix, token: @token,
75
- max: @max, user_project: @user_project
75
+ max: @max, user_project: @user_project,
76
+ soft_deleted: @soft_deleted
76
77
  Bucket::List.from_gapi gapi, @service, @prefix, @max,
77
78
  user_project: @user_project
78
79
  end
@@ -146,7 +147,7 @@ module Google
146
147
  # @private New Bucket::List from a Google API Client
147
148
  # Google::Apis::StorageV1::Buckets object.
148
149
  def self.from_gapi gapi_list, service, prefix = nil, max = nil,
149
- user_project: nil
150
+ user_project: nil, soft_deleted: nil
150
151
  buckets = new(Array(gapi_list.items).map do |gapi_object|
151
152
  Bucket.from_gapi gapi_object, service, user_project: user_project
152
153
  end)
@@ -155,6 +156,7 @@ module Google
155
156
  buckets.instance_variable_set :@prefix, prefix
156
157
  buckets.instance_variable_set :@max, max
157
158
  buckets.instance_variable_set :@user_project, user_project
159
+ buckets.instance_variable_set :@soft_deleted, soft_deleted
158
160
  buckets
159
161
  end
160
162
 
@@ -118,6 +118,15 @@ module Google
118
118
  @gapi.autoclass
119
119
  end
120
120
 
121
+ ##
122
+ # The object retention configuration of the bucket
123
+ #
124
+ # @return [Google::Apis::StorageV1::Bucket::ObjectRetention]
125
+ #
126
+ def object_retention
127
+ @gapi.object_retention
128
+ end
129
+
121
130
  ##
122
131
  # The name of the bucket.
123
132
  #
@@ -973,7 +982,7 @@ module Google
973
982
  #
974
983
  def uniform_bucket_level_access= new_uniform_bucket_level_access
975
984
  @gapi.iam_configuration ||= API::Bucket::IamConfiguration.new
976
- @gapi.iam_configuration.uniform_bucket_level_access ||= \
985
+ @gapi.iam_configuration.uniform_bucket_level_access ||=
977
986
  API::Bucket::IamConfiguration::UniformBucketLevelAccess.new
978
987
  @gapi.iam_configuration.uniform_bucket_level_access.enabled = new_uniform_bucket_level_access
979
988
  patch_gapi! :iam_configuration
@@ -1185,6 +1194,121 @@ module Google
1185
1194
  patch_gapi! :rpo
1186
1195
  end
1187
1196
 
1197
+ ##
1198
+ # The bucket's soft delete policy. If this policy is set, any deleted
1199
+ # objects will be soft-deleted according to the time specified in the
1200
+ # policy.
1201
+ # This value can be modified by calling {#soft_delete_policy=}.
1202
+ #
1203
+ # @return [Google::Apis::StorageV1::Bucket::SoftDeletePolicy] The default retention policy is for 7
1204
+ # days.
1205
+ #
1206
+ # @example
1207
+ # require "google/cloud/storage"
1208
+ #
1209
+ # storage = Google::Cloud::Storage.new
1210
+ #
1211
+ # bucket = storage.bucket "my-bucket"
1212
+ #
1213
+ # bucket.soft_delete_policy
1214
+ #
1215
+ def soft_delete_policy
1216
+ @gapi.soft_delete_policy
1217
+ end
1218
+
1219
+ ##
1220
+ # Sets the value for Soft Delete Policy in the bucket. This value can
1221
+ # be queried by calling {#soft_delete_policy}.
1222
+ #
1223
+ # @param [Google::Apis::StorageV1::Bucket::SoftDeletePolicy,
1224
+ # Hash(String => String)] new_soft_delete_policy The bucket's
1225
+ # new Soft Delete Policy.
1226
+ #
1227
+ # @example Set Soft Delete Policy to 10 days using SoftDeletePolicy class:
1228
+ # require "google/cloud/storage"
1229
+ # require "date"
1230
+ #
1231
+ # storage = Google::Cloud::Storage.new
1232
+ #
1233
+ # bucket = storage.bucket "my-bucket"
1234
+ #
1235
+ # soft_delete_policy = Google::Apis::StorageV1::Bucket::SoftDeletePolicy.new
1236
+ # soft_delete_policy.retention_duration_seconds = 10*24*60*60
1237
+ #
1238
+ # bucket.soft_delete_policy = soft_delete_policy
1239
+ #
1240
+ # @example Set Soft Delete Policy to 5 days using Hash:
1241
+ # require "google/cloud/storage"
1242
+ # require "date"
1243
+ #
1244
+ # storage = Google::Cloud::Storage.new
1245
+ #
1246
+ # bucket = storage.bucket "my-bucket"
1247
+ #
1248
+ # soft_delete_policy = { retention_duration_seconds: 432000 }
1249
+ # bucket.soft_delete_policy = soft_delete_policy
1250
+ #
1251
+ def soft_delete_policy= new_soft_delete_policy
1252
+ @gapi.soft_delete_policy = new_soft_delete_policy || {}
1253
+ patch_gapi! :soft_delete_policy
1254
+ end
1255
+
1256
+ ##
1257
+ # The bucket's hierarchical namespace (Folders) configuration.
1258
+ # This value can be modified by calling {#hierarchical_namespace=}.
1259
+ #
1260
+ # @return [Google::Apis::StorageV1::Bucket::HierarchicalNamespace]
1261
+ #
1262
+ # @example
1263
+ # require "google/cloud/storage"
1264
+ #
1265
+ # storage = Google::Cloud::Storage.new
1266
+ #
1267
+ # bucket = storage.bucket "my-bucket"
1268
+ #
1269
+ # bucket.hierarchical_namespace
1270
+ #
1271
+ def hierarchical_namespace
1272
+ @gapi.hierarchical_namespace
1273
+ end
1274
+
1275
+ ##
1276
+ # Sets the value of Hierarchical Namespace (Folders) for the bucket.
1277
+ # This can only be enabled at bucket create time. If this is enabled,
1278
+ # Uniform Bucket-Level Access must also be enabled.
1279
+ # This value can be queried by calling {#hierarchical_namespace}.
1280
+ #
1281
+ # @param [Google::Apis::StorageV1::Bucket::HierarchicalNamespace,
1282
+ # Hash(String => String)] new_hierarchical_namespace The
1283
+ # bucket's new Hierarchical Namespace Configuration.
1284
+ #
1285
+ # @example Enabled Hierarchical Namespace using HierarchicalNamespace class:
1286
+ # require "google/cloud/storage"
1287
+ #
1288
+ # storage = Google::Cloud::Storage.new
1289
+ #
1290
+ # bucket = storage.bucket "my-bucket"
1291
+ #
1292
+ # hierarchical_namespace = Google::Apis::StorageV1::Bucket::HierarchicalNamespace.new
1293
+ # hierarchical_namespace.enabled = true
1294
+ #
1295
+ # bucket.hierarchical_namespace = hierarchical_namespace
1296
+ #
1297
+ # @example Disable Hierarchical Namespace using Hash:
1298
+ # require "google/cloud/storage"
1299
+ #
1300
+ # storage = Google::Cloud::Storage.new
1301
+ #
1302
+ # bucket = storage.bucket "my-bucket"
1303
+ #
1304
+ # hierarchical_namespace = { enabled: false }
1305
+ # bucket.hierarchical_namespace = hierarchical_namespace
1306
+ #
1307
+ def hierarchical_namespace= new_hierarchical_namespace
1308
+ @gapi.hierarchical_namespace = new_hierarchical_namespace || {}
1309
+ patch_gapi! :hierarchical_namespace
1310
+ end
1311
+
1188
1312
  ##
1189
1313
  # Updates the bucket with changes made in the given block in a single
1190
1314
  # PATCH request. The following attributes may be set: {#cors},
@@ -1299,6 +1423,9 @@ module Google
1299
1423
  # `prefixes` are omitted.
1300
1424
  # @param [String] token A previously-returned page token representing
1301
1425
  # part of the larger set of results to view.
1426
+ # @param [String] match_glob A glob pattern used to filter results returned in items (e.g. `foo*bar`).
1427
+ # The string value must be UTF-8 encoded. See:
1428
+ # https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-object-glob
1302
1429
  # @param [Integer] max Maximum number of items plus prefixes to return.
1303
1430
  # As duplicate prefixes are omitted, fewer total results may be
1304
1431
  # returned than requested. The default value of this parameter is
@@ -1307,6 +1434,11 @@ module Google
1307
1434
  # as distinct results. The default is `false`. For more information,
1308
1435
  # see [Object Versioning
1309
1436
  # ](https://cloud.google.com/storage/docs/object-versioning).
1437
+ # @param [Boolean] include_folders_as_prefixes If `true`, will also include
1438
+ # folders and managed folders, besides objects, in the returned prefixes.
1439
+ # Only applicable if delimiter is set to '/'.
1440
+ # @param [Boolean] soft_deleted If true, only soft-deleted object
1441
+ # versions will be listed. The default is false.
1310
1442
  #
1311
1443
  # @return [Array<Google::Cloud::Storage::File>] (See
1312
1444
  # {Google::Cloud::Storage::File::List})
@@ -1334,14 +1466,22 @@ module Google
1334
1466
  # end
1335
1467
  #
1336
1468
  def files prefix: nil, delimiter: nil, token: nil, max: nil,
1337
- versions: nil
1469
+ versions: nil, match_glob: nil, include_folders_as_prefixes: nil,
1470
+ soft_deleted: nil
1338
1471
  ensure_service!
1339
1472
  gapi = service.list_files name, prefix: prefix, delimiter: delimiter,
1340
1473
  token: token, max: max,
1341
1474
  versions: versions,
1342
- user_project: user_project
1475
+ user_project: user_project,
1476
+ match_glob: match_glob,
1477
+ include_folders_as_prefixes: include_folders_as_prefixes,
1478
+ soft_deleted: soft_deleted
1343
1479
  File::List.from_gapi gapi, service, name, prefix, delimiter, max,
1344
- versions, user_project: user_project
1480
+ versions,
1481
+ user_project: user_project,
1482
+ match_glob: match_glob,
1483
+ include_folders_as_prefixes: include_folders_as_prefixes,
1484
+ soft_deleted: soft_deleted
1345
1485
  end
1346
1486
  alias find_files files
1347
1487
 
@@ -1377,6 +1517,8 @@ module Google
1377
1517
  # @param [String] encryption_key Optional. The customer-supplied,
1378
1518
  # AES-256 encryption key used to encrypt the file, if one was provided
1379
1519
  # to {#create_file}. (Not used if `skip_lookup` is also set.)
1520
+ # @param [Boolean] soft_deleted Optional. If true, only soft-deleted
1521
+ # object versions will be listed. The default is false.
1380
1522
  #
1381
1523
  # @return [Google::Cloud::Storage::File, nil] Returns nil if file does
1382
1524
  # not exist
@@ -1398,7 +1540,8 @@ module Google
1398
1540
  if_metageneration_match: nil,
1399
1541
  if_metageneration_not_match: nil,
1400
1542
  skip_lookup: nil,
1401
- encryption_key: nil
1543
+ encryption_key: nil,
1544
+ soft_deleted: nil
1402
1545
  ensure_service!
1403
1546
  if skip_lookup
1404
1547
  return File.new_lazy name, path, service,
@@ -1411,7 +1554,8 @@ module Google
1411
1554
  if_metageneration_match: if_metageneration_match,
1412
1555
  if_metageneration_not_match: if_metageneration_not_match,
1413
1556
  key: encryption_key,
1414
- user_project: user_project
1557
+ user_project: user_project,
1558
+ soft_deleted: soft_deleted
1415
1559
  File.from_gapi gapi, service, user_project: user_project
1416
1560
  rescue Google::Cloud::NotFoundError
1417
1561
  nil
@@ -1692,6 +1836,77 @@ module Google
1692
1836
  alias upload_file create_file
1693
1837
  alias new_file create_file
1694
1838
 
1839
+ ##
1840
+ # Restores a soft-deleted object.
1841
+ #
1842
+ # @param [String] file_path
1843
+ # Name of the file.
1844
+ # @param [Fixnum] generation
1845
+ # Selects a specific revision of this object.
1846
+ # @param [Boolean] copy_source_acl
1847
+ # If true, copies the source file's ACL; otherwise, uses the
1848
+ # bucket's default file ACL. The default is false.
1849
+ # @param [Fixnum] if_generation_match
1850
+ # Makes the operation conditional on whether the file's one live
1851
+ # generation matches the given value. Setting to 0 makes the
1852
+ # operation succeed only if there are no live versions of the file.
1853
+ # @param [Fixnum] if_generation_not_match
1854
+ # Makes the operation conditional on whether none of the file's live
1855
+ # generations match the given value. If no live file exists, the
1856
+ # precondition fails. Setting to 0 makes the operation succeed only
1857
+ # if there is a live version of the file.
1858
+ # @param [Fixnum] if_metageneration_match
1859
+ # Makes the operation conditional on whether the file's one live
1860
+ # metageneration matches the given value.
1861
+ # @param [Fixnum] if_metageneration_not_match
1862
+ # Makes the operation conditional on whether none of the object's
1863
+ # live metagenerations match the given value.
1864
+ # @param [String] projection
1865
+ # Set of properties to return. Defaults to full.
1866
+ # @param [String] user_project
1867
+ # The project to be billed for this request. Required for Requester
1868
+ # Pays buckets.
1869
+ # @param [String] fields
1870
+ # Selector specifying which fields to include in a partial response.
1871
+ #
1872
+ # @return [Google::Cloud::Storage::File]
1873
+ #
1874
+ # @example
1875
+ # require "google/cloud/storage"
1876
+ #
1877
+ # storage = Google::Cloud::Storage.new
1878
+ #
1879
+ # bucket = storage.bucket "my-bucket"
1880
+ #
1881
+ # bucket.restore_file "path/of/file", <generation-of-the-file>
1882
+ #
1883
+ def restore_file file_path,
1884
+ generation,
1885
+ copy_source_acl: nil,
1886
+ if_generation_match: nil,
1887
+ if_generation_not_match: nil,
1888
+ if_metageneration_match: nil,
1889
+ if_metageneration_not_match: nil,
1890
+ projection: nil,
1891
+ user_project: nil,
1892
+ fields: nil,
1893
+ options: {}
1894
+ ensure_service!
1895
+ gapi = service.restore_file name,
1896
+ file_path,
1897
+ generation,
1898
+ copy_source_acl: File::Acl.predefined_rule_for(copy_source_acl),
1899
+ if_generation_match: if_generation_match,
1900
+ if_generation_not_match: if_generation_not_match,
1901
+ if_metageneration_match: if_metageneration_match,
1902
+ if_metageneration_not_match: if_metageneration_not_match,
1903
+ projection: projection,
1904
+ user_project: user_project,
1905
+ fields: fields,
1906
+ options: options
1907
+ File.from_gapi gapi, service, user_project: user_project
1908
+ end
1909
+
1695
1910
  ##
1696
1911
  # Concatenates a list of existing files in the bucket into a new file in
1697
1912
  # the bucket. There is a limit (currently 32) to the number of files
@@ -2065,6 +2280,31 @@ module Google
2065
2280
  end
2066
2281
  end
2067
2282
 
2283
+ # Fetches generation of the bucket
2284
+ # @example
2285
+ # require "google/cloud/storage"
2286
+ # storage = Google::Cloud::Storage.new
2287
+ # bucket = storage.bucket "my-bucket"
2288
+ # generation= bucket.generation
2289
+ def generation
2290
+ @gapi.generation
2291
+ end
2292
+
2293
+ # Fetches soft_delete_time of a soft deleted bucket
2294
+ # @example
2295
+ # bucket.delete
2296
+ # bucket.soft_delete_time
2297
+ def soft_delete_time
2298
+ @gapi.soft_delete_time
2299
+ end
2300
+
2301
+ # Fetches hard_delete_time of a soft deleted bucket
2302
+ # @example
2303
+ # bucket.hard_delete_time
2304
+ def hard_delete_time
2305
+ @gapi.hard_delete_time
2306
+ end
2307
+
2068
2308
  ##
2069
2309
  # Generate a PostObject that includes the fields and URL to
2070
2310
  # upload objects via HTML forms.
@@ -2903,6 +3143,51 @@ module Google
2903
3143
  end
2904
3144
  alias refresh! reload!
2905
3145
 
3146
+ ##
3147
+ # Moves File from source to destination path within the same HNS-enabled bucket
3148
+ # This Operation is being performed at server side
3149
+ # @param [String] source_file The file name in existing bucket
3150
+ # @param [String] destination_file The new filename to be created on bucket
3151
+ # If the destination path includes non-existent parent folders, they will be created.
3152
+ # @example
3153
+ # require "google/cloud/storage"
3154
+ # storage = Google::Cloud::Storage.new
3155
+ # bucket = storage.bucket bucket_name, skip_lookup: true
3156
+ # bucket.move_file source_file_name, destination_file_name
3157
+ def move_file source_file,
3158
+ destination_file,
3159
+ if_generation_match: nil,
3160
+ if_generation_not_match: nil,
3161
+ if_metageneration_match: nil,
3162
+ if_metageneration_not_match: nil,
3163
+ if_source_generation_match: nil,
3164
+ if_source_generation_not_match: nil,
3165
+ if_source_metageneration_match: nil,
3166
+ if_source_metageneration_not_match: nil,
3167
+ user_project: nil,
3168
+ fields: nil,
3169
+ quota_user: nil,
3170
+ user_ip: nil,
3171
+ options: {}
3172
+ ensure_service!
3173
+ service.move_file name,
3174
+ source_file,
3175
+ destination_file,
3176
+ if_generation_match: if_generation_match,
3177
+ if_generation_not_match: if_generation_not_match,
3178
+ if_metageneration_match: if_metageneration_match,
3179
+ if_metageneration_not_match: if_metageneration_not_match,
3180
+ if_source_generation_match: if_source_generation_match,
3181
+ if_source_generation_not_match: if_source_generation_not_match,
3182
+ if_source_metageneration_match: if_source_metageneration_match,
3183
+ if_source_metageneration_not_match: if_source_metageneration_not_match,
3184
+ user_project: user_project,
3185
+ fields: fields,
3186
+ quota_user: quota_user,
3187
+ user_ip: user_ip,
3188
+ options: options
3189
+ end
3190
+
2906
3191
  ##
2907
3192
  # Determines whether the bucket exists in the Storage service.
2908
3193
  #
@@ -2972,9 +3257,9 @@ module Google
2972
3257
  attributes.flatten!
2973
3258
  return if attributes.empty?
2974
3259
  ensure_service!
2975
- patch_args = Hash[attributes.map do |attr|
3260
+ patch_args = attributes.to_h do |attr|
2976
3261
  [attr, @gapi.send(attr)]
2977
- end]
3262
+ end
2978
3263
  patch_gapi = API::Bucket.new(**patch_args)
2979
3264
  @gapi = service.patch_bucket name,
2980
3265
  patch_gapi,
@@ -2992,9 +3277,9 @@ module Google
2992
3277
  attributes.flatten!
2993
3278
  return if attributes.empty?
2994
3279
  ensure_service!
2995
- update_args = Hash[attributes.map do |attr|
3280
+ update_args = attributes.to_h do |attr|
2996
3281
  [attr, @gapi.send(attr)]
2997
- end]
3282
+ end
2998
3283
  update_gapi = API::Bucket.new(**update_args)
2999
3284
  @gapi = service.update_bucket name,
3000
3285
  update_gapi,
@@ -83,10 +83,12 @@ module Google
83
83
  token: @token,
84
84
  max: @max,
85
85
  versions: @versions,
86
- user_project: @user_project
86
+ user_project: @user_project,
87
+ match_glob: @match_glob
87
88
  File::List.from_gapi gapi, @service, @bucket, @prefix,
88
89
  @delimiter, @max, @versions,
89
- user_project: @user_project
90
+ user_project: @user_project,
91
+ match_glob: @match_glob
90
92
  end
91
93
 
92
94
  ##
@@ -163,7 +165,9 @@ module Google
163
165
  # Google::Apis::StorageV1::Objects object.
164
166
  def self.from_gapi gapi_list, service, bucket = nil, prefix = nil,
165
167
  delimiter = nil, max = nil, versions = nil,
166
- user_project: nil
168
+ user_project: nil, match_glob: nil,
169
+ include_folders_as_prefixes: nil,
170
+ soft_deleted: nil
167
171
  files = new(Array(gapi_list.items).map do |gapi_object|
168
172
  File.from_gapi gapi_object, service, user_project: user_project
169
173
  end)
@@ -176,6 +180,9 @@ module Google
176
180
  files.instance_variable_set :@max, max
177
181
  files.instance_variable_set :@versions, versions
178
182
  files.instance_variable_set :@user_project, user_project
183
+ files.instance_variable_set :@match_glob, match_glob
184
+ files.instance_variable_set :@include_folders_as_prefixes, include_folders_as_prefixes
185
+ files.instance_variable_set :@soft_deleted, soft_deleted
179
186
  files
180
187
  end
181
188
 
@@ -60,7 +60,8 @@ module Google
60
60
  ##
61
61
  # The external url to the file.
62
62
  def ext_url
63
- "#{GOOGLEAPIS_URL}#{ext_path}"
63
+ root_url = @service.service.root_url.chomp "/"
64
+ "#{root_url}#{ext_path}"
64
65
  end
65
66
 
66
67
  def apply_option_defaults options
@@ -91,7 +92,7 @@ module Google
91
92
 
92
93
  def error_msg attr_name
93
94
  "Service account credentials '#{attr_name}' is missing. To generate service account credentials " \
94
- "see https://cloud.google.com/iam/docs/service-accounts"
95
+ "see https://cloud.google.com/iam/docs/service-accounts"
95
96
  end
96
97
 
97
98
  def post_object options
@@ -144,8 +145,8 @@ module Google
144
145
 
145
146
  def generate_signed_url issuer, signed_string, expires, query
146
147
  url = "#{ext_url}?GoogleAccessId=#{url_escape issuer}" \
147
- "&Expires=#{expires}" \
148
- "&Signature=#{url_escape signed_string}"
148
+ "&Expires=#{expires}" \
149
+ "&Signature=#{url_escape signed_string}"
149
150
 
150
151
  query&.each do |name, value|
151
152
  url << "&#{url_escape name}=#{url_escape value}"
@@ -131,7 +131,7 @@ module Google
131
131
  # methods below are public visibility only for unit testing
132
132
  # rubocop:disable Style/StringLiterals
133
133
  def escape_characters str
134
- str.split("").map do |s|
134
+ str.chars.map do |s|
135
135
  if s.ascii_only?
136
136
  case s
137
137
  when "\\"
@@ -207,7 +207,7 @@ module Google
207
207
 
208
208
  def error_msg attr_name
209
209
  "Service account credentials '#{attr_name}' is missing. To generate service account credentials " \
210
- "see https://cloud.google.com/iam/docs/service-accounts"
210
+ "see https://cloud.google.com/iam/docs/service-accounts"
211
211
  end
212
212
 
213
213
  def service_account_signer signer
@@ -243,7 +243,7 @@ module Google
243
243
  headers_arr = canonical_headers.map do |k, v|
244
244
  [k.downcase, v.strip.gsub(/[^\S\t]+/, " ").gsub(/\t+/, " ")]
245
245
  end
246
- canonical_headers = Hash[headers_arr]
246
+ canonical_headers = headers_arr.to_h
247
247
  canonical_headers["host"] = host_name virtual_hosted_style, bucket_bound_hostname
248
248
 
249
249
  canonical_headers = canonical_headers.sort_by(&:first).to_h
@@ -295,13 +295,13 @@ module Google
295
295
  ##
296
296
  # The external path to the bucket, with trailing slash.
297
297
  def bucket_path path_style
298
- return "/#{@bucket_name}/" if path_style
298
+ "/#{@bucket_name}/" if path_style
299
299
  end
300
300
 
301
301
  ##
302
302
  # The external url to the file.
303
303
  def ext_url scheme, virtual_hosted_style, bucket_bound_hostname
304
- url = GOOGLEAPIS_URL.dup
304
+ url = @service.service.root_url.chomp "/"
305
305
  if virtual_hosted_style
306
306
  parts = url.split "//"
307
307
  parts[1] = "#{@bucket_name}.#{parts[1]}"