google_cloud_workstations_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 Cloud Workstations API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_workstations_v1::client::Workstations;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// async fn sample(
26/// project_id: &str,
27/// location_id: &str,
28/// workstation_cluster_id: &str,
29/// workstation_config_id: &str,
30/// ) -> anyhow::Result<()> {
31/// let client = Workstations::builder().build().await?;
32/// let mut list = client.list_workstations()
33/// .set_parent(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_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 for interacting with Cloud Workstations.
45///
46/// # Configuration
47///
48/// To configure `Workstations` use the `with_*` methods in the type returned
49/// by [builder()][Workstations::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://workstations.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::workstations::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::workstations::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/// `Workstations` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `Workstations` 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 Workstations {
74 inner: std::sync::Arc<dyn super::stub::dynamic::Workstations>,
75}
76
77impl Workstations {
78 /// Returns a builder for [Workstations].
79 ///
80 /// ```
81 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82 /// # use google_cloud_workstations_v1::client::Workstations;
83 /// let client = Workstations::builder().build().await?;
84 /// # Ok(()) }
85 /// ```
86 pub fn builder() -> super::builder::workstations::ClientBuilder {
87 crate::new_client_builder(super::builder::workstations::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::Workstations + '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::Workstations>> {
111 if gaxi::options::tracing_enabled(&conf) {
112 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
113 }
114 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
115 }
116
117 async fn build_transport(
118 conf: gaxi::options::ClientConfig,
119 ) -> crate::ClientBuilderResult<impl super::stub::Workstations> {
120 super::transport::Workstations::new(conf).await
121 }
122
123 async fn build_with_tracing(
124 conf: gaxi::options::ClientConfig,
125 ) -> crate::ClientBuilderResult<impl super::stub::Workstations> {
126 Self::build_transport(conf)
127 .await
128 .map(super::tracing::Workstations::new)
129 }
130
131 /// Returns the requested workstation cluster.
132 ///
133 /// # Example
134 /// ```
135 /// # use google_cloud_workstations_v1::client::Workstations;
136 /// use google_cloud_workstations_v1::Result;
137 /// async fn sample(
138 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str
139 /// ) -> Result<()> {
140 /// let response = client.get_workstation_cluster()
141 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}"))
142 /// .send().await?;
143 /// println!("response {:?}", response);
144 /// Ok(())
145 /// }
146 /// ```
147 pub fn get_workstation_cluster(&self) -> super::builder::workstations::GetWorkstationCluster {
148 super::builder::workstations::GetWorkstationCluster::new(self.inner.clone())
149 }
150
151 /// Returns all workstation clusters in the specified location.
152 ///
153 /// # Example
154 /// ```
155 /// # use google_cloud_workstations_v1::client::Workstations;
156 /// use google_cloud_gax::paginator::ItemPaginator as _;
157 /// use google_cloud_workstations_v1::Result;
158 /// async fn sample(
159 /// client: &Workstations, project_id: &str, location_id: &str
160 /// ) -> Result<()> {
161 /// let mut list = client.list_workstation_clusters()
162 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
163 /// .by_item();
164 /// while let Some(item) = list.next().await.transpose()? {
165 /// println!("{:?}", item);
166 /// }
167 /// Ok(())
168 /// }
169 /// ```
170 pub fn list_workstation_clusters(
171 &self,
172 ) -> super::builder::workstations::ListWorkstationClusters {
173 super::builder::workstations::ListWorkstationClusters::new(self.inner.clone())
174 }
175
176 /// Creates a new workstation cluster.
177 ///
178 /// # Long running operations
179 ///
180 /// This method is used to start, and/or poll a [long-running Operation].
181 /// The [Working with long-running operations] chapter in the [user guide]
182 /// covers these operations in detail.
183 ///
184 /// [long-running operation]: https://google.aip.dev/151
185 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
186 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
187 ///
188 /// # Example
189 /// ```
190 /// # use google_cloud_workstations_v1::client::Workstations;
191 /// use google_cloud_lro::Poller;
192 /// use google_cloud_workstations_v1::model::WorkstationCluster;
193 /// use google_cloud_workstations_v1::Result;
194 /// async fn sample(
195 /// client: &Workstations, project_id: &str, location_id: &str
196 /// ) -> Result<()> {
197 /// let response = client.create_workstation_cluster()
198 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
199 /// .set_workstation_cluster(
200 /// WorkstationCluster::new()/* set fields */
201 /// )
202 /// .poller().until_done().await?;
203 /// println!("response {:?}", response);
204 /// Ok(())
205 /// }
206 /// ```
207 pub fn create_workstation_cluster(
208 &self,
209 ) -> super::builder::workstations::CreateWorkstationCluster {
210 super::builder::workstations::CreateWorkstationCluster::new(self.inner.clone())
211 }
212
213 /// Updates an existing workstation cluster.
214 ///
215 /// # Long running operations
216 ///
217 /// This method is used to start, and/or poll a [long-running Operation].
218 /// The [Working with long-running operations] chapter in the [user guide]
219 /// covers these operations in detail.
220 ///
221 /// [long-running operation]: https://google.aip.dev/151
222 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
223 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
224 ///
225 /// # Example
226 /// ```
227 /// # use google_cloud_workstations_v1::client::Workstations;
228 /// use google_cloud_lro::Poller;
229 /// # extern crate wkt as google_cloud_wkt;
230 /// use google_cloud_wkt::FieldMask;
231 /// use google_cloud_workstations_v1::model::WorkstationCluster;
232 /// use google_cloud_workstations_v1::Result;
233 /// async fn sample(
234 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str
235 /// ) -> Result<()> {
236 /// let response = client.update_workstation_cluster()
237 /// .set_workstation_cluster(
238 /// WorkstationCluster::new().set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}"))/* set fields */
239 /// )
240 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
241 /// .poller().until_done().await?;
242 /// println!("response {:?}", response);
243 /// Ok(())
244 /// }
245 /// ```
246 pub fn update_workstation_cluster(
247 &self,
248 ) -> super::builder::workstations::UpdateWorkstationCluster {
249 super::builder::workstations::UpdateWorkstationCluster::new(self.inner.clone())
250 }
251
252 /// Deletes the specified workstation cluster.
253 ///
254 /// # Long running operations
255 ///
256 /// This method is used to start, and/or poll a [long-running Operation].
257 /// The [Working with long-running operations] chapter in the [user guide]
258 /// covers these operations in detail.
259 ///
260 /// [long-running operation]: https://google.aip.dev/151
261 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
262 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
263 ///
264 /// # Example
265 /// ```
266 /// # use google_cloud_workstations_v1::client::Workstations;
267 /// use google_cloud_lro::Poller;
268 /// use google_cloud_workstations_v1::Result;
269 /// async fn sample(
270 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str
271 /// ) -> Result<()> {
272 /// let response = client.delete_workstation_cluster()
273 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}"))
274 /// .poller().until_done().await?;
275 /// println!("response {:?}", response);
276 /// Ok(())
277 /// }
278 /// ```
279 pub fn delete_workstation_cluster(
280 &self,
281 ) -> super::builder::workstations::DeleteWorkstationCluster {
282 super::builder::workstations::DeleteWorkstationCluster::new(self.inner.clone())
283 }
284
285 /// Returns the requested workstation configuration.
286 ///
287 /// # Example
288 /// ```
289 /// # use google_cloud_workstations_v1::client::Workstations;
290 /// use google_cloud_workstations_v1::Result;
291 /// async fn sample(
292 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str
293 /// ) -> Result<()> {
294 /// let response = client.get_workstation_config()
295 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}"))
296 /// .send().await?;
297 /// println!("response {:?}", response);
298 /// Ok(())
299 /// }
300 /// ```
301 pub fn get_workstation_config(&self) -> super::builder::workstations::GetWorkstationConfig {
302 super::builder::workstations::GetWorkstationConfig::new(self.inner.clone())
303 }
304
305 /// Returns all workstation configurations in the specified cluster.
306 ///
307 /// # Example
308 /// ```
309 /// # use google_cloud_workstations_v1::client::Workstations;
310 /// use google_cloud_gax::paginator::ItemPaginator as _;
311 /// use google_cloud_workstations_v1::Result;
312 /// async fn sample(
313 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str
314 /// ) -> Result<()> {
315 /// let mut list = client.list_workstation_configs()
316 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}"))
317 /// .by_item();
318 /// while let Some(item) = list.next().await.transpose()? {
319 /// println!("{:?}", item);
320 /// }
321 /// Ok(())
322 /// }
323 /// ```
324 pub fn list_workstation_configs(&self) -> super::builder::workstations::ListWorkstationConfigs {
325 super::builder::workstations::ListWorkstationConfigs::new(self.inner.clone())
326 }
327
328 /// Returns all workstation configurations in the specified cluster on which
329 /// the caller has the "workstations.workstation.create" permission.
330 ///
331 /// # Example
332 /// ```
333 /// # use google_cloud_workstations_v1::client::Workstations;
334 /// use google_cloud_gax::paginator::ItemPaginator as _;
335 /// use google_cloud_workstations_v1::Result;
336 /// async fn sample(
337 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str
338 /// ) -> Result<()> {
339 /// let mut list = client.list_usable_workstation_configs()
340 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}"))
341 /// .by_item();
342 /// while let Some(item) = list.next().await.transpose()? {
343 /// println!("{:?}", item);
344 /// }
345 /// Ok(())
346 /// }
347 /// ```
348 pub fn list_usable_workstation_configs(
349 &self,
350 ) -> super::builder::workstations::ListUsableWorkstationConfigs {
351 super::builder::workstations::ListUsableWorkstationConfigs::new(self.inner.clone())
352 }
353
354 /// Creates a new workstation configuration.
355 ///
356 /// # Long running operations
357 ///
358 /// This method is used to start, and/or poll a [long-running Operation].
359 /// The [Working with long-running operations] chapter in the [user guide]
360 /// covers these operations in detail.
361 ///
362 /// [long-running operation]: https://google.aip.dev/151
363 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
364 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
365 ///
366 /// # Example
367 /// ```
368 /// # use google_cloud_workstations_v1::client::Workstations;
369 /// use google_cloud_lro::Poller;
370 /// use google_cloud_workstations_v1::model::WorkstationConfig;
371 /// use google_cloud_workstations_v1::Result;
372 /// async fn sample(
373 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str
374 /// ) -> Result<()> {
375 /// let response = client.create_workstation_config()
376 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}"))
377 /// .set_workstation_config(
378 /// WorkstationConfig::new()/* set fields */
379 /// )
380 /// .poller().until_done().await?;
381 /// println!("response {:?}", response);
382 /// Ok(())
383 /// }
384 /// ```
385 pub fn create_workstation_config(
386 &self,
387 ) -> super::builder::workstations::CreateWorkstationConfig {
388 super::builder::workstations::CreateWorkstationConfig::new(self.inner.clone())
389 }
390
391 /// Updates an existing workstation configuration.
392 ///
393 /// # Long running operations
394 ///
395 /// This method is used to start, and/or poll a [long-running Operation].
396 /// The [Working with long-running operations] chapter in the [user guide]
397 /// covers these operations in detail.
398 ///
399 /// [long-running operation]: https://google.aip.dev/151
400 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
401 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
402 ///
403 /// # Example
404 /// ```
405 /// # use google_cloud_workstations_v1::client::Workstations;
406 /// use google_cloud_lro::Poller;
407 /// # extern crate wkt as google_cloud_wkt;
408 /// use google_cloud_wkt::FieldMask;
409 /// use google_cloud_workstations_v1::model::WorkstationConfig;
410 /// use google_cloud_workstations_v1::Result;
411 /// async fn sample(
412 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str
413 /// ) -> Result<()> {
414 /// let response = client.update_workstation_config()
415 /// .set_workstation_config(
416 /// WorkstationConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}"))/* set fields */
417 /// )
418 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
419 /// .poller().until_done().await?;
420 /// println!("response {:?}", response);
421 /// Ok(())
422 /// }
423 /// ```
424 pub fn update_workstation_config(
425 &self,
426 ) -> super::builder::workstations::UpdateWorkstationConfig {
427 super::builder::workstations::UpdateWorkstationConfig::new(self.inner.clone())
428 }
429
430 /// Deletes the specified workstation configuration.
431 ///
432 /// # Long running operations
433 ///
434 /// This method is used to start, and/or poll a [long-running Operation].
435 /// The [Working with long-running operations] chapter in the [user guide]
436 /// covers these operations in detail.
437 ///
438 /// [long-running operation]: https://google.aip.dev/151
439 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
440 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
441 ///
442 /// # Example
443 /// ```
444 /// # use google_cloud_workstations_v1::client::Workstations;
445 /// use google_cloud_lro::Poller;
446 /// use google_cloud_workstations_v1::Result;
447 /// async fn sample(
448 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str
449 /// ) -> Result<()> {
450 /// let response = client.delete_workstation_config()
451 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}"))
452 /// .poller().until_done().await?;
453 /// println!("response {:?}", response);
454 /// Ok(())
455 /// }
456 /// ```
457 pub fn delete_workstation_config(
458 &self,
459 ) -> super::builder::workstations::DeleteWorkstationConfig {
460 super::builder::workstations::DeleteWorkstationConfig::new(self.inner.clone())
461 }
462
463 /// Returns the requested workstation.
464 ///
465 /// # Example
466 /// ```
467 /// # use google_cloud_workstations_v1::client::Workstations;
468 /// use google_cloud_workstations_v1::Result;
469 /// async fn sample(
470 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str, workstation_id: &str
471 /// ) -> Result<()> {
472 /// let response = client.get_workstation()
473 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}/workstations/{workstation_id}"))
474 /// .send().await?;
475 /// println!("response {:?}", response);
476 /// Ok(())
477 /// }
478 /// ```
479 pub fn get_workstation(&self) -> super::builder::workstations::GetWorkstation {
480 super::builder::workstations::GetWorkstation::new(self.inner.clone())
481 }
482
483 /// Returns all Workstations using the specified workstation configuration.
484 ///
485 /// # Example
486 /// ```
487 /// # use google_cloud_workstations_v1::client::Workstations;
488 /// use google_cloud_gax::paginator::ItemPaginator as _;
489 /// use google_cloud_workstations_v1::Result;
490 /// async fn sample(
491 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str
492 /// ) -> Result<()> {
493 /// let mut list = client.list_workstations()
494 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}"))
495 /// .by_item();
496 /// while let Some(item) = list.next().await.transpose()? {
497 /// println!("{:?}", item);
498 /// }
499 /// Ok(())
500 /// }
501 /// ```
502 pub fn list_workstations(&self) -> super::builder::workstations::ListWorkstations {
503 super::builder::workstations::ListWorkstations::new(self.inner.clone())
504 }
505
506 /// Returns all workstations using the specified workstation configuration
507 /// on which the caller has the "workstations.workstations.use" permission.
508 ///
509 /// # Example
510 /// ```
511 /// # use google_cloud_workstations_v1::client::Workstations;
512 /// use google_cloud_gax::paginator::ItemPaginator as _;
513 /// use google_cloud_workstations_v1::Result;
514 /// async fn sample(
515 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str
516 /// ) -> Result<()> {
517 /// let mut list = client.list_usable_workstations()
518 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}"))
519 /// .by_item();
520 /// while let Some(item) = list.next().await.transpose()? {
521 /// println!("{:?}", item);
522 /// }
523 /// Ok(())
524 /// }
525 /// ```
526 pub fn list_usable_workstations(&self) -> super::builder::workstations::ListUsableWorkstations {
527 super::builder::workstations::ListUsableWorkstations::new(self.inner.clone())
528 }
529
530 /// Creates a new workstation.
531 ///
532 /// # Long running operations
533 ///
534 /// This method is used to start, and/or poll a [long-running Operation].
535 /// The [Working with long-running operations] chapter in the [user guide]
536 /// covers these operations in detail.
537 ///
538 /// [long-running operation]: https://google.aip.dev/151
539 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
540 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
541 ///
542 /// # Example
543 /// ```
544 /// # use google_cloud_workstations_v1::client::Workstations;
545 /// use google_cloud_lro::Poller;
546 /// use google_cloud_workstations_v1::model::Workstation;
547 /// use google_cloud_workstations_v1::Result;
548 /// async fn sample(
549 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str
550 /// ) -> Result<()> {
551 /// let response = client.create_workstation()
552 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}"))
553 /// .set_workstation_id("workstation_id_value")
554 /// .set_workstation(
555 /// Workstation::new()/* set fields */
556 /// )
557 /// .poller().until_done().await?;
558 /// println!("response {:?}", response);
559 /// Ok(())
560 /// }
561 /// ```
562 pub fn create_workstation(&self) -> super::builder::workstations::CreateWorkstation {
563 super::builder::workstations::CreateWorkstation::new(self.inner.clone())
564 }
565
566 /// Updates an existing workstation.
567 ///
568 /// # Long running operations
569 ///
570 /// This method is used to start, and/or poll a [long-running Operation].
571 /// The [Working with long-running operations] chapter in the [user guide]
572 /// covers these operations in detail.
573 ///
574 /// [long-running operation]: https://google.aip.dev/151
575 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
576 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
577 ///
578 /// # Example
579 /// ```
580 /// # use google_cloud_workstations_v1::client::Workstations;
581 /// use google_cloud_lro::Poller;
582 /// # extern crate wkt as google_cloud_wkt;
583 /// use google_cloud_wkt::FieldMask;
584 /// use google_cloud_workstations_v1::model::Workstation;
585 /// use google_cloud_workstations_v1::Result;
586 /// async fn sample(
587 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str, workstation_id: &str
588 /// ) -> Result<()> {
589 /// let response = client.update_workstation()
590 /// .set_workstation(
591 /// Workstation::new().set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}/workstations/{workstation_id}"))/* set fields */
592 /// )
593 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
594 /// .poller().until_done().await?;
595 /// println!("response {:?}", response);
596 /// Ok(())
597 /// }
598 /// ```
599 pub fn update_workstation(&self) -> super::builder::workstations::UpdateWorkstation {
600 super::builder::workstations::UpdateWorkstation::new(self.inner.clone())
601 }
602
603 /// Deletes the specified workstation.
604 ///
605 /// # Long running operations
606 ///
607 /// This method is used to start, and/or poll a [long-running Operation].
608 /// The [Working with long-running operations] chapter in the [user guide]
609 /// covers these operations in detail.
610 ///
611 /// [long-running operation]: https://google.aip.dev/151
612 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
613 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
614 ///
615 /// # Example
616 /// ```
617 /// # use google_cloud_workstations_v1::client::Workstations;
618 /// use google_cloud_lro::Poller;
619 /// use google_cloud_workstations_v1::Result;
620 /// async fn sample(
621 /// client: &Workstations, project_id: &str, location_id: &str, workstation_cluster_id: &str, workstation_config_id: &str, workstation_id: &str
622 /// ) -> Result<()> {
623 /// let response = client.delete_workstation()
624 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workstationClusters/{workstation_cluster_id}/workstationConfigs/{workstation_config_id}/workstations/{workstation_id}"))
625 /// .poller().until_done().await?;
626 /// println!("response {:?}", response);
627 /// Ok(())
628 /// }
629 /// ```
630 pub fn delete_workstation(&self) -> super::builder::workstations::DeleteWorkstation {
631 super::builder::workstations::DeleteWorkstation::new(self.inner.clone())
632 }
633
634 /// Starts running a workstation so that users can connect to it.
635 ///
636 /// # Long running operations
637 ///
638 /// This method is used to start, and/or poll a [long-running Operation].
639 /// The [Working with long-running operations] chapter in the [user guide]
640 /// covers these operations in detail.
641 ///
642 /// [long-running operation]: https://google.aip.dev/151
643 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
644 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
645 ///
646 /// # Example
647 /// ```
648 /// # use google_cloud_workstations_v1::client::Workstations;
649 /// use google_cloud_lro::Poller;
650 /// use google_cloud_workstations_v1::Result;
651 /// async fn sample(
652 /// client: &Workstations
653 /// ) -> Result<()> {
654 /// let response = client.start_workstation()
655 /// /* set fields */
656 /// .poller().until_done().await?;
657 /// println!("response {:?}", response);
658 /// Ok(())
659 /// }
660 /// ```
661 pub fn start_workstation(&self) -> super::builder::workstations::StartWorkstation {
662 super::builder::workstations::StartWorkstation::new(self.inner.clone())
663 }
664
665 /// Stops running a workstation, reducing costs.
666 ///
667 /// # Long running operations
668 ///
669 /// This method is used to start, and/or poll a [long-running Operation].
670 /// The [Working with long-running operations] chapter in the [user guide]
671 /// covers these operations in detail.
672 ///
673 /// [long-running operation]: https://google.aip.dev/151
674 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
675 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
676 ///
677 /// # Example
678 /// ```
679 /// # use google_cloud_workstations_v1::client::Workstations;
680 /// use google_cloud_lro::Poller;
681 /// use google_cloud_workstations_v1::Result;
682 /// async fn sample(
683 /// client: &Workstations
684 /// ) -> Result<()> {
685 /// let response = client.stop_workstation()
686 /// /* set fields */
687 /// .poller().until_done().await?;
688 /// println!("response {:?}", response);
689 /// Ok(())
690 /// }
691 /// ```
692 pub fn stop_workstation(&self) -> super::builder::workstations::StopWorkstation {
693 super::builder::workstations::StopWorkstation::new(self.inner.clone())
694 }
695
696 /// Returns a short-lived credential that can be used to send authenticated and
697 /// authorized traffic to a workstation.
698 ///
699 /// # Example
700 /// ```
701 /// # use google_cloud_workstations_v1::client::Workstations;
702 /// use google_cloud_workstations_v1::Result;
703 /// async fn sample(
704 /// client: &Workstations
705 /// ) -> Result<()> {
706 /// let response = client.generate_access_token()
707 /// /* set fields */
708 /// .send().await?;
709 /// println!("response {:?}", response);
710 /// Ok(())
711 /// }
712 /// ```
713 pub fn generate_access_token(&self) -> super::builder::workstations::GenerateAccessToken {
714 super::builder::workstations::GenerateAccessToken::new(self.inner.clone())
715 }
716
717 /// Sets the access control policy on the specified resource. Replaces
718 /// any existing policy.
719 ///
720 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
721 /// errors.
722 ///
723 /// # Example
724 /// ```
725 /// # use google_cloud_workstations_v1::client::Workstations;
726 /// use google_cloud_workstations_v1::Result;
727 /// async fn sample(
728 /// client: &Workstations
729 /// ) -> Result<()> {
730 /// let response = client.set_iam_policy()
731 /// /* set fields */
732 /// .send().await?;
733 /// println!("response {:?}", response);
734 /// Ok(())
735 /// }
736 /// ```
737 pub fn set_iam_policy(&self) -> super::builder::workstations::SetIamPolicy {
738 super::builder::workstations::SetIamPolicy::new(self.inner.clone())
739 }
740
741 /// Gets the access control policy for a resource. Returns an empty policy
742 /// if the resource exists and does not have a policy set.
743 ///
744 /// # Example
745 /// ```
746 /// # use google_cloud_workstations_v1::client::Workstations;
747 /// use google_cloud_workstations_v1::Result;
748 /// async fn sample(
749 /// client: &Workstations
750 /// ) -> Result<()> {
751 /// let response = client.get_iam_policy()
752 /// /* set fields */
753 /// .send().await?;
754 /// println!("response {:?}", response);
755 /// Ok(())
756 /// }
757 /// ```
758 pub fn get_iam_policy(&self) -> super::builder::workstations::GetIamPolicy {
759 super::builder::workstations::GetIamPolicy::new(self.inner.clone())
760 }
761
762 /// Returns permissions that a caller has on the specified resource. If the
763 /// resource does not exist, this will return an empty set of
764 /// permissions, not a `NOT_FOUND` error.
765 ///
766 /// Note: This operation is designed to be used for building
767 /// permission-aware UIs and command-line tools, not for authorization
768 /// checking. This operation may "fail open" without warning.
769 ///
770 /// # Example
771 /// ```
772 /// # use google_cloud_workstations_v1::client::Workstations;
773 /// use google_cloud_workstations_v1::Result;
774 /// async fn sample(
775 /// client: &Workstations
776 /// ) -> Result<()> {
777 /// let response = client.test_iam_permissions()
778 /// /* set fields */
779 /// .send().await?;
780 /// println!("response {:?}", response);
781 /// Ok(())
782 /// }
783 /// ```
784 pub fn test_iam_permissions(&self) -> super::builder::workstations::TestIamPermissions {
785 super::builder::workstations::TestIamPermissions::new(self.inner.clone())
786 }
787
788 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
789 ///
790 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
791 ///
792 /// # Example
793 /// ```
794 /// # use google_cloud_workstations_v1::client::Workstations;
795 /// use google_cloud_gax::paginator::ItemPaginator as _;
796 /// use google_cloud_workstations_v1::Result;
797 /// async fn sample(
798 /// client: &Workstations
799 /// ) -> Result<()> {
800 /// let mut list = client.list_operations()
801 /// /* set fields */
802 /// .by_item();
803 /// while let Some(item) = list.next().await.transpose()? {
804 /// println!("{:?}", item);
805 /// }
806 /// Ok(())
807 /// }
808 /// ```
809 pub fn list_operations(&self) -> super::builder::workstations::ListOperations {
810 super::builder::workstations::ListOperations::new(self.inner.clone())
811 }
812
813 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
814 ///
815 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
816 ///
817 /// # Example
818 /// ```
819 /// # use google_cloud_workstations_v1::client::Workstations;
820 /// use google_cloud_workstations_v1::Result;
821 /// async fn sample(
822 /// client: &Workstations
823 /// ) -> Result<()> {
824 /// let response = client.get_operation()
825 /// /* set fields */
826 /// .send().await?;
827 /// println!("response {:?}", response);
828 /// Ok(())
829 /// }
830 /// ```
831 pub fn get_operation(&self) -> super::builder::workstations::GetOperation {
832 super::builder::workstations::GetOperation::new(self.inner.clone())
833 }
834
835 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
836 ///
837 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
838 ///
839 /// # Example
840 /// ```
841 /// # use google_cloud_workstations_v1::client::Workstations;
842 /// use google_cloud_workstations_v1::Result;
843 /// async fn sample(
844 /// client: &Workstations
845 /// ) -> Result<()> {
846 /// client.delete_operation()
847 /// /* set fields */
848 /// .send().await?;
849 /// Ok(())
850 /// }
851 /// ```
852 pub fn delete_operation(&self) -> super::builder::workstations::DeleteOperation {
853 super::builder::workstations::DeleteOperation::new(self.inner.clone())
854 }
855
856 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
857 ///
858 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
859 ///
860 /// # Example
861 /// ```
862 /// # use google_cloud_workstations_v1::client::Workstations;
863 /// use google_cloud_workstations_v1::Result;
864 /// async fn sample(
865 /// client: &Workstations
866 /// ) -> Result<()> {
867 /// client.cancel_operation()
868 /// /* set fields */
869 /// .send().await?;
870 /// Ok(())
871 /// }
872 /// ```
873 pub fn cancel_operation(&self) -> super::builder::workstations::CancelOperation {
874 super::builder::workstations::CancelOperation::new(self.inner.clone())
875 }
876}