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    pub fn delete_bucket(&self) -> crate::builder::storage_control::DeleteBucket {
34        self.storage.delete_bucket()
35    }
36
37    /// Returns metadata for the specified bucket.
38    pub fn get_bucket(&self) -> crate::builder::storage_control::GetBucket {
39        self.storage.get_bucket()
40    }
41
42    /// Creates a new bucket.
43    pub fn create_bucket(&self) -> crate::builder::storage_control::CreateBucket {
44        self.storage.create_bucket()
45    }
46
47    /// Retrieves a list of buckets for a given project.
48    pub fn list_buckets(&self) -> crate::builder::storage_control::ListBuckets {
49        self.storage.list_buckets()
50    }
51
52    /// Locks retention policy on a bucket.
53    pub fn lock_bucket_retention_policy(
54        &self,
55    ) -> crate::builder::storage_control::LockBucketRetentionPolicy {
56        self.storage.lock_bucket_retention_policy()
57    }
58
59    /// Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.
60    pub fn update_bucket(&self) -> crate::builder::storage_control::UpdateBucket {
61        self.storage.update_bucket()
62    }
63
64    /// Concatenates a list of existing objects into a new object in the same
65    /// bucket.
66    pub fn compose_object(&self) -> crate::builder::storage_control::ComposeObject {
67        self.storage.compose_object()
68    }
69
70    /// Deletes an object and its metadata. Deletions are permanent if versioning
71    /// is not enabled for the bucket, or if the generation parameter is used, or
72    /// if [soft delete](https://cloud.google.com/storage/docs/soft-delete) is not
73    /// enabled for the bucket.
74    /// When this API is used to delete an object from a bucket that has soft
75    /// delete policy enabled, the object becomes soft deleted, and the
76    /// `softDeleteTime` and `hardDeleteTime` properties are set on the object.
77    /// This API cannot be used to permanently delete soft-deleted objects.
78    /// Soft-deleted objects are permanently deleted according to their
79    /// `hardDeleteTime`.
80    ///
81    /// You can use the [`RestoreObject`][google.storage.v2.Storage.RestoreObject]
82    /// API to restore soft-deleted objects until the soft delete retention period
83    /// has passed.
84    ///
85    /// **IAM Permissions**:
86    ///
87    /// Requires `storage.objects.delete`
88    /// [IAM permission](https://cloud.google.com/iam/docs/overview#permissions) on
89    /// the bucket.
90    ///
91    /// [google.storage.v2.Storage.RestoreObject]: crate::client::StorageControl::restore_object
92    pub fn delete_object(&self) -> crate::builder::storage_control::DeleteObject {
93        self.storage.delete_object()
94    }
95
96    /// Restores a soft-deleted object.
97    pub fn restore_object(&self) -> crate::builder::storage_control::RestoreObject {
98        self.storage.restore_object()
99    }
100
101    /// Retrieves object metadata.
102    ///
103    /// **IAM Permissions**:
104    ///
105    /// Requires `storage.objects.get`
106    /// [IAM permission](https://cloud.google.com/iam/docs/overview#permissions) on
107    /// the bucket. To return object ACLs, the authenticated user must also have
108    /// the `storage.objects.getIamPolicy` permission.
109    pub fn get_object(&self) -> crate::builder::storage_control::GetObject {
110        self.storage.get_object()
111    }
112
113    /// Updates an object's metadata.
114    /// Equivalent to JSON API's storage.objects.patch.
115    pub fn update_object(&self) -> crate::builder::storage_control::UpdateObject {
116        self.storage.update_object()
117    }
118
119    /// Retrieves a list of objects matching the criteria.
120    ///
121    /// **IAM Permissions**:
122    ///
123    /// The authenticated user requires `storage.objects.list`
124    /// [IAM permission](https://cloud.google.com/iam/docs/overview#permissions)
125    /// to use this method. To return object ACLs, the authenticated user must also
126    /// have the `storage.objects.getIamPolicy` permission.
127    pub fn list_objects(&self) -> crate::builder::storage_control::ListObjects {
128        self.storage.list_objects()
129    }
130
131    /// Rewrites a source object to a destination object. Optionally overrides
132    /// metadata.
133    pub fn rewrite_object(&self) -> crate::builder::storage_control::RewriteObject {
134        self.storage.rewrite_object()
135    }
136
137    /// Moves the source object to the destination object in the same bucket.
138    pub fn move_object(&self) -> crate::builder::storage_control::MoveObject {
139        self.storage.move_object()
140    }
141
142    /// Creates a new folder. This operation is only applicable to a hierarchical
143    /// namespace enabled bucket.
144    pub fn create_folder(&self) -> crate::builder::storage_control::CreateFolder {
145        self.control.create_folder()
146    }
147
148    /// Permanently deletes an empty folder. This operation is only applicable to a
149    /// hierarchical namespace enabled bucket.
150    pub fn delete_folder(&self) -> crate::builder::storage_control::DeleteFolder {
151        self.control.delete_folder()
152    }
153
154    /// Returns metadata for the specified folder. This operation is only
155    /// applicable to a hierarchical namespace enabled bucket.
156    pub fn get_folder(&self) -> crate::builder::storage_control::GetFolder {
157        self.control.get_folder()
158    }
159
160    /// Retrieves a list of folders. This operation is only applicable to a
161    /// hierarchical namespace enabled bucket.
162    pub fn list_folders(&self) -> crate::builder::storage_control::ListFolders {
163        self.control.list_folders()
164    }
165
166    /// Renames a source folder to a destination folder. This operation is only
167    /// applicable to a hierarchical namespace enabled bucket. During a rename, the
168    /// source and destination folders are locked until the long running operation
169    /// completes.
170    ///
171    /// # Long running operations
172    ///
173    /// This method is used to start, and/or poll a [long-running Operation].
174    /// The [Working with long-running operations] chapter in the [user guide]
175    /// covers these operations in detail.
176    ///
177    /// [long-running operation]: https://google.aip.dev/151
178    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
179    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
180    pub fn rename_folder(&self) -> crate::builder::storage_control::RenameFolder {
181        self.control.rename_folder()
182    }
183
184    /// Returns the storage layout configuration for a given bucket.
185    pub fn get_storage_layout(&self) -> crate::builder::storage_control::GetStorageLayout {
186        self.control.get_storage_layout()
187    }
188
189    /// Creates a new managed folder.
190    pub fn create_managed_folder(&self) -> crate::builder::storage_control::CreateManagedFolder {
191        self.control.create_managed_folder()
192    }
193
194    /// Permanently deletes an empty managed folder.
195    pub fn delete_managed_folder(&self) -> crate::builder::storage_control::DeleteManagedFolder {
196        self.control.delete_managed_folder()
197    }
198
199    /// Returns metadata for the specified managed folder.
200    pub fn get_managed_folder(&self) -> crate::builder::storage_control::GetManagedFolder {
201        self.control.get_managed_folder()
202    }
203
204    /// Retrieves a list of managed folders for a given bucket.
205    pub fn list_managed_folders(&self) -> crate::builder::storage_control::ListManagedFolders {
206        self.control.list_managed_folders()
207    }
208
209    /// Creates an Anywhere Cache instance.
210    ///
211    /// # Long running operations
212    ///
213    /// This method is used to start, and/or poll a [long-running Operation].
214    /// The [Working with long-running operations] chapter in the [user guide]
215    /// covers these operations in detail.
216    ///
217    /// [long-running operation]: https://google.aip.dev/151
218    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
219    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
220    pub fn create_anywhere_cache(&self) -> crate::builder::storage_control::CreateAnywhereCache {
221        self.control.create_anywhere_cache()
222    }
223
224    /// Updates an Anywhere Cache instance. Mutable fields include `ttl` and
225    /// `admission_policy`.
226    ///
227    /// # Long running operations
228    ///
229    /// This method is used to start, and/or poll a [long-running Operation].
230    /// The [Working with long-running operations] chapter in the [user guide]
231    /// covers these operations in detail.
232    ///
233    /// [long-running operation]: https://google.aip.dev/151
234    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
235    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
236    pub fn update_anywhere_cache(&self) -> crate::builder::storage_control::UpdateAnywhereCache {
237        self.control.update_anywhere_cache()
238    }
239
240    /// Disables an Anywhere Cache instance. A disabled instance is read-only. The
241    /// disablement could be revoked by calling ResumeAnywhereCache. The cache
242    /// instance will be deleted automatically if it remains in the disabled state
243    /// for at least one hour.
244    pub fn disable_anywhere_cache(&self) -> crate::builder::storage_control::DisableAnywhereCache {
245        self.control.disable_anywhere_cache()
246    }
247
248    /// Pauses an Anywhere Cache instance.
249    pub fn pause_anywhere_cache(&self) -> crate::builder::storage_control::PauseAnywhereCache {
250        self.control.pause_anywhere_cache()
251    }
252
253    /// Resumes a disabled or paused Anywhere Cache instance.
254    pub fn resume_anywhere_cache(&self) -> crate::builder::storage_control::ResumeAnywhereCache {
255        self.control.resume_anywhere_cache()
256    }
257
258    /// Gets an Anywhere Cache instance.
259    pub fn get_anywhere_cache(&self) -> crate::builder::storage_control::GetAnywhereCache {
260        self.control.get_anywhere_cache()
261    }
262
263    /// Lists Anywhere Cache instances for a given bucket.
264    pub fn list_anywhere_caches(&self) -> crate::builder::storage_control::ListAnywhereCaches {
265        self.control.list_anywhere_caches()
266    }
267
268    /// Returns the Project scoped singleton IntelligenceConfig resource.
269    pub fn get_project_intelligence_config(
270        &self,
271    ) -> crate::builder::storage_control::GetProjectIntelligenceConfig {
272        self.control.get_project_intelligence_config()
273    }
274
275    /// Updates the Project scoped singleton IntelligenceConfig resource.
276    pub fn update_project_intelligence_config(
277        &self,
278    ) -> crate::builder::storage_control::UpdateProjectIntelligenceConfig {
279        self.control.update_project_intelligence_config()
280    }
281
282    /// Returns the Folder scoped singleton IntelligenceConfig resource.
283    pub fn get_folder_intelligence_config(
284        &self,
285    ) -> crate::builder::storage_control::GetFolderIntelligenceConfig {
286        self.control.get_folder_intelligence_config()
287    }
288
289    /// Updates the Folder scoped singleton IntelligenceConfig resource.
290    pub fn update_folder_intelligence_config(
291        &self,
292    ) -> crate::builder::storage_control::UpdateFolderIntelligenceConfig {
293        self.control.update_folder_intelligence_config()
294    }
295
296    /// Returns the Organization scoped singleton IntelligenceConfig resource.
297    pub fn get_organization_intelligence_config(
298        &self,
299    ) -> crate::builder::storage_control::GetOrganizationIntelligenceConfig {
300        self.control.get_organization_intelligence_config()
301    }
302
303    /// Updates the Organization scoped singleton IntelligenceConfig resource.
304    pub fn update_organization_intelligence_config(
305        &self,
306    ) -> crate::builder::storage_control::UpdateOrganizationIntelligenceConfig {
307        self.control.update_organization_intelligence_config()
308    }
309
310    /// Gets the IAM policy for a specified bucket.
311    /// The `resource` field in the request should be
312    /// `projects/_/buckets/{bucket}` for a bucket, or
313    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
314    /// for a managed folder.
315    pub fn get_iam_policy(&self) -> crate::builder::storage_control::GetIamPolicy {
316        self.control.get_iam_policy()
317    }
318
319    /// Updates an IAM policy for the specified bucket.
320    /// The `resource` field in the request should be
321    /// `projects/_/buckets/{bucket}` for a bucket, or
322    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
323    /// for a managed folder.
324    pub fn set_iam_policy(&self) -> crate::builder::storage_control::SetIamPolicy {
325        self.control.set_iam_policy()
326    }
327
328    /// Tests a set of permissions on the given bucket, object, or managed folder
329    /// to see which, if any, are held by the caller.
330    /// The `resource` field in the request should be
331    /// `projects/_/buckets/{bucket}` for a bucket,
332    /// `projects/_/buckets/{bucket}/objects/{object}` for an object, or
333    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
334    /// for a managed folder.
335    pub fn test_iam_permissions(&self) -> crate::builder::storage_control::TestIamPermissions {
336        self.control.test_iam_permissions()
337    }
338
339    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
340    ///
341    /// [google.longrunning.Operations]: longrunning::client::Operations
342    pub fn get_operation(&self) -> crate::builder::storage_control::GetOperation {
343        self.control.get_operation()
344    }
345
346    /// Creates a new client from the provided stub.
347    ///
348    /// The most common case for calling this function is in tests mocking the
349    /// client's behavior.
350    pub fn from_stub<T>(stub: T) -> Self
351    where
352        T: crate::stub::StorageControl + 'static,
353    {
354        let stub = std::sync::Arc::new(stub);
355        Self {
356            storage: crate::generated::gapic::client::StorageControl::from_stub(stub.clone()),
357            control: crate::generated::gapic_control::client::StorageControl::from_stub(stub),
358        }
359    }
360
361    pub(crate) async fn new(
362        config: gaxi::options::ClientConfig,
363    ) -> gax::client_builder::Result<Self> {
364        let storage = crate::generated::gapic::client::StorageControl::new(config.clone()).await?;
365        let control = crate::generated::gapic_control::client::StorageControl::new(config).await?;
366        Ok(Self { storage, control })
367    }
368}