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