Skip to main content

google_cloud_hypercomputecluster_v1/
client.rs

1// Copyright 2026 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 Cluster Director API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
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 = HypercomputeCluster::builder().build().await?;
32///     let mut list = client.list_clusters()
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///
46/// # Configuration
47///
48/// To configure `HypercomputeCluster` use the `with_*` methods in the type returned
49/// by [builder()][HypercomputeCluster::builder]. The default configuration should
50/// work for most applications. Common configuration changes include
51///
52/// * [with_endpoint()]: by default this client uses the global default endpoint
53///   (`https://hypercomputecluster.googleapis.com`). Applications using regional
54///   endpoints or running in restricted networks (e.g. a network configured
55///   with [Private Google Access with VPC Service Controls]) may want to
56///   override this default.
57/// * [with_credentials()]: by default this client uses
58///   [Application Default Credentials]. Applications using custom
59///   authentication may need to override this default.
60///
61/// [with_endpoint()]: super::builder::hypercompute_cluster::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::hypercompute_cluster::ClientBuilder::with_credentials
63/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
64/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
65///
66/// # Pooling and Cloning
67///
68/// `HypercomputeCluster` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `HypercomputeCluster` in
70/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
71/// already uses an `Arc` internally.
72#[derive(Clone, Debug)]
73pub struct HypercomputeCluster {
74    inner: std::sync::Arc<dyn super::stub::dynamic::HypercomputeCluster>,
75}
76
77impl HypercomputeCluster {
78    /// Returns a builder for [HypercomputeCluster].
79    ///
80    /// ```
81    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
83    /// let client = HypercomputeCluster::builder().build().await?;
84    /// # Ok(()) }
85    /// ```
86    pub fn builder() -> super::builder::hypercompute_cluster::ClientBuilder {
87        crate::new_client_builder(super::builder::hypercompute_cluster::client::Factory)
88    }
89
90    /// Creates a new client from the provided stub.
91    ///
92    /// The most common case for calling this function is in tests mocking the
93    /// client's behavior.
94    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
95    where
96        T: super::stub::HypercomputeCluster + 'static,
97    {
98        Self { inner: stub.into() }
99    }
100
101    pub(crate) async fn new(
102        config: gaxi::options::ClientConfig,
103    ) -> crate::ClientBuilderResult<Self> {
104        let inner = Self::build_inner(config).await?;
105        Ok(Self { inner })
106    }
107
108    async fn build_inner(
109        conf: gaxi::options::ClientConfig,
110    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::HypercomputeCluster>>
111    {
112        if gaxi::options::tracing_enabled(&conf) {
113            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
114        }
115        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
116    }
117
118    async fn build_transport(
119        conf: gaxi::options::ClientConfig,
120    ) -> crate::ClientBuilderResult<impl super::stub::HypercomputeCluster> {
121        super::transport::HypercomputeCluster::new(conf).await
122    }
123
124    async fn build_with_tracing(
125        conf: gaxi::options::ClientConfig,
126    ) -> crate::ClientBuilderResult<impl super::stub::HypercomputeCluster> {
127        Self::build_transport(conf)
128            .await
129            .map(super::tracing::HypercomputeCluster::new)
130    }
131
132    /// Lists Clusters in a given project and location.
133    ///
134    /// # Example
135    /// ```
136    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
137    /// use google_cloud_gax::paginator::ItemPaginator as _;
138    /// use google_cloud_hypercomputecluster_v1::Result;
139    /// async fn sample(
140    ///    client: &HypercomputeCluster, project_id: &str, location_id: &str
141    /// ) -> Result<()> {
142    ///     let mut list = client.list_clusters()
143    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
144    ///         .by_item();
145    ///     while let Some(item) = list.next().await.transpose()? {
146    ///         println!("{:?}", item);
147    ///     }
148    ///     Ok(())
149    /// }
150    /// ```
151    pub fn list_clusters(&self) -> super::builder::hypercompute_cluster::ListClusters {
152        super::builder::hypercompute_cluster::ListClusters::new(self.inner.clone())
153    }
154
155    /// Gets details of a single Cluster.
156    ///
157    /// # Example
158    /// ```
159    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
160    /// use google_cloud_hypercomputecluster_v1::Result;
161    /// async fn sample(
162    ///    client: &HypercomputeCluster, project_id: &str, location_id: &str, cluster_id: &str
163    /// ) -> Result<()> {
164    ///     let response = client.get_cluster()
165    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/clusters/{cluster_id}"))
166    ///         .send().await?;
167    ///     println!("response {:?}", response);
168    ///     Ok(())
169    /// }
170    /// ```
171    pub fn get_cluster(&self) -> super::builder::hypercompute_cluster::GetCluster {
172        super::builder::hypercompute_cluster::GetCluster::new(self.inner.clone())
173    }
174
175    /// Creates a new Cluster in a given project and location.
176    ///
177    /// # Long running operations
178    ///
179    /// This method is used to start, and/or poll a [long-running Operation].
180    /// The [Working with long-running operations] chapter in the [user guide]
181    /// covers these operations in detail.
182    ///
183    /// [long-running operation]: https://google.aip.dev/151
184    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
185    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
186    ///
187    /// # Example
188    /// ```
189    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
190    /// use google_cloud_lro::Poller;
191    /// use google_cloud_hypercomputecluster_v1::model::Cluster;
192    /// use google_cloud_hypercomputecluster_v1::Result;
193    /// async fn sample(
194    ///    client: &HypercomputeCluster, project_id: &str, location_id: &str
195    /// ) -> Result<()> {
196    ///     let response = client.create_cluster()
197    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
198    ///         .set_cluster_id("cluster_id_value")
199    ///         .set_cluster(
200    ///             Cluster::new()/* set fields */
201    ///         )
202    ///         .poller().until_done().await?;
203    ///     println!("response {:?}", response);
204    ///     Ok(())
205    /// }
206    /// ```
207    pub fn create_cluster(&self) -> super::builder::hypercompute_cluster::CreateCluster {
208        super::builder::hypercompute_cluster::CreateCluster::new(self.inner.clone())
209    }
210
211    /// Updates the parameters of a single Cluster.
212    ///
213    /// # Long running operations
214    ///
215    /// This method is used to start, and/or poll a [long-running Operation].
216    /// The [Working with long-running operations] chapter in the [user guide]
217    /// covers these operations in detail.
218    ///
219    /// [long-running operation]: https://google.aip.dev/151
220    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
221    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
222    ///
223    /// # Example
224    /// ```
225    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
226    /// use google_cloud_lro::Poller;
227    /// # extern crate wkt as google_cloud_wkt;
228    /// use google_cloud_wkt::FieldMask;
229    /// use google_cloud_hypercomputecluster_v1::model::Cluster;
230    /// use google_cloud_hypercomputecluster_v1::Result;
231    /// async fn sample(
232    ///    client: &HypercomputeCluster, project_id: &str, location_id: &str, cluster_id: &str
233    /// ) -> Result<()> {
234    ///     let response = client.update_cluster()
235    ///         .set_cluster(
236    ///             Cluster::new().set_name(format!("projects/{project_id}/locations/{location_id}/clusters/{cluster_id}"))/* set fields */
237    ///         )
238    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
239    ///         .poller().until_done().await?;
240    ///     println!("response {:?}", response);
241    ///     Ok(())
242    /// }
243    /// ```
244    pub fn update_cluster(&self) -> super::builder::hypercompute_cluster::UpdateCluster {
245        super::builder::hypercompute_cluster::UpdateCluster::new(self.inner.clone())
246    }
247
248    /// Deletes a single Cluster.
249    ///
250    /// # Long running operations
251    ///
252    /// This method is used to start, and/or poll a [long-running Operation].
253    /// The [Working with long-running operations] chapter in the [user guide]
254    /// covers these operations in detail.
255    ///
256    /// [long-running operation]: https://google.aip.dev/151
257    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
258    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
259    ///
260    /// # Example
261    /// ```
262    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
263    /// use google_cloud_lro::Poller;
264    /// use google_cloud_hypercomputecluster_v1::Result;
265    /// async fn sample(
266    ///    client: &HypercomputeCluster, project_id: &str, location_id: &str, cluster_id: &str
267    /// ) -> Result<()> {
268    ///     client.delete_cluster()
269    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/clusters/{cluster_id}"))
270    ///         .poller().until_done().await?;
271    ///     Ok(())
272    /// }
273    /// ```
274    pub fn delete_cluster(&self) -> super::builder::hypercompute_cluster::DeleteCluster {
275        super::builder::hypercompute_cluster::DeleteCluster::new(self.inner.clone())
276    }
277
278    /// Lists information about the supported locations for this service.
279    /// This method can be called in two ways:
280    ///
281    /// * **List all public locations:** Use the path `GET /v1/locations`.
282    /// * **List project-visible locations:** Use the path
283    ///   `GET /v1/projects/{project_id}/locations`. This may include public
284    ///   locations as well as private or other locations specifically visible
285    ///   to the project.
286    ///
287    /// # Example
288    /// ```
289    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
290    /// use google_cloud_gax::paginator::ItemPaginator as _;
291    /// use google_cloud_hypercomputecluster_v1::Result;
292    /// async fn sample(
293    ///    client: &HypercomputeCluster
294    /// ) -> Result<()> {
295    ///     let mut list = client.list_locations()
296    ///         /* set fields */
297    ///         .by_item();
298    ///     while let Some(item) = list.next().await.transpose()? {
299    ///         println!("{:?}", item);
300    ///     }
301    ///     Ok(())
302    /// }
303    /// ```
304    pub fn list_locations(&self) -> super::builder::hypercompute_cluster::ListLocations {
305        super::builder::hypercompute_cluster::ListLocations::new(self.inner.clone())
306    }
307
308    /// Gets information about a location.
309    ///
310    /// # Example
311    /// ```
312    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
313    /// use google_cloud_hypercomputecluster_v1::Result;
314    /// async fn sample(
315    ///    client: &HypercomputeCluster
316    /// ) -> Result<()> {
317    ///     let response = client.get_location()
318    ///         /* set fields */
319    ///         .send().await?;
320    ///     println!("response {:?}", response);
321    ///     Ok(())
322    /// }
323    /// ```
324    pub fn get_location(&self) -> super::builder::hypercompute_cluster::GetLocation {
325        super::builder::hypercompute_cluster::GetLocation::new(self.inner.clone())
326    }
327
328    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
329    ///
330    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
331    ///
332    /// # Example
333    /// ```
334    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
335    /// use google_cloud_gax::paginator::ItemPaginator as _;
336    /// use google_cloud_hypercomputecluster_v1::Result;
337    /// async fn sample(
338    ///    client: &HypercomputeCluster
339    /// ) -> Result<()> {
340    ///     let mut list = client.list_operations()
341    ///         /* set fields */
342    ///         .by_item();
343    ///     while let Some(item) = list.next().await.transpose()? {
344    ///         println!("{:?}", item);
345    ///     }
346    ///     Ok(())
347    /// }
348    /// ```
349    pub fn list_operations(&self) -> super::builder::hypercompute_cluster::ListOperations {
350        super::builder::hypercompute_cluster::ListOperations::new(self.inner.clone())
351    }
352
353    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
354    ///
355    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
356    ///
357    /// # Example
358    /// ```
359    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
360    /// use google_cloud_hypercomputecluster_v1::Result;
361    /// async fn sample(
362    ///    client: &HypercomputeCluster
363    /// ) -> Result<()> {
364    ///     let response = client.get_operation()
365    ///         /* set fields */
366    ///         .send().await?;
367    ///     println!("response {:?}", response);
368    ///     Ok(())
369    /// }
370    /// ```
371    pub fn get_operation(&self) -> super::builder::hypercompute_cluster::GetOperation {
372        super::builder::hypercompute_cluster::GetOperation::new(self.inner.clone())
373    }
374
375    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
376    ///
377    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
378    ///
379    /// # Example
380    /// ```
381    /// # use google_cloud_hypercomputecluster_v1::client::HypercomputeCluster;
382    /// use google_cloud_hypercomputecluster_v1::Result;
383    /// async fn sample(
384    ///    client: &HypercomputeCluster
385    /// ) -> Result<()> {
386    ///     client.delete_operation()
387    ///         /* set fields */
388    ///         .send().await?;
389    ///     Ok(())
390    /// }
391    /// ```
392    pub fn delete_operation(&self) -> super::builder::hypercompute_cluster::DeleteOperation {
393        super::builder::hypercompute_cluster::DeleteOperation::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_hypercomputecluster_v1::client::HypercomputeCluster;
403    /// use google_cloud_hypercomputecluster_v1::Result;
404    /// async fn sample(
405    ///    client: &HypercomputeCluster
406    /// ) -> Result<()> {
407    ///     client.cancel_operation()
408    ///         /* set fields */
409    ///         .send().await?;
410    ///     Ok(())
411    /// }
412    /// ```
413    pub fn cancel_operation(&self) -> super::builder::hypercompute_cluster::CancelOperation {
414        super::builder::hypercompute_cluster::CancelOperation::new(self.inner.clone())
415    }
416}