google_cloud_storagebatchoperations_v1/
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#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Storage Batch Operations API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_storagebatchoperations_v1::client::StorageBatchOperations;
25/// let client = StorageBatchOperations::builder().build().await?;
26/// // use `client` to make requests to the Storage Batch Operations API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Storage Batch Operations offers a managed experience to perform batch
33/// operations on millions of Cloud Storage objects in a serverless fashion. With
34/// this service, you can automate and simplify large scale API operations
35/// performed on Cloud Storage objects.
36///
37/// # Configuration
38///
39/// To configure `StorageBatchOperations` use the `with_*` methods in the type returned
40/// by [builder()][StorageBatchOperations::builder]. The default configuration should
41/// work for most applications. Common configuration changes include
42///
43/// * [with_endpoint()]: by default this client uses the global default endpoint
44///   (`https://storagebatchoperations.googleapis.com`). Applications using regional
45///   endpoints or running in restricted networks (e.g. a network configured
46//    with [Private Google Access with VPC Service Controls]) may want to
47///   override this default.
48/// * [with_credentials()]: by default this client uses
49///   [Application Default Credentials]. Applications using custom
50///   authentication may need to override this default.
51///
52/// [with_endpoint()]: super::builder::storage_batch_operations::ClientBuilder::with_endpoint
53/// [with_credentials()]: super::builder::storage_batch_operations::ClientBuilder::credentials
54/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
55/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
56///
57/// # Pooling and Cloning
58///
59/// `StorageBatchOperations` holds a connection pool internally, it is advised to
60/// create one and the reuse it.  You do not need to wrap `StorageBatchOperations` in
61/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
62/// already uses an `Arc` internally.
63#[derive(Clone, Debug)]
64pub struct StorageBatchOperations {
65    inner: std::sync::Arc<dyn super::stub::dynamic::StorageBatchOperations>,
66}
67
68impl StorageBatchOperations {
69    /// Returns a builder for [StorageBatchOperations].
70    ///
71    /// ```
72    /// # tokio_test::block_on(async {
73    /// # use google_cloud_storagebatchoperations_v1::client::StorageBatchOperations;
74    /// let client = StorageBatchOperations::builder().build().await?;
75    /// # gax::client_builder::Result::<()>::Ok(()) });
76    /// ```
77    pub fn builder() -> super::builder::storage_batch_operations::ClientBuilder {
78        gax::client_builder::internal::new_builder(
79            super::builder::storage_batch_operations::client::Factory,
80        )
81    }
82
83    /// Creates a new client from the provided stub.
84    ///
85    /// The most common case for calling this function is in tests mocking the
86    /// client's behavior.
87    pub fn from_stub<T>(stub: T) -> Self
88    where
89        T: super::stub::StorageBatchOperations + 'static,
90    {
91        Self {
92            inner: std::sync::Arc::new(stub),
93        }
94    }
95
96    pub(crate) async fn new(
97        config: gaxi::options::ClientConfig,
98    ) -> gax::client_builder::Result<Self> {
99        let inner = Self::build_inner(config).await?;
100        Ok(Self { inner })
101    }
102
103    async fn build_inner(
104        conf: gaxi::options::ClientConfig,
105    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::StorageBatchOperations>>
106    {
107        if gaxi::options::tracing_enabled(&conf) {
108            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
109        }
110        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
111    }
112
113    async fn build_transport(
114        conf: gaxi::options::ClientConfig,
115    ) -> gax::client_builder::Result<impl super::stub::StorageBatchOperations> {
116        super::transport::StorageBatchOperations::new(conf).await
117    }
118
119    async fn build_with_tracing(
120        conf: gaxi::options::ClientConfig,
121    ) -> gax::client_builder::Result<impl super::stub::StorageBatchOperations> {
122        Self::build_transport(conf)
123            .await
124            .map(super::tracing::StorageBatchOperations::new)
125    }
126
127    /// Lists Jobs in a given project.
128    pub fn list_jobs(&self) -> super::builder::storage_batch_operations::ListJobs {
129        super::builder::storage_batch_operations::ListJobs::new(self.inner.clone())
130    }
131
132    /// Gets a batch job.
133    pub fn get_job(&self) -> super::builder::storage_batch_operations::GetJob {
134        super::builder::storage_batch_operations::GetJob::new(self.inner.clone())
135    }
136
137    /// Creates a batch job.
138    ///
139    /// # Long running operations
140    ///
141    /// This method is used to start, and/or poll a [long-running Operation].
142    /// The [Working with long-running operations] chapter in the [user guide]
143    /// covers these operations in detail.
144    ///
145    /// [long-running operation]: https://google.aip.dev/151
146    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
147    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
148    pub fn create_job(&self) -> super::builder::storage_batch_operations::CreateJob {
149        super::builder::storage_batch_operations::CreateJob::new(self.inner.clone())
150    }
151
152    /// Deletes a batch job.
153    pub fn delete_job(&self) -> super::builder::storage_batch_operations::DeleteJob {
154        super::builder::storage_batch_operations::DeleteJob::new(self.inner.clone())
155    }
156
157    /// Cancels a batch job.
158    pub fn cancel_job(&self) -> super::builder::storage_batch_operations::CancelJob {
159        super::builder::storage_batch_operations::CancelJob::new(self.inner.clone())
160    }
161
162    /// Lists information about the supported locations for this service.
163    pub fn list_locations(&self) -> super::builder::storage_batch_operations::ListLocations {
164        super::builder::storage_batch_operations::ListLocations::new(self.inner.clone())
165    }
166
167    /// Gets information about a location.
168    pub fn get_location(&self) -> super::builder::storage_batch_operations::GetLocation {
169        super::builder::storage_batch_operations::GetLocation::new(self.inner.clone())
170    }
171
172    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
173    ///
174    /// [google.longrunning.Operations]: longrunning::client::Operations
175    pub fn list_operations(&self) -> super::builder::storage_batch_operations::ListOperations {
176        super::builder::storage_batch_operations::ListOperations::new(self.inner.clone())
177    }
178
179    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
180    ///
181    /// [google.longrunning.Operations]: longrunning::client::Operations
182    pub fn get_operation(&self) -> super::builder::storage_batch_operations::GetOperation {
183        super::builder::storage_batch_operations::GetOperation::new(self.inner.clone())
184    }
185
186    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
187    ///
188    /// [google.longrunning.Operations]: longrunning::client::Operations
189    pub fn delete_operation(&self) -> super::builder::storage_batch_operations::DeleteOperation {
190        super::builder::storage_batch_operations::DeleteOperation::new(self.inner.clone())
191    }
192
193    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
194    ///
195    /// [google.longrunning.Operations]: longrunning::client::Operations
196    pub fn cancel_operation(&self) -> super::builder::storage_batch_operations::CancelOperation {
197        super::builder::storage_batch_operations::CancelOperation::new(self.inner.clone())
198    }
199}