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 /// ```
23 /// # async fn sample() -> anyhow::Result<()> {
24 /// # use google_cloud_storage::client::StorageControl;
25 /// let client = StorageControl::builder().build().await?;
26 /// # Ok(()) }
27 /// ```
28 pub fn builder() -> ClientBuilder {
29 crate::new_client_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 /// Deletes a folder recursively. This operation is only applicable to a
327 /// hierarchical namespace enabled bucket.
328 ///
329 /// # Long running operations
330 ///
331 /// This method is used to start, and/or poll a [long-running Operation].
332 /// The [Working with long-running operations] chapter in the [user guide]
333 /// covers these operations in detail.
334 ///
335 /// [long-running operation]: https://google.aip.dev/151
336 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
337 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
338 pub fn delete_folder_recursive(
339 &self,
340 ) -> crate::builder::storage_control::DeleteFolderRecursive {
341 self.control.delete_folder_recursive()
342 }
343
344 /// Returns the storage layout configuration for a given bucket.
345 pub fn get_storage_layout(&self) -> crate::builder::storage_control::GetStorageLayout {
346 self.control.get_storage_layout()
347 }
348
349 /// Creates a new managed folder.
350 pub fn create_managed_folder(&self) -> crate::builder::storage_control::CreateManagedFolder {
351 self.control.create_managed_folder()
352 }
353
354 /// Permanently deletes an empty managed folder.
355 pub fn delete_managed_folder(&self) -> crate::builder::storage_control::DeleteManagedFolder {
356 self.control.delete_managed_folder()
357 }
358
359 /// Returns metadata for the specified managed folder.
360 pub fn get_managed_folder(&self) -> crate::builder::storage_control::GetManagedFolder {
361 self.control.get_managed_folder()
362 }
363
364 /// Retrieves a list of managed folders for a given bucket.
365 pub fn list_managed_folders(&self) -> crate::builder::storage_control::ListManagedFolders {
366 self.control.list_managed_folders()
367 }
368
369 /// Creates an Anywhere Cache instance.
370 ///
371 /// # Long running operations
372 ///
373 /// This method is used to start, and/or poll a [long-running Operation].
374 /// The [Working with long-running operations] chapter in the [user guide]
375 /// covers these operations in detail.
376 ///
377 /// [long-running operation]: https://google.aip.dev/151
378 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
379 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
380 pub fn create_anywhere_cache(&self) -> crate::builder::storage_control::CreateAnywhereCache {
381 self.control.create_anywhere_cache()
382 }
383
384 /// Updates an Anywhere Cache instance. Mutable fields include `ttl` and
385 /// `admission_policy`.
386 ///
387 /// # Long running operations
388 ///
389 /// This method is used to start, and/or poll a [long-running Operation].
390 /// The [Working with long-running operations] chapter in the [user guide]
391 /// covers these operations in detail.
392 ///
393 /// [long-running operation]: https://google.aip.dev/151
394 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
395 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
396 pub fn update_anywhere_cache(&self) -> crate::builder::storage_control::UpdateAnywhereCache {
397 self.control.update_anywhere_cache()
398 }
399
400 /// Disables an Anywhere Cache instance. A disabled instance is read-only. The
401 /// disablement could be revoked by calling ResumeAnywhereCache. The cache
402 /// instance will be deleted automatically if it remains in the disabled state
403 /// for at least one hour.
404 pub fn disable_anywhere_cache(&self) -> crate::builder::storage_control::DisableAnywhereCache {
405 self.control.disable_anywhere_cache()
406 }
407
408 /// Pauses an Anywhere Cache instance.
409 pub fn pause_anywhere_cache(&self) -> crate::builder::storage_control::PauseAnywhereCache {
410 self.control.pause_anywhere_cache()
411 }
412
413 /// Resumes a disabled or paused Anywhere Cache instance.
414 pub fn resume_anywhere_cache(&self) -> crate::builder::storage_control::ResumeAnywhereCache {
415 self.control.resume_anywhere_cache()
416 }
417
418 /// Gets an Anywhere Cache instance.
419 pub fn get_anywhere_cache(&self) -> crate::builder::storage_control::GetAnywhereCache {
420 self.control.get_anywhere_cache()
421 }
422
423 /// Lists Anywhere Cache instances for a given bucket.
424 pub fn list_anywhere_caches(&self) -> crate::builder::storage_control::ListAnywhereCaches {
425 self.control.list_anywhere_caches()
426 }
427
428 /// Returns the Project scoped singleton IntelligenceConfig resource.
429 pub fn get_project_intelligence_config(
430 &self,
431 ) -> crate::builder::storage_control::GetProjectIntelligenceConfig {
432 self.control.get_project_intelligence_config()
433 }
434
435 /// Updates the Project scoped singleton IntelligenceConfig resource.
436 pub fn update_project_intelligence_config(
437 &self,
438 ) -> crate::builder::storage_control::UpdateProjectIntelligenceConfig {
439 self.control.update_project_intelligence_config()
440 }
441
442 /// Returns the Folder scoped singleton IntelligenceConfig resource.
443 pub fn get_folder_intelligence_config(
444 &self,
445 ) -> crate::builder::storage_control::GetFolderIntelligenceConfig {
446 self.control.get_folder_intelligence_config()
447 }
448
449 /// Updates the Folder scoped singleton IntelligenceConfig resource.
450 pub fn update_folder_intelligence_config(
451 &self,
452 ) -> crate::builder::storage_control::UpdateFolderIntelligenceConfig {
453 self.control.update_folder_intelligence_config()
454 }
455
456 /// Returns the Organization scoped singleton IntelligenceConfig resource.
457 pub fn get_organization_intelligence_config(
458 &self,
459 ) -> crate::builder::storage_control::GetOrganizationIntelligenceConfig {
460 self.control.get_organization_intelligence_config()
461 }
462
463 /// Updates the Organization scoped singleton IntelligenceConfig resource.
464 pub fn update_organization_intelligence_config(
465 &self,
466 ) -> crate::builder::storage_control::UpdateOrganizationIntelligenceConfig {
467 self.control.update_organization_intelligence_config()
468 }
469
470 /// Gets the IAM policy for a specified bucket.
471 /// The `resource` field in the request should be
472 /// `projects/_/buckets/{bucket}` for a bucket, or
473 /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
474 /// for a managed folder.
475 pub fn get_iam_policy(&self) -> crate::builder::storage_control::GetIamPolicy {
476 self.control.get_iam_policy()
477 }
478
479 /// Updates an IAM policy for the specified bucket.
480 /// The `resource` field in the request should be
481 /// `projects/_/buckets/{bucket}` for a bucket, or
482 /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
483 /// for a managed folder.
484 pub fn set_iam_policy(&self) -> crate::builder::storage_control::SetIamPolicy {
485 self.control.set_iam_policy()
486 }
487
488 /// Tests a set of permissions on the given bucket, object, or managed folder
489 /// to see which, if any, are held by the caller.
490 /// The `resource` field in the request should be
491 /// `projects/_/buckets/{bucket}` for a bucket,
492 /// `projects/_/buckets/{bucket}/objects/{object}` for an object, or
493 /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
494 /// for a managed folder.
495 pub fn test_iam_permissions(&self) -> crate::builder::storage_control::TestIamPermissions {
496 self.control.test_iam_permissions()
497 }
498
499 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
500 ///
501 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
502 pub fn get_operation(&self) -> crate::builder::storage_control::GetOperation {
503 self.control.get_operation()
504 }
505
506 /// Creates a new client from the provided stub.
507 ///
508 /// The most common case for calling this function is in tests mocking the
509 /// client's behavior.
510 pub fn from_stub<T>(stub: T) -> Self
511 where
512 T: crate::stub::StorageControl + 'static,
513 {
514 let stub = std::sync::Arc::new(stub);
515 Self {
516 storage: crate::generated::gapic::client::StorageControl::from_stub(stub.clone()),
517 control: crate::generated::gapic_control::client::StorageControl::from_stub(stub),
518 }
519 }
520
521 pub(crate) async fn new(
522 config: gaxi::options::ClientConfig,
523 ) -> crate::ClientBuilderResult<Self> {
524 let storage = crate::generated::gapic::client::StorageControl::new(config.clone()).await?;
525 let control = crate::generated::gapic_control::client::StorageControl::new(config).await?;
526 Ok(Self { storage, control })
527 }
528}