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/// # async fn sample() -> gax::client_builder::Result<()> {
24/// # use google_cloud_workstations_v1::client::Workstations;
25/// let client = Workstations::builder().build().await?;
26/// // use `client` to make requests to the Cloud Workstations API.
27/// # Ok(()) }
28/// ```
29///
30/// # Service Description
31///
32/// Service for interacting with Cloud Workstations.
33///
34/// # Configuration
35///
36/// To configure `Workstations` use the `with_*` methods in the type returned
37/// by [builder()][Workstations::builder]. The default configuration should
38/// work for most applications. Common configuration changes include
39///
40/// * [with_endpoint()]: by default this client uses the global default endpoint
41/// (`https://workstations.googleapis.com`). Applications using regional
42/// endpoints or running in restricted networks (e.g. a network configured
43// with [Private Google Access with VPC Service Controls]) may want to
44/// override this default.
45/// * [with_credentials()]: by default this client uses
46/// [Application Default Credentials]. Applications using custom
47/// authentication may need to override this default.
48///
49/// [with_endpoint()]: super::builder::workstations::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::workstations::ClientBuilder::credentials
51/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
52/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
53///
54/// # Pooling and Cloning
55///
56/// `Workstations` holds a connection pool internally, it is advised to
57/// create one and the reuse it. You do not need to wrap `Workstations` in
58/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
59/// already uses an `Arc` internally.
60#[derive(Clone, Debug)]
61pub struct Workstations {
62 inner: std::sync::Arc<dyn super::stub::dynamic::Workstations>,
63}
64
65impl Workstations {
66 /// Returns a builder for [Workstations].
67 ///
68 /// ```
69 /// # async fn sample() -> gax::client_builder::Result<()> {
70 /// # use google_cloud_workstations_v1::client::Workstations;
71 /// let client = Workstations::builder().build().await?;
72 /// # Ok(()) }
73 /// ```
74 pub fn builder() -> super::builder::workstations::ClientBuilder {
75 gax::client_builder::internal::new_builder(super::builder::workstations::client::Factory)
76 }
77
78 /// Creates a new client from the provided stub.
79 ///
80 /// The most common case for calling this function is in tests mocking the
81 /// client's behavior.
82 pub fn from_stub<T>(stub: T) -> Self
83 where
84 T: super::stub::Workstations + 'static,
85 {
86 Self {
87 inner: std::sync::Arc::new(stub),
88 }
89 }
90
91 pub(crate) async fn new(
92 config: gaxi::options::ClientConfig,
93 ) -> gax::client_builder::Result<Self> {
94 let inner = Self::build_inner(config).await?;
95 Ok(Self { inner })
96 }
97
98 async fn build_inner(
99 conf: gaxi::options::ClientConfig,
100 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Workstations>> {
101 if gaxi::options::tracing_enabled(&conf) {
102 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
103 }
104 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
105 }
106
107 async fn build_transport(
108 conf: gaxi::options::ClientConfig,
109 ) -> gax::client_builder::Result<impl super::stub::Workstations> {
110 super::transport::Workstations::new(conf).await
111 }
112
113 async fn build_with_tracing(
114 conf: gaxi::options::ClientConfig,
115 ) -> gax::client_builder::Result<impl super::stub::Workstations> {
116 Self::build_transport(conf)
117 .await
118 .map(super::tracing::Workstations::new)
119 }
120
121 /// Returns the requested workstation cluster.
122 pub fn get_workstation_cluster(&self) -> super::builder::workstations::GetWorkstationCluster {
123 super::builder::workstations::GetWorkstationCluster::new(self.inner.clone())
124 }
125
126 /// Returns all workstation clusters in the specified location.
127 pub fn list_workstation_clusters(
128 &self,
129 ) -> super::builder::workstations::ListWorkstationClusters {
130 super::builder::workstations::ListWorkstationClusters::new(self.inner.clone())
131 }
132
133 /// Creates a new workstation cluster.
134 ///
135 /// # Long running operations
136 ///
137 /// This method is used to start, and/or poll a [long-running Operation].
138 /// The [Working with long-running operations] chapter in the [user guide]
139 /// covers these operations in detail.
140 ///
141 /// [long-running operation]: https://google.aip.dev/151
142 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
143 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
144 pub fn create_workstation_cluster(
145 &self,
146 ) -> super::builder::workstations::CreateWorkstationCluster {
147 super::builder::workstations::CreateWorkstationCluster::new(self.inner.clone())
148 }
149
150 /// Updates an existing workstation cluster.
151 ///
152 /// # Long running operations
153 ///
154 /// This method is used to start, and/or poll a [long-running Operation].
155 /// The [Working with long-running operations] chapter in the [user guide]
156 /// covers these operations in detail.
157 ///
158 /// [long-running operation]: https://google.aip.dev/151
159 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
160 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
161 pub fn update_workstation_cluster(
162 &self,
163 ) -> super::builder::workstations::UpdateWorkstationCluster {
164 super::builder::workstations::UpdateWorkstationCluster::new(self.inner.clone())
165 }
166
167 /// Deletes the specified workstation cluster.
168 ///
169 /// # Long running operations
170 ///
171 /// This method is used to start, and/or poll a [long-running Operation].
172 /// The [Working with long-running operations] chapter in the [user guide]
173 /// covers these operations in detail.
174 ///
175 /// [long-running operation]: https://google.aip.dev/151
176 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
177 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
178 pub fn delete_workstation_cluster(
179 &self,
180 ) -> super::builder::workstations::DeleteWorkstationCluster {
181 super::builder::workstations::DeleteWorkstationCluster::new(self.inner.clone())
182 }
183
184 /// Returns the requested workstation configuration.
185 pub fn get_workstation_config(&self) -> super::builder::workstations::GetWorkstationConfig {
186 super::builder::workstations::GetWorkstationConfig::new(self.inner.clone())
187 }
188
189 /// Returns all workstation configurations in the specified cluster.
190 pub fn list_workstation_configs(&self) -> super::builder::workstations::ListWorkstationConfigs {
191 super::builder::workstations::ListWorkstationConfigs::new(self.inner.clone())
192 }
193
194 /// Returns all workstation configurations in the specified cluster on which
195 /// the caller has the "workstations.workstation.create" permission.
196 pub fn list_usable_workstation_configs(
197 &self,
198 ) -> super::builder::workstations::ListUsableWorkstationConfigs {
199 super::builder::workstations::ListUsableWorkstationConfigs::new(self.inner.clone())
200 }
201
202 /// Creates a new workstation configuration.
203 ///
204 /// # Long running operations
205 ///
206 /// This method is used to start, and/or poll a [long-running Operation].
207 /// The [Working with long-running operations] chapter in the [user guide]
208 /// covers these operations in detail.
209 ///
210 /// [long-running operation]: https://google.aip.dev/151
211 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
212 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
213 pub fn create_workstation_config(
214 &self,
215 ) -> super::builder::workstations::CreateWorkstationConfig {
216 super::builder::workstations::CreateWorkstationConfig::new(self.inner.clone())
217 }
218
219 /// Updates an existing workstation configuration.
220 ///
221 /// # Long running operations
222 ///
223 /// This method is used to start, and/or poll a [long-running Operation].
224 /// The [Working with long-running operations] chapter in the [user guide]
225 /// covers these operations in detail.
226 ///
227 /// [long-running operation]: https://google.aip.dev/151
228 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
229 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
230 pub fn update_workstation_config(
231 &self,
232 ) -> super::builder::workstations::UpdateWorkstationConfig {
233 super::builder::workstations::UpdateWorkstationConfig::new(self.inner.clone())
234 }
235
236 /// Deletes the specified workstation configuration.
237 ///
238 /// # Long running operations
239 ///
240 /// This method is used to start, and/or poll a [long-running Operation].
241 /// The [Working with long-running operations] chapter in the [user guide]
242 /// covers these operations in detail.
243 ///
244 /// [long-running operation]: https://google.aip.dev/151
245 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
246 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
247 pub fn delete_workstation_config(
248 &self,
249 ) -> super::builder::workstations::DeleteWorkstationConfig {
250 super::builder::workstations::DeleteWorkstationConfig::new(self.inner.clone())
251 }
252
253 /// Returns the requested workstation.
254 pub fn get_workstation(&self) -> super::builder::workstations::GetWorkstation {
255 super::builder::workstations::GetWorkstation::new(self.inner.clone())
256 }
257
258 /// Returns all Workstations using the specified workstation configuration.
259 pub fn list_workstations(&self) -> super::builder::workstations::ListWorkstations {
260 super::builder::workstations::ListWorkstations::new(self.inner.clone())
261 }
262
263 /// Returns all workstations using the specified workstation configuration
264 /// on which the caller has the "workstations.workstations.use" permission.
265 pub fn list_usable_workstations(&self) -> super::builder::workstations::ListUsableWorkstations {
266 super::builder::workstations::ListUsableWorkstations::new(self.inner.clone())
267 }
268
269 /// Creates a new workstation.
270 ///
271 /// # Long running operations
272 ///
273 /// This method is used to start, and/or poll a [long-running Operation].
274 /// The [Working with long-running operations] chapter in the [user guide]
275 /// covers these operations in detail.
276 ///
277 /// [long-running operation]: https://google.aip.dev/151
278 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
279 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
280 pub fn create_workstation(&self) -> super::builder::workstations::CreateWorkstation {
281 super::builder::workstations::CreateWorkstation::new(self.inner.clone())
282 }
283
284 /// Updates an existing workstation.
285 ///
286 /// # Long running operations
287 ///
288 /// This method is used to start, and/or poll a [long-running Operation].
289 /// The [Working with long-running operations] chapter in the [user guide]
290 /// covers these operations in detail.
291 ///
292 /// [long-running operation]: https://google.aip.dev/151
293 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
294 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
295 pub fn update_workstation(&self) -> super::builder::workstations::UpdateWorkstation {
296 super::builder::workstations::UpdateWorkstation::new(self.inner.clone())
297 }
298
299 /// Deletes the specified workstation.
300 ///
301 /// # Long running operations
302 ///
303 /// This method is used to start, and/or poll a [long-running Operation].
304 /// The [Working with long-running operations] chapter in the [user guide]
305 /// covers these operations in detail.
306 ///
307 /// [long-running operation]: https://google.aip.dev/151
308 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
309 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
310 pub fn delete_workstation(&self) -> super::builder::workstations::DeleteWorkstation {
311 super::builder::workstations::DeleteWorkstation::new(self.inner.clone())
312 }
313
314 /// Starts running a workstation so that users can connect to it.
315 ///
316 /// # Long running operations
317 ///
318 /// This method is used to start, and/or poll a [long-running Operation].
319 /// The [Working with long-running operations] chapter in the [user guide]
320 /// covers these operations in detail.
321 ///
322 /// [long-running operation]: https://google.aip.dev/151
323 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
324 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
325 pub fn start_workstation(&self) -> super::builder::workstations::StartWorkstation {
326 super::builder::workstations::StartWorkstation::new(self.inner.clone())
327 }
328
329 /// Stops running a workstation, reducing costs.
330 ///
331 /// # Long running operations
332 ///
333 /// This method is used to start, and/or poll a [long-running Operation].
334 /// The [Working with long-running operations] chapter in the [user guide]
335 /// covers these operations in detail.
336 ///
337 /// [long-running operation]: https://google.aip.dev/151
338 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
339 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
340 pub fn stop_workstation(&self) -> super::builder::workstations::StopWorkstation {
341 super::builder::workstations::StopWorkstation::new(self.inner.clone())
342 }
343
344 /// Returns a short-lived credential that can be used to send authenticated and
345 /// authorized traffic to a workstation.
346 pub fn generate_access_token(&self) -> super::builder::workstations::GenerateAccessToken {
347 super::builder::workstations::GenerateAccessToken::new(self.inner.clone())
348 }
349
350 /// Sets the access control policy on the specified resource. Replaces
351 /// any existing policy.
352 ///
353 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
354 /// errors.
355 pub fn set_iam_policy(&self) -> super::builder::workstations::SetIamPolicy {
356 super::builder::workstations::SetIamPolicy::new(self.inner.clone())
357 }
358
359 /// Gets the access control policy for a resource. Returns an empty policy
360 /// if the resource exists and does not have a policy set.
361 pub fn get_iam_policy(&self) -> super::builder::workstations::GetIamPolicy {
362 super::builder::workstations::GetIamPolicy::new(self.inner.clone())
363 }
364
365 /// Returns permissions that a caller has on the specified resource. If the
366 /// resource does not exist, this will return an empty set of
367 /// permissions, not a `NOT_FOUND` error.
368 ///
369 /// Note: This operation is designed to be used for building
370 /// permission-aware UIs and command-line tools, not for authorization
371 /// checking. This operation may "fail open" without warning.
372 pub fn test_iam_permissions(&self) -> super::builder::workstations::TestIamPermissions {
373 super::builder::workstations::TestIamPermissions::new(self.inner.clone())
374 }
375
376 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
377 ///
378 /// [google.longrunning.Operations]: longrunning::client::Operations
379 pub fn list_operations(&self) -> super::builder::workstations::ListOperations {
380 super::builder::workstations::ListOperations::new(self.inner.clone())
381 }
382
383 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
384 ///
385 /// [google.longrunning.Operations]: longrunning::client::Operations
386 pub fn get_operation(&self) -> super::builder::workstations::GetOperation {
387 super::builder::workstations::GetOperation::new(self.inner.clone())
388 }
389
390 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
391 ///
392 /// [google.longrunning.Operations]: longrunning::client::Operations
393 pub fn delete_operation(&self) -> super::builder::workstations::DeleteOperation {
394 super::builder::workstations::DeleteOperation::new(self.inner.clone())
395 }
396
397 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
398 ///
399 /// [google.longrunning.Operations]: longrunning::client::Operations
400 pub fn cancel_operation(&self) -> super::builder::workstations::CancelOperation {
401 super::builder::workstations::CancelOperation::new(self.inner.clone())
402 }
403}