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