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