google_cloud_dataproc_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 Dataproc API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
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 = AutoscalingPolicyService::builder().build().await?;
30/// let mut list = client.list_autoscaling_policies()
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/// The API interface for managing autoscaling policies in the
43/// Dataproc API.
44///
45/// # Configuration
46///
47/// To configure `AutoscalingPolicyService` use the `with_*` methods in the type returned
48/// by [builder()][AutoscalingPolicyService::builder]. The default configuration should
49/// work for most applications. Common configuration changes include
50///
51/// * [with_endpoint()]: by default this client uses the global default endpoint
52/// (`https://dataproc.googleapis.com`). Applications using regional
53/// endpoints or running in restricted networks (e.g. a network configured
54/// with [Private Google Access with VPC Service Controls]) may want to
55/// override this default.
56/// * [with_credentials()]: by default this client uses
57/// [Application Default Credentials]. Applications using custom
58/// authentication may need to override this default.
59///
60/// [with_endpoint()]: super::builder::autoscaling_policy_service::ClientBuilder::with_endpoint
61/// [with_credentials()]: super::builder::autoscaling_policy_service::ClientBuilder::with_credentials
62/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
63/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
64///
65/// # Pooling and Cloning
66///
67/// `AutoscalingPolicyService` holds a connection pool internally, it is advised to
68/// create one and reuse it. You do not need to wrap `AutoscalingPolicyService` in
69/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
70/// already uses an `Arc` internally.
71#[derive(Clone, Debug)]
72pub struct AutoscalingPolicyService {
73 inner: std::sync::Arc<dyn super::stub::dynamic::AutoscalingPolicyService>,
74}
75
76impl AutoscalingPolicyService {
77 /// Returns a builder for [AutoscalingPolicyService].
78 ///
79 /// ```
80 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
81 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
82 /// let client = AutoscalingPolicyService::builder().build().await?;
83 /// # Ok(()) }
84 /// ```
85 pub fn builder() -> super::builder::autoscaling_policy_service::ClientBuilder {
86 crate::new_client_builder(super::builder::autoscaling_policy_service::client::Factory)
87 }
88
89 /// Creates a new client from the provided stub.
90 ///
91 /// The most common case for calling this function is in tests mocking the
92 /// client's behavior.
93 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
94 where
95 T: super::stub::AutoscalingPolicyService + 'static,
96 {
97 Self { inner: stub.into() }
98 }
99
100 pub(crate) async fn new(
101 config: gaxi::options::ClientConfig,
102 ) -> crate::ClientBuilderResult<Self> {
103 let inner = Self::build_inner(config).await?;
104 Ok(Self { inner })
105 }
106
107 async fn build_inner(
108 conf: gaxi::options::ClientConfig,
109 ) -> crate::ClientBuilderResult<
110 std::sync::Arc<dyn super::stub::dynamic::AutoscalingPolicyService>,
111 > {
112 if gaxi::options::tracing_enabled(&conf) {
113 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
114 }
115 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
116 }
117
118 async fn build_transport(
119 conf: gaxi::options::ClientConfig,
120 ) -> crate::ClientBuilderResult<impl super::stub::AutoscalingPolicyService> {
121 super::transport::AutoscalingPolicyService::new(conf).await
122 }
123
124 async fn build_with_tracing(
125 conf: gaxi::options::ClientConfig,
126 ) -> crate::ClientBuilderResult<impl super::stub::AutoscalingPolicyService> {
127 Self::build_transport(conf)
128 .await
129 .map(super::tracing::AutoscalingPolicyService::new)
130 }
131
132 /// Creates new autoscaling policy.
133 ///
134 /// # Example
135 /// ```
136 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
137 /// use google_cloud_dataproc_v1::model::AutoscalingPolicy;
138 /// use google_cloud_dataproc_v1::Result;
139 /// async fn sample(
140 /// client: &AutoscalingPolicyService, project_id: &str, location_id: &str
141 /// ) -> Result<()> {
142 /// let response = client.create_autoscaling_policy()
143 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
144 /// .set_policy(
145 /// AutoscalingPolicy::new()/* set fields */
146 /// )
147 /// .send().await?;
148 /// println!("response {:?}", response);
149 /// Ok(())
150 /// }
151 /// ```
152 pub fn create_autoscaling_policy(
153 &self,
154 ) -> super::builder::autoscaling_policy_service::CreateAutoscalingPolicy {
155 super::builder::autoscaling_policy_service::CreateAutoscalingPolicy::new(self.inner.clone())
156 }
157
158 /// Updates (replaces) autoscaling policy.
159 ///
160 /// Disabled check for update_mask, because all updates will be full
161 /// replacements.
162 ///
163 /// # Example
164 /// ```
165 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
166 /// use google_cloud_dataproc_v1::model::AutoscalingPolicy;
167 /// use google_cloud_dataproc_v1::Result;
168 /// async fn sample(
169 /// client: &AutoscalingPolicyService, project_id: &str, location_id: &str, autoscaling_policy_id: &str
170 /// ) -> Result<()> {
171 /// let response = client.update_autoscaling_policy()
172 /// .set_policy(
173 /// AutoscalingPolicy::new().set_name(format!("projects/{project_id}/locations/{location_id}/autoscalingPolicies/{autoscaling_policy_id}"))/* set fields */
174 /// )
175 /// .send().await?;
176 /// println!("response {:?}", response);
177 /// Ok(())
178 /// }
179 /// ```
180 pub fn update_autoscaling_policy(
181 &self,
182 ) -> super::builder::autoscaling_policy_service::UpdateAutoscalingPolicy {
183 super::builder::autoscaling_policy_service::UpdateAutoscalingPolicy::new(self.inner.clone())
184 }
185
186 /// Retrieves autoscaling policy.
187 ///
188 /// # Example
189 /// ```
190 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
191 /// use google_cloud_dataproc_v1::Result;
192 /// async fn sample(
193 /// client: &AutoscalingPolicyService, project_id: &str, location_id: &str, autoscaling_policy_id: &str
194 /// ) -> Result<()> {
195 /// let response = client.get_autoscaling_policy()
196 /// .set_name(format!("projects/{project_id}/locations/{location_id}/autoscalingPolicies/{autoscaling_policy_id}"))
197 /// .send().await?;
198 /// println!("response {:?}", response);
199 /// Ok(())
200 /// }
201 /// ```
202 pub fn get_autoscaling_policy(
203 &self,
204 ) -> super::builder::autoscaling_policy_service::GetAutoscalingPolicy {
205 super::builder::autoscaling_policy_service::GetAutoscalingPolicy::new(self.inner.clone())
206 }
207
208 /// Lists autoscaling policies in the project.
209 ///
210 /// # Example
211 /// ```
212 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
213 /// use google_cloud_gax::paginator::ItemPaginator as _;
214 /// use google_cloud_dataproc_v1::Result;
215 /// async fn sample(
216 /// client: &AutoscalingPolicyService, project_id: &str, location_id: &str
217 /// ) -> Result<()> {
218 /// let mut list = client.list_autoscaling_policies()
219 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
220 /// .by_item();
221 /// while let Some(item) = list.next().await.transpose()? {
222 /// println!("{:?}", item);
223 /// }
224 /// Ok(())
225 /// }
226 /// ```
227 pub fn list_autoscaling_policies(
228 &self,
229 ) -> super::builder::autoscaling_policy_service::ListAutoscalingPolicies {
230 super::builder::autoscaling_policy_service::ListAutoscalingPolicies::new(self.inner.clone())
231 }
232
233 /// Deletes an autoscaling policy. It is an error to delete an autoscaling
234 /// policy that is in use by one or more clusters.
235 ///
236 /// # Example
237 /// ```
238 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
239 /// use google_cloud_dataproc_v1::Result;
240 /// async fn sample(
241 /// client: &AutoscalingPolicyService, project_id: &str, location_id: &str, autoscaling_policy_id: &str
242 /// ) -> Result<()> {
243 /// client.delete_autoscaling_policy()
244 /// .set_name(format!("projects/{project_id}/locations/{location_id}/autoscalingPolicies/{autoscaling_policy_id}"))
245 /// .send().await?;
246 /// Ok(())
247 /// }
248 /// ```
249 pub fn delete_autoscaling_policy(
250 &self,
251 ) -> super::builder::autoscaling_policy_service::DeleteAutoscalingPolicy {
252 super::builder::autoscaling_policy_service::DeleteAutoscalingPolicy::new(self.inner.clone())
253 }
254
255 /// Sets the access control policy on the specified resource. Replaces
256 /// any existing policy.
257 ///
258 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
259 /// errors.
260 ///
261 /// # Example
262 /// ```
263 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
264 /// use google_cloud_dataproc_v1::Result;
265 /// async fn sample(
266 /// client: &AutoscalingPolicyService
267 /// ) -> Result<()> {
268 /// let response = client.set_iam_policy()
269 /// /* set fields */
270 /// .send().await?;
271 /// println!("response {:?}", response);
272 /// Ok(())
273 /// }
274 /// ```
275 pub fn set_iam_policy(&self) -> super::builder::autoscaling_policy_service::SetIamPolicy {
276 super::builder::autoscaling_policy_service::SetIamPolicy::new(self.inner.clone())
277 }
278
279 /// Gets the access control policy for a resource. Returns an empty policy
280 /// if the resource exists and does not have a policy set.
281 ///
282 /// # Example
283 /// ```
284 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
285 /// use google_cloud_dataproc_v1::Result;
286 /// async fn sample(
287 /// client: &AutoscalingPolicyService
288 /// ) -> Result<()> {
289 /// let response = client.get_iam_policy()
290 /// /* set fields */
291 /// .send().await?;
292 /// println!("response {:?}", response);
293 /// Ok(())
294 /// }
295 /// ```
296 pub fn get_iam_policy(&self) -> super::builder::autoscaling_policy_service::GetIamPolicy {
297 super::builder::autoscaling_policy_service::GetIamPolicy::new(self.inner.clone())
298 }
299
300 /// Returns permissions that a caller has on the specified resource. If the
301 /// resource does not exist, this will return an empty set of
302 /// permissions, not a `NOT_FOUND` error.
303 ///
304 /// Note: This operation is designed to be used for building
305 /// permission-aware UIs and command-line tools, not for authorization
306 /// checking. This operation may "fail open" without warning.
307 ///
308 /// # Example
309 /// ```
310 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
311 /// use google_cloud_dataproc_v1::Result;
312 /// async fn sample(
313 /// client: &AutoscalingPolicyService
314 /// ) -> Result<()> {
315 /// let response = client.test_iam_permissions()
316 /// /* set fields */
317 /// .send().await?;
318 /// println!("response {:?}", response);
319 /// Ok(())
320 /// }
321 /// ```
322 pub fn test_iam_permissions(
323 &self,
324 ) -> super::builder::autoscaling_policy_service::TestIamPermissions {
325 super::builder::autoscaling_policy_service::TestIamPermissions::new(self.inner.clone())
326 }
327
328 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
329 ///
330 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
331 ///
332 /// # Example
333 /// ```
334 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
335 /// use google_cloud_gax::paginator::ItemPaginator as _;
336 /// use google_cloud_dataproc_v1::Result;
337 /// async fn sample(
338 /// client: &AutoscalingPolicyService
339 /// ) -> Result<()> {
340 /// let mut list = client.list_operations()
341 /// /* set fields */
342 /// .by_item();
343 /// while let Some(item) = list.next().await.transpose()? {
344 /// println!("{:?}", item);
345 /// }
346 /// Ok(())
347 /// }
348 /// ```
349 pub fn list_operations(&self) -> super::builder::autoscaling_policy_service::ListOperations {
350 super::builder::autoscaling_policy_service::ListOperations::new(self.inner.clone())
351 }
352
353 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
354 ///
355 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
356 ///
357 /// # Example
358 /// ```
359 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
360 /// use google_cloud_dataproc_v1::Result;
361 /// async fn sample(
362 /// client: &AutoscalingPolicyService
363 /// ) -> Result<()> {
364 /// let response = client.get_operation()
365 /// /* set fields */
366 /// .send().await?;
367 /// println!("response {:?}", response);
368 /// Ok(())
369 /// }
370 /// ```
371 pub fn get_operation(&self) -> super::builder::autoscaling_policy_service::GetOperation {
372 super::builder::autoscaling_policy_service::GetOperation::new(self.inner.clone())
373 }
374
375 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
376 ///
377 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
378 ///
379 /// # Example
380 /// ```
381 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
382 /// use google_cloud_dataproc_v1::Result;
383 /// async fn sample(
384 /// client: &AutoscalingPolicyService
385 /// ) -> Result<()> {
386 /// client.delete_operation()
387 /// /* set fields */
388 /// .send().await?;
389 /// Ok(())
390 /// }
391 /// ```
392 pub fn delete_operation(&self) -> super::builder::autoscaling_policy_service::DeleteOperation {
393 super::builder::autoscaling_policy_service::DeleteOperation::new(self.inner.clone())
394 }
395
396 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
397 ///
398 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
399 ///
400 /// # Example
401 /// ```
402 /// # use google_cloud_dataproc_v1::client::AutoscalingPolicyService;
403 /// use google_cloud_dataproc_v1::Result;
404 /// async fn sample(
405 /// client: &AutoscalingPolicyService
406 /// ) -> Result<()> {
407 /// client.cancel_operation()
408 /// /* set fields */
409 /// .send().await?;
410 /// Ok(())
411 /// }
412 /// ```
413 pub fn cancel_operation(&self) -> super::builder::autoscaling_policy_service::CancelOperation {
414 super::builder::autoscaling_policy_service::CancelOperation::new(self.inner.clone())
415 }
416}
417
418/// Implements a client for the Cloud Dataproc API.
419///
420/// # Example
421/// ```
422/// # use google_cloud_dataproc_v1::client::BatchController;
423/// use google_cloud_gax::paginator::ItemPaginator as _;
424/// async fn sample(
425/// project_id: &str,
426/// location_id: &str,
427/// ) -> anyhow::Result<()> {
428/// let client = BatchController::builder().build().await?;
429/// let mut list = client.list_batches()
430/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
431/// .by_item();
432/// while let Some(item) = list.next().await.transpose()? {
433/// println!("{:?}", item);
434/// }
435/// Ok(())
436/// }
437/// ```
438///
439/// # Service Description
440///
441/// The BatchController provides methods to manage batch workloads.
442///
443/// # Configuration
444///
445/// To configure `BatchController` use the `with_*` methods in the type returned
446/// by [builder()][BatchController::builder]. The default configuration should
447/// work for most applications. Common configuration changes include
448///
449/// * [with_endpoint()]: by default this client uses the global default endpoint
450/// (`https://dataproc.googleapis.com`). Applications using regional
451/// endpoints or running in restricted networks (e.g. a network configured
452/// with [Private Google Access with VPC Service Controls]) may want to
453/// override this default.
454/// * [with_credentials()]: by default this client uses
455/// [Application Default Credentials]. Applications using custom
456/// authentication may need to override this default.
457///
458/// [with_endpoint()]: super::builder::batch_controller::ClientBuilder::with_endpoint
459/// [with_credentials()]: super::builder::batch_controller::ClientBuilder::with_credentials
460/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
461/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
462///
463/// # Pooling and Cloning
464///
465/// `BatchController` holds a connection pool internally, it is advised to
466/// create one and reuse it. You do not need to wrap `BatchController` in
467/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
468/// already uses an `Arc` internally.
469#[derive(Clone, Debug)]
470pub struct BatchController {
471 inner: std::sync::Arc<dyn super::stub::dynamic::BatchController>,
472}
473
474impl BatchController {
475 /// Returns a builder for [BatchController].
476 ///
477 /// ```
478 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
479 /// # use google_cloud_dataproc_v1::client::BatchController;
480 /// let client = BatchController::builder().build().await?;
481 /// # Ok(()) }
482 /// ```
483 pub fn builder() -> super::builder::batch_controller::ClientBuilder {
484 crate::new_client_builder(super::builder::batch_controller::client::Factory)
485 }
486
487 /// Creates a new client from the provided stub.
488 ///
489 /// The most common case for calling this function is in tests mocking the
490 /// client's behavior.
491 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
492 where
493 T: super::stub::BatchController + 'static,
494 {
495 Self { inner: stub.into() }
496 }
497
498 pub(crate) async fn new(
499 config: gaxi::options::ClientConfig,
500 ) -> crate::ClientBuilderResult<Self> {
501 let inner = Self::build_inner(config).await?;
502 Ok(Self { inner })
503 }
504
505 async fn build_inner(
506 conf: gaxi::options::ClientConfig,
507 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::BatchController>> {
508 if gaxi::options::tracing_enabled(&conf) {
509 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
510 }
511 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
512 }
513
514 async fn build_transport(
515 conf: gaxi::options::ClientConfig,
516 ) -> crate::ClientBuilderResult<impl super::stub::BatchController> {
517 super::transport::BatchController::new(conf).await
518 }
519
520 async fn build_with_tracing(
521 conf: gaxi::options::ClientConfig,
522 ) -> crate::ClientBuilderResult<impl super::stub::BatchController> {
523 Self::build_transport(conf)
524 .await
525 .map(super::tracing::BatchController::new)
526 }
527
528 /// Creates a batch workload that executes asynchronously.
529 ///
530 /// # Long running operations
531 ///
532 /// This method is used to start, and/or poll a [long-running Operation].
533 /// The [Working with long-running operations] chapter in the [user guide]
534 /// covers these operations in detail.
535 ///
536 /// [long-running operation]: https://google.aip.dev/151
537 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
538 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
539 ///
540 /// # Example
541 /// ```
542 /// # use google_cloud_dataproc_v1::client::BatchController;
543 /// use google_cloud_lro::Poller;
544 /// use google_cloud_dataproc_v1::model::Batch;
545 /// use google_cloud_dataproc_v1::Result;
546 /// async fn sample(
547 /// client: &BatchController, project_id: &str, location_id: &str
548 /// ) -> Result<()> {
549 /// let response = client.create_batch()
550 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
551 /// .set_batch_id("batch_id_value")
552 /// .set_batch(
553 /// Batch::new()/* set fields */
554 /// )
555 /// .poller().until_done().await?;
556 /// println!("response {:?}", response);
557 /// Ok(())
558 /// }
559 /// ```
560 pub fn create_batch(&self) -> super::builder::batch_controller::CreateBatch {
561 super::builder::batch_controller::CreateBatch::new(self.inner.clone())
562 }
563
564 /// Gets the batch workload resource representation.
565 ///
566 /// # Example
567 /// ```
568 /// # use google_cloud_dataproc_v1::client::BatchController;
569 /// use google_cloud_dataproc_v1::Result;
570 /// async fn sample(
571 /// client: &BatchController, project_id: &str, location_id: &str, batch_id: &str
572 /// ) -> Result<()> {
573 /// let response = client.get_batch()
574 /// .set_name(format!("projects/{project_id}/locations/{location_id}/batches/{batch_id}"))
575 /// .send().await?;
576 /// println!("response {:?}", response);
577 /// Ok(())
578 /// }
579 /// ```
580 pub fn get_batch(&self) -> super::builder::batch_controller::GetBatch {
581 super::builder::batch_controller::GetBatch::new(self.inner.clone())
582 }
583
584 /// Lists batch workloads.
585 ///
586 /// # Example
587 /// ```
588 /// # use google_cloud_dataproc_v1::client::BatchController;
589 /// use google_cloud_gax::paginator::ItemPaginator as _;
590 /// use google_cloud_dataproc_v1::Result;
591 /// async fn sample(
592 /// client: &BatchController, project_id: &str, location_id: &str
593 /// ) -> Result<()> {
594 /// let mut list = client.list_batches()
595 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
596 /// .by_item();
597 /// while let Some(item) = list.next().await.transpose()? {
598 /// println!("{:?}", item);
599 /// }
600 /// Ok(())
601 /// }
602 /// ```
603 pub fn list_batches(&self) -> super::builder::batch_controller::ListBatches {
604 super::builder::batch_controller::ListBatches::new(self.inner.clone())
605 }
606
607 /// Deletes the batch workload resource. If the batch is not in a
608 /// `CANCELLED`, `SUCCEEDED` or `FAILED`
609 /// [`State`][google.cloud.dataproc.v1.Batch.State], the delete operation fails
610 /// and the response returns `FAILED_PRECONDITION`.
611 ///
612 /// [google.cloud.dataproc.v1.Batch.State]: crate::model::batch::State
613 ///
614 /// # Example
615 /// ```
616 /// # use google_cloud_dataproc_v1::client::BatchController;
617 /// use google_cloud_dataproc_v1::Result;
618 /// async fn sample(
619 /// client: &BatchController, project_id: &str, location_id: &str, batch_id: &str
620 /// ) -> Result<()> {
621 /// client.delete_batch()
622 /// .set_name(format!("projects/{project_id}/locations/{location_id}/batches/{batch_id}"))
623 /// .send().await?;
624 /// Ok(())
625 /// }
626 /// ```
627 pub fn delete_batch(&self) -> super::builder::batch_controller::DeleteBatch {
628 super::builder::batch_controller::DeleteBatch::new(self.inner.clone())
629 }
630
631 /// Sets the access control policy on the specified resource. Replaces
632 /// any existing policy.
633 ///
634 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
635 /// errors.
636 ///
637 /// # Example
638 /// ```
639 /// # use google_cloud_dataproc_v1::client::BatchController;
640 /// use google_cloud_dataproc_v1::Result;
641 /// async fn sample(
642 /// client: &BatchController
643 /// ) -> Result<()> {
644 /// let response = client.set_iam_policy()
645 /// /* set fields */
646 /// .send().await?;
647 /// println!("response {:?}", response);
648 /// Ok(())
649 /// }
650 /// ```
651 pub fn set_iam_policy(&self) -> super::builder::batch_controller::SetIamPolicy {
652 super::builder::batch_controller::SetIamPolicy::new(self.inner.clone())
653 }
654
655 /// Gets the access control policy for a resource. Returns an empty policy
656 /// if the resource exists and does not have a policy set.
657 ///
658 /// # Example
659 /// ```
660 /// # use google_cloud_dataproc_v1::client::BatchController;
661 /// use google_cloud_dataproc_v1::Result;
662 /// async fn sample(
663 /// client: &BatchController
664 /// ) -> Result<()> {
665 /// let response = client.get_iam_policy()
666 /// /* set fields */
667 /// .send().await?;
668 /// println!("response {:?}", response);
669 /// Ok(())
670 /// }
671 /// ```
672 pub fn get_iam_policy(&self) -> super::builder::batch_controller::GetIamPolicy {
673 super::builder::batch_controller::GetIamPolicy::new(self.inner.clone())
674 }
675
676 /// Returns permissions that a caller has on the specified resource. If the
677 /// resource does not exist, this will return an empty set of
678 /// permissions, not a `NOT_FOUND` error.
679 ///
680 /// Note: This operation is designed to be used for building
681 /// permission-aware UIs and command-line tools, not for authorization
682 /// checking. This operation may "fail open" without warning.
683 ///
684 /// # Example
685 /// ```
686 /// # use google_cloud_dataproc_v1::client::BatchController;
687 /// use google_cloud_dataproc_v1::Result;
688 /// async fn sample(
689 /// client: &BatchController
690 /// ) -> Result<()> {
691 /// let response = client.test_iam_permissions()
692 /// /* set fields */
693 /// .send().await?;
694 /// println!("response {:?}", response);
695 /// Ok(())
696 /// }
697 /// ```
698 pub fn test_iam_permissions(&self) -> super::builder::batch_controller::TestIamPermissions {
699 super::builder::batch_controller::TestIamPermissions::new(self.inner.clone())
700 }
701
702 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
703 ///
704 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
705 ///
706 /// # Example
707 /// ```
708 /// # use google_cloud_dataproc_v1::client::BatchController;
709 /// use google_cloud_gax::paginator::ItemPaginator as _;
710 /// use google_cloud_dataproc_v1::Result;
711 /// async fn sample(
712 /// client: &BatchController
713 /// ) -> Result<()> {
714 /// let mut list = client.list_operations()
715 /// /* set fields */
716 /// .by_item();
717 /// while let Some(item) = list.next().await.transpose()? {
718 /// println!("{:?}", item);
719 /// }
720 /// Ok(())
721 /// }
722 /// ```
723 pub fn list_operations(&self) -> super::builder::batch_controller::ListOperations {
724 super::builder::batch_controller::ListOperations::new(self.inner.clone())
725 }
726
727 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
728 ///
729 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
730 ///
731 /// # Example
732 /// ```
733 /// # use google_cloud_dataproc_v1::client::BatchController;
734 /// use google_cloud_dataproc_v1::Result;
735 /// async fn sample(
736 /// client: &BatchController
737 /// ) -> Result<()> {
738 /// let response = client.get_operation()
739 /// /* set fields */
740 /// .send().await?;
741 /// println!("response {:?}", response);
742 /// Ok(())
743 /// }
744 /// ```
745 pub fn get_operation(&self) -> super::builder::batch_controller::GetOperation {
746 super::builder::batch_controller::GetOperation::new(self.inner.clone())
747 }
748
749 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
750 ///
751 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
752 ///
753 /// # Example
754 /// ```
755 /// # use google_cloud_dataproc_v1::client::BatchController;
756 /// use google_cloud_dataproc_v1::Result;
757 /// async fn sample(
758 /// client: &BatchController
759 /// ) -> Result<()> {
760 /// client.delete_operation()
761 /// /* set fields */
762 /// .send().await?;
763 /// Ok(())
764 /// }
765 /// ```
766 pub fn delete_operation(&self) -> super::builder::batch_controller::DeleteOperation {
767 super::builder::batch_controller::DeleteOperation::new(self.inner.clone())
768 }
769
770 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
771 ///
772 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
773 ///
774 /// # Example
775 /// ```
776 /// # use google_cloud_dataproc_v1::client::BatchController;
777 /// use google_cloud_dataproc_v1::Result;
778 /// async fn sample(
779 /// client: &BatchController
780 /// ) -> Result<()> {
781 /// client.cancel_operation()
782 /// /* set fields */
783 /// .send().await?;
784 /// Ok(())
785 /// }
786 /// ```
787 pub fn cancel_operation(&self) -> super::builder::batch_controller::CancelOperation {
788 super::builder::batch_controller::CancelOperation::new(self.inner.clone())
789 }
790}
791
792/// Implements a client for the Cloud Dataproc API.
793///
794/// # Example
795/// ```
796/// # use google_cloud_dataproc_v1::client::ClusterController;
797/// use google_cloud_lro::Poller;
798/// async fn sample(
799/// ) -> anyhow::Result<()> {
800/// let client = ClusterController::builder().build().await?;
801/// let response = client.create_cluster()
802/// /* set fields */
803/// .poller().until_done().await?;
804/// println!("response {:?}", response);
805/// Ok(())
806/// }
807/// ```
808///
809/// # Service Description
810///
811/// The ClusterControllerService provides methods to manage clusters
812/// of Compute Engine instances.
813///
814/// # Configuration
815///
816/// To configure `ClusterController` use the `with_*` methods in the type returned
817/// by [builder()][ClusterController::builder]. The default configuration should
818/// work for most applications. Common configuration changes include
819///
820/// * [with_endpoint()]: by default this client uses the global default endpoint
821/// (`https://dataproc.googleapis.com`). Applications using regional
822/// endpoints or running in restricted networks (e.g. a network configured
823/// with [Private Google Access with VPC Service Controls]) may want to
824/// override this default.
825/// * [with_credentials()]: by default this client uses
826/// [Application Default Credentials]. Applications using custom
827/// authentication may need to override this default.
828///
829/// [with_endpoint()]: super::builder::cluster_controller::ClientBuilder::with_endpoint
830/// [with_credentials()]: super::builder::cluster_controller::ClientBuilder::with_credentials
831/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
832/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
833///
834/// # Pooling and Cloning
835///
836/// `ClusterController` holds a connection pool internally, it is advised to
837/// create one and reuse it. You do not need to wrap `ClusterController` in
838/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
839/// already uses an `Arc` internally.
840#[derive(Clone, Debug)]
841pub struct ClusterController {
842 inner: std::sync::Arc<dyn super::stub::dynamic::ClusterController>,
843}
844
845impl ClusterController {
846 /// Returns a builder for [ClusterController].
847 ///
848 /// ```
849 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
850 /// # use google_cloud_dataproc_v1::client::ClusterController;
851 /// let client = ClusterController::builder().build().await?;
852 /// # Ok(()) }
853 /// ```
854 pub fn builder() -> super::builder::cluster_controller::ClientBuilder {
855 crate::new_client_builder(super::builder::cluster_controller::client::Factory)
856 }
857
858 /// Creates a new client from the provided stub.
859 ///
860 /// The most common case for calling this function is in tests mocking the
861 /// client's behavior.
862 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
863 where
864 T: super::stub::ClusterController + 'static,
865 {
866 Self { inner: stub.into() }
867 }
868
869 pub(crate) async fn new(
870 config: gaxi::options::ClientConfig,
871 ) -> crate::ClientBuilderResult<Self> {
872 let inner = Self::build_inner(config).await?;
873 Ok(Self { inner })
874 }
875
876 async fn build_inner(
877 conf: gaxi::options::ClientConfig,
878 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ClusterController>>
879 {
880 if gaxi::options::tracing_enabled(&conf) {
881 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
882 }
883 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
884 }
885
886 async fn build_transport(
887 conf: gaxi::options::ClientConfig,
888 ) -> crate::ClientBuilderResult<impl super::stub::ClusterController> {
889 super::transport::ClusterController::new(conf).await
890 }
891
892 async fn build_with_tracing(
893 conf: gaxi::options::ClientConfig,
894 ) -> crate::ClientBuilderResult<impl super::stub::ClusterController> {
895 Self::build_transport(conf)
896 .await
897 .map(super::tracing::ClusterController::new)
898 }
899
900 /// Creates a cluster in a project. The returned
901 /// [Operation.metadata][google.longrunning.Operation.metadata] will be
902 /// [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).
903 ///
904 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
905 ///
906 /// # Long running operations
907 ///
908 /// This method is used to start, and/or poll a [long-running Operation].
909 /// The [Working with long-running operations] chapter in the [user guide]
910 /// covers these operations in detail.
911 ///
912 /// [long-running operation]: https://google.aip.dev/151
913 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
914 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
915 ///
916 /// # Example
917 /// ```
918 /// # use google_cloud_dataproc_v1::client::ClusterController;
919 /// use google_cloud_lro::Poller;
920 /// use google_cloud_dataproc_v1::Result;
921 /// async fn sample(
922 /// client: &ClusterController
923 /// ) -> Result<()> {
924 /// let response = client.create_cluster()
925 /// /* set fields */
926 /// .poller().until_done().await?;
927 /// println!("response {:?}", response);
928 /// Ok(())
929 /// }
930 /// ```
931 pub fn create_cluster(&self) -> super::builder::cluster_controller::CreateCluster {
932 super::builder::cluster_controller::CreateCluster::new(self.inner.clone())
933 }
934
935 /// Updates a cluster in a project. The returned
936 /// [Operation.metadata][google.longrunning.Operation.metadata] will be
937 /// [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).
938 /// The cluster must be in a
939 /// [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error
940 /// is returned.
941 ///
942 /// [google.cloud.dataproc.v1.ClusterStatus.State]: crate::model::cluster_status::State
943 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
944 ///
945 /// # Long running operations
946 ///
947 /// This method is used to start, and/or poll a [long-running Operation].
948 /// The [Working with long-running operations] chapter in the [user guide]
949 /// covers these operations in detail.
950 ///
951 /// [long-running operation]: https://google.aip.dev/151
952 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
953 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
954 ///
955 /// # Example
956 /// ```
957 /// # use google_cloud_dataproc_v1::client::ClusterController;
958 /// use google_cloud_lro::Poller;
959 /// use google_cloud_dataproc_v1::Result;
960 /// async fn sample(
961 /// client: &ClusterController
962 /// ) -> Result<()> {
963 /// let response = client.update_cluster()
964 /// /* set fields */
965 /// .poller().until_done().await?;
966 /// println!("response {:?}", response);
967 /// Ok(())
968 /// }
969 /// ```
970 pub fn update_cluster(&self) -> super::builder::cluster_controller::UpdateCluster {
971 super::builder::cluster_controller::UpdateCluster::new(self.inner.clone())
972 }
973
974 /// Stops a cluster in a project.
975 ///
976 /// # Long running operations
977 ///
978 /// This method is used to start, and/or poll a [long-running Operation].
979 /// The [Working with long-running operations] chapter in the [user guide]
980 /// covers these operations in detail.
981 ///
982 /// [long-running operation]: https://google.aip.dev/151
983 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
984 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
985 ///
986 /// # Example
987 /// ```
988 /// # use google_cloud_dataproc_v1::client::ClusterController;
989 /// use google_cloud_lro::Poller;
990 /// use google_cloud_dataproc_v1::Result;
991 /// async fn sample(
992 /// client: &ClusterController
993 /// ) -> Result<()> {
994 /// let response = client.stop_cluster()
995 /// /* set fields */
996 /// .poller().until_done().await?;
997 /// println!("response {:?}", response);
998 /// Ok(())
999 /// }
1000 /// ```
1001 pub fn stop_cluster(&self) -> super::builder::cluster_controller::StopCluster {
1002 super::builder::cluster_controller::StopCluster::new(self.inner.clone())
1003 }
1004
1005 /// Starts a cluster in a project.
1006 ///
1007 /// # Long running operations
1008 ///
1009 /// This method is used to start, and/or poll a [long-running Operation].
1010 /// The [Working with long-running operations] chapter in the [user guide]
1011 /// covers these operations in detail.
1012 ///
1013 /// [long-running operation]: https://google.aip.dev/151
1014 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1015 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1016 ///
1017 /// # Example
1018 /// ```
1019 /// # use google_cloud_dataproc_v1::client::ClusterController;
1020 /// use google_cloud_lro::Poller;
1021 /// use google_cloud_dataproc_v1::Result;
1022 /// async fn sample(
1023 /// client: &ClusterController
1024 /// ) -> Result<()> {
1025 /// let response = client.start_cluster()
1026 /// /* set fields */
1027 /// .poller().until_done().await?;
1028 /// println!("response {:?}", response);
1029 /// Ok(())
1030 /// }
1031 /// ```
1032 pub fn start_cluster(&self) -> super::builder::cluster_controller::StartCluster {
1033 super::builder::cluster_controller::StartCluster::new(self.inner.clone())
1034 }
1035
1036 /// Deletes a cluster in a project. The returned
1037 /// [Operation.metadata][google.longrunning.Operation.metadata] will be
1038 /// [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).
1039 ///
1040 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
1041 ///
1042 /// # Long running operations
1043 ///
1044 /// This method is used to start, and/or poll a [long-running Operation].
1045 /// The [Working with long-running operations] chapter in the [user guide]
1046 /// covers these operations in detail.
1047 ///
1048 /// [long-running operation]: https://google.aip.dev/151
1049 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1050 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1051 ///
1052 /// # Example
1053 /// ```
1054 /// # use google_cloud_dataproc_v1::client::ClusterController;
1055 /// use google_cloud_lro::Poller;
1056 /// use google_cloud_dataproc_v1::Result;
1057 /// async fn sample(
1058 /// client: &ClusterController
1059 /// ) -> Result<()> {
1060 /// client.delete_cluster()
1061 /// /* set fields */
1062 /// .poller().until_done().await?;
1063 /// Ok(())
1064 /// }
1065 /// ```
1066 pub fn delete_cluster(&self) -> super::builder::cluster_controller::DeleteCluster {
1067 super::builder::cluster_controller::DeleteCluster::new(self.inner.clone())
1068 }
1069
1070 /// Gets the resource representation for a cluster in a project.
1071 ///
1072 /// # Example
1073 /// ```
1074 /// # use google_cloud_dataproc_v1::client::ClusterController;
1075 /// use google_cloud_dataproc_v1::Result;
1076 /// async fn sample(
1077 /// client: &ClusterController
1078 /// ) -> Result<()> {
1079 /// let response = client.get_cluster()
1080 /// /* set fields */
1081 /// .send().await?;
1082 /// println!("response {:?}", response);
1083 /// Ok(())
1084 /// }
1085 /// ```
1086 pub fn get_cluster(&self) -> super::builder::cluster_controller::GetCluster {
1087 super::builder::cluster_controller::GetCluster::new(self.inner.clone())
1088 }
1089
1090 /// Lists all regions/{region}/clusters in a project alphabetically.
1091 ///
1092 /// # Example
1093 /// ```
1094 /// # use google_cloud_dataproc_v1::client::ClusterController;
1095 /// use google_cloud_gax::paginator::ItemPaginator as _;
1096 /// use google_cloud_dataproc_v1::Result;
1097 /// async fn sample(
1098 /// client: &ClusterController
1099 /// ) -> Result<()> {
1100 /// let mut list = client.list_clusters()
1101 /// /* set fields */
1102 /// .by_item();
1103 /// while let Some(item) = list.next().await.transpose()? {
1104 /// println!("{:?}", item);
1105 /// }
1106 /// Ok(())
1107 /// }
1108 /// ```
1109 pub fn list_clusters(&self) -> super::builder::cluster_controller::ListClusters {
1110 super::builder::cluster_controller::ListClusters::new(self.inner.clone())
1111 }
1112
1113 /// Gets cluster diagnostic information. The returned
1114 /// [Operation.metadata][google.longrunning.Operation.metadata] will be
1115 /// [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).
1116 /// After the operation completes,
1117 /// [Operation.response][google.longrunning.Operation.response]
1118 /// contains
1119 /// [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults).
1120 ///
1121 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
1122 /// [google.longrunning.Operation.response]: google_cloud_longrunning::model::Operation::result
1123 ///
1124 /// # Long running operations
1125 ///
1126 /// This method is used to start, and/or poll a [long-running Operation].
1127 /// The [Working with long-running operations] chapter in the [user guide]
1128 /// covers these operations in detail.
1129 ///
1130 /// [long-running operation]: https://google.aip.dev/151
1131 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1132 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1133 ///
1134 /// # Example
1135 /// ```
1136 /// # use google_cloud_dataproc_v1::client::ClusterController;
1137 /// use google_cloud_lro::Poller;
1138 /// use google_cloud_dataproc_v1::Result;
1139 /// async fn sample(
1140 /// client: &ClusterController
1141 /// ) -> Result<()> {
1142 /// let response = client.diagnose_cluster()
1143 /// /* set fields */
1144 /// .poller().until_done().await?;
1145 /// println!("response {:?}", response);
1146 /// Ok(())
1147 /// }
1148 /// ```
1149 pub fn diagnose_cluster(&self) -> super::builder::cluster_controller::DiagnoseCluster {
1150 super::builder::cluster_controller::DiagnoseCluster::new(self.inner.clone())
1151 }
1152
1153 /// Sets the access control policy on the specified resource. Replaces
1154 /// any existing policy.
1155 ///
1156 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1157 /// errors.
1158 ///
1159 /// # Example
1160 /// ```
1161 /// # use google_cloud_dataproc_v1::client::ClusterController;
1162 /// use google_cloud_dataproc_v1::Result;
1163 /// async fn sample(
1164 /// client: &ClusterController
1165 /// ) -> Result<()> {
1166 /// let response = client.set_iam_policy()
1167 /// /* set fields */
1168 /// .send().await?;
1169 /// println!("response {:?}", response);
1170 /// Ok(())
1171 /// }
1172 /// ```
1173 pub fn set_iam_policy(&self) -> super::builder::cluster_controller::SetIamPolicy {
1174 super::builder::cluster_controller::SetIamPolicy::new(self.inner.clone())
1175 }
1176
1177 /// Gets the access control policy for a resource. Returns an empty policy
1178 /// if the resource exists and does not have a policy set.
1179 ///
1180 /// # Example
1181 /// ```
1182 /// # use google_cloud_dataproc_v1::client::ClusterController;
1183 /// use google_cloud_dataproc_v1::Result;
1184 /// async fn sample(
1185 /// client: &ClusterController
1186 /// ) -> Result<()> {
1187 /// let response = client.get_iam_policy()
1188 /// /* set fields */
1189 /// .send().await?;
1190 /// println!("response {:?}", response);
1191 /// Ok(())
1192 /// }
1193 /// ```
1194 pub fn get_iam_policy(&self) -> super::builder::cluster_controller::GetIamPolicy {
1195 super::builder::cluster_controller::GetIamPolicy::new(self.inner.clone())
1196 }
1197
1198 /// Returns permissions that a caller has on the specified resource. If the
1199 /// resource does not exist, this will return an empty set of
1200 /// permissions, not a `NOT_FOUND` error.
1201 ///
1202 /// Note: This operation is designed to be used for building
1203 /// permission-aware UIs and command-line tools, not for authorization
1204 /// checking. This operation may "fail open" without warning.
1205 ///
1206 /// # Example
1207 /// ```
1208 /// # use google_cloud_dataproc_v1::client::ClusterController;
1209 /// use google_cloud_dataproc_v1::Result;
1210 /// async fn sample(
1211 /// client: &ClusterController
1212 /// ) -> Result<()> {
1213 /// let response = client.test_iam_permissions()
1214 /// /* set fields */
1215 /// .send().await?;
1216 /// println!("response {:?}", response);
1217 /// Ok(())
1218 /// }
1219 /// ```
1220 pub fn test_iam_permissions(&self) -> super::builder::cluster_controller::TestIamPermissions {
1221 super::builder::cluster_controller::TestIamPermissions::new(self.inner.clone())
1222 }
1223
1224 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1225 ///
1226 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1227 ///
1228 /// # Example
1229 /// ```
1230 /// # use google_cloud_dataproc_v1::client::ClusterController;
1231 /// use google_cloud_gax::paginator::ItemPaginator as _;
1232 /// use google_cloud_dataproc_v1::Result;
1233 /// async fn sample(
1234 /// client: &ClusterController
1235 /// ) -> Result<()> {
1236 /// let mut list = client.list_operations()
1237 /// /* set fields */
1238 /// .by_item();
1239 /// while let Some(item) = list.next().await.transpose()? {
1240 /// println!("{:?}", item);
1241 /// }
1242 /// Ok(())
1243 /// }
1244 /// ```
1245 pub fn list_operations(&self) -> super::builder::cluster_controller::ListOperations {
1246 super::builder::cluster_controller::ListOperations::new(self.inner.clone())
1247 }
1248
1249 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1250 ///
1251 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1252 ///
1253 /// # Example
1254 /// ```
1255 /// # use google_cloud_dataproc_v1::client::ClusterController;
1256 /// use google_cloud_dataproc_v1::Result;
1257 /// async fn sample(
1258 /// client: &ClusterController
1259 /// ) -> Result<()> {
1260 /// let response = client.get_operation()
1261 /// /* set fields */
1262 /// .send().await?;
1263 /// println!("response {:?}", response);
1264 /// Ok(())
1265 /// }
1266 /// ```
1267 pub fn get_operation(&self) -> super::builder::cluster_controller::GetOperation {
1268 super::builder::cluster_controller::GetOperation::new(self.inner.clone())
1269 }
1270
1271 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1272 ///
1273 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1274 ///
1275 /// # Example
1276 /// ```
1277 /// # use google_cloud_dataproc_v1::client::ClusterController;
1278 /// use google_cloud_dataproc_v1::Result;
1279 /// async fn sample(
1280 /// client: &ClusterController
1281 /// ) -> Result<()> {
1282 /// client.delete_operation()
1283 /// /* set fields */
1284 /// .send().await?;
1285 /// Ok(())
1286 /// }
1287 /// ```
1288 pub fn delete_operation(&self) -> super::builder::cluster_controller::DeleteOperation {
1289 super::builder::cluster_controller::DeleteOperation::new(self.inner.clone())
1290 }
1291
1292 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1293 ///
1294 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1295 ///
1296 /// # Example
1297 /// ```
1298 /// # use google_cloud_dataproc_v1::client::ClusterController;
1299 /// use google_cloud_dataproc_v1::Result;
1300 /// async fn sample(
1301 /// client: &ClusterController
1302 /// ) -> Result<()> {
1303 /// client.cancel_operation()
1304 /// /* set fields */
1305 /// .send().await?;
1306 /// Ok(())
1307 /// }
1308 /// ```
1309 pub fn cancel_operation(&self) -> super::builder::cluster_controller::CancelOperation {
1310 super::builder::cluster_controller::CancelOperation::new(self.inner.clone())
1311 }
1312}
1313
1314/// Implements a client for the Cloud Dataproc API.
1315///
1316/// # Example
1317/// ```
1318/// # use google_cloud_dataproc_v1::client::JobController;
1319/// async fn sample(
1320/// ) -> anyhow::Result<()> {
1321/// let client = JobController::builder().build().await?;
1322/// let response = client.submit_job()
1323/// /* set fields */
1324/// .send().await?;
1325/// println!("response {:?}", response);
1326/// Ok(())
1327/// }
1328/// ```
1329///
1330/// # Service Description
1331///
1332/// The JobController provides methods to manage jobs.
1333///
1334/// # Configuration
1335///
1336/// To configure `JobController` use the `with_*` methods in the type returned
1337/// by [builder()][JobController::builder]. The default configuration should
1338/// work for most applications. Common configuration changes include
1339///
1340/// * [with_endpoint()]: by default this client uses the global default endpoint
1341/// (`https://dataproc.googleapis.com`). Applications using regional
1342/// endpoints or running in restricted networks (e.g. a network configured
1343/// with [Private Google Access with VPC Service Controls]) may want to
1344/// override this default.
1345/// * [with_credentials()]: by default this client uses
1346/// [Application Default Credentials]. Applications using custom
1347/// authentication may need to override this default.
1348///
1349/// [with_endpoint()]: super::builder::job_controller::ClientBuilder::with_endpoint
1350/// [with_credentials()]: super::builder::job_controller::ClientBuilder::with_credentials
1351/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1352/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1353///
1354/// # Pooling and Cloning
1355///
1356/// `JobController` holds a connection pool internally, it is advised to
1357/// create one and reuse it. You do not need to wrap `JobController` in
1358/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1359/// already uses an `Arc` internally.
1360#[derive(Clone, Debug)]
1361pub struct JobController {
1362 inner: std::sync::Arc<dyn super::stub::dynamic::JobController>,
1363}
1364
1365impl JobController {
1366 /// Returns a builder for [JobController].
1367 ///
1368 /// ```
1369 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1370 /// # use google_cloud_dataproc_v1::client::JobController;
1371 /// let client = JobController::builder().build().await?;
1372 /// # Ok(()) }
1373 /// ```
1374 pub fn builder() -> super::builder::job_controller::ClientBuilder {
1375 crate::new_client_builder(super::builder::job_controller::client::Factory)
1376 }
1377
1378 /// Creates a new client from the provided stub.
1379 ///
1380 /// The most common case for calling this function is in tests mocking the
1381 /// client's behavior.
1382 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1383 where
1384 T: super::stub::JobController + 'static,
1385 {
1386 Self { inner: stub.into() }
1387 }
1388
1389 pub(crate) async fn new(
1390 config: gaxi::options::ClientConfig,
1391 ) -> crate::ClientBuilderResult<Self> {
1392 let inner = Self::build_inner(config).await?;
1393 Ok(Self { inner })
1394 }
1395
1396 async fn build_inner(
1397 conf: gaxi::options::ClientConfig,
1398 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::JobController>> {
1399 if gaxi::options::tracing_enabled(&conf) {
1400 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1401 }
1402 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1403 }
1404
1405 async fn build_transport(
1406 conf: gaxi::options::ClientConfig,
1407 ) -> crate::ClientBuilderResult<impl super::stub::JobController> {
1408 super::transport::JobController::new(conf).await
1409 }
1410
1411 async fn build_with_tracing(
1412 conf: gaxi::options::ClientConfig,
1413 ) -> crate::ClientBuilderResult<impl super::stub::JobController> {
1414 Self::build_transport(conf)
1415 .await
1416 .map(super::tracing::JobController::new)
1417 }
1418
1419 /// Submits a job to a cluster.
1420 ///
1421 /// # Example
1422 /// ```
1423 /// # use google_cloud_dataproc_v1::client::JobController;
1424 /// use google_cloud_dataproc_v1::Result;
1425 /// async fn sample(
1426 /// client: &JobController
1427 /// ) -> Result<()> {
1428 /// let response = client.submit_job()
1429 /// /* set fields */
1430 /// .send().await?;
1431 /// println!("response {:?}", response);
1432 /// Ok(())
1433 /// }
1434 /// ```
1435 pub fn submit_job(&self) -> super::builder::job_controller::SubmitJob {
1436 super::builder::job_controller::SubmitJob::new(self.inner.clone())
1437 }
1438
1439 /// Submits job to a cluster.
1440 ///
1441 /// # Long running operations
1442 ///
1443 /// This method is used to start, and/or poll a [long-running Operation].
1444 /// The [Working with long-running operations] chapter in the [user guide]
1445 /// covers these operations in detail.
1446 ///
1447 /// [long-running operation]: https://google.aip.dev/151
1448 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1449 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1450 ///
1451 /// # Example
1452 /// ```
1453 /// # use google_cloud_dataproc_v1::client::JobController;
1454 /// use google_cloud_lro::Poller;
1455 /// use google_cloud_dataproc_v1::Result;
1456 /// async fn sample(
1457 /// client: &JobController
1458 /// ) -> Result<()> {
1459 /// let response = client.submit_job_as_operation()
1460 /// /* set fields */
1461 /// .poller().until_done().await?;
1462 /// println!("response {:?}", response);
1463 /// Ok(())
1464 /// }
1465 /// ```
1466 pub fn submit_job_as_operation(&self) -> super::builder::job_controller::SubmitJobAsOperation {
1467 super::builder::job_controller::SubmitJobAsOperation::new(self.inner.clone())
1468 }
1469
1470 /// Gets the resource representation for a job in a project.
1471 ///
1472 /// # Example
1473 /// ```
1474 /// # use google_cloud_dataproc_v1::client::JobController;
1475 /// use google_cloud_dataproc_v1::Result;
1476 /// async fn sample(
1477 /// client: &JobController
1478 /// ) -> Result<()> {
1479 /// let response = client.get_job()
1480 /// /* set fields */
1481 /// .send().await?;
1482 /// println!("response {:?}", response);
1483 /// Ok(())
1484 /// }
1485 /// ```
1486 pub fn get_job(&self) -> super::builder::job_controller::GetJob {
1487 super::builder::job_controller::GetJob::new(self.inner.clone())
1488 }
1489
1490 /// Lists regions/{region}/jobs in a project.
1491 ///
1492 /// # Example
1493 /// ```
1494 /// # use google_cloud_dataproc_v1::client::JobController;
1495 /// use google_cloud_gax::paginator::ItemPaginator as _;
1496 /// use google_cloud_dataproc_v1::Result;
1497 /// async fn sample(
1498 /// client: &JobController
1499 /// ) -> Result<()> {
1500 /// let mut list = client.list_jobs()
1501 /// /* set fields */
1502 /// .by_item();
1503 /// while let Some(item) = list.next().await.transpose()? {
1504 /// println!("{:?}", item);
1505 /// }
1506 /// Ok(())
1507 /// }
1508 /// ```
1509 pub fn list_jobs(&self) -> super::builder::job_controller::ListJobs {
1510 super::builder::job_controller::ListJobs::new(self.inner.clone())
1511 }
1512
1513 /// Updates a job in a project.
1514 ///
1515 /// # Example
1516 /// ```
1517 /// # use google_cloud_dataproc_v1::client::JobController;
1518 /// use google_cloud_dataproc_v1::Result;
1519 /// async fn sample(
1520 /// client: &JobController
1521 /// ) -> Result<()> {
1522 /// let response = client.update_job()
1523 /// /* set fields */
1524 /// .send().await?;
1525 /// println!("response {:?}", response);
1526 /// Ok(())
1527 /// }
1528 /// ```
1529 pub fn update_job(&self) -> super::builder::job_controller::UpdateJob {
1530 super::builder::job_controller::UpdateJob::new(self.inner.clone())
1531 }
1532
1533 /// Starts a job cancellation request. To access the job resource
1534 /// after cancellation, call
1535 /// [regions/{region}/jobs.list](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/list)
1536 /// or
1537 /// [regions/{region}/jobs.get](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/get).
1538 ///
1539 /// # Example
1540 /// ```
1541 /// # use google_cloud_dataproc_v1::client::JobController;
1542 /// use google_cloud_dataproc_v1::Result;
1543 /// async fn sample(
1544 /// client: &JobController
1545 /// ) -> Result<()> {
1546 /// let response = client.cancel_job()
1547 /// /* set fields */
1548 /// .send().await?;
1549 /// println!("response {:?}", response);
1550 /// Ok(())
1551 /// }
1552 /// ```
1553 pub fn cancel_job(&self) -> super::builder::job_controller::CancelJob {
1554 super::builder::job_controller::CancelJob::new(self.inner.clone())
1555 }
1556
1557 /// Deletes the job from the project. If the job is active, the delete fails,
1558 /// and the response returns `FAILED_PRECONDITION`.
1559 ///
1560 /// # Example
1561 /// ```
1562 /// # use google_cloud_dataproc_v1::client::JobController;
1563 /// use google_cloud_dataproc_v1::Result;
1564 /// async fn sample(
1565 /// client: &JobController
1566 /// ) -> Result<()> {
1567 /// client.delete_job()
1568 /// /* set fields */
1569 /// .send().await?;
1570 /// Ok(())
1571 /// }
1572 /// ```
1573 pub fn delete_job(&self) -> super::builder::job_controller::DeleteJob {
1574 super::builder::job_controller::DeleteJob::new(self.inner.clone())
1575 }
1576
1577 /// Sets the access control policy on the specified resource. Replaces
1578 /// any existing policy.
1579 ///
1580 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1581 /// errors.
1582 ///
1583 /// # Example
1584 /// ```
1585 /// # use google_cloud_dataproc_v1::client::JobController;
1586 /// use google_cloud_dataproc_v1::Result;
1587 /// async fn sample(
1588 /// client: &JobController
1589 /// ) -> Result<()> {
1590 /// let response = client.set_iam_policy()
1591 /// /* set fields */
1592 /// .send().await?;
1593 /// println!("response {:?}", response);
1594 /// Ok(())
1595 /// }
1596 /// ```
1597 pub fn set_iam_policy(&self) -> super::builder::job_controller::SetIamPolicy {
1598 super::builder::job_controller::SetIamPolicy::new(self.inner.clone())
1599 }
1600
1601 /// Gets the access control policy for a resource. Returns an empty policy
1602 /// if the resource exists and does not have a policy set.
1603 ///
1604 /// # Example
1605 /// ```
1606 /// # use google_cloud_dataproc_v1::client::JobController;
1607 /// use google_cloud_dataproc_v1::Result;
1608 /// async fn sample(
1609 /// client: &JobController
1610 /// ) -> Result<()> {
1611 /// let response = client.get_iam_policy()
1612 /// /* set fields */
1613 /// .send().await?;
1614 /// println!("response {:?}", response);
1615 /// Ok(())
1616 /// }
1617 /// ```
1618 pub fn get_iam_policy(&self) -> super::builder::job_controller::GetIamPolicy {
1619 super::builder::job_controller::GetIamPolicy::new(self.inner.clone())
1620 }
1621
1622 /// Returns permissions that a caller has on the specified resource. If the
1623 /// resource does not exist, this will return an empty set of
1624 /// permissions, not a `NOT_FOUND` error.
1625 ///
1626 /// Note: This operation is designed to be used for building
1627 /// permission-aware UIs and command-line tools, not for authorization
1628 /// checking. This operation may "fail open" without warning.
1629 ///
1630 /// # Example
1631 /// ```
1632 /// # use google_cloud_dataproc_v1::client::JobController;
1633 /// use google_cloud_dataproc_v1::Result;
1634 /// async fn sample(
1635 /// client: &JobController
1636 /// ) -> Result<()> {
1637 /// let response = client.test_iam_permissions()
1638 /// /* set fields */
1639 /// .send().await?;
1640 /// println!("response {:?}", response);
1641 /// Ok(())
1642 /// }
1643 /// ```
1644 pub fn test_iam_permissions(&self) -> super::builder::job_controller::TestIamPermissions {
1645 super::builder::job_controller::TestIamPermissions::new(self.inner.clone())
1646 }
1647
1648 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1649 ///
1650 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1651 ///
1652 /// # Example
1653 /// ```
1654 /// # use google_cloud_dataproc_v1::client::JobController;
1655 /// use google_cloud_gax::paginator::ItemPaginator as _;
1656 /// use google_cloud_dataproc_v1::Result;
1657 /// async fn sample(
1658 /// client: &JobController
1659 /// ) -> Result<()> {
1660 /// let mut list = client.list_operations()
1661 /// /* set fields */
1662 /// .by_item();
1663 /// while let Some(item) = list.next().await.transpose()? {
1664 /// println!("{:?}", item);
1665 /// }
1666 /// Ok(())
1667 /// }
1668 /// ```
1669 pub fn list_operations(&self) -> super::builder::job_controller::ListOperations {
1670 super::builder::job_controller::ListOperations::new(self.inner.clone())
1671 }
1672
1673 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1674 ///
1675 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1676 ///
1677 /// # Example
1678 /// ```
1679 /// # use google_cloud_dataproc_v1::client::JobController;
1680 /// use google_cloud_dataproc_v1::Result;
1681 /// async fn sample(
1682 /// client: &JobController
1683 /// ) -> Result<()> {
1684 /// let response = client.get_operation()
1685 /// /* set fields */
1686 /// .send().await?;
1687 /// println!("response {:?}", response);
1688 /// Ok(())
1689 /// }
1690 /// ```
1691 pub fn get_operation(&self) -> super::builder::job_controller::GetOperation {
1692 super::builder::job_controller::GetOperation::new(self.inner.clone())
1693 }
1694
1695 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1696 ///
1697 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1698 ///
1699 /// # Example
1700 /// ```
1701 /// # use google_cloud_dataproc_v1::client::JobController;
1702 /// use google_cloud_dataproc_v1::Result;
1703 /// async fn sample(
1704 /// client: &JobController
1705 /// ) -> Result<()> {
1706 /// client.delete_operation()
1707 /// /* set fields */
1708 /// .send().await?;
1709 /// Ok(())
1710 /// }
1711 /// ```
1712 pub fn delete_operation(&self) -> super::builder::job_controller::DeleteOperation {
1713 super::builder::job_controller::DeleteOperation::new(self.inner.clone())
1714 }
1715
1716 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1717 ///
1718 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1719 ///
1720 /// # Example
1721 /// ```
1722 /// # use google_cloud_dataproc_v1::client::JobController;
1723 /// use google_cloud_dataproc_v1::Result;
1724 /// async fn sample(
1725 /// client: &JobController
1726 /// ) -> Result<()> {
1727 /// client.cancel_operation()
1728 /// /* set fields */
1729 /// .send().await?;
1730 /// Ok(())
1731 /// }
1732 /// ```
1733 pub fn cancel_operation(&self) -> super::builder::job_controller::CancelOperation {
1734 super::builder::job_controller::CancelOperation::new(self.inner.clone())
1735 }
1736}
1737
1738/// Implements a client for the Cloud Dataproc API.
1739///
1740/// # Example
1741/// ```
1742/// # use google_cloud_dataproc_v1::client::NodeGroupController;
1743/// async fn sample(
1744/// project_id: &str,
1745/// region_id: &str,
1746/// cluster_id: &str,
1747/// node_group_id: &str,
1748/// ) -> anyhow::Result<()> {
1749/// let client = NodeGroupController::builder().build().await?;
1750/// let response = client.get_node_group()
1751/// .set_name(format!("projects/{project_id}/regions/{region_id}/clusters/{cluster_id}/nodeGroups/{node_group_id}"))
1752/// .send().await?;
1753/// println!("response {:?}", response);
1754/// Ok(())
1755/// }
1756/// ```
1757///
1758/// # Service Description
1759///
1760/// The `NodeGroupControllerService` provides methods to manage node groups
1761/// of Compute Engine managed instances.
1762///
1763/// # Configuration
1764///
1765/// To configure `NodeGroupController` use the `with_*` methods in the type returned
1766/// by [builder()][NodeGroupController::builder]. The default configuration should
1767/// work for most applications. Common configuration changes include
1768///
1769/// * [with_endpoint()]: by default this client uses the global default endpoint
1770/// (`https://dataproc.googleapis.com`). Applications using regional
1771/// endpoints or running in restricted networks (e.g. a network configured
1772/// with [Private Google Access with VPC Service Controls]) may want to
1773/// override this default.
1774/// * [with_credentials()]: by default this client uses
1775/// [Application Default Credentials]. Applications using custom
1776/// authentication may need to override this default.
1777///
1778/// [with_endpoint()]: super::builder::node_group_controller::ClientBuilder::with_endpoint
1779/// [with_credentials()]: super::builder::node_group_controller::ClientBuilder::with_credentials
1780/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1781/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1782///
1783/// # Pooling and Cloning
1784///
1785/// `NodeGroupController` holds a connection pool internally, it is advised to
1786/// create one and reuse it. You do not need to wrap `NodeGroupController` in
1787/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1788/// already uses an `Arc` internally.
1789#[derive(Clone, Debug)]
1790pub struct NodeGroupController {
1791 inner: std::sync::Arc<dyn super::stub::dynamic::NodeGroupController>,
1792}
1793
1794impl NodeGroupController {
1795 /// Returns a builder for [NodeGroupController].
1796 ///
1797 /// ```
1798 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1799 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
1800 /// let client = NodeGroupController::builder().build().await?;
1801 /// # Ok(()) }
1802 /// ```
1803 pub fn builder() -> super::builder::node_group_controller::ClientBuilder {
1804 crate::new_client_builder(super::builder::node_group_controller::client::Factory)
1805 }
1806
1807 /// Creates a new client from the provided stub.
1808 ///
1809 /// The most common case for calling this function is in tests mocking the
1810 /// client's behavior.
1811 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1812 where
1813 T: super::stub::NodeGroupController + 'static,
1814 {
1815 Self { inner: stub.into() }
1816 }
1817
1818 pub(crate) async fn new(
1819 config: gaxi::options::ClientConfig,
1820 ) -> crate::ClientBuilderResult<Self> {
1821 let inner = Self::build_inner(config).await?;
1822 Ok(Self { inner })
1823 }
1824
1825 async fn build_inner(
1826 conf: gaxi::options::ClientConfig,
1827 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::NodeGroupController>>
1828 {
1829 if gaxi::options::tracing_enabled(&conf) {
1830 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1831 }
1832 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1833 }
1834
1835 async fn build_transport(
1836 conf: gaxi::options::ClientConfig,
1837 ) -> crate::ClientBuilderResult<impl super::stub::NodeGroupController> {
1838 super::transport::NodeGroupController::new(conf).await
1839 }
1840
1841 async fn build_with_tracing(
1842 conf: gaxi::options::ClientConfig,
1843 ) -> crate::ClientBuilderResult<impl super::stub::NodeGroupController> {
1844 Self::build_transport(conf)
1845 .await
1846 .map(super::tracing::NodeGroupController::new)
1847 }
1848
1849 /// Creates a node group in a cluster. The returned
1850 /// [Operation.metadata][google.longrunning.Operation.metadata] is
1851 /// [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata).
1852 ///
1853 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
1854 ///
1855 /// # Long running operations
1856 ///
1857 /// This method is used to start, and/or poll a [long-running Operation].
1858 /// The [Working with long-running operations] chapter in the [user guide]
1859 /// covers these operations in detail.
1860 ///
1861 /// [long-running operation]: https://google.aip.dev/151
1862 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1863 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1864 ///
1865 /// # Example
1866 /// ```
1867 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
1868 /// use google_cloud_lro::Poller;
1869 /// use google_cloud_dataproc_v1::model::NodeGroup;
1870 /// use google_cloud_dataproc_v1::Result;
1871 /// async fn sample(
1872 /// client: &NodeGroupController, project_id: &str, region_id: &str, cluster_id: &str
1873 /// ) -> Result<()> {
1874 /// let response = client.create_node_group()
1875 /// .set_parent(format!("projects/{project_id}/regions/{region_id}/clusters/{cluster_id}"))
1876 /// .set_node_group(
1877 /// NodeGroup::new()/* set fields */
1878 /// )
1879 /// .poller().until_done().await?;
1880 /// println!("response {:?}", response);
1881 /// Ok(())
1882 /// }
1883 /// ```
1884 pub fn create_node_group(&self) -> super::builder::node_group_controller::CreateNodeGroup {
1885 super::builder::node_group_controller::CreateNodeGroup::new(self.inner.clone())
1886 }
1887
1888 /// Resizes a node group in a cluster. The returned
1889 /// [Operation.metadata][google.longrunning.Operation.metadata] is
1890 /// [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata).
1891 ///
1892 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
1893 ///
1894 /// # Long running operations
1895 ///
1896 /// This method is used to start, and/or poll a [long-running Operation].
1897 /// The [Working with long-running operations] chapter in the [user guide]
1898 /// covers these operations in detail.
1899 ///
1900 /// [long-running operation]: https://google.aip.dev/151
1901 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1902 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1903 ///
1904 /// # Example
1905 /// ```
1906 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
1907 /// use google_cloud_lro::Poller;
1908 /// use google_cloud_dataproc_v1::Result;
1909 /// async fn sample(
1910 /// client: &NodeGroupController
1911 /// ) -> Result<()> {
1912 /// let response = client.resize_node_group()
1913 /// /* set fields */
1914 /// .poller().until_done().await?;
1915 /// println!("response {:?}", response);
1916 /// Ok(())
1917 /// }
1918 /// ```
1919 pub fn resize_node_group(&self) -> super::builder::node_group_controller::ResizeNodeGroup {
1920 super::builder::node_group_controller::ResizeNodeGroup::new(self.inner.clone())
1921 }
1922
1923 /// Gets the resource representation for a node group in a
1924 /// cluster.
1925 ///
1926 /// # Example
1927 /// ```
1928 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
1929 /// use google_cloud_dataproc_v1::Result;
1930 /// async fn sample(
1931 /// client: &NodeGroupController, project_id: &str, region_id: &str, cluster_id: &str, node_group_id: &str
1932 /// ) -> Result<()> {
1933 /// let response = client.get_node_group()
1934 /// .set_name(format!("projects/{project_id}/regions/{region_id}/clusters/{cluster_id}/nodeGroups/{node_group_id}"))
1935 /// .send().await?;
1936 /// println!("response {:?}", response);
1937 /// Ok(())
1938 /// }
1939 /// ```
1940 pub fn get_node_group(&self) -> super::builder::node_group_controller::GetNodeGroup {
1941 super::builder::node_group_controller::GetNodeGroup::new(self.inner.clone())
1942 }
1943
1944 /// Sets the access control policy on the specified resource. Replaces
1945 /// any existing policy.
1946 ///
1947 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1948 /// errors.
1949 ///
1950 /// # Example
1951 /// ```
1952 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
1953 /// use google_cloud_dataproc_v1::Result;
1954 /// async fn sample(
1955 /// client: &NodeGroupController
1956 /// ) -> Result<()> {
1957 /// let response = client.set_iam_policy()
1958 /// /* set fields */
1959 /// .send().await?;
1960 /// println!("response {:?}", response);
1961 /// Ok(())
1962 /// }
1963 /// ```
1964 pub fn set_iam_policy(&self) -> super::builder::node_group_controller::SetIamPolicy {
1965 super::builder::node_group_controller::SetIamPolicy::new(self.inner.clone())
1966 }
1967
1968 /// Gets the access control policy for a resource. Returns an empty policy
1969 /// if the resource exists and does not have a policy set.
1970 ///
1971 /// # Example
1972 /// ```
1973 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
1974 /// use google_cloud_dataproc_v1::Result;
1975 /// async fn sample(
1976 /// client: &NodeGroupController
1977 /// ) -> Result<()> {
1978 /// let response = client.get_iam_policy()
1979 /// /* set fields */
1980 /// .send().await?;
1981 /// println!("response {:?}", response);
1982 /// Ok(())
1983 /// }
1984 /// ```
1985 pub fn get_iam_policy(&self) -> super::builder::node_group_controller::GetIamPolicy {
1986 super::builder::node_group_controller::GetIamPolicy::new(self.inner.clone())
1987 }
1988
1989 /// Returns permissions that a caller has on the specified resource. If the
1990 /// resource does not exist, this will return an empty set of
1991 /// permissions, not a `NOT_FOUND` error.
1992 ///
1993 /// Note: This operation is designed to be used for building
1994 /// permission-aware UIs and command-line tools, not for authorization
1995 /// checking. This operation may "fail open" without warning.
1996 ///
1997 /// # Example
1998 /// ```
1999 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
2000 /// use google_cloud_dataproc_v1::Result;
2001 /// async fn sample(
2002 /// client: &NodeGroupController
2003 /// ) -> Result<()> {
2004 /// let response = client.test_iam_permissions()
2005 /// /* set fields */
2006 /// .send().await?;
2007 /// println!("response {:?}", response);
2008 /// Ok(())
2009 /// }
2010 /// ```
2011 pub fn test_iam_permissions(
2012 &self,
2013 ) -> super::builder::node_group_controller::TestIamPermissions {
2014 super::builder::node_group_controller::TestIamPermissions::new(self.inner.clone())
2015 }
2016
2017 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2018 ///
2019 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2020 ///
2021 /// # Example
2022 /// ```
2023 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
2024 /// use google_cloud_gax::paginator::ItemPaginator as _;
2025 /// use google_cloud_dataproc_v1::Result;
2026 /// async fn sample(
2027 /// client: &NodeGroupController
2028 /// ) -> Result<()> {
2029 /// let mut list = client.list_operations()
2030 /// /* set fields */
2031 /// .by_item();
2032 /// while let Some(item) = list.next().await.transpose()? {
2033 /// println!("{:?}", item);
2034 /// }
2035 /// Ok(())
2036 /// }
2037 /// ```
2038 pub fn list_operations(&self) -> super::builder::node_group_controller::ListOperations {
2039 super::builder::node_group_controller::ListOperations::new(self.inner.clone())
2040 }
2041
2042 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2043 ///
2044 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2045 ///
2046 /// # Example
2047 /// ```
2048 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
2049 /// use google_cloud_dataproc_v1::Result;
2050 /// async fn sample(
2051 /// client: &NodeGroupController
2052 /// ) -> Result<()> {
2053 /// let response = client.get_operation()
2054 /// /* set fields */
2055 /// .send().await?;
2056 /// println!("response {:?}", response);
2057 /// Ok(())
2058 /// }
2059 /// ```
2060 pub fn get_operation(&self) -> super::builder::node_group_controller::GetOperation {
2061 super::builder::node_group_controller::GetOperation::new(self.inner.clone())
2062 }
2063
2064 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2065 ///
2066 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2067 ///
2068 /// # Example
2069 /// ```
2070 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
2071 /// use google_cloud_dataproc_v1::Result;
2072 /// async fn sample(
2073 /// client: &NodeGroupController
2074 /// ) -> Result<()> {
2075 /// client.delete_operation()
2076 /// /* set fields */
2077 /// .send().await?;
2078 /// Ok(())
2079 /// }
2080 /// ```
2081 pub fn delete_operation(&self) -> super::builder::node_group_controller::DeleteOperation {
2082 super::builder::node_group_controller::DeleteOperation::new(self.inner.clone())
2083 }
2084
2085 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2086 ///
2087 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2088 ///
2089 /// # Example
2090 /// ```
2091 /// # use google_cloud_dataproc_v1::client::NodeGroupController;
2092 /// use google_cloud_dataproc_v1::Result;
2093 /// async fn sample(
2094 /// client: &NodeGroupController
2095 /// ) -> Result<()> {
2096 /// client.cancel_operation()
2097 /// /* set fields */
2098 /// .send().await?;
2099 /// Ok(())
2100 /// }
2101 /// ```
2102 pub fn cancel_operation(&self) -> super::builder::node_group_controller::CancelOperation {
2103 super::builder::node_group_controller::CancelOperation::new(self.inner.clone())
2104 }
2105}
2106
2107/// Implements a client for the Cloud Dataproc API.
2108///
2109/// # Example
2110/// ```
2111/// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2112/// use google_cloud_gax::paginator::ItemPaginator as _;
2113/// async fn sample(
2114/// project_id: &str,
2115/// location_id: &str,
2116/// ) -> anyhow::Result<()> {
2117/// let client = SessionTemplateController::builder().build().await?;
2118/// let mut list = client.list_session_templates()
2119/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2120/// .by_item();
2121/// while let Some(item) = list.next().await.transpose()? {
2122/// println!("{:?}", item);
2123/// }
2124/// Ok(())
2125/// }
2126/// ```
2127///
2128/// # Service Description
2129///
2130/// The SessionTemplateController provides methods to manage session templates.
2131///
2132/// # Configuration
2133///
2134/// To configure `SessionTemplateController` use the `with_*` methods in the type returned
2135/// by [builder()][SessionTemplateController::builder]. The default configuration should
2136/// work for most applications. Common configuration changes include
2137///
2138/// * [with_endpoint()]: by default this client uses the global default endpoint
2139/// (`https://dataproc.googleapis.com`). Applications using regional
2140/// endpoints or running in restricted networks (e.g. a network configured
2141/// with [Private Google Access with VPC Service Controls]) may want to
2142/// override this default.
2143/// * [with_credentials()]: by default this client uses
2144/// [Application Default Credentials]. Applications using custom
2145/// authentication may need to override this default.
2146///
2147/// [with_endpoint()]: super::builder::session_template_controller::ClientBuilder::with_endpoint
2148/// [with_credentials()]: super::builder::session_template_controller::ClientBuilder::with_credentials
2149/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2150/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2151///
2152/// # Pooling and Cloning
2153///
2154/// `SessionTemplateController` holds a connection pool internally, it is advised to
2155/// create one and reuse it. You do not need to wrap `SessionTemplateController` in
2156/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2157/// already uses an `Arc` internally.
2158#[derive(Clone, Debug)]
2159pub struct SessionTemplateController {
2160 inner: std::sync::Arc<dyn super::stub::dynamic::SessionTemplateController>,
2161}
2162
2163impl SessionTemplateController {
2164 /// Returns a builder for [SessionTemplateController].
2165 ///
2166 /// ```
2167 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2168 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2169 /// let client = SessionTemplateController::builder().build().await?;
2170 /// # Ok(()) }
2171 /// ```
2172 pub fn builder() -> super::builder::session_template_controller::ClientBuilder {
2173 crate::new_client_builder(super::builder::session_template_controller::client::Factory)
2174 }
2175
2176 /// Creates a new client from the provided stub.
2177 ///
2178 /// The most common case for calling this function is in tests mocking the
2179 /// client's behavior.
2180 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2181 where
2182 T: super::stub::SessionTemplateController + 'static,
2183 {
2184 Self { inner: stub.into() }
2185 }
2186
2187 pub(crate) async fn new(
2188 config: gaxi::options::ClientConfig,
2189 ) -> crate::ClientBuilderResult<Self> {
2190 let inner = Self::build_inner(config).await?;
2191 Ok(Self { inner })
2192 }
2193
2194 async fn build_inner(
2195 conf: gaxi::options::ClientConfig,
2196 ) -> crate::ClientBuilderResult<
2197 std::sync::Arc<dyn super::stub::dynamic::SessionTemplateController>,
2198 > {
2199 if gaxi::options::tracing_enabled(&conf) {
2200 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2201 }
2202 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2203 }
2204
2205 async fn build_transport(
2206 conf: gaxi::options::ClientConfig,
2207 ) -> crate::ClientBuilderResult<impl super::stub::SessionTemplateController> {
2208 super::transport::SessionTemplateController::new(conf).await
2209 }
2210
2211 async fn build_with_tracing(
2212 conf: gaxi::options::ClientConfig,
2213 ) -> crate::ClientBuilderResult<impl super::stub::SessionTemplateController> {
2214 Self::build_transport(conf)
2215 .await
2216 .map(super::tracing::SessionTemplateController::new)
2217 }
2218
2219 /// Create a session template synchronously.
2220 ///
2221 /// # Example
2222 /// ```
2223 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2224 /// use google_cloud_dataproc_v1::model::SessionTemplate;
2225 /// use google_cloud_dataproc_v1::Result;
2226 /// async fn sample(
2227 /// client: &SessionTemplateController, project_id: &str, location_id: &str
2228 /// ) -> Result<()> {
2229 /// let response = client.create_session_template()
2230 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2231 /// .set_session_template(
2232 /// SessionTemplate::new()/* set fields */
2233 /// )
2234 /// .send().await?;
2235 /// println!("response {:?}", response);
2236 /// Ok(())
2237 /// }
2238 /// ```
2239 pub fn create_session_template(
2240 &self,
2241 ) -> super::builder::session_template_controller::CreateSessionTemplate {
2242 super::builder::session_template_controller::CreateSessionTemplate::new(self.inner.clone())
2243 }
2244
2245 /// Updates the session template synchronously.
2246 ///
2247 /// # Example
2248 /// ```
2249 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2250 /// use google_cloud_dataproc_v1::model::SessionTemplate;
2251 /// use google_cloud_dataproc_v1::Result;
2252 /// async fn sample(
2253 /// client: &SessionTemplateController, project_id: &str, location_id: &str, template_id: &str
2254 /// ) -> Result<()> {
2255 /// let response = client.update_session_template()
2256 /// .set_session_template(
2257 /// SessionTemplate::new().set_name(format!("projects/{project_id}/locations/{location_id}/sessionTemplates/{template_id}"))/* set fields */
2258 /// )
2259 /// .send().await?;
2260 /// println!("response {:?}", response);
2261 /// Ok(())
2262 /// }
2263 /// ```
2264 pub fn update_session_template(
2265 &self,
2266 ) -> super::builder::session_template_controller::UpdateSessionTemplate {
2267 super::builder::session_template_controller::UpdateSessionTemplate::new(self.inner.clone())
2268 }
2269
2270 /// Gets the resource representation for a session template.
2271 ///
2272 /// # Example
2273 /// ```
2274 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2275 /// use google_cloud_dataproc_v1::Result;
2276 /// async fn sample(
2277 /// client: &SessionTemplateController, project_id: &str, location_id: &str, template_id: &str
2278 /// ) -> Result<()> {
2279 /// let response = client.get_session_template()
2280 /// .set_name(format!("projects/{project_id}/locations/{location_id}/sessionTemplates/{template_id}"))
2281 /// .send().await?;
2282 /// println!("response {:?}", response);
2283 /// Ok(())
2284 /// }
2285 /// ```
2286 pub fn get_session_template(
2287 &self,
2288 ) -> super::builder::session_template_controller::GetSessionTemplate {
2289 super::builder::session_template_controller::GetSessionTemplate::new(self.inner.clone())
2290 }
2291
2292 /// Lists session templates.
2293 ///
2294 /// # Example
2295 /// ```
2296 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2297 /// use google_cloud_gax::paginator::ItemPaginator as _;
2298 /// use google_cloud_dataproc_v1::Result;
2299 /// async fn sample(
2300 /// client: &SessionTemplateController, project_id: &str, location_id: &str
2301 /// ) -> Result<()> {
2302 /// let mut list = client.list_session_templates()
2303 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2304 /// .by_item();
2305 /// while let Some(item) = list.next().await.transpose()? {
2306 /// println!("{:?}", item);
2307 /// }
2308 /// Ok(())
2309 /// }
2310 /// ```
2311 pub fn list_session_templates(
2312 &self,
2313 ) -> super::builder::session_template_controller::ListSessionTemplates {
2314 super::builder::session_template_controller::ListSessionTemplates::new(self.inner.clone())
2315 }
2316
2317 /// Deletes a session template.
2318 ///
2319 /// # Example
2320 /// ```
2321 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2322 /// use google_cloud_dataproc_v1::Result;
2323 /// async fn sample(
2324 /// client: &SessionTemplateController, project_id: &str, location_id: &str, template_id: &str
2325 /// ) -> Result<()> {
2326 /// client.delete_session_template()
2327 /// .set_name(format!("projects/{project_id}/locations/{location_id}/sessionTemplates/{template_id}"))
2328 /// .send().await?;
2329 /// Ok(())
2330 /// }
2331 /// ```
2332 pub fn delete_session_template(
2333 &self,
2334 ) -> super::builder::session_template_controller::DeleteSessionTemplate {
2335 super::builder::session_template_controller::DeleteSessionTemplate::new(self.inner.clone())
2336 }
2337
2338 /// Sets the access control policy on the specified resource. Replaces
2339 /// any existing policy.
2340 ///
2341 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
2342 /// errors.
2343 ///
2344 /// # Example
2345 /// ```
2346 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2347 /// use google_cloud_dataproc_v1::Result;
2348 /// async fn sample(
2349 /// client: &SessionTemplateController
2350 /// ) -> Result<()> {
2351 /// let response = client.set_iam_policy()
2352 /// /* set fields */
2353 /// .send().await?;
2354 /// println!("response {:?}", response);
2355 /// Ok(())
2356 /// }
2357 /// ```
2358 pub fn set_iam_policy(&self) -> super::builder::session_template_controller::SetIamPolicy {
2359 super::builder::session_template_controller::SetIamPolicy::new(self.inner.clone())
2360 }
2361
2362 /// Gets the access control policy for a resource. Returns an empty policy
2363 /// if the resource exists and does not have a policy set.
2364 ///
2365 /// # Example
2366 /// ```
2367 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2368 /// use google_cloud_dataproc_v1::Result;
2369 /// async fn sample(
2370 /// client: &SessionTemplateController
2371 /// ) -> Result<()> {
2372 /// let response = client.get_iam_policy()
2373 /// /* set fields */
2374 /// .send().await?;
2375 /// println!("response {:?}", response);
2376 /// Ok(())
2377 /// }
2378 /// ```
2379 pub fn get_iam_policy(&self) -> super::builder::session_template_controller::GetIamPolicy {
2380 super::builder::session_template_controller::GetIamPolicy::new(self.inner.clone())
2381 }
2382
2383 /// Returns permissions that a caller has on the specified resource. If the
2384 /// resource does not exist, this will return an empty set of
2385 /// permissions, not a `NOT_FOUND` error.
2386 ///
2387 /// Note: This operation is designed to be used for building
2388 /// permission-aware UIs and command-line tools, not for authorization
2389 /// checking. This operation may "fail open" without warning.
2390 ///
2391 /// # Example
2392 /// ```
2393 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2394 /// use google_cloud_dataproc_v1::Result;
2395 /// async fn sample(
2396 /// client: &SessionTemplateController
2397 /// ) -> Result<()> {
2398 /// let response = client.test_iam_permissions()
2399 /// /* set fields */
2400 /// .send().await?;
2401 /// println!("response {:?}", response);
2402 /// Ok(())
2403 /// }
2404 /// ```
2405 pub fn test_iam_permissions(
2406 &self,
2407 ) -> super::builder::session_template_controller::TestIamPermissions {
2408 super::builder::session_template_controller::TestIamPermissions::new(self.inner.clone())
2409 }
2410
2411 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2412 ///
2413 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2414 ///
2415 /// # Example
2416 /// ```
2417 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2418 /// use google_cloud_gax::paginator::ItemPaginator as _;
2419 /// use google_cloud_dataproc_v1::Result;
2420 /// async fn sample(
2421 /// client: &SessionTemplateController
2422 /// ) -> Result<()> {
2423 /// let mut list = client.list_operations()
2424 /// /* set fields */
2425 /// .by_item();
2426 /// while let Some(item) = list.next().await.transpose()? {
2427 /// println!("{:?}", item);
2428 /// }
2429 /// Ok(())
2430 /// }
2431 /// ```
2432 pub fn list_operations(&self) -> super::builder::session_template_controller::ListOperations {
2433 super::builder::session_template_controller::ListOperations::new(self.inner.clone())
2434 }
2435
2436 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2437 ///
2438 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2439 ///
2440 /// # Example
2441 /// ```
2442 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2443 /// use google_cloud_dataproc_v1::Result;
2444 /// async fn sample(
2445 /// client: &SessionTemplateController
2446 /// ) -> Result<()> {
2447 /// let response = client.get_operation()
2448 /// /* set fields */
2449 /// .send().await?;
2450 /// println!("response {:?}", response);
2451 /// Ok(())
2452 /// }
2453 /// ```
2454 pub fn get_operation(&self) -> super::builder::session_template_controller::GetOperation {
2455 super::builder::session_template_controller::GetOperation::new(self.inner.clone())
2456 }
2457
2458 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2459 ///
2460 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2461 ///
2462 /// # Example
2463 /// ```
2464 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2465 /// use google_cloud_dataproc_v1::Result;
2466 /// async fn sample(
2467 /// client: &SessionTemplateController
2468 /// ) -> Result<()> {
2469 /// client.delete_operation()
2470 /// /* set fields */
2471 /// .send().await?;
2472 /// Ok(())
2473 /// }
2474 /// ```
2475 pub fn delete_operation(&self) -> super::builder::session_template_controller::DeleteOperation {
2476 super::builder::session_template_controller::DeleteOperation::new(self.inner.clone())
2477 }
2478
2479 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2480 ///
2481 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2482 ///
2483 /// # Example
2484 /// ```
2485 /// # use google_cloud_dataproc_v1::client::SessionTemplateController;
2486 /// use google_cloud_dataproc_v1::Result;
2487 /// async fn sample(
2488 /// client: &SessionTemplateController
2489 /// ) -> Result<()> {
2490 /// client.cancel_operation()
2491 /// /* set fields */
2492 /// .send().await?;
2493 /// Ok(())
2494 /// }
2495 /// ```
2496 pub fn cancel_operation(&self) -> super::builder::session_template_controller::CancelOperation {
2497 super::builder::session_template_controller::CancelOperation::new(self.inner.clone())
2498 }
2499}
2500
2501/// Implements a client for the Cloud Dataproc API.
2502///
2503/// # Example
2504/// ```
2505/// # use google_cloud_dataproc_v1::client::SessionController;
2506/// use google_cloud_gax::paginator::ItemPaginator as _;
2507/// async fn sample(
2508/// project_id: &str,
2509/// location_id: &str,
2510/// ) -> anyhow::Result<()> {
2511/// let client = SessionController::builder().build().await?;
2512/// let mut list = client.list_sessions()
2513/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2514/// .by_item();
2515/// while let Some(item) = list.next().await.transpose()? {
2516/// println!("{:?}", item);
2517/// }
2518/// Ok(())
2519/// }
2520/// ```
2521///
2522/// # Service Description
2523///
2524/// The `SessionController` provides methods to manage interactive sessions.
2525///
2526/// # Configuration
2527///
2528/// To configure `SessionController` use the `with_*` methods in the type returned
2529/// by [builder()][SessionController::builder]. The default configuration should
2530/// work for most applications. Common configuration changes include
2531///
2532/// * [with_endpoint()]: by default this client uses the global default endpoint
2533/// (`https://dataproc.googleapis.com`). Applications using regional
2534/// endpoints or running in restricted networks (e.g. a network configured
2535/// with [Private Google Access with VPC Service Controls]) may want to
2536/// override this default.
2537/// * [with_credentials()]: by default this client uses
2538/// [Application Default Credentials]. Applications using custom
2539/// authentication may need to override this default.
2540///
2541/// [with_endpoint()]: super::builder::session_controller::ClientBuilder::with_endpoint
2542/// [with_credentials()]: super::builder::session_controller::ClientBuilder::with_credentials
2543/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2544/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2545///
2546/// # Pooling and Cloning
2547///
2548/// `SessionController` holds a connection pool internally, it is advised to
2549/// create one and reuse it. You do not need to wrap `SessionController` in
2550/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2551/// already uses an `Arc` internally.
2552#[derive(Clone, Debug)]
2553pub struct SessionController {
2554 inner: std::sync::Arc<dyn super::stub::dynamic::SessionController>,
2555}
2556
2557impl SessionController {
2558 /// Returns a builder for [SessionController].
2559 ///
2560 /// ```
2561 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2562 /// # use google_cloud_dataproc_v1::client::SessionController;
2563 /// let client = SessionController::builder().build().await?;
2564 /// # Ok(()) }
2565 /// ```
2566 pub fn builder() -> super::builder::session_controller::ClientBuilder {
2567 crate::new_client_builder(super::builder::session_controller::client::Factory)
2568 }
2569
2570 /// Creates a new client from the provided stub.
2571 ///
2572 /// The most common case for calling this function is in tests mocking the
2573 /// client's behavior.
2574 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2575 where
2576 T: super::stub::SessionController + 'static,
2577 {
2578 Self { inner: stub.into() }
2579 }
2580
2581 pub(crate) async fn new(
2582 config: gaxi::options::ClientConfig,
2583 ) -> crate::ClientBuilderResult<Self> {
2584 let inner = Self::build_inner(config).await?;
2585 Ok(Self { inner })
2586 }
2587
2588 async fn build_inner(
2589 conf: gaxi::options::ClientConfig,
2590 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SessionController>>
2591 {
2592 if gaxi::options::tracing_enabled(&conf) {
2593 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2594 }
2595 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2596 }
2597
2598 async fn build_transport(
2599 conf: gaxi::options::ClientConfig,
2600 ) -> crate::ClientBuilderResult<impl super::stub::SessionController> {
2601 super::transport::SessionController::new(conf).await
2602 }
2603
2604 async fn build_with_tracing(
2605 conf: gaxi::options::ClientConfig,
2606 ) -> crate::ClientBuilderResult<impl super::stub::SessionController> {
2607 Self::build_transport(conf)
2608 .await
2609 .map(super::tracing::SessionController::new)
2610 }
2611
2612 /// Create an interactive session asynchronously.
2613 ///
2614 /// # Long running operations
2615 ///
2616 /// This method is used to start, and/or poll a [long-running Operation].
2617 /// The [Working with long-running operations] chapter in the [user guide]
2618 /// covers these operations in detail.
2619 ///
2620 /// [long-running operation]: https://google.aip.dev/151
2621 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2622 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2623 ///
2624 /// # Example
2625 /// ```
2626 /// # use google_cloud_dataproc_v1::client::SessionController;
2627 /// use google_cloud_lro::Poller;
2628 /// use google_cloud_dataproc_v1::model::Session;
2629 /// use google_cloud_dataproc_v1::Result;
2630 /// async fn sample(
2631 /// client: &SessionController, project_id: &str, location_id: &str
2632 /// ) -> Result<()> {
2633 /// let response = client.create_session()
2634 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2635 /// .set_session_id("session_id_value")
2636 /// .set_session(
2637 /// Session::new()/* set fields */
2638 /// )
2639 /// .poller().until_done().await?;
2640 /// println!("response {:?}", response);
2641 /// Ok(())
2642 /// }
2643 /// ```
2644 pub fn create_session(&self) -> super::builder::session_controller::CreateSession {
2645 super::builder::session_controller::CreateSession::new(self.inner.clone())
2646 }
2647
2648 /// Gets the resource representation for an interactive session.
2649 ///
2650 /// # Example
2651 /// ```
2652 /// # use google_cloud_dataproc_v1::client::SessionController;
2653 /// use google_cloud_dataproc_v1::Result;
2654 /// async fn sample(
2655 /// client: &SessionController, project_id: &str, location_id: &str, session_id: &str
2656 /// ) -> Result<()> {
2657 /// let response = client.get_session()
2658 /// .set_name(format!("projects/{project_id}/locations/{location_id}/sessions/{session_id}"))
2659 /// .send().await?;
2660 /// println!("response {:?}", response);
2661 /// Ok(())
2662 /// }
2663 /// ```
2664 pub fn get_session(&self) -> super::builder::session_controller::GetSession {
2665 super::builder::session_controller::GetSession::new(self.inner.clone())
2666 }
2667
2668 /// Lists interactive sessions.
2669 ///
2670 /// # Example
2671 /// ```
2672 /// # use google_cloud_dataproc_v1::client::SessionController;
2673 /// use google_cloud_gax::paginator::ItemPaginator as _;
2674 /// use google_cloud_dataproc_v1::Result;
2675 /// async fn sample(
2676 /// client: &SessionController, project_id: &str, location_id: &str
2677 /// ) -> Result<()> {
2678 /// let mut list = client.list_sessions()
2679 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2680 /// .by_item();
2681 /// while let Some(item) = list.next().await.transpose()? {
2682 /// println!("{:?}", item);
2683 /// }
2684 /// Ok(())
2685 /// }
2686 /// ```
2687 pub fn list_sessions(&self) -> super::builder::session_controller::ListSessions {
2688 super::builder::session_controller::ListSessions::new(self.inner.clone())
2689 }
2690
2691 /// Terminates the interactive session.
2692 ///
2693 /// # Long running operations
2694 ///
2695 /// This method is used to start, and/or poll a [long-running Operation].
2696 /// The [Working with long-running operations] chapter in the [user guide]
2697 /// covers these operations in detail.
2698 ///
2699 /// [long-running operation]: https://google.aip.dev/151
2700 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2701 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2702 ///
2703 /// # Example
2704 /// ```
2705 /// # use google_cloud_dataproc_v1::client::SessionController;
2706 /// use google_cloud_lro::Poller;
2707 /// use google_cloud_dataproc_v1::Result;
2708 /// async fn sample(
2709 /// client: &SessionController
2710 /// ) -> Result<()> {
2711 /// let response = client.terminate_session()
2712 /// /* set fields */
2713 /// .poller().until_done().await?;
2714 /// println!("response {:?}", response);
2715 /// Ok(())
2716 /// }
2717 /// ```
2718 pub fn terminate_session(&self) -> super::builder::session_controller::TerminateSession {
2719 super::builder::session_controller::TerminateSession::new(self.inner.clone())
2720 }
2721
2722 /// Deletes the interactive session resource. If the session is not in terminal
2723 /// state, it is terminated, and then deleted.
2724 ///
2725 /// # Long running operations
2726 ///
2727 /// This method is used to start, and/or poll a [long-running Operation].
2728 /// The [Working with long-running operations] chapter in the [user guide]
2729 /// covers these operations in detail.
2730 ///
2731 /// [long-running operation]: https://google.aip.dev/151
2732 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2733 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2734 ///
2735 /// # Example
2736 /// ```
2737 /// # use google_cloud_dataproc_v1::client::SessionController;
2738 /// use google_cloud_lro::Poller;
2739 /// use google_cloud_dataproc_v1::Result;
2740 /// async fn sample(
2741 /// client: &SessionController, project_id: &str, location_id: &str, session_id: &str
2742 /// ) -> Result<()> {
2743 /// let response = client.delete_session()
2744 /// .set_name(format!("projects/{project_id}/locations/{location_id}/sessions/{session_id}"))
2745 /// .poller().until_done().await?;
2746 /// println!("response {:?}", response);
2747 /// Ok(())
2748 /// }
2749 /// ```
2750 pub fn delete_session(&self) -> super::builder::session_controller::DeleteSession {
2751 super::builder::session_controller::DeleteSession::new(self.inner.clone())
2752 }
2753
2754 /// Sets the access control policy on the specified resource. Replaces
2755 /// any existing policy.
2756 ///
2757 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
2758 /// errors.
2759 ///
2760 /// # Example
2761 /// ```
2762 /// # use google_cloud_dataproc_v1::client::SessionController;
2763 /// use google_cloud_dataproc_v1::Result;
2764 /// async fn sample(
2765 /// client: &SessionController
2766 /// ) -> Result<()> {
2767 /// let response = client.set_iam_policy()
2768 /// /* set fields */
2769 /// .send().await?;
2770 /// println!("response {:?}", response);
2771 /// Ok(())
2772 /// }
2773 /// ```
2774 pub fn set_iam_policy(&self) -> super::builder::session_controller::SetIamPolicy {
2775 super::builder::session_controller::SetIamPolicy::new(self.inner.clone())
2776 }
2777
2778 /// Gets the access control policy for a resource. Returns an empty policy
2779 /// if the resource exists and does not have a policy set.
2780 ///
2781 /// # Example
2782 /// ```
2783 /// # use google_cloud_dataproc_v1::client::SessionController;
2784 /// use google_cloud_dataproc_v1::Result;
2785 /// async fn sample(
2786 /// client: &SessionController
2787 /// ) -> Result<()> {
2788 /// let response = client.get_iam_policy()
2789 /// /* set fields */
2790 /// .send().await?;
2791 /// println!("response {:?}", response);
2792 /// Ok(())
2793 /// }
2794 /// ```
2795 pub fn get_iam_policy(&self) -> super::builder::session_controller::GetIamPolicy {
2796 super::builder::session_controller::GetIamPolicy::new(self.inner.clone())
2797 }
2798
2799 /// Returns permissions that a caller has on the specified resource. If the
2800 /// resource does not exist, this will return an empty set of
2801 /// permissions, not a `NOT_FOUND` error.
2802 ///
2803 /// Note: This operation is designed to be used for building
2804 /// permission-aware UIs and command-line tools, not for authorization
2805 /// checking. This operation may "fail open" without warning.
2806 ///
2807 /// # Example
2808 /// ```
2809 /// # use google_cloud_dataproc_v1::client::SessionController;
2810 /// use google_cloud_dataproc_v1::Result;
2811 /// async fn sample(
2812 /// client: &SessionController
2813 /// ) -> Result<()> {
2814 /// let response = client.test_iam_permissions()
2815 /// /* set fields */
2816 /// .send().await?;
2817 /// println!("response {:?}", response);
2818 /// Ok(())
2819 /// }
2820 /// ```
2821 pub fn test_iam_permissions(&self) -> super::builder::session_controller::TestIamPermissions {
2822 super::builder::session_controller::TestIamPermissions::new(self.inner.clone())
2823 }
2824
2825 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2826 ///
2827 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2828 ///
2829 /// # Example
2830 /// ```
2831 /// # use google_cloud_dataproc_v1::client::SessionController;
2832 /// use google_cloud_gax::paginator::ItemPaginator as _;
2833 /// use google_cloud_dataproc_v1::Result;
2834 /// async fn sample(
2835 /// client: &SessionController
2836 /// ) -> Result<()> {
2837 /// let mut list = client.list_operations()
2838 /// /* set fields */
2839 /// .by_item();
2840 /// while let Some(item) = list.next().await.transpose()? {
2841 /// println!("{:?}", item);
2842 /// }
2843 /// Ok(())
2844 /// }
2845 /// ```
2846 pub fn list_operations(&self) -> super::builder::session_controller::ListOperations {
2847 super::builder::session_controller::ListOperations::new(self.inner.clone())
2848 }
2849
2850 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2851 ///
2852 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2853 ///
2854 /// # Example
2855 /// ```
2856 /// # use google_cloud_dataproc_v1::client::SessionController;
2857 /// use google_cloud_dataproc_v1::Result;
2858 /// async fn sample(
2859 /// client: &SessionController
2860 /// ) -> Result<()> {
2861 /// let response = client.get_operation()
2862 /// /* set fields */
2863 /// .send().await?;
2864 /// println!("response {:?}", response);
2865 /// Ok(())
2866 /// }
2867 /// ```
2868 pub fn get_operation(&self) -> super::builder::session_controller::GetOperation {
2869 super::builder::session_controller::GetOperation::new(self.inner.clone())
2870 }
2871
2872 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2873 ///
2874 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2875 ///
2876 /// # Example
2877 /// ```
2878 /// # use google_cloud_dataproc_v1::client::SessionController;
2879 /// use google_cloud_dataproc_v1::Result;
2880 /// async fn sample(
2881 /// client: &SessionController
2882 /// ) -> Result<()> {
2883 /// client.delete_operation()
2884 /// /* set fields */
2885 /// .send().await?;
2886 /// Ok(())
2887 /// }
2888 /// ```
2889 pub fn delete_operation(&self) -> super::builder::session_controller::DeleteOperation {
2890 super::builder::session_controller::DeleteOperation::new(self.inner.clone())
2891 }
2892
2893 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2894 ///
2895 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2896 ///
2897 /// # Example
2898 /// ```
2899 /// # use google_cloud_dataproc_v1::client::SessionController;
2900 /// use google_cloud_dataproc_v1::Result;
2901 /// async fn sample(
2902 /// client: &SessionController
2903 /// ) -> Result<()> {
2904 /// client.cancel_operation()
2905 /// /* set fields */
2906 /// .send().await?;
2907 /// Ok(())
2908 /// }
2909 /// ```
2910 pub fn cancel_operation(&self) -> super::builder::session_controller::CancelOperation {
2911 super::builder::session_controller::CancelOperation::new(self.inner.clone())
2912 }
2913}
2914
2915/// Implements a client for the Cloud Dataproc API.
2916///
2917/// # Example
2918/// ```
2919/// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
2920/// use google_cloud_gax::paginator::ItemPaginator as _;
2921/// async fn sample(
2922/// project_id: &str,
2923/// region_id: &str,
2924/// ) -> anyhow::Result<()> {
2925/// let client = WorkflowTemplateService::builder().build().await?;
2926/// let mut list = client.list_workflow_templates()
2927/// .set_parent(format!("projects/{project_id}/regions/{region_id}"))
2928/// .by_item();
2929/// while let Some(item) = list.next().await.transpose()? {
2930/// println!("{:?}", item);
2931/// }
2932/// Ok(())
2933/// }
2934/// ```
2935///
2936/// # Service Description
2937///
2938/// The API interface for managing Workflow Templates in the
2939/// Dataproc API.
2940///
2941/// # Configuration
2942///
2943/// To configure `WorkflowTemplateService` use the `with_*` methods in the type returned
2944/// by [builder()][WorkflowTemplateService::builder]. The default configuration should
2945/// work for most applications. Common configuration changes include
2946///
2947/// * [with_endpoint()]: by default this client uses the global default endpoint
2948/// (`https://dataproc.googleapis.com`). Applications using regional
2949/// endpoints or running in restricted networks (e.g. a network configured
2950/// with [Private Google Access with VPC Service Controls]) may want to
2951/// override this default.
2952/// * [with_credentials()]: by default this client uses
2953/// [Application Default Credentials]. Applications using custom
2954/// authentication may need to override this default.
2955///
2956/// [with_endpoint()]: super::builder::workflow_template_service::ClientBuilder::with_endpoint
2957/// [with_credentials()]: super::builder::workflow_template_service::ClientBuilder::with_credentials
2958/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2959/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2960///
2961/// # Pooling and Cloning
2962///
2963/// `WorkflowTemplateService` holds a connection pool internally, it is advised to
2964/// create one and reuse it. You do not need to wrap `WorkflowTemplateService` in
2965/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2966/// already uses an `Arc` internally.
2967#[derive(Clone, Debug)]
2968pub struct WorkflowTemplateService {
2969 inner: std::sync::Arc<dyn super::stub::dynamic::WorkflowTemplateService>,
2970}
2971
2972impl WorkflowTemplateService {
2973 /// Returns a builder for [WorkflowTemplateService].
2974 ///
2975 /// ```
2976 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2977 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
2978 /// let client = WorkflowTemplateService::builder().build().await?;
2979 /// # Ok(()) }
2980 /// ```
2981 pub fn builder() -> super::builder::workflow_template_service::ClientBuilder {
2982 crate::new_client_builder(super::builder::workflow_template_service::client::Factory)
2983 }
2984
2985 /// Creates a new client from the provided stub.
2986 ///
2987 /// The most common case for calling this function is in tests mocking the
2988 /// client's behavior.
2989 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2990 where
2991 T: super::stub::WorkflowTemplateService + 'static,
2992 {
2993 Self { inner: stub.into() }
2994 }
2995
2996 pub(crate) async fn new(
2997 config: gaxi::options::ClientConfig,
2998 ) -> crate::ClientBuilderResult<Self> {
2999 let inner = Self::build_inner(config).await?;
3000 Ok(Self { inner })
3001 }
3002
3003 async fn build_inner(
3004 conf: gaxi::options::ClientConfig,
3005 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::WorkflowTemplateService>>
3006 {
3007 if gaxi::options::tracing_enabled(&conf) {
3008 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
3009 }
3010 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
3011 }
3012
3013 async fn build_transport(
3014 conf: gaxi::options::ClientConfig,
3015 ) -> crate::ClientBuilderResult<impl super::stub::WorkflowTemplateService> {
3016 super::transport::WorkflowTemplateService::new(conf).await
3017 }
3018
3019 async fn build_with_tracing(
3020 conf: gaxi::options::ClientConfig,
3021 ) -> crate::ClientBuilderResult<impl super::stub::WorkflowTemplateService> {
3022 Self::build_transport(conf)
3023 .await
3024 .map(super::tracing::WorkflowTemplateService::new)
3025 }
3026
3027 /// Creates new workflow template.
3028 ///
3029 /// # Example
3030 /// ```
3031 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3032 /// use google_cloud_dataproc_v1::model::WorkflowTemplate;
3033 /// use google_cloud_dataproc_v1::Result;
3034 /// async fn sample(
3035 /// client: &WorkflowTemplateService, project_id: &str, region_id: &str
3036 /// ) -> Result<()> {
3037 /// let response = client.create_workflow_template()
3038 /// .set_parent(format!("projects/{project_id}/regions/{region_id}"))
3039 /// .set_template(
3040 /// WorkflowTemplate::new()/* set fields */
3041 /// )
3042 /// .send().await?;
3043 /// println!("response {:?}", response);
3044 /// Ok(())
3045 /// }
3046 /// ```
3047 pub fn create_workflow_template(
3048 &self,
3049 ) -> super::builder::workflow_template_service::CreateWorkflowTemplate {
3050 super::builder::workflow_template_service::CreateWorkflowTemplate::new(self.inner.clone())
3051 }
3052
3053 /// Retrieves the latest workflow template.
3054 ///
3055 /// Can retrieve previously instantiated template by specifying optional
3056 /// version parameter.
3057 ///
3058 /// # Example
3059 /// ```
3060 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3061 /// use google_cloud_dataproc_v1::Result;
3062 /// async fn sample(
3063 /// client: &WorkflowTemplateService, project_id: &str, region_id: &str, workflow_template_id: &str
3064 /// ) -> Result<()> {
3065 /// let response = client.get_workflow_template()
3066 /// .set_name(format!("projects/{project_id}/regions/{region_id}/workflowTemplates/{workflow_template_id}"))
3067 /// .send().await?;
3068 /// println!("response {:?}", response);
3069 /// Ok(())
3070 /// }
3071 /// ```
3072 pub fn get_workflow_template(
3073 &self,
3074 ) -> super::builder::workflow_template_service::GetWorkflowTemplate {
3075 super::builder::workflow_template_service::GetWorkflowTemplate::new(self.inner.clone())
3076 }
3077
3078 /// Instantiates a template and begins execution.
3079 ///
3080 /// The returned Operation can be used to track execution of
3081 /// workflow by polling
3082 /// [operations.get][google.longrunning.Operations.GetOperation].
3083 /// The Operation will complete when entire workflow is finished.
3084 ///
3085 /// The running workflow can be aborted via
3086 /// [operations.cancel][google.longrunning.Operations.CancelOperation].
3087 /// This will cause any inflight jobs to be cancelled and workflow-owned
3088 /// clusters to be deleted.
3089 ///
3090 /// The [Operation.metadata][google.longrunning.Operation.metadata] will be
3091 /// [WorkflowMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata).
3092 /// Also see [Using
3093 /// WorkflowMetadata](https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata).
3094 ///
3095 /// On successful completion,
3096 /// [Operation.response][google.longrunning.Operation.response] will be
3097 /// [Empty][google.protobuf.Empty].
3098 ///
3099 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
3100 /// [google.longrunning.Operation.response]: google_cloud_longrunning::model::Operation::result
3101 /// [google.protobuf.Empty]: wkt::Empty
3102 ///
3103 /// # Long running operations
3104 ///
3105 /// This method is used to start, and/or poll a [long-running Operation].
3106 /// The [Working with long-running operations] chapter in the [user guide]
3107 /// covers these operations in detail.
3108 ///
3109 /// [long-running operation]: https://google.aip.dev/151
3110 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3111 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3112 ///
3113 /// # Example
3114 /// ```
3115 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3116 /// use google_cloud_lro::Poller;
3117 /// use google_cloud_dataproc_v1::Result;
3118 /// async fn sample(
3119 /// client: &WorkflowTemplateService
3120 /// ) -> Result<()> {
3121 /// client.instantiate_workflow_template()
3122 /// /* set fields */
3123 /// .poller().until_done().await?;
3124 /// Ok(())
3125 /// }
3126 /// ```
3127 pub fn instantiate_workflow_template(
3128 &self,
3129 ) -> super::builder::workflow_template_service::InstantiateWorkflowTemplate {
3130 super::builder::workflow_template_service::InstantiateWorkflowTemplate::new(
3131 self.inner.clone(),
3132 )
3133 }
3134
3135 /// Instantiates a template and begins execution.
3136 ///
3137 /// This method is equivalent to executing the sequence
3138 /// [CreateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.CreateWorkflowTemplate],
3139 /// [InstantiateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.InstantiateWorkflowTemplate],
3140 /// [DeleteWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.DeleteWorkflowTemplate].
3141 ///
3142 /// The returned Operation can be used to track execution of
3143 /// workflow by polling
3144 /// [operations.get][google.longrunning.Operations.GetOperation].
3145 /// The Operation will complete when entire workflow is finished.
3146 ///
3147 /// The running workflow can be aborted via
3148 /// [operations.cancel][google.longrunning.Operations.CancelOperation].
3149 /// This will cause any inflight jobs to be cancelled and workflow-owned
3150 /// clusters to be deleted.
3151 ///
3152 /// The [Operation.metadata][google.longrunning.Operation.metadata] will be
3153 /// [WorkflowMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata).
3154 /// Also see [Using
3155 /// WorkflowMetadata](https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata).
3156 ///
3157 /// On successful completion,
3158 /// [Operation.response][google.longrunning.Operation.response] will be
3159 /// [Empty][google.protobuf.Empty].
3160 ///
3161 /// [google.cloud.dataproc.v1.WorkflowTemplateService.CreateWorkflowTemplate]: crate::client::WorkflowTemplateService::create_workflow_template
3162 /// [google.cloud.dataproc.v1.WorkflowTemplateService.DeleteWorkflowTemplate]: crate::client::WorkflowTemplateService::delete_workflow_template
3163 /// [google.cloud.dataproc.v1.WorkflowTemplateService.InstantiateWorkflowTemplate]: crate::client::WorkflowTemplateService::instantiate_workflow_template
3164 /// [google.longrunning.Operation.metadata]: google_cloud_longrunning::model::Operation::metadata
3165 /// [google.longrunning.Operation.response]: google_cloud_longrunning::model::Operation::result
3166 /// [google.protobuf.Empty]: wkt::Empty
3167 ///
3168 /// # Long running operations
3169 ///
3170 /// This method is used to start, and/or poll a [long-running Operation].
3171 /// The [Working with long-running operations] chapter in the [user guide]
3172 /// covers these operations in detail.
3173 ///
3174 /// [long-running operation]: https://google.aip.dev/151
3175 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
3176 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
3177 ///
3178 /// # Example
3179 /// ```
3180 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3181 /// use google_cloud_lro::Poller;
3182 /// use google_cloud_dataproc_v1::Result;
3183 /// async fn sample(
3184 /// client: &WorkflowTemplateService
3185 /// ) -> Result<()> {
3186 /// client.instantiate_inline_workflow_template()
3187 /// /* set fields */
3188 /// .poller().until_done().await?;
3189 /// Ok(())
3190 /// }
3191 /// ```
3192 pub fn instantiate_inline_workflow_template(
3193 &self,
3194 ) -> super::builder::workflow_template_service::InstantiateInlineWorkflowTemplate {
3195 super::builder::workflow_template_service::InstantiateInlineWorkflowTemplate::new(
3196 self.inner.clone(),
3197 )
3198 }
3199
3200 /// Updates (replaces) workflow template. The updated template
3201 /// must contain version that matches the current server version.
3202 ///
3203 /// # Example
3204 /// ```
3205 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3206 /// use google_cloud_dataproc_v1::model::WorkflowTemplate;
3207 /// use google_cloud_dataproc_v1::Result;
3208 /// async fn sample(
3209 /// client: &WorkflowTemplateService, project_id: &str, region_id: &str, workflow_template_id: &str
3210 /// ) -> Result<()> {
3211 /// let response = client.update_workflow_template()
3212 /// .set_template(
3213 /// WorkflowTemplate::new().set_name(format!("projects/{project_id}/regions/{region_id}/workflowTemplates/{workflow_template_id}"))/* set fields */
3214 /// )
3215 /// .send().await?;
3216 /// println!("response {:?}", response);
3217 /// Ok(())
3218 /// }
3219 /// ```
3220 pub fn update_workflow_template(
3221 &self,
3222 ) -> super::builder::workflow_template_service::UpdateWorkflowTemplate {
3223 super::builder::workflow_template_service::UpdateWorkflowTemplate::new(self.inner.clone())
3224 }
3225
3226 /// Lists workflows that match the specified filter in the request.
3227 ///
3228 /// # Example
3229 /// ```
3230 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3231 /// use google_cloud_gax::paginator::ItemPaginator as _;
3232 /// use google_cloud_dataproc_v1::Result;
3233 /// async fn sample(
3234 /// client: &WorkflowTemplateService, project_id: &str, region_id: &str
3235 /// ) -> Result<()> {
3236 /// let mut list = client.list_workflow_templates()
3237 /// .set_parent(format!("projects/{project_id}/regions/{region_id}"))
3238 /// .by_item();
3239 /// while let Some(item) = list.next().await.transpose()? {
3240 /// println!("{:?}", item);
3241 /// }
3242 /// Ok(())
3243 /// }
3244 /// ```
3245 pub fn list_workflow_templates(
3246 &self,
3247 ) -> super::builder::workflow_template_service::ListWorkflowTemplates {
3248 super::builder::workflow_template_service::ListWorkflowTemplates::new(self.inner.clone())
3249 }
3250
3251 /// Deletes a workflow template. It does not cancel in-progress workflows.
3252 ///
3253 /// # Example
3254 /// ```
3255 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3256 /// use google_cloud_dataproc_v1::Result;
3257 /// async fn sample(
3258 /// client: &WorkflowTemplateService, project_id: &str, region_id: &str, workflow_template_id: &str
3259 /// ) -> Result<()> {
3260 /// client.delete_workflow_template()
3261 /// .set_name(format!("projects/{project_id}/regions/{region_id}/workflowTemplates/{workflow_template_id}"))
3262 /// .send().await?;
3263 /// Ok(())
3264 /// }
3265 /// ```
3266 pub fn delete_workflow_template(
3267 &self,
3268 ) -> super::builder::workflow_template_service::DeleteWorkflowTemplate {
3269 super::builder::workflow_template_service::DeleteWorkflowTemplate::new(self.inner.clone())
3270 }
3271
3272 /// Sets the access control policy on the specified resource. Replaces
3273 /// any existing policy.
3274 ///
3275 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
3276 /// errors.
3277 ///
3278 /// # Example
3279 /// ```
3280 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3281 /// use google_cloud_dataproc_v1::Result;
3282 /// async fn sample(
3283 /// client: &WorkflowTemplateService
3284 /// ) -> Result<()> {
3285 /// let response = client.set_iam_policy()
3286 /// /* set fields */
3287 /// .send().await?;
3288 /// println!("response {:?}", response);
3289 /// Ok(())
3290 /// }
3291 /// ```
3292 pub fn set_iam_policy(&self) -> super::builder::workflow_template_service::SetIamPolicy {
3293 super::builder::workflow_template_service::SetIamPolicy::new(self.inner.clone())
3294 }
3295
3296 /// Gets the access control policy for a resource. Returns an empty policy
3297 /// if the resource exists and does not have a policy set.
3298 ///
3299 /// # Example
3300 /// ```
3301 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3302 /// use google_cloud_dataproc_v1::Result;
3303 /// async fn sample(
3304 /// client: &WorkflowTemplateService
3305 /// ) -> Result<()> {
3306 /// let response = client.get_iam_policy()
3307 /// /* set fields */
3308 /// .send().await?;
3309 /// println!("response {:?}", response);
3310 /// Ok(())
3311 /// }
3312 /// ```
3313 pub fn get_iam_policy(&self) -> super::builder::workflow_template_service::GetIamPolicy {
3314 super::builder::workflow_template_service::GetIamPolicy::new(self.inner.clone())
3315 }
3316
3317 /// Returns permissions that a caller has on the specified resource. If the
3318 /// resource does not exist, this will return an empty set of
3319 /// permissions, not a `NOT_FOUND` error.
3320 ///
3321 /// Note: This operation is designed to be used for building
3322 /// permission-aware UIs and command-line tools, not for authorization
3323 /// checking. This operation may "fail open" without warning.
3324 ///
3325 /// # Example
3326 /// ```
3327 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3328 /// use google_cloud_dataproc_v1::Result;
3329 /// async fn sample(
3330 /// client: &WorkflowTemplateService
3331 /// ) -> Result<()> {
3332 /// let response = client.test_iam_permissions()
3333 /// /* set fields */
3334 /// .send().await?;
3335 /// println!("response {:?}", response);
3336 /// Ok(())
3337 /// }
3338 /// ```
3339 pub fn test_iam_permissions(
3340 &self,
3341 ) -> super::builder::workflow_template_service::TestIamPermissions {
3342 super::builder::workflow_template_service::TestIamPermissions::new(self.inner.clone())
3343 }
3344
3345 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3346 ///
3347 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3348 ///
3349 /// # Example
3350 /// ```
3351 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3352 /// use google_cloud_gax::paginator::ItemPaginator as _;
3353 /// use google_cloud_dataproc_v1::Result;
3354 /// async fn sample(
3355 /// client: &WorkflowTemplateService
3356 /// ) -> Result<()> {
3357 /// let mut list = client.list_operations()
3358 /// /* set fields */
3359 /// .by_item();
3360 /// while let Some(item) = list.next().await.transpose()? {
3361 /// println!("{:?}", item);
3362 /// }
3363 /// Ok(())
3364 /// }
3365 /// ```
3366 pub fn list_operations(&self) -> super::builder::workflow_template_service::ListOperations {
3367 super::builder::workflow_template_service::ListOperations::new(self.inner.clone())
3368 }
3369
3370 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3371 ///
3372 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3373 ///
3374 /// # Example
3375 /// ```
3376 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3377 /// use google_cloud_dataproc_v1::Result;
3378 /// async fn sample(
3379 /// client: &WorkflowTemplateService
3380 /// ) -> Result<()> {
3381 /// let response = client.get_operation()
3382 /// /* set fields */
3383 /// .send().await?;
3384 /// println!("response {:?}", response);
3385 /// Ok(())
3386 /// }
3387 /// ```
3388 pub fn get_operation(&self) -> super::builder::workflow_template_service::GetOperation {
3389 super::builder::workflow_template_service::GetOperation::new(self.inner.clone())
3390 }
3391
3392 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3393 ///
3394 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3395 ///
3396 /// # Example
3397 /// ```
3398 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3399 /// use google_cloud_dataproc_v1::Result;
3400 /// async fn sample(
3401 /// client: &WorkflowTemplateService
3402 /// ) -> Result<()> {
3403 /// client.delete_operation()
3404 /// /* set fields */
3405 /// .send().await?;
3406 /// Ok(())
3407 /// }
3408 /// ```
3409 pub fn delete_operation(&self) -> super::builder::workflow_template_service::DeleteOperation {
3410 super::builder::workflow_template_service::DeleteOperation::new(self.inner.clone())
3411 }
3412
3413 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3414 ///
3415 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3416 ///
3417 /// # Example
3418 /// ```
3419 /// # use google_cloud_dataproc_v1::client::WorkflowTemplateService;
3420 /// use google_cloud_dataproc_v1::Result;
3421 /// async fn sample(
3422 /// client: &WorkflowTemplateService
3423 /// ) -> Result<()> {
3424 /// client.cancel_operation()
3425 /// /* set fields */
3426 /// .send().await?;
3427 /// Ok(())
3428 /// }
3429 /// ```
3430 pub fn cancel_operation(&self) -> super::builder::workflow_template_service::CancelOperation {
3431 super::builder::workflow_template_service::CancelOperation::new(self.inner.clone())
3432 }
3433}