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