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