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