google-cloud-storage 1.11.0

Google Cloud Client Libraries for Rust - Storage
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

use crate::control::client::*;

impl StorageControl {
    /// Returns a builder for [StorageControl].
    ///
    /// ```
    /// # async fn sample() -> anyhow::Result<()> {
    /// # use google_cloud_storage::client::StorageControl;
    /// let client = StorageControl::builder().build().await?;
    /// # Ok(()) }
    /// ```
    pub fn builder() -> ClientBuilder {
        crate::new_client_builder(client_builder::Factory)
    }

    /// Permanently deletes an empty bucket.
    /// The request fails if there are any live or
    /// noncurrent objects in the bucket, but the request succeeds if the
    /// bucket only contains soft-deleted objects or incomplete uploads, such
    /// as ongoing XML API multipart uploads. Does not permanently delete
    /// soft-deleted objects.
    ///
    /// When this API is used to delete a bucket containing an object that has a
    /// soft delete policy
    /// enabled, the object becomes soft deleted, and the
    /// `softDeleteTime` and `hardDeleteTime` properties are set on the
    /// object.
    ///
    /// Objects and multipart uploads that were in the bucket at the time of
    /// deletion are also retained for the specified retention duration. When
    /// a soft-deleted bucket reaches the end of its retention duration, it
    /// is permanently deleted. The `hardDeleteTime` of the bucket always
    /// equals
    /// or exceeds the expiration time of the last soft-deleted object in the
    /// bucket.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.buckets.delete` IAM permission on the bucket.
    pub fn delete_bucket(&self) -> crate::builder::storage_control::DeleteBucket {
        self.storage.delete_bucket()
    }

    /// Returns metadata for the specified bucket.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.buckets.get`
    /// IAM permission on
    /// the bucket. Additionally, to return specific bucket metadata, the
    /// authenticated user must have the following permissions:
    ///
    /// - To return the IAM policies: `storage.buckets.getIamPolicy`
    /// - To return the bucket IP filtering rules: `storage.buckets.getIpFilter`
    pub fn get_bucket(&self) -> crate::builder::storage_control::GetBucket {
        self.storage.get_bucket()
    }

    /// Creates a new bucket.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.buckets.create` IAM permission on the bucket.
    /// Additionally, to enable specific bucket features, the authenticated user
    /// must have the following permissions:
    ///
    /// - To enable object retention using the `enableObjectRetention` query
    ///   parameter: `storage.buckets.enableObjectRetention`
    /// - To set the bucket IP filtering rules: `storage.buckets.setIpFilter`
    pub fn create_bucket(&self) -> crate::builder::storage_control::CreateBucket {
        self.storage.create_bucket()
    }

    /// Retrieves a list of buckets for a given project, ordered
    /// lexicographically by name.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.buckets.list` IAM permission on the bucket.
    /// Additionally, to enable specific bucket features, the authenticated
    /// user must have the following permissions:
    ///
    /// - To list the IAM policies: `storage.buckets.getIamPolicy`
    /// - To list the bucket IP filtering rules: `storage.buckets.getIpFilter`
    pub fn list_buckets(&self) -> crate::builder::storage_control::ListBuckets {
        self.storage.list_buckets()
    }

    /// Permanently locks the retention
    /// policy that is
    /// currently applied to the specified bucket.
    ///
    /// Caution: Locking a bucket is an
    /// irreversible action. Once you lock a bucket:
    ///
    /// - You cannot remove the retention policy from the bucket.
    /// - You cannot decrease the retention period for the policy.
    ///
    /// Once locked, you must delete the entire bucket in order to remove the
    /// bucket's retention policy. However, before you can delete the bucket, you
    /// must delete all the objects in the bucket, which is only
    /// possible if all the objects have reached the retention period set by the
    /// retention policy.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.buckets.update` IAM permission on the bucket.
    pub fn lock_bucket_retention_policy(
        &self,
    ) -> crate::builder::storage_control::LockBucketRetentionPolicy {
        self.storage.lock_bucket_retention_policy()
    }

    /// Updates a bucket. Changes to the bucket are readable immediately after
    /// writing, but configuration changes might take time to propagate. This
    /// method supports `patch` semantics.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.buckets.update` IAM permission on the bucket.
    /// Additionally, to enable specific bucket features, the authenticated user
    /// must have the following permissions:
    ///
    /// - To set bucket IP filtering rules: `storage.buckets.setIpFilter`
    /// - To update public access prevention policies or access control lists
    ///   (ACLs): `storage.buckets.setIamPolicy`
    pub fn update_bucket(&self) -> crate::builder::storage_control::UpdateBucket {
        self.storage.update_bucket()
    }

    /// Concatenates a list of existing objects into a new object in the same
    /// bucket. The existing source objects are unaffected by this operation.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires the `storage.objects.create` and `storage.objects.get` IAM
    /// permissions to use this method. If the new composite object
    /// overwrites an existing object, the authenticated user must also have
    /// the `storage.objects.delete` permission. If the request body includes
    /// the retention property, the authenticated user must also have the
    /// `storage.objects.setRetention` IAM permission.
    pub fn compose_object(&self) -> crate::builder::storage_control::ComposeObject {
        self.storage.compose_object()
    }

    /// Deletes an object and its metadata. Deletions are permanent if versioning
    /// is not enabled for the bucket, or if the generation parameter is used, or
    /// if soft delete is not
    /// enabled for the bucket.
    /// When this API is used to delete an object from a bucket that has soft
    /// delete policy enabled, the object becomes soft deleted, and the
    /// `softDeleteTime` and `hardDeleteTime` properties are set on the object.
    /// This API cannot be used to permanently delete soft-deleted objects.
    /// Soft-deleted objects are permanently deleted according to their
    /// `hardDeleteTime`.
    ///
    /// You can use the [`RestoreObject`][google.storage.v2.Storage.RestoreObject]
    /// API to restore soft-deleted objects until the soft delete retention period
    /// has passed.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.objects.delete` IAM permission on the bucket.
    ///
    /// [google.storage.v2.Storage.RestoreObject]: crate::client::StorageControl::restore_object
    pub fn delete_object(&self) -> crate::builder::storage_control::DeleteObject {
        self.storage.delete_object()
    }

    /// Restores a
    /// soft-deleted object.
    /// When a soft-deleted object is restored, a new copy of that object is
    /// created in the same bucket and inherits the same metadata as the
    /// soft-deleted object. The inherited metadata is the metadata that existed
    /// when the original object became soft deleted, with the following
    /// exceptions:
    ///
    /// - The `createTime` of the new object is set to the time at which the
    ///   soft-deleted object was restored.
    /// - The `softDeleteTime` and `hardDeleteTime` values are cleared.
    /// - A new generation is assigned and the metageneration is reset to 1.
    /// - If the soft-deleted object was in a bucket that had Autoclass enabled,
    ///   the new object is
    ///   restored to Standard storage.
    /// - The restored object inherits the bucket's default object ACL, unless
    ///   `copySourceAcl` is `true`.
    ///
    /// If a live object using the same name already exists in the bucket and
    /// becomes overwritten, the live object becomes a noncurrent object if Object
    /// Versioning is enabled on the bucket. If Object Versioning is not enabled,
    /// the live object becomes soft deleted.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires the following IAM permissions to use this method:
    ///
    /// - `storage.objects.restore`
    /// - `storage.objects.create`
    /// - `storage.objects.delete` (only required if overwriting an existing
    ///   object)
    /// - `storage.objects.getIamPolicy` (only required if `projection` is `full`
    ///   and the relevant bucket
    ///   has uniform bucket-level access disabled)
    /// - `storage.objects.setIamPolicy` (only required if `copySourceAcl` is
    ///   `true` and the relevant
    ///   bucket has uniform bucket-level access disabled)
    pub fn restore_object(&self) -> crate::builder::storage_control::RestoreObject {
        self.storage.restore_object()
    }

    /// Retrieves object metadata.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.objects.get` IAM permission on the bucket.
    /// To return object ACLs, the authenticated user must also have
    /// the `storage.objects.getIamPolicy` permission.
    pub fn get_object(&self) -> crate::builder::storage_control::GetObject {
        self.storage.get_object()
    }

    /// Updates an object's metadata.
    /// Equivalent to JSON API's `storage.objects.patch` method.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.objects.update` IAM permission on the bucket.
    pub fn update_object(&self) -> crate::builder::storage_control::UpdateObject {
        self.storage.update_object()
    }

    /// Retrieves a list of objects matching the criteria.
    ///
    /// **IAM Permissions**:
    ///
    /// The authenticated user requires `storage.objects.list`
    /// IAM permission to use this method. To return object ACLs, the
    /// authenticated user must also
    /// have the `storage.objects.getIamPolicy` permission.
    pub fn list_objects(&self) -> crate::builder::storage_control::ListObjects {
        self.storage.list_objects()
    }

    /// Rewrites a source object to a destination object. Optionally overrides
    /// metadata.
    pub fn rewrite_object(&self) -> crate::builder::storage_control::RewriteObject {
        self.storage.rewrite_object()
    }

    /// Moves the source object to the destination object in the same bucket.
    /// This operation moves a source object to a destination object in the
    /// same bucket by renaming the object. The move itself is an atomic
    /// transaction, ensuring all steps either complete successfully or no
    /// changes are made.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires the following IAM permissions to use this method:
    ///
    /// - `storage.objects.move`
    /// - `storage.objects.create`
    /// - `storage.objects.delete` (only required if overwriting an existing
    ///   object)
    pub fn move_object(&self) -> crate::builder::storage_control::MoveObject {
        self.storage.move_object()
    }

    /// Creates a new folder. This operation is only applicable to a hierarchical
    /// namespace enabled bucket.
    pub fn create_folder(&self) -> crate::builder::storage_control::CreateFolder {
        self.control.create_folder()
    }

    /// Permanently deletes an empty folder. This operation is only applicable to a
    /// hierarchical namespace enabled bucket.
    pub fn delete_folder(&self) -> crate::builder::storage_control::DeleteFolder {
        self.control.delete_folder()
    }

    /// Returns metadata for the specified folder. This operation is only
    /// applicable to a hierarchical namespace enabled bucket.
    pub fn get_folder(&self) -> crate::builder::storage_control::GetFolder {
        self.control.get_folder()
    }

    /// Retrieves a list of folders. This operation is only applicable to a
    /// hierarchical namespace enabled bucket.
    pub fn list_folders(&self) -> crate::builder::storage_control::ListFolders {
        self.control.list_folders()
    }

    /// Renames a source folder to a destination folder. This operation is only
    /// applicable to a hierarchical namespace enabled bucket. During a rename, the
    /// source and destination folders are locked until the long running operation
    /// completes.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn rename_folder(&self) -> crate::builder::storage_control::RenameFolder {
        self.control.rename_folder()
    }

    /// Deletes a folder recursively. This operation is only applicable to a
    /// hierarchical namespace enabled bucket.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_folder_recursive(
        &self,
    ) -> crate::builder::storage_control::DeleteFolderRecursive {
        self.control.delete_folder_recursive()
    }

    /// Returns the storage layout configuration for a given bucket.
    pub fn get_storage_layout(&self) -> crate::builder::storage_control::GetStorageLayout {
        self.control.get_storage_layout()
    }

    /// Creates a new managed folder.
    pub fn create_managed_folder(&self) -> crate::builder::storage_control::CreateManagedFolder {
        self.control.create_managed_folder()
    }

    /// Permanently deletes an empty managed folder.
    pub fn delete_managed_folder(&self) -> crate::builder::storage_control::DeleteManagedFolder {
        self.control.delete_managed_folder()
    }

    /// Returns metadata for the specified managed folder.
    pub fn get_managed_folder(&self) -> crate::builder::storage_control::GetManagedFolder {
        self.control.get_managed_folder()
    }

    /// Retrieves a list of managed folders for a given bucket.
    pub fn list_managed_folders(&self) -> crate::builder::storage_control::ListManagedFolders {
        self.control.list_managed_folders()
    }

    /// Creates an Anywhere Cache instance.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_anywhere_cache(&self) -> crate::builder::storage_control::CreateAnywhereCache {
        self.control.create_anywhere_cache()
    }

    /// Updates an Anywhere Cache instance. Mutable fields include `ttl` and
    /// `admission_policy`.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_anywhere_cache(&self) -> crate::builder::storage_control::UpdateAnywhereCache {
        self.control.update_anywhere_cache()
    }

    /// Disables an Anywhere Cache instance. A disabled instance is read-only. The
    /// disablement could be revoked by calling ResumeAnywhereCache. The cache
    /// instance will be deleted automatically if it remains in the disabled state
    /// for at least one hour.
    pub fn disable_anywhere_cache(&self) -> crate::builder::storage_control::DisableAnywhereCache {
        self.control.disable_anywhere_cache()
    }

    /// Pauses an Anywhere Cache instance.
    pub fn pause_anywhere_cache(&self) -> crate::builder::storage_control::PauseAnywhereCache {
        self.control.pause_anywhere_cache()
    }

    /// Resumes a disabled or paused Anywhere Cache instance.
    pub fn resume_anywhere_cache(&self) -> crate::builder::storage_control::ResumeAnywhereCache {
        self.control.resume_anywhere_cache()
    }

    /// Gets an Anywhere Cache instance.
    pub fn get_anywhere_cache(&self) -> crate::builder::storage_control::GetAnywhereCache {
        self.control.get_anywhere_cache()
    }

    /// Lists Anywhere Cache instances for a given bucket.
    pub fn list_anywhere_caches(&self) -> crate::builder::storage_control::ListAnywhereCaches {
        self.control.list_anywhere_caches()
    }

    /// Returns the Project scoped singleton IntelligenceConfig resource.
    pub fn get_project_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::GetProjectIntelligenceConfig {
        self.control.get_project_intelligence_config()
    }

    /// Updates the Project scoped singleton IntelligenceConfig resource.
    pub fn update_project_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::UpdateProjectIntelligenceConfig {
        self.control.update_project_intelligence_config()
    }

    /// Returns the Folder scoped singleton IntelligenceConfig resource.
    pub fn get_folder_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::GetFolderIntelligenceConfig {
        self.control.get_folder_intelligence_config()
    }

    /// Updates the Folder scoped singleton IntelligenceConfig resource.
    pub fn update_folder_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::UpdateFolderIntelligenceConfig {
        self.control.update_folder_intelligence_config()
    }

    /// Returns the Organization scoped singleton IntelligenceConfig resource.
    pub fn get_organization_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::GetOrganizationIntelligenceConfig {
        self.control.get_organization_intelligence_config()
    }

    /// Updates the Organization scoped singleton IntelligenceConfig resource.
    pub fn update_organization_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::UpdateOrganizationIntelligenceConfig {
        self.control.update_organization_intelligence_config()
    }

    /// Gets the IAM policy for a specified bucket.
    /// The `resource` field in the request should be
    /// `projects/_/buckets/{bucket}` for a bucket, or
    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
    /// for a managed folder.
    pub fn get_iam_policy(&self) -> crate::builder::storage_control::GetIamPolicy {
        self.control.get_iam_policy()
    }

    /// Updates an IAM policy for the specified bucket.
    /// The `resource` field in the request should be
    /// `projects/_/buckets/{bucket}` for a bucket, or
    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
    /// for a managed folder.
    pub fn set_iam_policy(&self) -> crate::builder::storage_control::SetIamPolicy {
        self.control.set_iam_policy()
    }

    /// Tests a set of permissions on the given bucket, object, or managed folder
    /// to see which, if any, are held by the caller.
    /// The `resource` field in the request should be
    /// `projects/_/buckets/{bucket}` for a bucket,
    /// `projects/_/buckets/{bucket}/objects/{object}` for an object, or
    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
    /// for a managed folder.
    pub fn test_iam_permissions(&self) -> crate::builder::storage_control::TestIamPermissions {
        self.control.test_iam_permissions()
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn get_operation(&self) -> crate::builder::storage_control::GetOperation {
        self.control.get_operation()
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: crate::stub::StorageControl + 'static,
    {
        let stub = std::sync::Arc::new(stub);
        Self {
            storage: crate::generated::gapic::client::StorageControl::from_stub(stub.clone()),
            control: crate::generated::gapic_control::client::StorageControl::from_stub(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<Self> {
        let storage = crate::generated::gapic::client::StorageControl::new(config.clone()).await?;
        let control = crate::generated::gapic_control::client::StorageControl::new(config).await?;
        Ok(Self { storage, control })
    }
}