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::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Parallelstore API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_parallelstore_v1::client::Parallelstore;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// project_id: &str,
29/// location_id: &str,
30/// ) -> anyhow::Result<()> {
31/// let client = Parallelstore::builder().build().await?;
32/// let mut list = client.list_instances()
33/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
34/// .by_item();
35/// while let Some(item) = list.next().await.transpose()? {
36/// println!("{:?}", item);
37/// }
38/// Ok(())
39/// }
40/// ```
41///
42/// # Service Description
43///
44/// Service describing handlers for resources
45/// Configures and manages parallelstore resources.
46///
47/// Parallelstore service.
48///
49/// The `parallelstore.googleapis.com` service implements the parallelstore API
50/// and defines the following resource model for managing instances:
51///
52/// * The service works with a collection of cloud projects, named: `/projects/*`
53/// * Each project has a collection of available locations, named: `/locations/*`
54/// * Each location has a collection of instances named `/instances/*`.
55/// * Parallelstore instances are resources of the form:
56/// `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
57///
58/// Note that location_id must be a Google Cloud `zone`; for example:
59///
60/// * `projects/12345/locations/us-central1-c/instances/my-parallelstore-share`
61///
62/// # Configuration
63///
64/// To configure `Parallelstore` use the `with_*` methods in the type returned
65/// by [builder()][Parallelstore::builder]. The default configuration should
66/// work for most applications. Common configuration changes include
67///
68/// * [with_endpoint()]: by default this client uses the global default endpoint
69/// (`https://parallelstore.googleapis.com`). Applications using regional
70/// endpoints or running in restricted networks (e.g. a network configured
71/// with [Private Google Access with VPC Service Controls]) may want to
72/// override this default.
73/// * [with_credentials()]: by default this client uses
74/// [Application Default Credentials]. Applications using custom
75/// authentication may need to override this default.
76///
77/// [with_endpoint()]: super::builder::parallelstore::ClientBuilder::with_endpoint
78/// [with_credentials()]: super::builder::parallelstore::ClientBuilder::with_credentials
79/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
80/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
81///
82/// # Pooling and Cloning
83///
84/// `Parallelstore` holds a connection pool internally, it is advised to
85/// create one and reuse it. You do not need to wrap `Parallelstore` in
86/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
87/// already uses an `Arc` internally.
88#[derive(Clone, Debug)]
89pub struct Parallelstore {
90 inner: std::sync::Arc<dyn super::stub::dynamic::Parallelstore>,
91}
92
93impl Parallelstore {
94 /// Returns a builder for [Parallelstore].
95 ///
96 /// ```
97 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
98 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
99 /// let client = Parallelstore::builder().build().await?;
100 /// # Ok(()) }
101 /// ```
102 pub fn builder() -> super::builder::parallelstore::ClientBuilder {
103 crate::new_client_builder(super::builder::parallelstore::client::Factory)
104 }
105
106 /// Creates a new client from the provided stub.
107 ///
108 /// The most common case for calling this function is in tests mocking the
109 /// client's behavior.
110 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
111 where
112 T: super::stub::Parallelstore + 'static,
113 {
114 Self { inner: stub.into() }
115 }
116
117 pub(crate) async fn new(
118 config: gaxi::options::ClientConfig,
119 ) -> crate::ClientBuilderResult<Self> {
120 let inner = Self::build_inner(config).await?;
121 Ok(Self { inner })
122 }
123
124 async fn build_inner(
125 conf: gaxi::options::ClientConfig,
126 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Parallelstore>> {
127 if gaxi::options::tracing_enabled(&conf) {
128 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
129 }
130 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
131 }
132
133 async fn build_transport(
134 conf: gaxi::options::ClientConfig,
135 ) -> crate::ClientBuilderResult<impl super::stub::Parallelstore> {
136 super::transport::Parallelstore::new(conf).await
137 }
138
139 async fn build_with_tracing(
140 conf: gaxi::options::ClientConfig,
141 ) -> crate::ClientBuilderResult<impl super::stub::Parallelstore> {
142 Self::build_transport(conf)
143 .await
144 .map(super::tracing::Parallelstore::new)
145 }
146
147 /// Lists all instances in a given project and location.
148 ///
149 /// # Example
150 /// ```
151 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
152 /// use google_cloud_gax::paginator::ItemPaginator as _;
153 /// use google_cloud_parallelstore_v1::Result;
154 /// async fn sample(
155 /// client: &Parallelstore, project_id: &str, location_id: &str
156 /// ) -> Result<()> {
157 /// let mut list = client.list_instances()
158 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
159 /// .by_item();
160 /// while let Some(item) = list.next().await.transpose()? {
161 /// println!("{:?}", item);
162 /// }
163 /// Ok(())
164 /// }
165 /// ```
166 pub fn list_instances(&self) -> super::builder::parallelstore::ListInstances {
167 super::builder::parallelstore::ListInstances::new(self.inner.clone())
168 }
169
170 /// Gets details of a single instance.
171 ///
172 /// # Example
173 /// ```
174 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
175 /// use google_cloud_parallelstore_v1::Result;
176 /// async fn sample(
177 /// client: &Parallelstore, project_id: &str, location_id: &str, instance_id: &str
178 /// ) -> Result<()> {
179 /// let response = client.get_instance()
180 /// .set_name(format!("projects/{project_id}/locations/{location_id}/instances/{instance_id}"))
181 /// .send().await?;
182 /// println!("response {:?}", response);
183 /// Ok(())
184 /// }
185 /// ```
186 pub fn get_instance(&self) -> super::builder::parallelstore::GetInstance {
187 super::builder::parallelstore::GetInstance::new(self.inner.clone())
188 }
189
190 /// Creates a Parallelstore instance in a given project and location.
191 ///
192 /// # Long running operations
193 ///
194 /// This method is used to start, and/or poll a [long-running Operation].
195 /// The [Working with long-running operations] chapter in the [user guide]
196 /// covers these operations in detail.
197 ///
198 /// [long-running operation]: https://google.aip.dev/151
199 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
200 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
201 ///
202 /// # Example
203 /// ```
204 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
205 /// use google_cloud_lro::Poller;
206 /// use google_cloud_parallelstore_v1::model::Instance;
207 /// use google_cloud_parallelstore_v1::Result;
208 /// async fn sample(
209 /// client: &Parallelstore, project_id: &str, location_id: &str
210 /// ) -> Result<()> {
211 /// let response = client.create_instance()
212 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
213 /// .set_instance_id("instance_id_value")
214 /// .set_instance(
215 /// Instance::new()/* set fields */
216 /// )
217 /// .poller().until_done().await?;
218 /// println!("response {:?}", response);
219 /// Ok(())
220 /// }
221 /// ```
222 pub fn create_instance(&self) -> super::builder::parallelstore::CreateInstance {
223 super::builder::parallelstore::CreateInstance::new(self.inner.clone())
224 }
225
226 /// Updates the parameters of a single instance.
227 ///
228 /// # Long running operations
229 ///
230 /// This method is used to start, and/or poll a [long-running Operation].
231 /// The [Working with long-running operations] chapter in the [user guide]
232 /// covers these operations in detail.
233 ///
234 /// [long-running operation]: https://google.aip.dev/151
235 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
236 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
237 ///
238 /// # Example
239 /// ```
240 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
241 /// use google_cloud_lro::Poller;
242 /// # extern crate wkt as google_cloud_wkt;
243 /// use google_cloud_wkt::FieldMask;
244 /// use google_cloud_parallelstore_v1::model::Instance;
245 /// use google_cloud_parallelstore_v1::Result;
246 /// async fn sample(
247 /// client: &Parallelstore, project_id: &str, location_id: &str, instance_id: &str
248 /// ) -> Result<()> {
249 /// let response = client.update_instance()
250 /// .set_instance(
251 /// Instance::new().set_name(format!("projects/{project_id}/locations/{location_id}/instances/{instance_id}"))/* set fields */
252 /// )
253 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
254 /// .poller().until_done().await?;
255 /// println!("response {:?}", response);
256 /// Ok(())
257 /// }
258 /// ```
259 pub fn update_instance(&self) -> super::builder::parallelstore::UpdateInstance {
260 super::builder::parallelstore::UpdateInstance::new(self.inner.clone())
261 }
262
263 /// Deletes a single instance.
264 ///
265 /// # Long running operations
266 ///
267 /// This method is used to start, and/or poll a [long-running Operation].
268 /// The [Working with long-running operations] chapter in the [user guide]
269 /// covers these operations in detail.
270 ///
271 /// [long-running operation]: https://google.aip.dev/151
272 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
273 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
274 ///
275 /// # Example
276 /// ```
277 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
278 /// use google_cloud_lro::Poller;
279 /// use google_cloud_parallelstore_v1::Result;
280 /// async fn sample(
281 /// client: &Parallelstore, project_id: &str, location_id: &str, instance_id: &str
282 /// ) -> Result<()> {
283 /// client.delete_instance()
284 /// .set_name(format!("projects/{project_id}/locations/{location_id}/instances/{instance_id}"))
285 /// .poller().until_done().await?;
286 /// Ok(())
287 /// }
288 /// ```
289 pub fn delete_instance(&self) -> super::builder::parallelstore::DeleteInstance {
290 super::builder::parallelstore::DeleteInstance::new(self.inner.clone())
291 }
292
293 /// Copies data from Cloud Storage to Parallelstore.
294 ///
295 /// # Long running operations
296 ///
297 /// This method is used to start, and/or poll a [long-running Operation].
298 /// The [Working with long-running operations] chapter in the [user guide]
299 /// covers these operations in detail.
300 ///
301 /// [long-running operation]: https://google.aip.dev/151
302 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
303 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
304 ///
305 /// # Example
306 /// ```
307 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
308 /// use google_cloud_lro::Poller;
309 /// use google_cloud_parallelstore_v1::Result;
310 /// async fn sample(
311 /// client: &Parallelstore
312 /// ) -> Result<()> {
313 /// let response = client.import_data()
314 /// /* set fields */
315 /// .poller().until_done().await?;
316 /// println!("response {:?}", response);
317 /// Ok(())
318 /// }
319 /// ```
320 pub fn import_data(&self) -> super::builder::parallelstore::ImportData {
321 super::builder::parallelstore::ImportData::new(self.inner.clone())
322 }
323
324 /// Copies data from Parallelstore to Cloud Storage.
325 ///
326 /// # Long running operations
327 ///
328 /// This method is used to start, and/or poll a [long-running Operation].
329 /// The [Working with long-running operations] chapter in the [user guide]
330 /// covers these operations in detail.
331 ///
332 /// [long-running operation]: https://google.aip.dev/151
333 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
334 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
335 ///
336 /// # Example
337 /// ```
338 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
339 /// use google_cloud_lro::Poller;
340 /// use google_cloud_parallelstore_v1::Result;
341 /// async fn sample(
342 /// client: &Parallelstore
343 /// ) -> Result<()> {
344 /// let response = client.export_data()
345 /// /* set fields */
346 /// .poller().until_done().await?;
347 /// println!("response {:?}", response);
348 /// Ok(())
349 /// }
350 /// ```
351 pub fn export_data(&self) -> super::builder::parallelstore::ExportData {
352 super::builder::parallelstore::ExportData::new(self.inner.clone())
353 }
354
355 /// Lists information about the supported locations for this service.
356 ///
357 /// # Example
358 /// ```
359 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
360 /// use google_cloud_gax::paginator::ItemPaginator as _;
361 /// use google_cloud_parallelstore_v1::Result;
362 /// async fn sample(
363 /// client: &Parallelstore
364 /// ) -> Result<()> {
365 /// let mut list = client.list_locations()
366 /// /* set fields */
367 /// .by_item();
368 /// while let Some(item) = list.next().await.transpose()? {
369 /// println!("{:?}", item);
370 /// }
371 /// Ok(())
372 /// }
373 /// ```
374 pub fn list_locations(&self) -> super::builder::parallelstore::ListLocations {
375 super::builder::parallelstore::ListLocations::new(self.inner.clone())
376 }
377
378 /// Gets information about a location.
379 ///
380 /// # Example
381 /// ```
382 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
383 /// use google_cloud_parallelstore_v1::Result;
384 /// async fn sample(
385 /// client: &Parallelstore
386 /// ) -> Result<()> {
387 /// let response = client.get_location()
388 /// /* set fields */
389 /// .send().await?;
390 /// println!("response {:?}", response);
391 /// Ok(())
392 /// }
393 /// ```
394 pub fn get_location(&self) -> super::builder::parallelstore::GetLocation {
395 super::builder::parallelstore::GetLocation::new(self.inner.clone())
396 }
397
398 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
399 ///
400 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
401 ///
402 /// # Example
403 /// ```
404 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
405 /// use google_cloud_gax::paginator::ItemPaginator as _;
406 /// use google_cloud_parallelstore_v1::Result;
407 /// async fn sample(
408 /// client: &Parallelstore
409 /// ) -> Result<()> {
410 /// let mut list = client.list_operations()
411 /// /* set fields */
412 /// .by_item();
413 /// while let Some(item) = list.next().await.transpose()? {
414 /// println!("{:?}", item);
415 /// }
416 /// Ok(())
417 /// }
418 /// ```
419 pub fn list_operations(&self) -> super::builder::parallelstore::ListOperations {
420 super::builder::parallelstore::ListOperations::new(self.inner.clone())
421 }
422
423 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
424 ///
425 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
426 ///
427 /// # Example
428 /// ```
429 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
430 /// use google_cloud_parallelstore_v1::Result;
431 /// async fn sample(
432 /// client: &Parallelstore
433 /// ) -> Result<()> {
434 /// let response = client.get_operation()
435 /// /* set fields */
436 /// .send().await?;
437 /// println!("response {:?}", response);
438 /// Ok(())
439 /// }
440 /// ```
441 pub fn get_operation(&self) -> super::builder::parallelstore::GetOperation {
442 super::builder::parallelstore::GetOperation::new(self.inner.clone())
443 }
444
445 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
446 ///
447 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
448 ///
449 /// # Example
450 /// ```
451 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
452 /// use google_cloud_parallelstore_v1::Result;
453 /// async fn sample(
454 /// client: &Parallelstore
455 /// ) -> Result<()> {
456 /// client.delete_operation()
457 /// /* set fields */
458 /// .send().await?;
459 /// Ok(())
460 /// }
461 /// ```
462 pub fn delete_operation(&self) -> super::builder::parallelstore::DeleteOperation {
463 super::builder::parallelstore::DeleteOperation::new(self.inner.clone())
464 }
465
466 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
467 ///
468 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
469 ///
470 /// # Example
471 /// ```
472 /// # use google_cloud_parallelstore_v1::client::Parallelstore;
473 /// use google_cloud_parallelstore_v1::Result;
474 /// async fn sample(
475 /// client: &Parallelstore
476 /// ) -> Result<()> {
477 /// client.cancel_operation()
478 /// /* set fields */
479 /// .send().await?;
480 /// Ok(())
481 /// }
482 /// ```
483 pub fn cancel_operation(&self) -> super::builder::parallelstore::CancelOperation {
484 super::builder::parallelstore::CancelOperation::new(self.inner.clone())
485 }
486}