google_cloud_storage/control/generated/
client.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17use crate::control::client::*;
18
19impl StorageControl {
20    /// Returns a builder for [StorageControl].
21    ///
22    /// ```no_run
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_storage::client::StorageControl;
25    /// let client = StorageControl::builder().build().await?;
26    /// # gax::client_builder::Result::<()>::Ok(()) });
27    /// ```
28    pub fn builder() -> ClientBuilder {
29        gax::client_builder::internal::new_builder(client_builder::Factory)
30    }
31
32    /// Permanently deletes an empty bucket.
33    /// The request fails if there are any live or
34    /// noncurrent objects in the bucket, but the request succeeds if the
35    /// bucket only contains soft-deleted objects or incomplete uploads, such
36    /// as ongoing XML API multipart uploads. Does not permanently delete
37    /// soft-deleted objects.
38    ///
39    /// When this API is used to delete a bucket containing an object that has a
40    /// soft delete policy
41    /// enabled, the object becomes soft deleted, and the
42    /// `softDeleteTime` and `hardDeleteTime` properties are set on the
43    /// object.
44    ///
45    /// Objects and multipart uploads that were in the bucket at the time of
46    /// deletion are also retained for the specified retention duration. When
47    /// a soft-deleted bucket reaches the end of its retention duration, it
48    /// is permanently deleted. The `hardDeleteTime` of the bucket always
49    /// equals
50    /// or exceeds the expiration time of the last soft-deleted object in the
51    /// bucket.
52    ///
53    /// **IAM Permissions**:
54    ///
55    /// Requires `storage.buckets.delete` IAM permission on the bucket.
56    pub fn delete_bucket(&self) -> crate::builder::storage_control::DeleteBucket {
57        self.storage.delete_bucket()
58    }
59
60    /// Returns metadata for the specified bucket.
61    ///
62    /// **IAM Permissions**:
63    ///
64    /// Requires `storage.buckets.get`
65    /// IAM permission on
66    /// the bucket. Additionally, to return specific bucket metadata, the
67    /// authenticated user must have the following permissions:
68    ///
69    /// - To return the IAM policies: `storage.buckets.getIamPolicy`
70    /// - To return the bucket IP filtering rules: `storage.buckets.getIpFilter`
71    pub fn get_bucket(&self) -> crate::builder::storage_control::GetBucket {
72        self.storage.get_bucket()
73    }
74
75    /// Creates a new bucket.
76    ///
77    /// **IAM Permissions**:
78    ///
79    /// Requires `storage.buckets.create` IAM permission on the bucket.
80    /// Additionally, to enable specific bucket features, the authenticated user
81    /// must have the following permissions:
82    ///
83    /// - To enable object retention using the `enableObjectRetention` query
84    ///   parameter: `storage.buckets.enableObjectRetention`
85    /// - To set the bucket IP filtering rules: `storage.buckets.setIpFilter`
86    pub fn create_bucket(&self) -> crate::builder::storage_control::CreateBucket {
87        self.storage.create_bucket()
88    }
89
90    /// Retrieves a list of buckets for a given project, ordered
91    /// lexicographically by name.
92    ///
93    /// **IAM Permissions**:
94    ///
95    /// Requires `storage.buckets.list` IAM permission on the bucket.
96    /// Additionally, to enable specific bucket features, the authenticated
97    /// user must have the following permissions:
98    ///
99    /// - To list the IAM policies: `storage.buckets.getIamPolicy`
100    /// - To list the bucket IP filtering rules: `storage.buckets.getIpFilter`
101    pub fn list_buckets(&self) -> crate::builder::storage_control::ListBuckets {
102        self.storage.list_buckets()
103    }
104
105    /// Permanently locks the retention
106    /// policy that is
107    /// currently applied to the specified bucket.
108    ///
109    /// Caution: Locking a bucket is an
110    /// irreversible action. Once you lock a bucket:
111    ///
112    /// - You cannot remove the retention policy from the bucket.
113    /// - You cannot decrease the retention period for the policy.
114    ///
115    /// Once locked, you must delete the entire bucket in order to remove the
116    /// bucket's retention policy. However, before you can delete the bucket, you
117    /// must delete all the objects in the bucket, which is only
118    /// possible if all the objects have reached the retention period set by the
119    /// retention policy.
120    ///
121    /// **IAM Permissions**:
122    ///
123    /// Requires `storage.buckets.update` IAM permission on the bucket.
124    pub fn lock_bucket_retention_policy(
125        &self,
126    ) -> crate::builder::storage_control::LockBucketRetentionPolicy {
127        self.storage.lock_bucket_retention_policy()
128    }
129
130    /// Updates a bucket. Changes to the bucket are readable immediately after
131    /// writing, but configuration changes might take time to propagate. This
132    /// method supports `patch` semantics.
133    ///
134    /// **IAM Permissions**:
135    ///
136    /// Requires `storage.buckets.update` IAM permission on the bucket.
137    /// Additionally, to enable specific bucket features, the authenticated user
138    /// must have the following permissions:
139    ///
140    /// - To set bucket IP filtering rules: `storage.buckets.setIpFilter`
141    /// - To update public access prevention policies or access control lists
142    ///   (ACLs): `storage.buckets.setIamPolicy`
143    pub fn update_bucket(&self) -> crate::builder::storage_control::UpdateBucket {
144        self.storage.update_bucket()
145    }
146
147    /// Concatenates a list of existing objects into a new object in the same
148    /// bucket. The existing source objects are unaffected by this operation.
149    ///
150    /// **IAM Permissions**:
151    ///
152    /// Requires the `storage.objects.create` and `storage.objects.get` IAM
153    /// permissions to use this method. If the new composite object
154    /// overwrites an existing object, the authenticated user must also have
155    /// the `storage.objects.delete` permission. If the request body includes
156    /// the retention property, the authenticated user must also have the
157    /// `storage.objects.setRetention` IAM permission.
158    pub fn compose_object(&self) -> crate::builder::storage_control::ComposeObject {
159        self.storage.compose_object()
160    }
161
162    /// Deletes an object and its metadata. Deletions are permanent if versioning
163    /// is not enabled for the bucket, or if the generation parameter is used, or
164    /// if soft delete is not
165    /// enabled for the bucket.
166    /// When this API is used to delete an object from a bucket that has soft
167    /// delete policy enabled, the object becomes soft deleted, and the
168    /// `softDeleteTime` and `hardDeleteTime` properties are set on the object.
169    /// This API cannot be used to permanently delete soft-deleted objects.
170    /// Soft-deleted objects are permanently deleted according to their
171    /// `hardDeleteTime`.
172    ///
173    /// You can use the [`RestoreObject`][google.storage.v2.Storage.RestoreObject]
174    /// API to restore soft-deleted objects until the soft delete retention period
175    /// has passed.
176    ///
177    /// **IAM Permissions**:
178    ///
179    /// Requires `storage.objects.delete` IAM permission on the bucket.
180    ///
181    /// [google.storage.v2.Storage.RestoreObject]: crate::client::StorageControl::restore_object
182    pub fn delete_object(&self) -> crate::builder::storage_control::DeleteObject {
183        self.storage.delete_object()
184    }
185
186    /// Restores a
187    /// soft-deleted object.
188    /// When a soft-deleted object is restored, a new copy of that object is
189    /// created in the same bucket and inherits the same metadata as the
190    /// soft-deleted object. The inherited metadata is the metadata that existed
191    /// when the original object became soft deleted, with the following
192    /// exceptions:
193    ///
194    /// - The `createTime` of the new object is set to the time at which the
195    ///   soft-deleted object was restored.
196    /// - The `softDeleteTime` and `hardDeleteTime` values are cleared.
197    /// - A new generation is assigned and the metageneration is reset to 1.
198    /// - If the soft-deleted object was in a bucket that had Autoclass enabled,
199    ///   the new object is
200    ///   restored to Standard storage.
201    /// - The restored object inherits the bucket's default object ACL, unless
202    ///   `copySourceAcl` is `true`.
203    ///
204    /// If a live object using the same name already exists in the bucket and
205    /// becomes overwritten, the live object becomes a noncurrent object if Object
206    /// Versioning is enabled on the bucket. If Object Versioning is not enabled,
207    /// the live object becomes soft deleted.
208    ///
209    /// **IAM Permissions**:
210    ///
211    /// Requires the following IAM permissions to use this method:
212    ///
213    /// - `storage.objects.restore`
214    /// - `storage.objects.create`
215    /// - `storage.objects.delete` (only required if overwriting an existing
216    ///   object)
217    /// - `storage.objects.getIamPolicy` (only required if `projection` is `full`
218    ///   and the relevant bucket
219    ///   has uniform bucket-level access disabled)
220    /// - `storage.objects.setIamPolicy` (only required if `copySourceAcl` is
221    ///   `true` and the relevant
222    ///   bucket has uniform bucket-level access disabled)
223    pub fn restore_object(&self) -> crate::builder::storage_control::RestoreObject {
224        self.storage.restore_object()
225    }
226
227    /// Retrieves object metadata.
228    ///
229    /// **IAM Permissions**:
230    ///
231    /// Requires `storage.objects.get` IAM permission on the bucket.
232    /// To return object ACLs, the authenticated user must also have
233    /// the `storage.objects.getIamPolicy` permission.
234    pub fn get_object(&self) -> crate::builder::storage_control::GetObject {
235        self.storage.get_object()
236    }
237
238    /// Updates an object's metadata.
239    /// Equivalent to JSON API's `storage.objects.patch` method.
240    ///
241    /// **IAM Permissions**:
242    ///
243    /// Requires `storage.objects.update` IAM permission on the bucket.
244    pub fn update_object(&self) -> crate::builder::storage_control::UpdateObject {
245        self.storage.update_object()
246    }
247
248    /// Retrieves a list of objects matching the criteria.
249    ///
250    /// **IAM Permissions**:
251    ///
252    /// The authenticated user requires `storage.objects.list`
253    /// IAM permission to use this method. To return object ACLs, the
254    /// authenticated user must also
255    /// have the `storage.objects.getIamPolicy` permission.
256    pub fn list_objects(&self) -> crate::builder::storage_control::ListObjects {
257        self.storage.list_objects()
258    }
259
260    /// Rewrites a source object to a destination object. Optionally overrides
261    /// metadata.
262    pub fn rewrite_object(&self) -> crate::builder::storage_control::RewriteObject {
263        self.storage.rewrite_object()
264    }
265
266    /// Moves the source object to the destination object in the same bucket.
267    /// This operation moves a source object to a destination object in the
268    /// same bucket by renaming the object. The move itself is an atomic
269    /// transaction, ensuring all steps either complete successfully or no
270    /// changes are made.
271    ///
272    /// **IAM Permissions**:
273    ///
274    /// Requires the following IAM permissions to use this method:
275    ///
276    /// - `storage.objects.move`
277    /// - `storage.objects.create`
278    /// - `storage.objects.delete` (only required if overwriting an existing
279    ///   object)
280    pub fn move_object(&self) -> crate::builder::storage_control::MoveObject {
281        self.storage.move_object()
282    }
283
284    /// Creates a new folder. This operation is only applicable to a hierarchical
285    /// namespace enabled bucket.
286    pub fn create_folder(&self) -> crate::builder::storage_control::CreateFolder {
287        self.control.create_folder()
288    }
289
290    /// Permanently deletes an empty folder. This operation is only applicable to a
291    /// hierarchical namespace enabled bucket.
292    pub fn delete_folder(&self) -> crate::builder::storage_control::DeleteFolder {
293        self.control.delete_folder()
294    }
295
296    /// Returns metadata for the specified folder. This operation is only
297    /// applicable to a hierarchical namespace enabled bucket.
298    pub fn get_folder(&self) -> crate::builder::storage_control::GetFolder {
299        self.control.get_folder()
300    }
301
302    /// Retrieves a list of folders. This operation is only applicable to a
303    /// hierarchical namespace enabled bucket.
304    pub fn list_folders(&self) -> crate::builder::storage_control::ListFolders {
305        self.control.list_folders()
306    }
307
308    /// Renames a source folder to a destination folder. This operation is only
309    /// applicable to a hierarchical namespace enabled bucket. During a rename, the
310    /// source and destination folders are locked until the long running operation
311    /// completes.
312    ///
313    /// # Long running operations
314    ///
315    /// This method is used to start, and/or poll a [long-running Operation].
316    /// The [Working with long-running operations] chapter in the [user guide]
317    /// covers these operations in detail.
318    ///
319    /// [long-running operation]: https://google.aip.dev/151
320    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
321    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
322    pub fn rename_folder(&self) -> crate::builder::storage_control::RenameFolder {
323        self.control.rename_folder()
324    }
325
326    /// Returns the storage layout configuration for a given bucket.
327    pub fn get_storage_layout(&self) -> crate::builder::storage_control::GetStorageLayout {
328        self.control.get_storage_layout()
329    }
330
331    /// Creates a new managed folder.
332    pub fn create_managed_folder(&self) -> crate::builder::storage_control::CreateManagedFolder {
333        self.control.create_managed_folder()
334    }
335
336    /// Permanently deletes an empty managed folder.
337    pub fn delete_managed_folder(&self) -> crate::builder::storage_control::DeleteManagedFolder {
338        self.control.delete_managed_folder()
339    }
340
341    /// Returns metadata for the specified managed folder.
342    pub fn get_managed_folder(&self) -> crate::builder::storage_control::GetManagedFolder {
343        self.control.get_managed_folder()
344    }
345
346    /// Retrieves a list of managed folders for a given bucket.
347    pub fn list_managed_folders(&self) -> crate::builder::storage_control::ListManagedFolders {
348        self.control.list_managed_folders()
349    }
350
351    /// Creates an Anywhere Cache instance.
352    ///
353    /// # Long running operations
354    ///
355    /// This method is used to start, and/or poll a [long-running Operation].
356    /// The [Working with long-running operations] chapter in the [user guide]
357    /// covers these operations in detail.
358    ///
359    /// [long-running operation]: https://google.aip.dev/151
360    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
361    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
362    pub fn create_anywhere_cache(&self) -> crate::builder::storage_control::CreateAnywhereCache {
363        self.control.create_anywhere_cache()
364    }
365
366    /// Updates an Anywhere Cache instance. Mutable fields include `ttl` and
367    /// `admission_policy`.
368    ///
369    /// # Long running operations
370    ///
371    /// This method is used to start, and/or poll a [long-running Operation].
372    /// The [Working with long-running operations] chapter in the [user guide]
373    /// covers these operations in detail.
374    ///
375    /// [long-running operation]: https://google.aip.dev/151
376    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
377    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
378    pub fn update_anywhere_cache(&self) -> crate::builder::storage_control::UpdateAnywhereCache {
379        self.control.update_anywhere_cache()
380    }
381
382    /// Disables an Anywhere Cache instance. A disabled instance is read-only. The
383    /// disablement could be revoked by calling ResumeAnywhereCache. The cache
384    /// instance will be deleted automatically if it remains in the disabled state
385    /// for at least one hour.
386    pub fn disable_anywhere_cache(&self) -> crate::builder::storage_control::DisableAnywhereCache {
387        self.control.disable_anywhere_cache()
388    }
389
390    /// Pauses an Anywhere Cache instance.
391    pub fn pause_anywhere_cache(&self) -> crate::builder::storage_control::PauseAnywhereCache {
392        self.control.pause_anywhere_cache()
393    }
394
395    /// Resumes a disabled or paused Anywhere Cache instance.
396    pub fn resume_anywhere_cache(&self) -> crate::builder::storage_control::ResumeAnywhereCache {
397        self.control.resume_anywhere_cache()
398    }
399
400    /// Gets an Anywhere Cache instance.
401    pub fn get_anywhere_cache(&self) -> crate::builder::storage_control::GetAnywhereCache {
402        self.control.get_anywhere_cache()
403    }
404
405    /// Lists Anywhere Cache instances for a given bucket.
406    pub fn list_anywhere_caches(&self) -> crate::builder::storage_control::ListAnywhereCaches {
407        self.control.list_anywhere_caches()
408    }
409
410    /// Returns the Project scoped singleton IntelligenceConfig resource.
411    pub fn get_project_intelligence_config(
412        &self,
413    ) -> crate::builder::storage_control::GetProjectIntelligenceConfig {
414        self.control.get_project_intelligence_config()
415    }
416
417    /// Updates the Project scoped singleton IntelligenceConfig resource.
418    pub fn update_project_intelligence_config(
419        &self,
420    ) -> crate::builder::storage_control::UpdateProjectIntelligenceConfig {
421        self.control.update_project_intelligence_config()
422    }
423
424    /// Returns the Folder scoped singleton IntelligenceConfig resource.
425    pub fn get_folder_intelligence_config(
426        &self,
427    ) -> crate::builder::storage_control::GetFolderIntelligenceConfig {
428        self.control.get_folder_intelligence_config()
429    }
430
431    /// Updates the Folder scoped singleton IntelligenceConfig resource.
432    pub fn update_folder_intelligence_config(
433        &self,
434    ) -> crate::builder::storage_control::UpdateFolderIntelligenceConfig {
435        self.control.update_folder_intelligence_config()
436    }
437
438    /// Returns the Organization scoped singleton IntelligenceConfig resource.
439    pub fn get_organization_intelligence_config(
440        &self,
441    ) -> crate::builder::storage_control::GetOrganizationIntelligenceConfig {
442        self.control.get_organization_intelligence_config()
443    }
444
445    /// Updates the Organization scoped singleton IntelligenceConfig resource.
446    pub fn update_organization_intelligence_config(
447        &self,
448    ) -> crate::builder::storage_control::UpdateOrganizationIntelligenceConfig {
449        self.control.update_organization_intelligence_config()
450    }
451
452    /// Gets the IAM policy for a specified bucket.
453    /// The `resource` field in the request should be
454    /// `projects/_/buckets/{bucket}` for a bucket, or
455    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
456    /// for a managed folder.
457    pub fn get_iam_policy(&self) -> crate::builder::storage_control::GetIamPolicy {
458        self.control.get_iam_policy()
459    }
460
461    /// Updates an IAM policy for the specified bucket.
462    /// The `resource` field in the request should be
463    /// `projects/_/buckets/{bucket}` for a bucket, or
464    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
465    /// for a managed folder.
466    pub fn set_iam_policy(&self) -> crate::builder::storage_control::SetIamPolicy {
467        self.control.set_iam_policy()
468    }
469
470    /// Tests a set of permissions on the given bucket, object, or managed folder
471    /// to see which, if any, are held by the caller.
472    /// The `resource` field in the request should be
473    /// `projects/_/buckets/{bucket}` for a bucket,
474    /// `projects/_/buckets/{bucket}/objects/{object}` for an object, or
475    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
476    /// for a managed folder.
477    pub fn test_iam_permissions(&self) -> crate::builder::storage_control::TestIamPermissions {
478        self.control.test_iam_permissions()
479    }
480
481    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
482    ///
483    /// [google.longrunning.Operations]: longrunning::client::Operations
484    pub fn get_operation(&self) -> crate::builder::storage_control::GetOperation {
485        self.control.get_operation()
486    }
487
488    /// Creates a new client from the provided stub.
489    ///
490    /// The most common case for calling this function is in tests mocking the
491    /// client's behavior.
492    pub fn from_stub<T>(stub: T) -> Self
493    where
494        T: crate::stub::StorageControl + 'static,
495    {
496        let stub = std::sync::Arc::new(stub);
497        Self {
498            storage: crate::generated::gapic::client::StorageControl::from_stub(stub.clone()),
499            control: crate::generated::gapic_control::client::StorageControl::from_stub(stub),
500        }
501    }
502
503    pub(crate) async fn new(
504        config: gaxi::options::ClientConfig,
505    ) -> gax::client_builder::Result<Self> {
506        let storage = crate::generated::gapic::client::StorageControl::new(config.clone()).await?;
507        let control = crate::generated::gapic_control::client::StorageControl::new(config).await?;
508        Ok(Self { storage, control })
509    }
510}