google_cloud_storage/control/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//! Contains the StorageControl client and related types.
16
17/// Implements a client for the Cloud Storage API.
18///
19/// # Example
20/// ```
21/// # tokio_test::block_on(async {
22/// # use google_cloud_storage::client::StorageControl;
23/// let client = StorageControl::builder().build().await?;
24/// // use `client` to make requests to Cloud Storage.
25/// # gax::client_builder::Result::<()>::Ok(()) });
26/// ```
27///
28/// # Configuration
29///
30/// To configure `StorageControl` use the `with_*` methods in the type returned
31/// by [builder()][StorageControl::builder]. The default configuration should
32/// work for most applications. Common configuration changes include
33///
34/// * [with_endpoint()]: by default this client uses the global default endpoint
35/// (`https://storage.googleapis.com`). Applications using regional
36/// endpoints or running in restricted networks (e.g. a network configured
37// with [Private Google Access with VPC Service Controls]) may want to
38/// override this default.
39/// * [with_credentials()]: by default this client uses
40/// [Application Default Credentials]. Applications using custom
41/// authentication may need to override this default.
42///
43/// # Pooling and Cloning
44///
45/// `StorageControl` holds a connection pool internally, it is advised to
46/// create one and the reuse it. You do not need to wrap `StorageControl` in
47/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
48/// already uses an `Arc` internally.
49///
50/// # Service Description
51///
52/// The Cloud Storage API allows applications to read and write data through
53/// the abstractions of buckets and objects. For a description of these
54/// abstractions please see <https://cloud.google.com/storage/docs>.
55///
56/// This client is used to perform metadata operations, such as creating
57/// buckets, deleting objects, listing objects, etc. It does not expose any
58/// functions to write or read data in objects.
59///
60/// Resources are named as follows:
61///
62/// - Projects are referred to as they are defined by the Resource Manager API,
63/// using strings like `projects/123456` or `projects/my-string-id`.
64///
65/// - Buckets are named using string names of the form:
66/// `projects/{project}/buckets/{bucket}`
67/// For globally unique buckets, `_` may be substituted for the project.
68///
69/// - Objects are uniquely identified by their name along with the name of the
70/// bucket they belong to, as separate strings in this API. For example:
71/// ```no_rust
72/// bucket = "projects/_/buckets/my-bucket"
73/// object = "my-object/with/a/folder-like/name"
74/// ```
75/// Note that object names can contain `/` characters, which are treated as
76/// any other character (no special directory semantics).
77///
78/// [with_endpoint()]: ClientBuilder::with_endpoint
79/// [with_credentials()]: ClientBuilder::with_credentials
80/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
81/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
82#[derive(Clone, Debug)]
83pub struct StorageControl {
84 storage: crate::generated::gapic::client::StorageControl,
85 control: crate::generated::gapic_control::client::StorageControl,
86}
87
88impl StorageControl {
89 /// Returns a builder for [StorageControl].
90 ///
91 /// ```no_run
92 /// # tokio_test::block_on(async {
93 /// # use google_cloud_storage::client::StorageControl;
94 /// let client = StorageControl::builder().build().await?;
95 /// # gax::client_builder::Result::<()>::Ok(()) });
96 /// ```
97 pub fn builder() -> ClientBuilder {
98 gax::client_builder::internal::new_builder(client_builder::Factory)
99 }
100
101 /// Permanently deletes an empty bucket.
102 ///
103 /// This request will fail if the bucket is not empty. You must manually
104 /// delete the objects in a bucket (including archived and soft deleted
105 /// objects) before deleting the bucket.
106 ///
107 /// # Example
108 /// ```
109 /// # use google_cloud_storage::client::StorageControl;
110 /// async fn example(client: &StorageControl) -> gax::Result<()> {
111 /// client.delete_bucket()
112 /// .set_name("projects/_/buckets/my-bucket")
113 /// .send()
114 /// .await?;
115 /// Ok(())
116 /// }
117 /// ```
118 pub fn delete_bucket(&self) -> crate::builder::storage_control::DeleteBucket {
119 self.storage.delete_bucket()
120 }
121
122 /// Returns metadata for the specified bucket.
123 ///
124 /// # Example
125 /// ```
126 /// # use google_cloud_storage::client::StorageControl;
127 /// async fn example(client: &StorageControl) -> gax::Result<()> {
128 /// let bucket = client.get_bucket()
129 /// .set_name("projects/_/buckets/my-bucket")
130 /// .send()
131 /// .await?;
132 /// assert_eq!(&bucket.name, "projects/_/buckets/my-bucket");
133 /// println!("bucket details={bucket:?}");
134 /// Ok(())
135 /// }
136 /// ```
137 pub fn get_bucket(&self) -> crate::builder::storage_control::GetBucket {
138 self.storage.get_bucket()
139 }
140
141 /// Creates a new bucket.
142 ///
143 /// # Example
144 /// ```
145 /// # use google_cloud_storage::client::StorageControl;
146 /// async fn example(client: &StorageControl) -> gax::Result<()> {
147 /// let bucket = client.create_bucket()
148 /// .set_parent("projects/my-project")
149 /// .set_bucket_id("my-bucket")
150 /// .send()
151 /// .await?;
152 /// assert_eq!(&bucket.name, "projects/_/buckets/my-bucket");
153 /// println!("bucket details={bucket:?}");
154 /// Ok(())
155 /// }
156 /// ```
157 pub fn create_bucket(&self) -> crate::builder::storage_control::CreateBucket {
158 self.storage.create_bucket()
159 }
160
161 /// Retrieves a list of buckets for a given project.
162 ///
163 /// # Example
164 /// ```
165 /// # use google_cloud_storage::client::StorageControl;
166 /// async fn example(client: &StorageControl) -> gax::Result<()> {
167 /// use gax::paginator::{ItemPaginator, Paginator};
168 /// let mut items = client.list_buckets()
169 /// .set_parent("projects/my-project")
170 /// .by_item();
171 /// while let Some(bucket) = items.next().await {
172 /// let bucket = bucket?;
173 /// println!(" {bucket:?}");
174 /// }
175 /// Ok(())
176 /// }
177 /// ```
178 pub fn list_buckets(&self) -> crate::builder::storage_control::ListBuckets {
179 self.storage.list_buckets()
180 }
181
182 /// Locks retention policy on a bucket.
183 pub fn lock_bucket_retention_policy(
184 &self,
185 ) -> crate::builder::storage_control::LockBucketRetentionPolicy {
186 self.storage.lock_bucket_retention_policy()
187 }
188
189 /// Gets the IAM policy for a specified bucket.
190 ///
191 /// # Example
192 /// ```
193 /// # use google_cloud_storage::client::StorageControl;
194 /// async fn example(client: &StorageControl) -> gax::Result<()> {
195 /// let policy = client.get_iam_policy()
196 /// .set_resource("projects/_/buckets/my-bucket")
197 /// .send()
198 /// .await?;
199 /// println!("policy details={policy:?}");
200 /// Ok(())
201 /// }
202 /// ```
203 pub fn get_iam_policy(&self) -> crate::builder::storage_control::GetIamPolicy {
204 self.storage.get_iam_policy()
205 }
206
207 /// Updates the IAM policy for a specified bucket.
208 ///
209 /// This is not an update. The supplied policy will overwrite any existing
210 /// IAM Policy. You should first get the current IAM policy with
211 /// `get_iam_policy()` and then modify that policy before supplying it to
212 /// `set_iam_policy()`.
213 ///
214 /// # Example
215 ///
216 /// ```
217 /// # use google_cloud_storage::client::StorageControl;
218 /// # use iam_v1::model::Policy;
219 /// async fn example(client: &StorageControl, updated_policy: Policy) -> gax::Result<()> {
220 /// let policy = client.set_iam_policy()
221 /// .set_resource("projects/_/buckets/my-bucket")
222 /// .set_update_mask(wkt::FieldMask::default().set_paths(["bindings"]))
223 /// .set_policy(updated_policy)
224 /// .send()
225 /// .await?;
226 /// println!("policy details={policy:?}");
227 /// Ok(())
228 /// }
229 /// ```
230 pub fn set_iam_policy(&self) -> crate::builder::storage_control::SetIamPolicy {
231 self.storage.set_iam_policy()
232 }
233
234 /// Tests a set of permissions on the given bucket, object, or managed folder
235 /// to see which, if any, are held by the caller.
236 ///
237 /// # Example
238 /// ```
239 /// # use google_cloud_storage::client::StorageControl;
240 /// async fn example(client: &StorageControl) -> gax::Result<()> {
241 /// let response = client.test_iam_permissions()
242 /// .set_resource("projects/_/buckets/my-bucket")
243 /// .set_permissions(["storage.buckets.get"])
244 /// .send()
245 /// .await?;
246 /// println!("response details={response:?}");
247 /// Ok(())
248 /// }
249 /// ```
250 pub fn test_iam_permissions(&self) -> crate::builder::storage_control::TestIamPermissions {
251 self.storage.test_iam_permissions()
252 }
253
254 /// Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.
255 pub fn update_bucket(&self) -> crate::builder::storage_control::UpdateBucket {
256 self.storage.update_bucket()
257 }
258
259 /// Concatenates a list of existing objects into a new object in the same
260 /// bucket.
261 pub fn compose_object(&self) -> crate::builder::storage_control::ComposeObject {
262 self.storage.compose_object()
263 }
264
265 /// Permanently deletes an object and its metadata.
266 ///
267 /// # Example
268 /// ```
269 /// # use google_cloud_storage::client::StorageControl;
270 /// async fn example(client: &StorageControl) -> gax::Result<()> {
271 /// client.delete_object()
272 /// .set_bucket("projects/_/buckets/my-bucket")
273 /// .set_object("my-object")
274 /// .send()
275 /// .await?;
276 /// Ok(())
277 /// }
278 /// ```
279 ///
280 /// Deletions are permanent if versioning is not enabled for the bucket, or
281 /// if the generation parameter is used, or if [soft delete] is not
282 /// enabled for the bucket.
283 ///
284 /// When this method is used to delete an object from a bucket that has soft
285 /// delete policy enabled, the object becomes soft deleted, and the
286 /// `soft_delete_time` and `hard_delete_time` properties are set on the
287 /// object. This method cannot be used to permanently delete soft-deleted
288 /// objects. Soft-deleted objects are permanently deleted according to their
289 /// `hard_delete_time`.
290 ///
291 /// You can use the `restore_object` method to restore soft-deleted objects
292 /// until the soft delete retention period has passed.
293 ///
294 /// [soft delete]: https://cloud.google.com/storage/docs/soft-delete
295 pub fn delete_object(&self) -> crate::builder::storage_control::DeleteObject {
296 self.storage.delete_object()
297 }
298
299 /// Restores a soft-deleted object.
300 pub fn restore_object(&self) -> crate::builder::storage_control::RestoreObject {
301 self.storage.restore_object()
302 }
303
304 /// Retrieves object metadata.
305 ///
306 /// **IAM Permissions**:
307 ///
308 /// Requires `storage.objects.get`
309 /// [IAM permission](https://cloud.google.com/iam/docs/overview#permissions) on
310 /// the bucket. To return object ACLs, the authenticated user must also have
311 /// the `storage.objects.getIamPolicy` permission.
312 pub fn get_object(&self) -> crate::builder::storage_control::GetObject {
313 self.storage.get_object()
314 }
315
316 /// Updates an object's metadata.
317 /// Equivalent to JSON API's storage.objects.patch.
318 pub fn update_object(&self) -> crate::builder::storage_control::UpdateObject {
319 self.storage.update_object()
320 }
321
322 /// Retrieves the list of objects for a given bucket.
323 ///
324 /// # Example
325 /// ```
326 /// # use google_cloud_storage::client::StorageControl;
327 /// async fn example(client: &StorageControl) -> gax::Result<()> {
328 /// use gax::paginator::{ItemPaginator, Paginator};
329 /// let mut items = client.list_objects()
330 /// .set_parent("projects/_/buckets/my-bucket")
331 /// .by_item();
332 /// while let Some(object) = items.next().await {
333 /// let object = object?;
334 /// println!(" {object:?}");
335 /// }
336 /// Ok(())
337 /// }
338 /// ```
339 pub fn list_objects(&self) -> crate::builder::storage_control::ListObjects {
340 self.storage.list_objects()
341 }
342
343 /// Rewrites a source object to a destination object. Optionally overrides
344 /// metadata.
345 pub fn rewrite_object(&self) -> crate::builder::storage_control::RewriteObject {
346 self.storage.rewrite_object()
347 }
348
349 /// Moves the source object to the destination object in the same bucket.
350 pub fn move_object(&self) -> crate::builder::storage_control::MoveObject {
351 self.storage.move_object()
352 }
353
354 /// Creates a new folder.
355 ///
356 /// This operation is only applicable to a hierarchical namespace enabled
357 /// bucket.
358 ///
359 /// # Example
360 /// ```
361 /// # use google_cloud_storage::client::StorageControl;
362 /// async fn example(client: &StorageControl) -> gax::Result<()> {
363 /// let folder = client.create_folder()
364 /// .set_parent("projects/my-project/buckets/my-bucket")
365 /// .set_folder_id("my-folder/my-subfolder/")
366 /// .send()
367 /// .await?;
368 /// println!("folder details={folder:?}");
369 /// Ok(())
370 /// }
371 /// ```
372 pub fn create_folder(&self) -> crate::builder::storage_control::CreateFolder {
373 self.control.create_folder()
374 }
375
376 /// Permanently deletes an empty folder.
377 ///
378 /// This operation is only applicable to a hierarchical namespace enabled
379 /// bucket.
380 ///
381 /// # Example
382 /// ```
383 /// # use google_cloud_storage::client::StorageControl;
384 /// async fn example(client: &StorageControl) -> gax::Result<()> {
385 /// client.delete_folder()
386 /// .set_name("projects/_/buckets/my-bucket/folders/my-folder/my-subfolder/")
387 /// .send()
388 /// .await?;
389 /// Ok(())
390 /// }
391 /// ```
392 pub fn delete_folder(&self) -> crate::builder::storage_control::DeleteFolder {
393 self.control.delete_folder()
394 }
395
396 /// Returns metadata for the specified folder.
397 ///
398 /// This operation is only applicable to a hierarchical namespace enabled
399 /// bucket.
400 ///
401 /// # Example
402 /// ```
403 /// # use google_cloud_storage::client::StorageControl;
404 /// async fn example(client: &StorageControl) -> gax::Result<()> {
405 /// let folder = client.get_folder()
406 /// .set_name("projects/_/buckets/my-bucket/folders/my-folder/my-subfolder/")
407 /// .send()
408 /// .await?;
409 /// println!("folder details={folder:?}");
410 /// Ok(())
411 /// }
412 /// ```
413 pub fn get_folder(&self) -> crate::builder::storage_control::GetFolder {
414 self.control.get_folder()
415 }
416
417 /// Retrieves a list of folders.
418 ///
419 /// This operation is only applicable to a hierarchical namespace enabled
420 /// bucket.
421 ///
422 /// # Example
423 /// ```
424 /// # use google_cloud_storage::client::StorageControl;
425 /// async fn example(client: &StorageControl) -> gax::Result<()> {
426 /// use gax::paginator::ItemPaginator as _;
427 /// let mut folders = client.list_folders()
428 /// .set_parent("projects/_/buckets/my-bucket")
429 /// .by_item();
430 /// while let Some(folder) = folders.next().await {
431 /// let folder = folder?;
432 /// println!(" {folder:?}");
433 /// }
434 /// Ok(())
435 /// }
436 /// ```
437 pub fn list_folders(&self) -> crate::builder::storage_control::ListFolders {
438 self.control.list_folders()
439 }
440
441 /// Renames a source folder to a destination folder.
442 ///
443 /// This operation is only applicable to a hierarchical namespace enabled
444 /// bucket.
445 ///
446 /// During a rename, the source and destination folders are locked until the
447 /// long running operation completes.
448 ///
449 /// # Example
450 /// ```
451 /// # use google_cloud_storage::client::StorageControl;
452 /// async fn example(client: &StorageControl) -> gax::Result<()> {
453 /// use lro::Poller as _;
454 /// let folder = client.rename_folder()
455 /// .set_name("projects/_/buckets/my-bucket/folders/my-folder/my-subfolder/")
456 /// .set_destination_folder_id("my-folder/my-renamed-subfolder/")
457 /// .poller()
458 /// .until_done()
459 /// .await?;
460 /// println!("folder details={folder:?}");
461 /// Ok(())
462 /// }
463 /// ```
464 ///
465 /// # Long running operations
466 ///
467 /// This method is used to start, and/or poll a [long-running Operation].
468 /// The [Working with long-running operations] chapter in the [user guide]
469 /// covers these operations in detail.
470 ///
471 /// [long-running operation]: https://google.aip.dev/151
472 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
473 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
474 pub fn rename_folder(&self) -> crate::builder::storage_control::RenameFolder {
475 self.control.rename_folder()
476 }
477
478 /// Returns the storage layout configuration for a given bucket.
479 pub fn get_storage_layout(&self) -> crate::builder::storage_control::GetStorageLayout {
480 self.control.get_storage_layout()
481 }
482
483 /// Creates a new managed folder.
484 pub fn create_managed_folder(&self) -> crate::builder::storage_control::CreateManagedFolder {
485 self.control.create_managed_folder()
486 }
487
488 /// Permanently deletes an empty managed folder.
489 pub fn delete_managed_folder(&self) -> crate::builder::storage_control::DeleteManagedFolder {
490 self.control.delete_managed_folder()
491 }
492
493 /// Returns metadata for the specified managed folder.
494 pub fn get_managed_folder(&self) -> crate::builder::storage_control::GetManagedFolder {
495 self.control.get_managed_folder()
496 }
497
498 /// Retrieves a list of managed folders for a given bucket.
499 pub fn list_managed_folders(&self) -> crate::builder::storage_control::ListManagedFolders {
500 self.control.list_managed_folders()
501 }
502
503 /// Creates an Anywhere Cache instance.
504 ///
505 /// # Long running operations
506 ///
507 /// This method is used to start, and/or poll a [long-running Operation].
508 /// The [Working with long-running operations] chapter in the [user guide]
509 /// covers these operations in detail.
510 ///
511 /// [long-running operation]: https://google.aip.dev/151
512 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
513 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
514 pub fn create_anywhere_cache(&self) -> crate::builder::storage_control::CreateAnywhereCache {
515 self.control.create_anywhere_cache()
516 }
517
518 /// Updates an Anywhere Cache instance. Mutable fields include `ttl` and
519 /// `admission_policy`.
520 ///
521 /// # Long running operations
522 ///
523 /// This method is used to start, and/or poll a [long-running Operation].
524 /// The [Working with long-running operations] chapter in the [user guide]
525 /// covers these operations in detail.
526 ///
527 /// [long-running operation]: https://google.aip.dev/151
528 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
529 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
530 pub fn update_anywhere_cache(&self) -> crate::builder::storage_control::UpdateAnywhereCache {
531 self.control.update_anywhere_cache()
532 }
533
534 /// Disables an Anywhere Cache instance. A disabled instance is read-only. The
535 /// disablement could be revoked by calling ResumeAnywhereCache. The cache
536 /// instance will be deleted automatically if it remains in the disabled state
537 /// for at least one hour.
538 pub fn disable_anywhere_cache(&self) -> crate::builder::storage_control::DisableAnywhereCache {
539 self.control.disable_anywhere_cache()
540 }
541
542 /// Pauses an Anywhere Cache instance.
543 pub fn pause_anywhere_cache(&self) -> crate::builder::storage_control::PauseAnywhereCache {
544 self.control.pause_anywhere_cache()
545 }
546
547 /// Resumes a disabled or paused Anywhere Cache instance.
548 pub fn resume_anywhere_cache(&self) -> crate::builder::storage_control::ResumeAnywhereCache {
549 self.control.resume_anywhere_cache()
550 }
551
552 /// Gets an Anywhere Cache instance.
553 pub fn get_anywhere_cache(&self) -> crate::builder::storage_control::GetAnywhereCache {
554 self.control.get_anywhere_cache()
555 }
556
557 /// Lists Anywhere Cache instances for a given bucket.
558 pub fn list_anywhere_caches(&self) -> crate::builder::storage_control::ListAnywhereCaches {
559 self.control.list_anywhere_caches()
560 }
561
562 /// Returns the Project scoped singleton IntelligenceConfig resource.
563 pub fn get_project_intelligence_config(
564 &self,
565 ) -> crate::builder::storage_control::GetProjectIntelligenceConfig {
566 self.control.get_project_intelligence_config()
567 }
568
569 /// Updates the Project scoped singleton IntelligenceConfig resource.
570 pub fn update_project_intelligence_config(
571 &self,
572 ) -> crate::builder::storage_control::UpdateProjectIntelligenceConfig {
573 self.control.update_project_intelligence_config()
574 }
575
576 /// Returns the Folder scoped singleton IntelligenceConfig resource.
577 pub fn get_folder_intelligence_config(
578 &self,
579 ) -> crate::builder::storage_control::GetFolderIntelligenceConfig {
580 self.control.get_folder_intelligence_config()
581 }
582
583 /// Updates the Folder scoped singleton IntelligenceConfig resource.
584 pub fn update_folder_intelligence_config(
585 &self,
586 ) -> crate::builder::storage_control::UpdateFolderIntelligenceConfig {
587 self.control.update_folder_intelligence_config()
588 }
589
590 /// Returns the Organization scoped singleton IntelligenceConfig resource.
591 pub fn get_organization_intelligence_config(
592 &self,
593 ) -> crate::builder::storage_control::GetOrganizationIntelligenceConfig {
594 self.control.get_organization_intelligence_config()
595 }
596
597 /// Updates the Organization scoped singleton IntelligenceConfig resource.
598 pub fn update_organization_intelligence_config(
599 &self,
600 ) -> crate::builder::storage_control::UpdateOrganizationIntelligenceConfig {
601 self.control.update_organization_intelligence_config()
602 }
603
604 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
605 ///
606 /// [google.longrunning.Operations]: longrunning::client::Operations
607 pub fn get_operation(&self) -> crate::builder::storage_control::GetOperation {
608 self.control.get_operation()
609 }
610
611 /// Creates a new client from the provided stub.
612 ///
613 /// The most common case for calling this function is in tests mocking the
614 /// client's behavior.
615 pub fn from_stub<T>(stub: T) -> Self
616 where
617 T: super::stub::StorageControl + 'static,
618 {
619 let stub = std::sync::Arc::new(stub);
620 Self {
621 storage: crate::generated::gapic::client::StorageControl::from_stub(stub.clone()),
622 control: crate::generated::gapic_control::client::StorageControl::from_stub(stub),
623 }
624 }
625
626 pub(crate) async fn new(
627 config: gaxi::options::ClientConfig,
628 ) -> gax::client_builder::Result<Self> {
629 let storage = crate::generated::gapic::client::StorageControl::new(config.clone()).await?;
630 let control = crate::generated::gapic_control::client::StorageControl::new(config).await?;
631 Ok(Self { storage, control })
632 }
633}
634
635/// A builder for [StorageControl].
636///
637/// ```
638/// # tokio_test::block_on(async {
639/// # use google_cloud_storage::*;
640/// # use builder::storage_control::ClientBuilder;
641/// # use client::StorageControl;
642/// let builder : ClientBuilder = StorageControl::builder();
643/// let client = builder
644/// .with_endpoint("https://storage.googleapis.com")
645/// .build().await?;
646/// # gax::client_builder::Result::<()>::Ok(()) });
647/// ```
648pub type ClientBuilder =
649 gax::client_builder::ClientBuilder<client_builder::Factory, gaxi::options::Credentials>;
650
651pub(crate) mod client_builder {
652 use super::StorageControl;
653 pub struct Factory;
654 impl gax::client_builder::internal::ClientFactory for Factory {
655 type Client = StorageControl;
656 type Credentials = gaxi::options::Credentials;
657 async fn build(
658 self,
659 config: gaxi::options::ClientConfig,
660 ) -> gax::client_builder::Result<Self::Client> {
661 Self::Client::new(config).await
662 }
663 }
664}
665
666#[cfg(test)]
667mod tests {
668 use super::StorageControl;
669
670 #[tokio::test]
671 async fn builder() -> anyhow::Result<()> {
672 let _ = StorageControl::builder()
673 .with_credentials(auth::credentials::testing::test_credentials())
674 .build()
675 .await?;
676 Ok(())
677 }
678}