google-cloud-storage 1.44.0 → 1.54.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: 7829a0c2c9afddc17d897bd33e73af95e922a4767bfd6d6e8474eec0bac46194
4
- data.tar.gz: 41f4328eb840bb9f2373cd291e2271e95d6f066db1a0dd62dbb7354e9e9c8c0e
3
+ metadata.gz: 67fa1effce117003750f759eba79de92380616365652f2a19ba49b1986c75634
4
+ data.tar.gz: 9729e6dc51f15a9a5e2e0370771f980908f9d6284973503c9c4d4c1e561b8d84
5
5
  SHA512:
6
- metadata.gz: ec55a9d4632ee6f5d3637e6b4dc5d156ba45fc01da7b20d7f2e69a1fa4945d55d300385ee6aafba2244edcdf8fe0f36be1340adb28c074920cfad4eca667af21
7
- data.tar.gz: 2194c91da01d5719d35756e3a9e1aceb49bfd9e15fb0466ddd8a7c4fae64074e06be41ea14437d0ed8698c777ab7c81f5ea6d90d5932336603c7dd99c5907558
6
+ metadata.gz: ec9022c921c0714ebf7f47131c745c113bb0480a34a376ca10055ccdee024821a518d1a87f742486118d7fb3e570beaeef5746f12676d5790e6ae697439dabd9
7
+ data.tar.gz: d5e57fd75d565a8328cf79ce42374883e4da7f875c7fd9571e928f9648c05578bee5743d68465819f3e5d488469d277749aecebd44810198fd1a1ca0cac6f3c3
data/AUTHENTICATION.md CHANGED
@@ -112,15 +112,6 @@ those that produce
112
112
  post objects. For these methods, authentication using a service account JSON key file
113
113
  is required.
114
114
 
115
- [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
116
- [dev-console]: https://console.cloud.google.com/project
117
-
118
- [enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
119
-
120
- [create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
121
- [create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
122
- [reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
123
-
124
115
  ## Creating a Service Account
125
116
 
126
117
  Google Cloud requires a **Project ID** and **Service Account Credentials** to
@@ -130,31 +121,22 @@ connect to most services with google-cloud-storage.
130
121
  If you are not running this client on Google Compute Engine, you need a Google
131
122
  Developers service account.
132
123
 
133
- 1. Visit the [Google Developers Console][dev-console].
124
+ 1. Visit the [Google Cloud Console](https://console.cloud.google.com/project).
134
125
  1. Create a new project or click on an existing project.
135
- 1. Activate the slide-out navigation tray and select **API Manager**. From
126
+ 1. Activate the menu in the upper left and select **APIs & Services**. From
136
127
  here, you will enable the APIs that your application requires.
137
128
 
138
- ![Enable the APIs that your application requires][enable-apis]
139
-
140
129
  *Note: You may need to enable billing in order to use these services.*
141
130
 
142
131
  1. Select **Credentials** from the side navigation.
143
132
 
144
- You should see a screen like one of the following.
145
-
146
- ![Create a new service account][create-new-service-account]
147
-
148
- ![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
149
-
150
- Find the "Add credentials" drop down and select "Service account" to be
151
- guided through downloading a new JSON key file.
152
-
153
- If you want to re-use an existing service account, you can easily generate a
154
- new key file. Just select the account you wish to re-use, and click "Generate
155
- new JSON key":
133
+ Find the "Create credentials" drop down near the top of the page, and select
134
+ "Service account" to be guided through downloading a new JSON key file.
156
135
 
157
- ![Re-use an existing service account][reuse-service-account]
136
+ If you want to re-use an existing service account, you can easily generate
137
+ a new key file. Just select the account you wish to re-use click the pencil
138
+ tool on the right side to edit the service account, select the **Keys** tab,
139
+ and then select **Add Key**.
158
140
 
159
141
  The key file you download will be used by this library to authenticate API
160
142
  requests and should be stored in a secure location.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # Release History
2
2
 
3
+ ### 1.54.0 (2024-12-11)
4
+
5
+ #### Features
6
+
7
+ * Updated required Ruby version to 3.0 or later ([#27599](https://github.com/googleapis/google-cloud-ruby/issues/27599))
8
+
9
+ ### 1.53.0 (2024-12-04)
10
+
11
+ #### Features
12
+
13
+ * add integration test for universe domain ([#27384](https://github.com/googleapis/google-cloud-ruby/issues/27384))
14
+ * fetch file and bucket details from url ([#27322](https://github.com/googleapis/google-cloud-ruby/issues/27322))
15
+
16
+ ### 1.52.0 (2024-05-31)
17
+
18
+ #### Features
19
+
20
+ * support for hierarchical namespace (folders) ([#25967](https://github.com/googleapis/google-cloud-ruby/issues/25967))
21
+
22
+ ### 1.51.0 (2024-04-25)
23
+
24
+ #### Features
25
+
26
+ * Respect custom endpoint for signed_url ([#25469](https://github.com/googleapis/google-cloud-ruby/issues/25469))
27
+
28
+ ### 1.50.0 (2024-04-19)
29
+
30
+ #### Features
31
+
32
+ * Add support for soft deletion ([#25340](https://github.com/googleapis/google-cloud-ruby/issues/25340))
33
+ #### Bug Fixes
34
+
35
+ * Set configured univer_domain and endpoint when initializing through Service ([#25665](https://github.com/googleapis/google-cloud-ruby/issues/25665))
36
+
37
+ ### 1.49.0 (2024-02-21)
38
+
39
+ #### Features
40
+
41
+ * Support of Managed Folders ([#24809](https://github.com/googleapis/google-cloud-ruby/issues/24809))
42
+
43
+ ### 1.48.1 (2024-01-26)
44
+
45
+ #### Bug Fixes
46
+
47
+ * Raise an error on mismatching universe domain ([#24486](https://github.com/googleapis/google-cloud-ruby/issues/24486))
48
+
49
+ ### 1.48.0 (2024-01-25)
50
+
51
+ #### Features
52
+
53
+ * Support for universe_domain ([#24449](https://github.com/googleapis/google-cloud-ruby/issues/24449))
54
+
55
+ ### 1.47.0 (2024-01-09)
56
+
57
+ #### Features
58
+
59
+ * support for object lock / retention ([#23732](https://github.com/googleapis/google-cloud-ruby/issues/23732))
60
+
61
+ ### 1.46.0 (2024-01-08)
62
+
63
+ #### Features
64
+
65
+ * support match_glob for Object.list
66
+
67
+ ### 1.45.0 (2023-11-06)
68
+
69
+ #### Features
70
+
71
+ * added autoclass v2.1 features ([#23483](https://github.com/googleapis/google-cloud-ruby/issues/23483))
72
+
3
73
  ### 1.44.0 (2022-11-02)
4
74
 
5
75
  #### 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
@@ -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
  #
@@ -434,6 +443,24 @@ module Google
434
443
  @gapi.autoclass&.toggle_time
435
444
  end
436
445
 
446
+ ##
447
+ # Terminal Storage class of the autoclass
448
+ #
449
+ # @return [String]
450
+ #
451
+ def autoclass_terminal_storage_class
452
+ @gapi.autoclass&.terminal_storage_class
453
+ end
454
+
455
+ ##
456
+ # Update time at which the autoclass terminal storage class was last modified
457
+ #
458
+ # @return [DateTime]
459
+ #
460
+ def autoclass_terminal_storage_class_update_time
461
+ @gapi.autoclass&.terminal_storage_class_update_time
462
+ end
463
+
437
464
  ##
438
465
  # Updates bucket's autoclass configuration. This defines the default class for objects in the
439
466
  # bucket and down/up-grades the storage class of objects based on the access patterns.
@@ -442,9 +469,6 @@ module Google
442
469
  # For more information, see [Storage
443
470
  # Classes](https://cloud.google.com/storage/docs/using-autoclass).
444
471
  #
445
- # Note: Only patch requests that disable autoclass are currently supported.
446
- # To enable autoclass, you must set it at bucket creation time.
447
- #
448
472
  # @param [Boolean] toggle for autoclass configuration of the bucket.
449
473
  #
450
474
  def autoclass_enabled= toggle
@@ -453,6 +477,25 @@ module Google
453
477
  patch_gapi! :autoclass
454
478
  end
455
479
 
480
+ ##
481
+ # Update method to update all attributes of autoclass of a bucket
482
+ # It accepts params as a Hash of attributes in the following format:
483
+ #
484
+ # { enabled: true, terminal_storage_class: "ARCHIVE" }
485
+ #
486
+ # terminal_storage_class field is optional. It defaults to `NEARLINE`.
487
+ # Valid terminal_storage_class values are `NEARLINE` and `ARCHIVE`.
488
+ #
489
+ # @param [Hash(String => String)] autoclass_attributes
490
+ #
491
+ def update_autoclass autoclass_attributes
492
+ @gapi.autoclass ||= API::Bucket::Autoclass.new
493
+ autoclass_attributes.each do |k, v|
494
+ @gapi.autoclass.send "#{k}=", v
495
+ end
496
+ patch_gapi! :autoclass
497
+ end
498
+
456
499
  ##
457
500
  # Whether [Object
458
501
  # Versioning](https://cloud.google.com/storage/docs/object-versioning)
@@ -1151,6 +1194,121 @@ module Google
1151
1194
  patch_gapi! :rpo
1152
1195
  end
1153
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
+
1154
1312
  ##
1155
1313
  # Updates the bucket with changes made in the given block in a single
1156
1314
  # PATCH request. The following attributes may be set: {#cors},
@@ -1265,6 +1423,9 @@ module Google
1265
1423
  # `prefixes` are omitted.
1266
1424
  # @param [String] token A previously-returned page token representing
1267
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
1268
1429
  # @param [Integer] max Maximum number of items plus prefixes to return.
1269
1430
  # As duplicate prefixes are omitted, fewer total results may be
1270
1431
  # returned than requested. The default value of this parameter is
@@ -1273,6 +1434,11 @@ module Google
1273
1434
  # as distinct results. The default is `false`. For more information,
1274
1435
  # see [Object Versioning
1275
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.
1276
1442
  #
1277
1443
  # @return [Array<Google::Cloud::Storage::File>] (See
1278
1444
  # {Google::Cloud::Storage::File::List})
@@ -1300,14 +1466,22 @@ module Google
1300
1466
  # end
1301
1467
  #
1302
1468
  def files prefix: nil, delimiter: nil, token: nil, max: nil,
1303
- versions: nil
1469
+ versions: nil, match_glob: nil, include_folders_as_prefixes: nil,
1470
+ soft_deleted: nil
1304
1471
  ensure_service!
1305
1472
  gapi = service.list_files name, prefix: prefix, delimiter: delimiter,
1306
1473
  token: token, max: max,
1307
1474
  versions: versions,
1308
- 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
1309
1479
  File::List.from_gapi gapi, service, name, prefix, delimiter, max,
1310
- 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
1311
1485
  end
1312
1486
  alias find_files files
1313
1487
 
@@ -1343,6 +1517,8 @@ module Google
1343
1517
  # @param [String] encryption_key Optional. The customer-supplied,
1344
1518
  # AES-256 encryption key used to encrypt the file, if one was provided
1345
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.
1346
1522
  #
1347
1523
  # @return [Google::Cloud::Storage::File, nil] Returns nil if file does
1348
1524
  # not exist
@@ -1364,7 +1540,8 @@ module Google
1364
1540
  if_metageneration_match: nil,
1365
1541
  if_metageneration_not_match: nil,
1366
1542
  skip_lookup: nil,
1367
- encryption_key: nil
1543
+ encryption_key: nil,
1544
+ soft_deleted: nil
1368
1545
  ensure_service!
1369
1546
  if skip_lookup
1370
1547
  return File.new_lazy name, path, service,
@@ -1377,7 +1554,8 @@ module Google
1377
1554
  if_metageneration_match: if_metageneration_match,
1378
1555
  if_metageneration_not_match: if_metageneration_not_match,
1379
1556
  key: encryption_key,
1380
- user_project: user_project
1557
+ user_project: user_project,
1558
+ soft_deleted: soft_deleted
1381
1559
  File.from_gapi gapi, service, user_project: user_project
1382
1560
  rescue Google::Cloud::NotFoundError
1383
1561
  nil
@@ -1658,6 +1836,77 @@ module Google
1658
1836
  alias upload_file create_file
1659
1837
  alias new_file create_file
1660
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
+
1661
1910
  ##
1662
1911
  # Concatenates a list of existing files in the bucket into a new file in
1663
1912
  # the bucket. There is a limit (currently 32) to the number of files
@@ -2938,9 +3187,9 @@ module Google
2938
3187
  attributes.flatten!
2939
3188
  return if attributes.empty?
2940
3189
  ensure_service!
2941
- patch_args = Hash[attributes.map do |attr|
3190
+ patch_args = attributes.to_h do |attr|
2942
3191
  [attr, @gapi.send(attr)]
2943
- end]
3192
+ end
2944
3193
  patch_gapi = API::Bucket.new(**patch_args)
2945
3194
  @gapi = service.patch_bucket name,
2946
3195
  patch_gapi,
@@ -2958,9 +3207,9 @@ module Google
2958
3207
  attributes.flatten!
2959
3208
  return if attributes.empty?
2960
3209
  ensure_service!
2961
- update_args = Hash[attributes.map do |attr|
3210
+ update_args = attributes.to_h do |attr|
2962
3211
  [attr, @gapi.send(attr)]
2963
- end]
3212
+ end
2964
3213
  update_gapi = API::Bucket.new(**update_args)
2965
3214
  @gapi = service.update_bucket name,
2966
3215
  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]}"