google_cloud_parallelstore_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 Parallelstore API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_parallelstore_v1::client::Parallelstore;
25/// let client = Parallelstore::builder().build().await?;
26/// // use `client` to make requests to the Parallelstore API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Service describing handlers for resources
33/// Configures and manages parallelstore resources.
34///
35/// Parallelstore service.
36///
37/// The `parallelstore.googleapis.com` service implements the parallelstore API
38/// and defines the following resource model for managing instances:
39///
40/// * The service works with a collection of cloud projects, named: `/projects/*`
41/// * Each project has a collection of available locations, named: `/locations/*`
42/// * Each location has a collection of instances named `/instances/*`.
43/// * Parallelstore instances are resources of the form:
44///   `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
45///
46/// Note that location_id must be a Google Cloud `zone`; for example:
47///
48/// * `projects/12345/locations/us-central1-c/instances/my-parallelstore-share`
49///
50/// # Configuration
51///
52/// To configure `Parallelstore` use the `with_*` methods in the type returned
53/// by [builder()][Parallelstore::builder]. The default configuration should
54/// work for most applications. Common configuration changes include
55///
56/// * [with_endpoint()]: by default this client uses the global default endpoint
57///   (`https://parallelstore.googleapis.com`). Applications using regional
58///   endpoints or running in restricted networks (e.g. a network configured
59//    with [Private Google Access with VPC Service Controls]) may want to
60///   override this default.
61/// * [with_credentials()]: by default this client uses
62///   [Application Default Credentials]. Applications using custom
63///   authentication may need to override this default.
64///
65/// [with_endpoint()]: super::builder::parallelstore::ClientBuilder::with_endpoint
66/// [with_credentials()]: super::builder::parallelstore::ClientBuilder::credentials
67/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
68/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
69///
70/// # Pooling and Cloning
71///
72/// `Parallelstore` holds a connection pool internally, it is advised to
73/// create one and the reuse it.  You do not need to wrap `Parallelstore` in
74/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
75/// already uses an `Arc` internally.
76#[derive(Clone, Debug)]
77pub struct Parallelstore {
78    inner: std::sync::Arc<dyn super::stub::dynamic::Parallelstore>,
79}
80
81impl Parallelstore {
82    /// Returns a builder for [Parallelstore].
83    ///
84    /// ```
85    /// # tokio_test::block_on(async {
86    /// # use google_cloud_parallelstore_v1::client::Parallelstore;
87    /// let client = Parallelstore::builder().build().await?;
88    /// # gax::client_builder::Result::<()>::Ok(()) });
89    /// ```
90    pub fn builder() -> super::builder::parallelstore::ClientBuilder {
91        gax::client_builder::internal::new_builder(super::builder::parallelstore::client::Factory)
92    }
93
94    /// Creates a new client from the provided stub.
95    ///
96    /// The most common case for calling this function is in tests mocking the
97    /// client's behavior.
98    pub fn from_stub<T>(stub: T) -> Self
99    where
100        T: super::stub::Parallelstore + 'static,
101    {
102        Self {
103            inner: std::sync::Arc::new(stub),
104        }
105    }
106
107    pub(crate) async fn new(
108        config: gaxi::options::ClientConfig,
109    ) -> gax::client_builder::Result<Self> {
110        let inner = Self::build_inner(config).await?;
111        Ok(Self { inner })
112    }
113
114    async fn build_inner(
115        conf: gaxi::options::ClientConfig,
116    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Parallelstore>> {
117        if gaxi::options::tracing_enabled(&conf) {
118            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
119        }
120        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
121    }
122
123    async fn build_transport(
124        conf: gaxi::options::ClientConfig,
125    ) -> gax::client_builder::Result<impl super::stub::Parallelstore> {
126        super::transport::Parallelstore::new(conf).await
127    }
128
129    async fn build_with_tracing(
130        conf: gaxi::options::ClientConfig,
131    ) -> gax::client_builder::Result<impl super::stub::Parallelstore> {
132        Self::build_transport(conf)
133            .await
134            .map(super::tracing::Parallelstore::new)
135    }
136
137    /// Lists all instances in a given project and location.
138    pub fn list_instances(&self) -> super::builder::parallelstore::ListInstances {
139        super::builder::parallelstore::ListInstances::new(self.inner.clone())
140    }
141
142    /// Gets details of a single instance.
143    pub fn get_instance(&self) -> super::builder::parallelstore::GetInstance {
144        super::builder::parallelstore::GetInstance::new(self.inner.clone())
145    }
146
147    /// Creates a Parallelstore instance in a given project and location.
148    ///
149    /// # Long running operations
150    ///
151    /// This method is used to start, and/or poll a [long-running Operation].
152    /// The [Working with long-running operations] chapter in the [user guide]
153    /// covers these operations in detail.
154    ///
155    /// [long-running operation]: https://google.aip.dev/151
156    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
157    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
158    pub fn create_instance(&self) -> super::builder::parallelstore::CreateInstance {
159        super::builder::parallelstore::CreateInstance::new(self.inner.clone())
160    }
161
162    /// Updates the parameters of a single instance.
163    ///
164    /// # Long running operations
165    ///
166    /// This method is used to start, and/or poll a [long-running Operation].
167    /// The [Working with long-running operations] chapter in the [user guide]
168    /// covers these operations in detail.
169    ///
170    /// [long-running operation]: https://google.aip.dev/151
171    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
172    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
173    pub fn update_instance(&self) -> super::builder::parallelstore::UpdateInstance {
174        super::builder::parallelstore::UpdateInstance::new(self.inner.clone())
175    }
176
177    /// Deletes a single instance.
178    ///
179    /// # Long running operations
180    ///
181    /// This method is used to start, and/or poll a [long-running Operation].
182    /// The [Working with long-running operations] chapter in the [user guide]
183    /// covers these operations in detail.
184    ///
185    /// [long-running operation]: https://google.aip.dev/151
186    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
187    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
188    pub fn delete_instance(&self) -> super::builder::parallelstore::DeleteInstance {
189        super::builder::parallelstore::DeleteInstance::new(self.inner.clone())
190    }
191
192    /// Copies data from Cloud Storage to Parallelstore.
193    ///
194    /// # Long running operations
195    ///
196    /// This method is used to start, and/or poll a [long-running Operation].
197    /// The [Working with long-running operations] chapter in the [user guide]
198    /// covers these operations in detail.
199    ///
200    /// [long-running operation]: https://google.aip.dev/151
201    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
202    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
203    pub fn import_data(&self) -> super::builder::parallelstore::ImportData {
204        super::builder::parallelstore::ImportData::new(self.inner.clone())
205    }
206
207    /// Copies data from Parallelstore to Cloud Storage.
208    ///
209    /// # Long running operations
210    ///
211    /// This method is used to start, and/or poll a [long-running Operation].
212    /// The [Working with long-running operations] chapter in the [user guide]
213    /// covers these operations in detail.
214    ///
215    /// [long-running operation]: https://google.aip.dev/151
216    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
217    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
218    pub fn export_data(&self) -> super::builder::parallelstore::ExportData {
219        super::builder::parallelstore::ExportData::new(self.inner.clone())
220    }
221
222    /// Lists information about the supported locations for this service.
223    pub fn list_locations(&self) -> super::builder::parallelstore::ListLocations {
224        super::builder::parallelstore::ListLocations::new(self.inner.clone())
225    }
226
227    /// Gets information about a location.
228    pub fn get_location(&self) -> super::builder::parallelstore::GetLocation {
229        super::builder::parallelstore::GetLocation::new(self.inner.clone())
230    }
231
232    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
233    ///
234    /// [google.longrunning.Operations]: longrunning::client::Operations
235    pub fn list_operations(&self) -> super::builder::parallelstore::ListOperations {
236        super::builder::parallelstore::ListOperations::new(self.inner.clone())
237    }
238
239    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
240    ///
241    /// [google.longrunning.Operations]: longrunning::client::Operations
242    pub fn get_operation(&self) -> super::builder::parallelstore::GetOperation {
243        super::builder::parallelstore::GetOperation::new(self.inner.clone())
244    }
245
246    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
247    ///
248    /// [google.longrunning.Operations]: longrunning::client::Operations
249    pub fn delete_operation(&self) -> super::builder::parallelstore::DeleteOperation {
250        super::builder::parallelstore::DeleteOperation::new(self.inner.clone())
251    }
252
253    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
254    ///
255    /// [google.longrunning.Operations]: longrunning::client::Operations
256    pub fn cancel_operation(&self) -> super::builder::parallelstore::CancelOperation {
257        super::builder::parallelstore::CancelOperation::new(self.inner.clone())
258    }
259}