Skip to main content

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/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
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/// # 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    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
73    /// # use google_cloud_storagebatchoperations_v1::client::StorageBatchOperations;
74    /// let client = StorageBatchOperations::builder().build().await?;
75    /// # Ok(()) }
76    /// ```
77    pub fn builder() -> super::builder::storage_batch_operations::ClientBuilder {
78        crate::new_client_builder(super::builder::storage_batch_operations::client::Factory)
79    }
80
81    /// Creates a new client from the provided stub.
82    ///
83    /// The most common case for calling this function is in tests mocking the
84    /// client's behavior.
85    pub fn from_stub<T>(stub: T) -> Self
86    where
87        T: super::stub::StorageBatchOperations + 'static,
88    {
89        Self {
90            inner: std::sync::Arc::new(stub),
91        }
92    }
93
94    pub(crate) async fn new(
95        config: gaxi::options::ClientConfig,
96    ) -> crate::ClientBuilderResult<Self> {
97        let inner = Self::build_inner(config).await?;
98        Ok(Self { inner })
99    }
100
101    async fn build_inner(
102        conf: gaxi::options::ClientConfig,
103    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::StorageBatchOperations>>
104    {
105        if gaxi::options::tracing_enabled(&conf) {
106            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
107        }
108        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
109    }
110
111    async fn build_transport(
112        conf: gaxi::options::ClientConfig,
113    ) -> crate::ClientBuilderResult<impl super::stub::StorageBatchOperations> {
114        super::transport::StorageBatchOperations::new(conf).await
115    }
116
117    async fn build_with_tracing(
118        conf: gaxi::options::ClientConfig,
119    ) -> crate::ClientBuilderResult<impl super::stub::StorageBatchOperations> {
120        Self::build_transport(conf)
121            .await
122            .map(super::tracing::StorageBatchOperations::new)
123    }
124
125    /// Lists Jobs in a given project.
126    pub fn list_jobs(&self) -> super::builder::storage_batch_operations::ListJobs {
127        super::builder::storage_batch_operations::ListJobs::new(self.inner.clone())
128    }
129
130    /// Gets a batch job.
131    pub fn get_job(&self) -> super::builder::storage_batch_operations::GetJob {
132        super::builder::storage_batch_operations::GetJob::new(self.inner.clone())
133    }
134
135    /// Creates a batch job.
136    ///
137    /// # Long running operations
138    ///
139    /// This method is used to start, and/or poll a [long-running Operation].
140    /// The [Working with long-running operations] chapter in the [user guide]
141    /// covers these operations in detail.
142    ///
143    /// [long-running operation]: https://google.aip.dev/151
144    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
145    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
146    pub fn create_job(&self) -> super::builder::storage_batch_operations::CreateJob {
147        super::builder::storage_batch_operations::CreateJob::new(self.inner.clone())
148    }
149
150    /// Deletes a batch job.
151    pub fn delete_job(&self) -> super::builder::storage_batch_operations::DeleteJob {
152        super::builder::storage_batch_operations::DeleteJob::new(self.inner.clone())
153    }
154
155    /// Cancels a batch job.
156    pub fn cancel_job(&self) -> super::builder::storage_batch_operations::CancelJob {
157        super::builder::storage_batch_operations::CancelJob::new(self.inner.clone())
158    }
159
160    /// Lists information about the supported locations for this service.
161    pub fn list_locations(&self) -> super::builder::storage_batch_operations::ListLocations {
162        super::builder::storage_batch_operations::ListLocations::new(self.inner.clone())
163    }
164
165    /// Gets information about a location.
166    pub fn get_location(&self) -> super::builder::storage_batch_operations::GetLocation {
167        super::builder::storage_batch_operations::GetLocation::new(self.inner.clone())
168    }
169
170    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
171    ///
172    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
173    pub fn list_operations(&self) -> super::builder::storage_batch_operations::ListOperations {
174        super::builder::storage_batch_operations::ListOperations::new(self.inner.clone())
175    }
176
177    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
178    ///
179    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
180    pub fn get_operation(&self) -> super::builder::storage_batch_operations::GetOperation {
181        super::builder::storage_batch_operations::GetOperation::new(self.inner.clone())
182    }
183
184    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
185    ///
186    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
187    pub fn delete_operation(&self) -> super::builder::storage_batch_operations::DeleteOperation {
188        super::builder::storage_batch_operations::DeleteOperation::new(self.inner.clone())
189    }
190
191    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
192    ///
193    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
194    pub fn cancel_operation(&self) -> super::builder::storage_batch_operations::CancelOperation {
195        super::builder::storage_batch_operations::CancelOperation::new(self.inner.clone())
196    }
197}