google_cloud_run_v2/client.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Cloud Run Admin API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_run_v2::client::Builds;
24/// async fn sample(
25/// ) -> anyhow::Result<()> {
26/// let client = Builds::builder().build().await?;
27/// let response = client.submit_build()
28/// /* set fields */
29/// .send().await?;
30/// println!("response {:?}", response);
31/// Ok(())
32/// }
33/// ```
34///
35/// # Service Description
36///
37/// Cloud Run Build Control Plane API
38///
39/// # Configuration
40///
41/// To configure `Builds` use the `with_*` methods in the type returned
42/// by [builder()][Builds::builder]. The default configuration should
43/// work for most applications. Common configuration changes include
44///
45/// * [with_endpoint()]: by default this client uses the global default endpoint
46/// (`https://run.googleapis.com`). Applications using regional
47/// endpoints or running in restricted networks (e.g. a network configured
48// with [Private Google Access with VPC Service Controls]) may want to
49/// override this default.
50/// * [with_credentials()]: by default this client uses
51/// [Application Default Credentials]. Applications using custom
52/// authentication may need to override this default.
53///
54/// [with_endpoint()]: super::builder::builds::ClientBuilder::with_endpoint
55/// [with_credentials()]: super::builder::builds::ClientBuilder::with_credentials
56/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
57/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
58///
59/// # Pooling and Cloning
60///
61/// `Builds` holds a connection pool internally, it is advised to
62/// create one and reuse it. You do not need to wrap `Builds` in
63/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
64/// already uses an `Arc` internally.
65#[derive(Clone, Debug)]
66pub struct Builds {
67 inner: std::sync::Arc<dyn super::stub::dynamic::Builds>,
68}
69
70impl Builds {
71 /// Returns a builder for [Builds].
72 ///
73 /// ```
74 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
75 /// # use google_cloud_run_v2::client::Builds;
76 /// let client = Builds::builder().build().await?;
77 /// # Ok(()) }
78 /// ```
79 pub fn builder() -> super::builder::builds::ClientBuilder {
80 crate::new_client_builder(super::builder::builds::client::Factory)
81 }
82
83 /// Creates a new client from the provided stub.
84 ///
85 /// The most common case for calling this function is in tests mocking the
86 /// client's behavior.
87 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
88 where
89 T: super::stub::Builds + 'static,
90 {
91 Self { inner: stub.into() }
92 }
93
94 pub(crate) async fn new(
95 config: gaxi::options::ClientConfig,
96 ) -> crate::ClientBuilderResult<Self> {
97 let inner = Self::build_inner(config).await?;
98 Ok(Self { inner })
99 }
100
101 async fn build_inner(
102 conf: gaxi::options::ClientConfig,
103 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Builds>> {
104 if gaxi::options::tracing_enabled(&conf) {
105 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
106 }
107 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
108 }
109
110 async fn build_transport(
111 conf: gaxi::options::ClientConfig,
112 ) -> crate::ClientBuilderResult<impl super::stub::Builds> {
113 super::transport::Builds::new(conf).await
114 }
115
116 async fn build_with_tracing(
117 conf: gaxi::options::ClientConfig,
118 ) -> crate::ClientBuilderResult<impl super::stub::Builds> {
119 Self::build_transport(conf)
120 .await
121 .map(super::tracing::Builds::new)
122 }
123
124 /// Submits a build in a given project.
125 ///
126 /// # Example
127 /// ```
128 /// # use google_cloud_run_v2::client::Builds;
129 /// use google_cloud_run_v2::Result;
130 /// async fn sample(
131 /// client: &Builds
132 /// ) -> Result<()> {
133 /// let response = client.submit_build()
134 /// /* set fields */
135 /// .send().await?;
136 /// println!("response {:?}", response);
137 /// Ok(())
138 /// }
139 /// ```
140 pub fn submit_build(&self) -> super::builder::builds::SubmitBuild {
141 super::builder::builds::SubmitBuild::new(self.inner.clone())
142 }
143
144 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
145 ///
146 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
147 ///
148 /// # Example
149 /// ```
150 /// # use google_cloud_run_v2::client::Builds;
151 /// use google_cloud_gax::paginator::ItemPaginator as _;
152 /// use google_cloud_run_v2::Result;
153 /// async fn sample(
154 /// client: &Builds
155 /// ) -> Result<()> {
156 /// let mut list = client.list_operations()
157 /// /* set fields */
158 /// .by_item();
159 /// while let Some(item) = list.next().await.transpose()? {
160 /// println!("{:?}", item);
161 /// }
162 /// Ok(())
163 /// }
164 /// ```
165 pub fn list_operations(&self) -> super::builder::builds::ListOperations {
166 super::builder::builds::ListOperations::new(self.inner.clone())
167 }
168
169 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
170 ///
171 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
172 ///
173 /// # Example
174 /// ```
175 /// # use google_cloud_run_v2::client::Builds;
176 /// use google_cloud_run_v2::Result;
177 /// async fn sample(
178 /// client: &Builds
179 /// ) -> Result<()> {
180 /// let response = client.get_operation()
181 /// /* set fields */
182 /// .send().await?;
183 /// println!("response {:?}", response);
184 /// Ok(())
185 /// }
186 /// ```
187 pub fn get_operation(&self) -> super::builder::builds::GetOperation {
188 super::builder::builds::GetOperation::new(self.inner.clone())
189 }
190
191 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
192 ///
193 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
194 ///
195 /// # Example
196 /// ```
197 /// # use google_cloud_run_v2::client::Builds;
198 /// use google_cloud_run_v2::Result;
199 /// async fn sample(
200 /// client: &Builds
201 /// ) -> Result<()> {
202 /// client.delete_operation()
203 /// /* set fields */
204 /// .send().await?;
205 /// Ok(())
206 /// }
207 /// ```
208 pub fn delete_operation(&self) -> super::builder::builds::DeleteOperation {
209 super::builder::builds::DeleteOperation::new(self.inner.clone())
210 }
211
212 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
213 ///
214 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
215 ///
216 /// # Example
217 /// ```
218 /// # use google_cloud_run_v2::client::Builds;
219 /// use google_cloud_run_v2::Result;
220 /// async fn sample(
221 /// client: &Builds
222 /// ) -> Result<()> {
223 /// let response = client.wait_operation()
224 /// /* set fields */
225 /// .send().await?;
226 /// println!("response {:?}", response);
227 /// Ok(())
228 /// }
229 /// ```
230 pub fn wait_operation(&self) -> super::builder::builds::WaitOperation {
231 super::builder::builds::WaitOperation::new(self.inner.clone())
232 }
233}
234
235/// Implements a client for the Cloud Run Admin API.
236///
237/// # Example
238/// ```
239/// # use google_cloud_run_v2::client::Executions;
240/// use google_cloud_gax::paginator::ItemPaginator as _;
241/// async fn sample(
242/// project_id: &str,
243/// location_id: &str,
244/// job_id: &str,
245/// ) -> anyhow::Result<()> {
246/// let client = Executions::builder().build().await?;
247/// let mut list = client.list_executions()
248/// .set_parent(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}"))
249/// .by_item();
250/// while let Some(item) = list.next().await.transpose()? {
251/// println!("{:?}", item);
252/// }
253/// Ok(())
254/// }
255/// ```
256///
257/// # Service Description
258///
259/// Cloud Run Execution Control Plane API.
260///
261/// # Configuration
262///
263/// To configure `Executions` use the `with_*` methods in the type returned
264/// by [builder()][Executions::builder]. The default configuration should
265/// work for most applications. Common configuration changes include
266///
267/// * [with_endpoint()]: by default this client uses the global default endpoint
268/// (`https://run.googleapis.com`). Applications using regional
269/// endpoints or running in restricted networks (e.g. a network configured
270// with [Private Google Access with VPC Service Controls]) may want to
271/// override this default.
272/// * [with_credentials()]: by default this client uses
273/// [Application Default Credentials]. Applications using custom
274/// authentication may need to override this default.
275///
276/// [with_endpoint()]: super::builder::executions::ClientBuilder::with_endpoint
277/// [with_credentials()]: super::builder::executions::ClientBuilder::with_credentials
278/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
279/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
280///
281/// # Pooling and Cloning
282///
283/// `Executions` holds a connection pool internally, it is advised to
284/// create one and reuse it. You do not need to wrap `Executions` in
285/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
286/// already uses an `Arc` internally.
287#[derive(Clone, Debug)]
288pub struct Executions {
289 inner: std::sync::Arc<dyn super::stub::dynamic::Executions>,
290}
291
292impl Executions {
293 /// Returns a builder for [Executions].
294 ///
295 /// ```
296 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
297 /// # use google_cloud_run_v2::client::Executions;
298 /// let client = Executions::builder().build().await?;
299 /// # Ok(()) }
300 /// ```
301 pub fn builder() -> super::builder::executions::ClientBuilder {
302 crate::new_client_builder(super::builder::executions::client::Factory)
303 }
304
305 /// Creates a new client from the provided stub.
306 ///
307 /// The most common case for calling this function is in tests mocking the
308 /// client's behavior.
309 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
310 where
311 T: super::stub::Executions + 'static,
312 {
313 Self { inner: stub.into() }
314 }
315
316 pub(crate) async fn new(
317 config: gaxi::options::ClientConfig,
318 ) -> crate::ClientBuilderResult<Self> {
319 let inner = Self::build_inner(config).await?;
320 Ok(Self { inner })
321 }
322
323 async fn build_inner(
324 conf: gaxi::options::ClientConfig,
325 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Executions>> {
326 if gaxi::options::tracing_enabled(&conf) {
327 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
328 }
329 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
330 }
331
332 async fn build_transport(
333 conf: gaxi::options::ClientConfig,
334 ) -> crate::ClientBuilderResult<impl super::stub::Executions> {
335 super::transport::Executions::new(conf).await
336 }
337
338 async fn build_with_tracing(
339 conf: gaxi::options::ClientConfig,
340 ) -> crate::ClientBuilderResult<impl super::stub::Executions> {
341 Self::build_transport(conf)
342 .await
343 .map(super::tracing::Executions::new)
344 }
345
346 /// Gets information about an Execution.
347 ///
348 /// # Example
349 /// ```
350 /// # use google_cloud_run_v2::client::Executions;
351 /// use google_cloud_run_v2::Result;
352 /// async fn sample(
353 /// client: &Executions, project_id: &str, location_id: &str, job_id: &str, execution_id: &str
354 /// ) -> Result<()> {
355 /// let response = client.get_execution()
356 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}/executions/{execution_id}"))
357 /// .send().await?;
358 /// println!("response {:?}", response);
359 /// Ok(())
360 /// }
361 /// ```
362 pub fn get_execution(&self) -> super::builder::executions::GetExecution {
363 super::builder::executions::GetExecution::new(self.inner.clone())
364 }
365
366 /// Lists Executions from a Job. Results are sorted by creation time,
367 /// descending.
368 ///
369 /// # Example
370 /// ```
371 /// # use google_cloud_run_v2::client::Executions;
372 /// use google_cloud_gax::paginator::ItemPaginator as _;
373 /// use google_cloud_run_v2::Result;
374 /// async fn sample(
375 /// client: &Executions, project_id: &str, location_id: &str, job_id: &str
376 /// ) -> Result<()> {
377 /// let mut list = client.list_executions()
378 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}"))
379 /// .by_item();
380 /// while let Some(item) = list.next().await.transpose()? {
381 /// println!("{:?}", item);
382 /// }
383 /// Ok(())
384 /// }
385 /// ```
386 pub fn list_executions(&self) -> super::builder::executions::ListExecutions {
387 super::builder::executions::ListExecutions::new(self.inner.clone())
388 }
389
390 /// Deletes an Execution.
391 ///
392 /// # Long running operations
393 ///
394 /// This method is used to start, and/or poll a [long-running Operation].
395 /// The [Working with long-running operations] chapter in the [user guide]
396 /// covers these operations in detail.
397 ///
398 /// [long-running operation]: https://google.aip.dev/151
399 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
400 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
401 ///
402 /// # Example
403 /// ```
404 /// # use google_cloud_run_v2::client::Executions;
405 /// use google_cloud_lro::Poller;
406 /// use google_cloud_run_v2::Result;
407 /// async fn sample(
408 /// client: &Executions, project_id: &str, location_id: &str, job_id: &str, execution_id: &str
409 /// ) -> Result<()> {
410 /// let response = client.delete_execution()
411 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}/executions/{execution_id}"))
412 /// .poller().until_done().await?;
413 /// println!("response {:?}", response);
414 /// Ok(())
415 /// }
416 /// ```
417 pub fn delete_execution(&self) -> super::builder::executions::DeleteExecution {
418 super::builder::executions::DeleteExecution::new(self.inner.clone())
419 }
420
421 /// Cancels an Execution.
422 ///
423 /// # Long running operations
424 ///
425 /// This method is used to start, and/or poll a [long-running Operation].
426 /// The [Working with long-running operations] chapter in the [user guide]
427 /// covers these operations in detail.
428 ///
429 /// [long-running operation]: https://google.aip.dev/151
430 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
431 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
432 ///
433 /// # Example
434 /// ```
435 /// # use google_cloud_run_v2::client::Executions;
436 /// use google_cloud_lro::Poller;
437 /// use google_cloud_run_v2::Result;
438 /// async fn sample(
439 /// client: &Executions
440 /// ) -> Result<()> {
441 /// let response = client.cancel_execution()
442 /// /* set fields */
443 /// .poller().until_done().await?;
444 /// println!("response {:?}", response);
445 /// Ok(())
446 /// }
447 /// ```
448 pub fn cancel_execution(&self) -> super::builder::executions::CancelExecution {
449 super::builder::executions::CancelExecution::new(self.inner.clone())
450 }
451
452 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
453 ///
454 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
455 ///
456 /// # Example
457 /// ```
458 /// # use google_cloud_run_v2::client::Executions;
459 /// use google_cloud_gax::paginator::ItemPaginator as _;
460 /// use google_cloud_run_v2::Result;
461 /// async fn sample(
462 /// client: &Executions
463 /// ) -> Result<()> {
464 /// let mut list = client.list_operations()
465 /// /* set fields */
466 /// .by_item();
467 /// while let Some(item) = list.next().await.transpose()? {
468 /// println!("{:?}", item);
469 /// }
470 /// Ok(())
471 /// }
472 /// ```
473 pub fn list_operations(&self) -> super::builder::executions::ListOperations {
474 super::builder::executions::ListOperations::new(self.inner.clone())
475 }
476
477 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
478 ///
479 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
480 ///
481 /// # Example
482 /// ```
483 /// # use google_cloud_run_v2::client::Executions;
484 /// use google_cloud_run_v2::Result;
485 /// async fn sample(
486 /// client: &Executions
487 /// ) -> Result<()> {
488 /// let response = client.get_operation()
489 /// /* set fields */
490 /// .send().await?;
491 /// println!("response {:?}", response);
492 /// Ok(())
493 /// }
494 /// ```
495 pub fn get_operation(&self) -> super::builder::executions::GetOperation {
496 super::builder::executions::GetOperation::new(self.inner.clone())
497 }
498
499 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
500 ///
501 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
502 ///
503 /// # Example
504 /// ```
505 /// # use google_cloud_run_v2::client::Executions;
506 /// use google_cloud_run_v2::Result;
507 /// async fn sample(
508 /// client: &Executions
509 /// ) -> Result<()> {
510 /// client.delete_operation()
511 /// /* set fields */
512 /// .send().await?;
513 /// Ok(())
514 /// }
515 /// ```
516 pub fn delete_operation(&self) -> super::builder::executions::DeleteOperation {
517 super::builder::executions::DeleteOperation::new(self.inner.clone())
518 }
519
520 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
521 ///
522 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
523 ///
524 /// # Example
525 /// ```
526 /// # use google_cloud_run_v2::client::Executions;
527 /// use google_cloud_run_v2::Result;
528 /// async fn sample(
529 /// client: &Executions
530 /// ) -> Result<()> {
531 /// let response = client.wait_operation()
532 /// /* set fields */
533 /// .send().await?;
534 /// println!("response {:?}", response);
535 /// Ok(())
536 /// }
537 /// ```
538 pub fn wait_operation(&self) -> super::builder::executions::WaitOperation {
539 super::builder::executions::WaitOperation::new(self.inner.clone())
540 }
541}
542
543/// Implements a client for the Cloud Run Admin API.
544///
545/// # Example
546/// ```
547/// # use google_cloud_run_v2::client::Instances;
548/// use google_cloud_gax::paginator::ItemPaginator as _;
549/// async fn sample(
550/// project_id: &str,
551/// location_id: &str,
552/// ) -> anyhow::Result<()> {
553/// let client = Instances::builder().build().await?;
554/// let mut list = client.list_instances()
555/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
556/// .by_item();
557/// while let Some(item) = list.next().await.transpose()? {
558/// println!("{:?}", item);
559/// }
560/// Ok(())
561/// }
562/// ```
563///
564/// # Service Description
565///
566/// The Cloud Run Instances API allows you to manage Cloud Run Instances.
567///
568/// # Configuration
569///
570/// To configure `Instances` use the `with_*` methods in the type returned
571/// by [builder()][Instances::builder]. The default configuration should
572/// work for most applications. Common configuration changes include
573///
574/// * [with_endpoint()]: by default this client uses the global default endpoint
575/// (`https://run.googleapis.com`). Applications using regional
576/// endpoints or running in restricted networks (e.g. a network configured
577// with [Private Google Access with VPC Service Controls]) may want to
578/// override this default.
579/// * [with_credentials()]: by default this client uses
580/// [Application Default Credentials]. Applications using custom
581/// authentication may need to override this default.
582///
583/// [with_endpoint()]: super::builder::instances::ClientBuilder::with_endpoint
584/// [with_credentials()]: super::builder::instances::ClientBuilder::with_credentials
585/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
586/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
587///
588/// # Pooling and Cloning
589///
590/// `Instances` holds a connection pool internally, it is advised to
591/// create one and reuse it. You do not need to wrap `Instances` in
592/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
593/// already uses an `Arc` internally.
594#[derive(Clone, Debug)]
595pub struct Instances {
596 inner: std::sync::Arc<dyn super::stub::dynamic::Instances>,
597}
598
599impl Instances {
600 /// Returns a builder for [Instances].
601 ///
602 /// ```
603 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
604 /// # use google_cloud_run_v2::client::Instances;
605 /// let client = Instances::builder().build().await?;
606 /// # Ok(()) }
607 /// ```
608 pub fn builder() -> super::builder::instances::ClientBuilder {
609 crate::new_client_builder(super::builder::instances::client::Factory)
610 }
611
612 /// Creates a new client from the provided stub.
613 ///
614 /// The most common case for calling this function is in tests mocking the
615 /// client's behavior.
616 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
617 where
618 T: super::stub::Instances + 'static,
619 {
620 Self { inner: stub.into() }
621 }
622
623 pub(crate) async fn new(
624 config: gaxi::options::ClientConfig,
625 ) -> crate::ClientBuilderResult<Self> {
626 let inner = Self::build_inner(config).await?;
627 Ok(Self { inner })
628 }
629
630 async fn build_inner(
631 conf: gaxi::options::ClientConfig,
632 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Instances>> {
633 if gaxi::options::tracing_enabled(&conf) {
634 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
635 }
636 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
637 }
638
639 async fn build_transport(
640 conf: gaxi::options::ClientConfig,
641 ) -> crate::ClientBuilderResult<impl super::stub::Instances> {
642 super::transport::Instances::new(conf).await
643 }
644
645 async fn build_with_tracing(
646 conf: gaxi::options::ClientConfig,
647 ) -> crate::ClientBuilderResult<impl super::stub::Instances> {
648 Self::build_transport(conf)
649 .await
650 .map(super::tracing::Instances::new)
651 }
652
653 /// Creates an Instance.
654 ///
655 /// # Long running operations
656 ///
657 /// This method is used to start, and/or poll a [long-running Operation].
658 /// The [Working with long-running operations] chapter in the [user guide]
659 /// covers these operations in detail.
660 ///
661 /// [long-running operation]: https://google.aip.dev/151
662 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
663 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
664 ///
665 /// # Example
666 /// ```
667 /// # use google_cloud_run_v2::client::Instances;
668 /// use google_cloud_lro::Poller;
669 /// use google_cloud_run_v2::model::Instance;
670 /// use google_cloud_run_v2::Result;
671 /// async fn sample(
672 /// client: &Instances, project_id: &str, location_id: &str
673 /// ) -> Result<()> {
674 /// let response = client.create_instance()
675 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
676 /// .set_instance_id("instance_id_value")
677 /// .set_instance(
678 /// Instance::new()/* set fields */
679 /// )
680 /// .poller().until_done().await?;
681 /// println!("response {:?}", response);
682 /// Ok(())
683 /// }
684 /// ```
685 pub fn create_instance(&self) -> super::builder::instances::CreateInstance {
686 super::builder::instances::CreateInstance::new(self.inner.clone())
687 }
688
689 /// Deletes a Instance
690 ///
691 /// # Long running operations
692 ///
693 /// This method is used to start, and/or poll a [long-running Operation].
694 /// The [Working with long-running operations] chapter in the [user guide]
695 /// covers these operations in detail.
696 ///
697 /// [long-running operation]: https://google.aip.dev/151
698 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
699 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
700 ///
701 /// # Example
702 /// ```
703 /// # use google_cloud_run_v2::client::Instances;
704 /// use google_cloud_lro::Poller;
705 /// use google_cloud_run_v2::Result;
706 /// async fn sample(
707 /// client: &Instances, project_id: &str, location_id: &str, instance_id: &str
708 /// ) -> Result<()> {
709 /// let response = client.delete_instance()
710 /// .set_name(format!("projects/{project_id}/locations/{location_id}/instances/{instance_id}"))
711 /// .poller().until_done().await?;
712 /// println!("response {:?}", response);
713 /// Ok(())
714 /// }
715 /// ```
716 pub fn delete_instance(&self) -> super::builder::instances::DeleteInstance {
717 super::builder::instances::DeleteInstance::new(self.inner.clone())
718 }
719
720 /// Gets a Instance
721 ///
722 /// # Example
723 /// ```
724 /// # use google_cloud_run_v2::client::Instances;
725 /// use google_cloud_run_v2::Result;
726 /// async fn sample(
727 /// client: &Instances, project_id: &str, location_id: &str, instance_id: &str
728 /// ) -> Result<()> {
729 /// let response = client.get_instance()
730 /// .set_name(format!("projects/{project_id}/locations/{location_id}/instances/{instance_id}"))
731 /// .send().await?;
732 /// println!("response {:?}", response);
733 /// Ok(())
734 /// }
735 /// ```
736 pub fn get_instance(&self) -> super::builder::instances::GetInstance {
737 super::builder::instances::GetInstance::new(self.inner.clone())
738 }
739
740 /// Lists Instances. Results are sorted by creation time, descending.
741 ///
742 /// # Example
743 /// ```
744 /// # use google_cloud_run_v2::client::Instances;
745 /// use google_cloud_gax::paginator::ItemPaginator as _;
746 /// use google_cloud_run_v2::Result;
747 /// async fn sample(
748 /// client: &Instances, project_id: &str, location_id: &str
749 /// ) -> Result<()> {
750 /// let mut list = client.list_instances()
751 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
752 /// .by_item();
753 /// while let Some(item) = list.next().await.transpose()? {
754 /// println!("{:?}", item);
755 /// }
756 /// Ok(())
757 /// }
758 /// ```
759 pub fn list_instances(&self) -> super::builder::instances::ListInstances {
760 super::builder::instances::ListInstances::new(self.inner.clone())
761 }
762
763 /// Stops an Instance.
764 ///
765 /// # Long running operations
766 ///
767 /// This method is used to start, and/or poll a [long-running Operation].
768 /// The [Working with long-running operations] chapter in the [user guide]
769 /// covers these operations in detail.
770 ///
771 /// [long-running operation]: https://google.aip.dev/151
772 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
773 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
774 ///
775 /// # Example
776 /// ```
777 /// # use google_cloud_run_v2::client::Instances;
778 /// use google_cloud_lro::Poller;
779 /// use google_cloud_run_v2::Result;
780 /// async fn sample(
781 /// client: &Instances
782 /// ) -> Result<()> {
783 /// let response = client.stop_instance()
784 /// /* set fields */
785 /// .poller().until_done().await?;
786 /// println!("response {:?}", response);
787 /// Ok(())
788 /// }
789 /// ```
790 pub fn stop_instance(&self) -> super::builder::instances::StopInstance {
791 super::builder::instances::StopInstance::new(self.inner.clone())
792 }
793
794 /// Starts an Instance.
795 ///
796 /// # Long running operations
797 ///
798 /// This method is used to start, and/or poll a [long-running Operation].
799 /// The [Working with long-running operations] chapter in the [user guide]
800 /// covers these operations in detail.
801 ///
802 /// [long-running operation]: https://google.aip.dev/151
803 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
804 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
805 ///
806 /// # Example
807 /// ```
808 /// # use google_cloud_run_v2::client::Instances;
809 /// use google_cloud_lro::Poller;
810 /// use google_cloud_run_v2::Result;
811 /// async fn sample(
812 /// client: &Instances
813 /// ) -> Result<()> {
814 /// let response = client.start_instance()
815 /// /* set fields */
816 /// .poller().until_done().await?;
817 /// println!("response {:?}", response);
818 /// Ok(())
819 /// }
820 /// ```
821 pub fn start_instance(&self) -> super::builder::instances::StartInstance {
822 super::builder::instances::StartInstance::new(self.inner.clone())
823 }
824
825 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
826 ///
827 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
828 ///
829 /// # Example
830 /// ```
831 /// # use google_cloud_run_v2::client::Instances;
832 /// use google_cloud_gax::paginator::ItemPaginator as _;
833 /// use google_cloud_run_v2::Result;
834 /// async fn sample(
835 /// client: &Instances
836 /// ) -> Result<()> {
837 /// let mut list = client.list_operations()
838 /// /* set fields */
839 /// .by_item();
840 /// while let Some(item) = list.next().await.transpose()? {
841 /// println!("{:?}", item);
842 /// }
843 /// Ok(())
844 /// }
845 /// ```
846 pub fn list_operations(&self) -> super::builder::instances::ListOperations {
847 super::builder::instances::ListOperations::new(self.inner.clone())
848 }
849
850 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
851 ///
852 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
853 ///
854 /// # Example
855 /// ```
856 /// # use google_cloud_run_v2::client::Instances;
857 /// use google_cloud_run_v2::Result;
858 /// async fn sample(
859 /// client: &Instances
860 /// ) -> Result<()> {
861 /// let response = client.get_operation()
862 /// /* set fields */
863 /// .send().await?;
864 /// println!("response {:?}", response);
865 /// Ok(())
866 /// }
867 /// ```
868 pub fn get_operation(&self) -> super::builder::instances::GetOperation {
869 super::builder::instances::GetOperation::new(self.inner.clone())
870 }
871
872 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
873 ///
874 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
875 ///
876 /// # Example
877 /// ```
878 /// # use google_cloud_run_v2::client::Instances;
879 /// use google_cloud_run_v2::Result;
880 /// async fn sample(
881 /// client: &Instances
882 /// ) -> Result<()> {
883 /// client.delete_operation()
884 /// /* set fields */
885 /// .send().await?;
886 /// Ok(())
887 /// }
888 /// ```
889 pub fn delete_operation(&self) -> super::builder::instances::DeleteOperation {
890 super::builder::instances::DeleteOperation::new(self.inner.clone())
891 }
892
893 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
894 ///
895 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
896 ///
897 /// # Example
898 /// ```
899 /// # use google_cloud_run_v2::client::Instances;
900 /// use google_cloud_run_v2::Result;
901 /// async fn sample(
902 /// client: &Instances
903 /// ) -> Result<()> {
904 /// let response = client.wait_operation()
905 /// /* set fields */
906 /// .send().await?;
907 /// println!("response {:?}", response);
908 /// Ok(())
909 /// }
910 /// ```
911 pub fn wait_operation(&self) -> super::builder::instances::WaitOperation {
912 super::builder::instances::WaitOperation::new(self.inner.clone())
913 }
914}
915
916/// Implements a client for the Cloud Run Admin API.
917///
918/// # Example
919/// ```
920/// # use google_cloud_run_v2::client::Jobs;
921/// use google_cloud_gax::paginator::ItemPaginator as _;
922/// async fn sample(
923/// project_id: &str,
924/// location_id: &str,
925/// ) -> anyhow::Result<()> {
926/// let client = Jobs::builder().build().await?;
927/// let mut list = client.list_jobs()
928/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
929/// .by_item();
930/// while let Some(item) = list.next().await.transpose()? {
931/// println!("{:?}", item);
932/// }
933/// Ok(())
934/// }
935/// ```
936///
937/// # Service Description
938///
939/// Cloud Run Job Control Plane API.
940///
941/// # Configuration
942///
943/// To configure `Jobs` use the `with_*` methods in the type returned
944/// by [builder()][Jobs::builder]. The default configuration should
945/// work for most applications. Common configuration changes include
946///
947/// * [with_endpoint()]: by default this client uses the global default endpoint
948/// (`https://run.googleapis.com`). Applications using regional
949/// endpoints or running in restricted networks (e.g. a network configured
950// with [Private Google Access with VPC Service Controls]) may want to
951/// override this default.
952/// * [with_credentials()]: by default this client uses
953/// [Application Default Credentials]. Applications using custom
954/// authentication may need to override this default.
955///
956/// [with_endpoint()]: super::builder::jobs::ClientBuilder::with_endpoint
957/// [with_credentials()]: super::builder::jobs::ClientBuilder::with_credentials
958/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
959/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
960///
961/// # Pooling and Cloning
962///
963/// `Jobs` holds a connection pool internally, it is advised to
964/// create one and reuse it. You do not need to wrap `Jobs` in
965/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
966/// already uses an `Arc` internally.
967#[derive(Clone, Debug)]
968pub struct Jobs {
969 inner: std::sync::Arc<dyn super::stub::dynamic::Jobs>,
970}
971
972impl Jobs {
973 /// Returns a builder for [Jobs].
974 ///
975 /// ```
976 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
977 /// # use google_cloud_run_v2::client::Jobs;
978 /// let client = Jobs::builder().build().await?;
979 /// # Ok(()) }
980 /// ```
981 pub fn builder() -> super::builder::jobs::ClientBuilder {
982 crate::new_client_builder(super::builder::jobs::client::Factory)
983 }
984
985 /// Creates a new client from the provided stub.
986 ///
987 /// The most common case for calling this function is in tests mocking the
988 /// client's behavior.
989 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
990 where
991 T: super::stub::Jobs + 'static,
992 {
993 Self { inner: stub.into() }
994 }
995
996 pub(crate) async fn new(
997 config: gaxi::options::ClientConfig,
998 ) -> crate::ClientBuilderResult<Self> {
999 let inner = Self::build_inner(config).await?;
1000 Ok(Self { inner })
1001 }
1002
1003 async fn build_inner(
1004 conf: gaxi::options::ClientConfig,
1005 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Jobs>> {
1006 if gaxi::options::tracing_enabled(&conf) {
1007 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1008 }
1009 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1010 }
1011
1012 async fn build_transport(
1013 conf: gaxi::options::ClientConfig,
1014 ) -> crate::ClientBuilderResult<impl super::stub::Jobs> {
1015 super::transport::Jobs::new(conf).await
1016 }
1017
1018 async fn build_with_tracing(
1019 conf: gaxi::options::ClientConfig,
1020 ) -> crate::ClientBuilderResult<impl super::stub::Jobs> {
1021 Self::build_transport(conf)
1022 .await
1023 .map(super::tracing::Jobs::new)
1024 }
1025
1026 /// Creates a Job.
1027 ///
1028 /// # Long running operations
1029 ///
1030 /// This method is used to start, and/or poll a [long-running Operation].
1031 /// The [Working with long-running operations] chapter in the [user guide]
1032 /// covers these operations in detail.
1033 ///
1034 /// [long-running operation]: https://google.aip.dev/151
1035 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1036 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1037 ///
1038 /// # Example
1039 /// ```
1040 /// # use google_cloud_run_v2::client::Jobs;
1041 /// use google_cloud_lro::Poller;
1042 /// use google_cloud_run_v2::model::Job;
1043 /// use google_cloud_run_v2::Result;
1044 /// async fn sample(
1045 /// client: &Jobs, project_id: &str, location_id: &str
1046 /// ) -> Result<()> {
1047 /// let response = client.create_job()
1048 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1049 /// .set_job_id("job_id_value")
1050 /// .set_job(
1051 /// Job::new()/* set fields */
1052 /// )
1053 /// .poller().until_done().await?;
1054 /// println!("response {:?}", response);
1055 /// Ok(())
1056 /// }
1057 /// ```
1058 pub fn create_job(&self) -> super::builder::jobs::CreateJob {
1059 super::builder::jobs::CreateJob::new(self.inner.clone())
1060 }
1061
1062 /// Gets information about a Job.
1063 ///
1064 /// # Example
1065 /// ```
1066 /// # use google_cloud_run_v2::client::Jobs;
1067 /// use google_cloud_run_v2::Result;
1068 /// async fn sample(
1069 /// client: &Jobs, project_id: &str, location_id: &str, job_id: &str
1070 /// ) -> Result<()> {
1071 /// let response = client.get_job()
1072 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}"))
1073 /// .send().await?;
1074 /// println!("response {:?}", response);
1075 /// Ok(())
1076 /// }
1077 /// ```
1078 pub fn get_job(&self) -> super::builder::jobs::GetJob {
1079 super::builder::jobs::GetJob::new(self.inner.clone())
1080 }
1081
1082 /// Lists Jobs. Results are sorted by creation time, descending.
1083 ///
1084 /// # Example
1085 /// ```
1086 /// # use google_cloud_run_v2::client::Jobs;
1087 /// use google_cloud_gax::paginator::ItemPaginator as _;
1088 /// use google_cloud_run_v2::Result;
1089 /// async fn sample(
1090 /// client: &Jobs, project_id: &str, location_id: &str
1091 /// ) -> Result<()> {
1092 /// let mut list = client.list_jobs()
1093 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1094 /// .by_item();
1095 /// while let Some(item) = list.next().await.transpose()? {
1096 /// println!("{:?}", item);
1097 /// }
1098 /// Ok(())
1099 /// }
1100 /// ```
1101 pub fn list_jobs(&self) -> super::builder::jobs::ListJobs {
1102 super::builder::jobs::ListJobs::new(self.inner.clone())
1103 }
1104
1105 /// Updates a Job.
1106 ///
1107 /// # Long running operations
1108 ///
1109 /// This method is used to start, and/or poll a [long-running Operation].
1110 /// The [Working with long-running operations] chapter in the [user guide]
1111 /// covers these operations in detail.
1112 ///
1113 /// [long-running operation]: https://google.aip.dev/151
1114 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1115 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1116 ///
1117 /// # Example
1118 /// ```
1119 /// # use google_cloud_run_v2::client::Jobs;
1120 /// use google_cloud_lro::Poller;
1121 /// use google_cloud_run_v2::model::Job;
1122 /// use google_cloud_run_v2::Result;
1123 /// async fn sample(
1124 /// client: &Jobs, project_id: &str, location_id: &str, job_id: &str
1125 /// ) -> Result<()> {
1126 /// let response = client.update_job()
1127 /// .set_job(
1128 /// Job::new().set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}"))/* set fields */
1129 /// )
1130 /// .poller().until_done().await?;
1131 /// println!("response {:?}", response);
1132 /// Ok(())
1133 /// }
1134 /// ```
1135 pub fn update_job(&self) -> super::builder::jobs::UpdateJob {
1136 super::builder::jobs::UpdateJob::new(self.inner.clone())
1137 }
1138
1139 /// Deletes a Job.
1140 ///
1141 /// # Long running operations
1142 ///
1143 /// This method is used to start, and/or poll a [long-running Operation].
1144 /// The [Working with long-running operations] chapter in the [user guide]
1145 /// covers these operations in detail.
1146 ///
1147 /// [long-running operation]: https://google.aip.dev/151
1148 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1149 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1150 ///
1151 /// # Example
1152 /// ```
1153 /// # use google_cloud_run_v2::client::Jobs;
1154 /// use google_cloud_lro::Poller;
1155 /// use google_cloud_run_v2::Result;
1156 /// async fn sample(
1157 /// client: &Jobs, project_id: &str, location_id: &str, job_id: &str
1158 /// ) -> Result<()> {
1159 /// let response = client.delete_job()
1160 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}"))
1161 /// .poller().until_done().await?;
1162 /// println!("response {:?}", response);
1163 /// Ok(())
1164 /// }
1165 /// ```
1166 pub fn delete_job(&self) -> super::builder::jobs::DeleteJob {
1167 super::builder::jobs::DeleteJob::new(self.inner.clone())
1168 }
1169
1170 /// Triggers creation of a new Execution of this Job.
1171 ///
1172 /// # Long running operations
1173 ///
1174 /// This method is used to start, and/or poll a [long-running Operation].
1175 /// The [Working with long-running operations] chapter in the [user guide]
1176 /// covers these operations in detail.
1177 ///
1178 /// [long-running operation]: https://google.aip.dev/151
1179 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1180 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1181 ///
1182 /// # Example
1183 /// ```
1184 /// # use google_cloud_run_v2::client::Jobs;
1185 /// use google_cloud_lro::Poller;
1186 /// use google_cloud_run_v2::Result;
1187 /// async fn sample(
1188 /// client: &Jobs
1189 /// ) -> Result<()> {
1190 /// let response = client.run_job()
1191 /// /* set fields */
1192 /// .poller().until_done().await?;
1193 /// println!("response {:?}", response);
1194 /// Ok(())
1195 /// }
1196 /// ```
1197 pub fn run_job(&self) -> super::builder::jobs::RunJob {
1198 super::builder::jobs::RunJob::new(self.inner.clone())
1199 }
1200
1201 /// Gets the IAM Access Control policy currently in effect for the given Job.
1202 /// This result does not include any inherited policies.
1203 ///
1204 /// # Example
1205 /// ```
1206 /// # use google_cloud_run_v2::client::Jobs;
1207 /// use google_cloud_run_v2::Result;
1208 /// async fn sample(
1209 /// client: &Jobs
1210 /// ) -> Result<()> {
1211 /// let response = client.get_iam_policy()
1212 /// /* set fields */
1213 /// .send().await?;
1214 /// println!("response {:?}", response);
1215 /// Ok(())
1216 /// }
1217 /// ```
1218 pub fn get_iam_policy(&self) -> super::builder::jobs::GetIamPolicy {
1219 super::builder::jobs::GetIamPolicy::new(self.inner.clone())
1220 }
1221
1222 /// Sets the IAM Access control policy for the specified Job. Overwrites
1223 /// any existing policy.
1224 ///
1225 /// # Example
1226 /// ```
1227 /// # use google_cloud_run_v2::client::Jobs;
1228 /// use google_cloud_run_v2::Result;
1229 /// async fn sample(
1230 /// client: &Jobs
1231 /// ) -> Result<()> {
1232 /// let response = client.set_iam_policy()
1233 /// /* set fields */
1234 /// .send().await?;
1235 /// println!("response {:?}", response);
1236 /// Ok(())
1237 /// }
1238 /// ```
1239 pub fn set_iam_policy(&self) -> super::builder::jobs::SetIamPolicy {
1240 super::builder::jobs::SetIamPolicy::new(self.inner.clone())
1241 }
1242
1243 /// Returns permissions that a caller has on the specified Project.
1244 ///
1245 /// There are no permissions required for making this API call.
1246 ///
1247 /// # Example
1248 /// ```
1249 /// # use google_cloud_run_v2::client::Jobs;
1250 /// use google_cloud_run_v2::Result;
1251 /// async fn sample(
1252 /// client: &Jobs
1253 /// ) -> Result<()> {
1254 /// let response = client.test_iam_permissions()
1255 /// /* set fields */
1256 /// .send().await?;
1257 /// println!("response {:?}", response);
1258 /// Ok(())
1259 /// }
1260 /// ```
1261 pub fn test_iam_permissions(&self) -> super::builder::jobs::TestIamPermissions {
1262 super::builder::jobs::TestIamPermissions::new(self.inner.clone())
1263 }
1264
1265 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1266 ///
1267 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1268 ///
1269 /// # Example
1270 /// ```
1271 /// # use google_cloud_run_v2::client::Jobs;
1272 /// use google_cloud_gax::paginator::ItemPaginator as _;
1273 /// use google_cloud_run_v2::Result;
1274 /// async fn sample(
1275 /// client: &Jobs
1276 /// ) -> Result<()> {
1277 /// let mut list = client.list_operations()
1278 /// /* set fields */
1279 /// .by_item();
1280 /// while let Some(item) = list.next().await.transpose()? {
1281 /// println!("{:?}", item);
1282 /// }
1283 /// Ok(())
1284 /// }
1285 /// ```
1286 pub fn list_operations(&self) -> super::builder::jobs::ListOperations {
1287 super::builder::jobs::ListOperations::new(self.inner.clone())
1288 }
1289
1290 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1291 ///
1292 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1293 ///
1294 /// # Example
1295 /// ```
1296 /// # use google_cloud_run_v2::client::Jobs;
1297 /// use google_cloud_run_v2::Result;
1298 /// async fn sample(
1299 /// client: &Jobs
1300 /// ) -> Result<()> {
1301 /// let response = client.get_operation()
1302 /// /* set fields */
1303 /// .send().await?;
1304 /// println!("response {:?}", response);
1305 /// Ok(())
1306 /// }
1307 /// ```
1308 pub fn get_operation(&self) -> super::builder::jobs::GetOperation {
1309 super::builder::jobs::GetOperation::new(self.inner.clone())
1310 }
1311
1312 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1313 ///
1314 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1315 ///
1316 /// # Example
1317 /// ```
1318 /// # use google_cloud_run_v2::client::Jobs;
1319 /// use google_cloud_run_v2::Result;
1320 /// async fn sample(
1321 /// client: &Jobs
1322 /// ) -> Result<()> {
1323 /// client.delete_operation()
1324 /// /* set fields */
1325 /// .send().await?;
1326 /// Ok(())
1327 /// }
1328 /// ```
1329 pub fn delete_operation(&self) -> super::builder::jobs::DeleteOperation {
1330 super::builder::jobs::DeleteOperation::new(self.inner.clone())
1331 }
1332
1333 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1334 ///
1335 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1336 ///
1337 /// # Example
1338 /// ```
1339 /// # use google_cloud_run_v2::client::Jobs;
1340 /// use google_cloud_run_v2::Result;
1341 /// async fn sample(
1342 /// client: &Jobs
1343 /// ) -> Result<()> {
1344 /// let response = client.wait_operation()
1345 /// /* set fields */
1346 /// .send().await?;
1347 /// println!("response {:?}", response);
1348 /// Ok(())
1349 /// }
1350 /// ```
1351 pub fn wait_operation(&self) -> super::builder::jobs::WaitOperation {
1352 super::builder::jobs::WaitOperation::new(self.inner.clone())
1353 }
1354}
1355
1356/// Implements a client for the Cloud Run Admin API.
1357///
1358/// # Example
1359/// ```
1360/// # use google_cloud_run_v2::client::Revisions;
1361/// use google_cloud_gax::paginator::ItemPaginator as _;
1362/// async fn sample(
1363/// project_id: &str,
1364/// location_id: &str,
1365/// service_id: &str,
1366/// ) -> anyhow::Result<()> {
1367/// let client = Revisions::builder().build().await?;
1368/// let mut list = client.list_revisions()
1369/// .set_parent(format!("projects/{project_id}/locations/{location_id}/services/{service_id}"))
1370/// .by_item();
1371/// while let Some(item) = list.next().await.transpose()? {
1372/// println!("{:?}", item);
1373/// }
1374/// Ok(())
1375/// }
1376/// ```
1377///
1378/// # Service Description
1379///
1380/// Cloud Run Revision Control Plane API.
1381///
1382/// # Configuration
1383///
1384/// To configure `Revisions` use the `with_*` methods in the type returned
1385/// by [builder()][Revisions::builder]. The default configuration should
1386/// work for most applications. Common configuration changes include
1387///
1388/// * [with_endpoint()]: by default this client uses the global default endpoint
1389/// (`https://run.googleapis.com`). Applications using regional
1390/// endpoints or running in restricted networks (e.g. a network configured
1391// with [Private Google Access with VPC Service Controls]) may want to
1392/// override this default.
1393/// * [with_credentials()]: by default this client uses
1394/// [Application Default Credentials]. Applications using custom
1395/// authentication may need to override this default.
1396///
1397/// [with_endpoint()]: super::builder::revisions::ClientBuilder::with_endpoint
1398/// [with_credentials()]: super::builder::revisions::ClientBuilder::with_credentials
1399/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1400/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1401///
1402/// # Pooling and Cloning
1403///
1404/// `Revisions` holds a connection pool internally, it is advised to
1405/// create one and reuse it. You do not need to wrap `Revisions` in
1406/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1407/// already uses an `Arc` internally.
1408#[derive(Clone, Debug)]
1409pub struct Revisions {
1410 inner: std::sync::Arc<dyn super::stub::dynamic::Revisions>,
1411}
1412
1413impl Revisions {
1414 /// Returns a builder for [Revisions].
1415 ///
1416 /// ```
1417 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1418 /// # use google_cloud_run_v2::client::Revisions;
1419 /// let client = Revisions::builder().build().await?;
1420 /// # Ok(()) }
1421 /// ```
1422 pub fn builder() -> super::builder::revisions::ClientBuilder {
1423 crate::new_client_builder(super::builder::revisions::client::Factory)
1424 }
1425
1426 /// Creates a new client from the provided stub.
1427 ///
1428 /// The most common case for calling this function is in tests mocking the
1429 /// client's behavior.
1430 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1431 where
1432 T: super::stub::Revisions + 'static,
1433 {
1434 Self { inner: stub.into() }
1435 }
1436
1437 pub(crate) async fn new(
1438 config: gaxi::options::ClientConfig,
1439 ) -> crate::ClientBuilderResult<Self> {
1440 let inner = Self::build_inner(config).await?;
1441 Ok(Self { inner })
1442 }
1443
1444 async fn build_inner(
1445 conf: gaxi::options::ClientConfig,
1446 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Revisions>> {
1447 if gaxi::options::tracing_enabled(&conf) {
1448 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1449 }
1450 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1451 }
1452
1453 async fn build_transport(
1454 conf: gaxi::options::ClientConfig,
1455 ) -> crate::ClientBuilderResult<impl super::stub::Revisions> {
1456 super::transport::Revisions::new(conf).await
1457 }
1458
1459 async fn build_with_tracing(
1460 conf: gaxi::options::ClientConfig,
1461 ) -> crate::ClientBuilderResult<impl super::stub::Revisions> {
1462 Self::build_transport(conf)
1463 .await
1464 .map(super::tracing::Revisions::new)
1465 }
1466
1467 /// Gets information about a Revision.
1468 ///
1469 /// # Example
1470 /// ```
1471 /// # use google_cloud_run_v2::client::Revisions;
1472 /// use google_cloud_run_v2::Result;
1473 /// async fn sample(
1474 /// client: &Revisions, project_id: &str, location_id: &str, service_id: &str, revision_id: &str
1475 /// ) -> Result<()> {
1476 /// let response = client.get_revision()
1477 /// .set_name(format!("projects/{project_id}/locations/{location_id}/services/{service_id}/revisions/{revision_id}"))
1478 /// .send().await?;
1479 /// println!("response {:?}", response);
1480 /// Ok(())
1481 /// }
1482 /// ```
1483 pub fn get_revision(&self) -> super::builder::revisions::GetRevision {
1484 super::builder::revisions::GetRevision::new(self.inner.clone())
1485 }
1486
1487 /// Lists Revisions from a given Service, or from a given location. Results
1488 /// are sorted by creation time, descending.
1489 ///
1490 /// # Example
1491 /// ```
1492 /// # use google_cloud_run_v2::client::Revisions;
1493 /// use google_cloud_gax::paginator::ItemPaginator as _;
1494 /// use google_cloud_run_v2::Result;
1495 /// async fn sample(
1496 /// client: &Revisions, project_id: &str, location_id: &str, service_id: &str
1497 /// ) -> Result<()> {
1498 /// let mut list = client.list_revisions()
1499 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/services/{service_id}"))
1500 /// .by_item();
1501 /// while let Some(item) = list.next().await.transpose()? {
1502 /// println!("{:?}", item);
1503 /// }
1504 /// Ok(())
1505 /// }
1506 /// ```
1507 pub fn list_revisions(&self) -> super::builder::revisions::ListRevisions {
1508 super::builder::revisions::ListRevisions::new(self.inner.clone())
1509 }
1510
1511 /// Deletes a Revision.
1512 ///
1513 /// # Long running operations
1514 ///
1515 /// This method is used to start, and/or poll a [long-running Operation].
1516 /// The [Working with long-running operations] chapter in the [user guide]
1517 /// covers these operations in detail.
1518 ///
1519 /// [long-running operation]: https://google.aip.dev/151
1520 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1521 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1522 ///
1523 /// # Example
1524 /// ```
1525 /// # use google_cloud_run_v2::client::Revisions;
1526 /// use google_cloud_lro::Poller;
1527 /// use google_cloud_run_v2::Result;
1528 /// async fn sample(
1529 /// client: &Revisions, project_id: &str, location_id: &str, service_id: &str, revision_id: &str
1530 /// ) -> Result<()> {
1531 /// let response = client.delete_revision()
1532 /// .set_name(format!("projects/{project_id}/locations/{location_id}/services/{service_id}/revisions/{revision_id}"))
1533 /// .poller().until_done().await?;
1534 /// println!("response {:?}", response);
1535 /// Ok(())
1536 /// }
1537 /// ```
1538 pub fn delete_revision(&self) -> super::builder::revisions::DeleteRevision {
1539 super::builder::revisions::DeleteRevision::new(self.inner.clone())
1540 }
1541
1542 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1543 ///
1544 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1545 ///
1546 /// # Example
1547 /// ```
1548 /// # use google_cloud_run_v2::client::Revisions;
1549 /// use google_cloud_gax::paginator::ItemPaginator as _;
1550 /// use google_cloud_run_v2::Result;
1551 /// async fn sample(
1552 /// client: &Revisions
1553 /// ) -> Result<()> {
1554 /// let mut list = client.list_operations()
1555 /// /* set fields */
1556 /// .by_item();
1557 /// while let Some(item) = list.next().await.transpose()? {
1558 /// println!("{:?}", item);
1559 /// }
1560 /// Ok(())
1561 /// }
1562 /// ```
1563 pub fn list_operations(&self) -> super::builder::revisions::ListOperations {
1564 super::builder::revisions::ListOperations::new(self.inner.clone())
1565 }
1566
1567 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1568 ///
1569 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1570 ///
1571 /// # Example
1572 /// ```
1573 /// # use google_cloud_run_v2::client::Revisions;
1574 /// use google_cloud_run_v2::Result;
1575 /// async fn sample(
1576 /// client: &Revisions
1577 /// ) -> Result<()> {
1578 /// let response = client.get_operation()
1579 /// /* set fields */
1580 /// .send().await?;
1581 /// println!("response {:?}", response);
1582 /// Ok(())
1583 /// }
1584 /// ```
1585 pub fn get_operation(&self) -> super::builder::revisions::GetOperation {
1586 super::builder::revisions::GetOperation::new(self.inner.clone())
1587 }
1588
1589 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1590 ///
1591 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1592 ///
1593 /// # Example
1594 /// ```
1595 /// # use google_cloud_run_v2::client::Revisions;
1596 /// use google_cloud_run_v2::Result;
1597 /// async fn sample(
1598 /// client: &Revisions
1599 /// ) -> Result<()> {
1600 /// client.delete_operation()
1601 /// /* set fields */
1602 /// .send().await?;
1603 /// Ok(())
1604 /// }
1605 /// ```
1606 pub fn delete_operation(&self) -> super::builder::revisions::DeleteOperation {
1607 super::builder::revisions::DeleteOperation::new(self.inner.clone())
1608 }
1609
1610 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1611 ///
1612 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1613 ///
1614 /// # Example
1615 /// ```
1616 /// # use google_cloud_run_v2::client::Revisions;
1617 /// use google_cloud_run_v2::Result;
1618 /// async fn sample(
1619 /// client: &Revisions
1620 /// ) -> Result<()> {
1621 /// let response = client.wait_operation()
1622 /// /* set fields */
1623 /// .send().await?;
1624 /// println!("response {:?}", response);
1625 /// Ok(())
1626 /// }
1627 /// ```
1628 pub fn wait_operation(&self) -> super::builder::revisions::WaitOperation {
1629 super::builder::revisions::WaitOperation::new(self.inner.clone())
1630 }
1631}
1632
1633/// Implements a client for the Cloud Run Admin API.
1634///
1635/// # Example
1636/// ```
1637/// # use google_cloud_run_v2::client::Services;
1638/// use google_cloud_gax::paginator::ItemPaginator as _;
1639/// async fn sample(
1640/// project_id: &str,
1641/// location_id: &str,
1642/// ) -> anyhow::Result<()> {
1643/// let client = Services::builder().build().await?;
1644/// let mut list = client.list_services()
1645/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1646/// .by_item();
1647/// while let Some(item) = list.next().await.transpose()? {
1648/// println!("{:?}", item);
1649/// }
1650/// Ok(())
1651/// }
1652/// ```
1653///
1654/// # Service Description
1655///
1656/// Cloud Run Service Control Plane API
1657///
1658/// # Configuration
1659///
1660/// To configure `Services` use the `with_*` methods in the type returned
1661/// by [builder()][Services::builder]. The default configuration should
1662/// work for most applications. Common configuration changes include
1663///
1664/// * [with_endpoint()]: by default this client uses the global default endpoint
1665/// (`https://run.googleapis.com`). Applications using regional
1666/// endpoints or running in restricted networks (e.g. a network configured
1667// with [Private Google Access with VPC Service Controls]) may want to
1668/// override this default.
1669/// * [with_credentials()]: by default this client uses
1670/// [Application Default Credentials]. Applications using custom
1671/// authentication may need to override this default.
1672///
1673/// [with_endpoint()]: super::builder::services::ClientBuilder::with_endpoint
1674/// [with_credentials()]: super::builder::services::ClientBuilder::with_credentials
1675/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1676/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1677///
1678/// # Pooling and Cloning
1679///
1680/// `Services` holds a connection pool internally, it is advised to
1681/// create one and reuse it. You do not need to wrap `Services` in
1682/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1683/// already uses an `Arc` internally.
1684#[derive(Clone, Debug)]
1685pub struct Services {
1686 inner: std::sync::Arc<dyn super::stub::dynamic::Services>,
1687}
1688
1689impl Services {
1690 /// Returns a builder for [Services].
1691 ///
1692 /// ```
1693 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1694 /// # use google_cloud_run_v2::client::Services;
1695 /// let client = Services::builder().build().await?;
1696 /// # Ok(()) }
1697 /// ```
1698 pub fn builder() -> super::builder::services::ClientBuilder {
1699 crate::new_client_builder(super::builder::services::client::Factory)
1700 }
1701
1702 /// Creates a new client from the provided stub.
1703 ///
1704 /// The most common case for calling this function is in tests mocking the
1705 /// client's behavior.
1706 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1707 where
1708 T: super::stub::Services + 'static,
1709 {
1710 Self { inner: stub.into() }
1711 }
1712
1713 pub(crate) async fn new(
1714 config: gaxi::options::ClientConfig,
1715 ) -> crate::ClientBuilderResult<Self> {
1716 let inner = Self::build_inner(config).await?;
1717 Ok(Self { inner })
1718 }
1719
1720 async fn build_inner(
1721 conf: gaxi::options::ClientConfig,
1722 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Services>> {
1723 if gaxi::options::tracing_enabled(&conf) {
1724 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1725 }
1726 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1727 }
1728
1729 async fn build_transport(
1730 conf: gaxi::options::ClientConfig,
1731 ) -> crate::ClientBuilderResult<impl super::stub::Services> {
1732 super::transport::Services::new(conf).await
1733 }
1734
1735 async fn build_with_tracing(
1736 conf: gaxi::options::ClientConfig,
1737 ) -> crate::ClientBuilderResult<impl super::stub::Services> {
1738 Self::build_transport(conf)
1739 .await
1740 .map(super::tracing::Services::new)
1741 }
1742
1743 /// Creates a new Service in a given project and location.
1744 ///
1745 /// # Long running operations
1746 ///
1747 /// This method is used to start, and/or poll a [long-running Operation].
1748 /// The [Working with long-running operations] chapter in the [user guide]
1749 /// covers these operations in detail.
1750 ///
1751 /// [long-running operation]: https://google.aip.dev/151
1752 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1753 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1754 ///
1755 /// # Example
1756 /// ```
1757 /// # use google_cloud_run_v2::client::Services;
1758 /// use google_cloud_lro::Poller;
1759 /// use google_cloud_run_v2::model::Service;
1760 /// use google_cloud_run_v2::Result;
1761 /// async fn sample(
1762 /// client: &Services, project_id: &str, location_id: &str
1763 /// ) -> Result<()> {
1764 /// let response = client.create_service()
1765 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1766 /// .set_service_id("service_id_value")
1767 /// .set_service(
1768 /// Service::new()/* set fields */
1769 /// )
1770 /// .poller().until_done().await?;
1771 /// println!("response {:?}", response);
1772 /// Ok(())
1773 /// }
1774 /// ```
1775 pub fn create_service(&self) -> super::builder::services::CreateService {
1776 super::builder::services::CreateService::new(self.inner.clone())
1777 }
1778
1779 /// Gets information about a Service.
1780 ///
1781 /// # Example
1782 /// ```
1783 /// # use google_cloud_run_v2::client::Services;
1784 /// use google_cloud_run_v2::Result;
1785 /// async fn sample(
1786 /// client: &Services, project_id: &str, location_id: &str, service_id: &str
1787 /// ) -> Result<()> {
1788 /// let response = client.get_service()
1789 /// .set_name(format!("projects/{project_id}/locations/{location_id}/services/{service_id}"))
1790 /// .send().await?;
1791 /// println!("response {:?}", response);
1792 /// Ok(())
1793 /// }
1794 /// ```
1795 pub fn get_service(&self) -> super::builder::services::GetService {
1796 super::builder::services::GetService::new(self.inner.clone())
1797 }
1798
1799 /// Lists Services. Results are sorted by creation time, descending.
1800 ///
1801 /// # Example
1802 /// ```
1803 /// # use google_cloud_run_v2::client::Services;
1804 /// use google_cloud_gax::paginator::ItemPaginator as _;
1805 /// use google_cloud_run_v2::Result;
1806 /// async fn sample(
1807 /// client: &Services, project_id: &str, location_id: &str
1808 /// ) -> Result<()> {
1809 /// let mut list = client.list_services()
1810 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
1811 /// .by_item();
1812 /// while let Some(item) = list.next().await.transpose()? {
1813 /// println!("{:?}", item);
1814 /// }
1815 /// Ok(())
1816 /// }
1817 /// ```
1818 pub fn list_services(&self) -> super::builder::services::ListServices {
1819 super::builder::services::ListServices::new(self.inner.clone())
1820 }
1821
1822 /// Updates a Service.
1823 ///
1824 /// # Long running operations
1825 ///
1826 /// This method is used to start, and/or poll a [long-running Operation].
1827 /// The [Working with long-running operations] chapter in the [user guide]
1828 /// covers these operations in detail.
1829 ///
1830 /// [long-running operation]: https://google.aip.dev/151
1831 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1832 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1833 ///
1834 /// # Example
1835 /// ```
1836 /// # use google_cloud_run_v2::client::Services;
1837 /// use google_cloud_lro::Poller;
1838 /// # extern crate wkt as google_cloud_wkt;
1839 /// use google_cloud_wkt::FieldMask;
1840 /// use google_cloud_run_v2::model::Service;
1841 /// use google_cloud_run_v2::Result;
1842 /// async fn sample(
1843 /// client: &Services, project_id: &str, location_id: &str, service_id: &str
1844 /// ) -> Result<()> {
1845 /// let response = client.update_service()
1846 /// .set_service(
1847 /// Service::new().set_name(format!("projects/{project_id}/locations/{location_id}/services/{service_id}"))/* set fields */
1848 /// )
1849 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1850 /// .poller().until_done().await?;
1851 /// println!("response {:?}", response);
1852 /// Ok(())
1853 /// }
1854 /// ```
1855 pub fn update_service(&self) -> super::builder::services::UpdateService {
1856 super::builder::services::UpdateService::new(self.inner.clone())
1857 }
1858
1859 /// Deletes a Service.
1860 /// This will cause the Service to stop serving traffic and will delete all
1861 /// revisions.
1862 ///
1863 /// # Long running operations
1864 ///
1865 /// This method is used to start, and/or poll a [long-running Operation].
1866 /// The [Working with long-running operations] chapter in the [user guide]
1867 /// covers these operations in detail.
1868 ///
1869 /// [long-running operation]: https://google.aip.dev/151
1870 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1871 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1872 ///
1873 /// # Example
1874 /// ```
1875 /// # use google_cloud_run_v2::client::Services;
1876 /// use google_cloud_lro::Poller;
1877 /// use google_cloud_run_v2::Result;
1878 /// async fn sample(
1879 /// client: &Services, project_id: &str, location_id: &str, service_id: &str
1880 /// ) -> Result<()> {
1881 /// let response = client.delete_service()
1882 /// .set_name(format!("projects/{project_id}/locations/{location_id}/services/{service_id}"))
1883 /// .poller().until_done().await?;
1884 /// println!("response {:?}", response);
1885 /// Ok(())
1886 /// }
1887 /// ```
1888 pub fn delete_service(&self) -> super::builder::services::DeleteService {
1889 super::builder::services::DeleteService::new(self.inner.clone())
1890 }
1891
1892 /// Gets the IAM Access Control policy currently in effect for the given
1893 /// Cloud Run Service. This result does not include any inherited policies.
1894 ///
1895 /// # Example
1896 /// ```
1897 /// # use google_cloud_run_v2::client::Services;
1898 /// use google_cloud_run_v2::Result;
1899 /// async fn sample(
1900 /// client: &Services
1901 /// ) -> Result<()> {
1902 /// let response = client.get_iam_policy()
1903 /// /* set fields */
1904 /// .send().await?;
1905 /// println!("response {:?}", response);
1906 /// Ok(())
1907 /// }
1908 /// ```
1909 pub fn get_iam_policy(&self) -> super::builder::services::GetIamPolicy {
1910 super::builder::services::GetIamPolicy::new(self.inner.clone())
1911 }
1912
1913 /// Sets the IAM Access control policy for the specified Service. Overwrites
1914 /// any existing policy.
1915 ///
1916 /// # Example
1917 /// ```
1918 /// # use google_cloud_run_v2::client::Services;
1919 /// use google_cloud_run_v2::Result;
1920 /// async fn sample(
1921 /// client: &Services
1922 /// ) -> Result<()> {
1923 /// let response = client.set_iam_policy()
1924 /// /* set fields */
1925 /// .send().await?;
1926 /// println!("response {:?}", response);
1927 /// Ok(())
1928 /// }
1929 /// ```
1930 pub fn set_iam_policy(&self) -> super::builder::services::SetIamPolicy {
1931 super::builder::services::SetIamPolicy::new(self.inner.clone())
1932 }
1933
1934 /// Returns permissions that a caller has on the specified Project.
1935 ///
1936 /// There are no permissions required for making this API call.
1937 ///
1938 /// # Example
1939 /// ```
1940 /// # use google_cloud_run_v2::client::Services;
1941 /// use google_cloud_run_v2::Result;
1942 /// async fn sample(
1943 /// client: &Services
1944 /// ) -> Result<()> {
1945 /// let response = client.test_iam_permissions()
1946 /// /* set fields */
1947 /// .send().await?;
1948 /// println!("response {:?}", response);
1949 /// Ok(())
1950 /// }
1951 /// ```
1952 pub fn test_iam_permissions(&self) -> super::builder::services::TestIamPermissions {
1953 super::builder::services::TestIamPermissions::new(self.inner.clone())
1954 }
1955
1956 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1957 ///
1958 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1959 ///
1960 /// # Example
1961 /// ```
1962 /// # use google_cloud_run_v2::client::Services;
1963 /// use google_cloud_gax::paginator::ItemPaginator as _;
1964 /// use google_cloud_run_v2::Result;
1965 /// async fn sample(
1966 /// client: &Services
1967 /// ) -> Result<()> {
1968 /// let mut list = client.list_operations()
1969 /// /* set fields */
1970 /// .by_item();
1971 /// while let Some(item) = list.next().await.transpose()? {
1972 /// println!("{:?}", item);
1973 /// }
1974 /// Ok(())
1975 /// }
1976 /// ```
1977 pub fn list_operations(&self) -> super::builder::services::ListOperations {
1978 super::builder::services::ListOperations::new(self.inner.clone())
1979 }
1980
1981 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1982 ///
1983 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1984 ///
1985 /// # Example
1986 /// ```
1987 /// # use google_cloud_run_v2::client::Services;
1988 /// use google_cloud_run_v2::Result;
1989 /// async fn sample(
1990 /// client: &Services
1991 /// ) -> Result<()> {
1992 /// let response = client.get_operation()
1993 /// /* set fields */
1994 /// .send().await?;
1995 /// println!("response {:?}", response);
1996 /// Ok(())
1997 /// }
1998 /// ```
1999 pub fn get_operation(&self) -> super::builder::services::GetOperation {
2000 super::builder::services::GetOperation::new(self.inner.clone())
2001 }
2002
2003 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2004 ///
2005 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2006 ///
2007 /// # Example
2008 /// ```
2009 /// # use google_cloud_run_v2::client::Services;
2010 /// use google_cloud_run_v2::Result;
2011 /// async fn sample(
2012 /// client: &Services
2013 /// ) -> Result<()> {
2014 /// client.delete_operation()
2015 /// /* set fields */
2016 /// .send().await?;
2017 /// Ok(())
2018 /// }
2019 /// ```
2020 pub fn delete_operation(&self) -> super::builder::services::DeleteOperation {
2021 super::builder::services::DeleteOperation::new(self.inner.clone())
2022 }
2023
2024 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2025 ///
2026 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2027 ///
2028 /// # Example
2029 /// ```
2030 /// # use google_cloud_run_v2::client::Services;
2031 /// use google_cloud_run_v2::Result;
2032 /// async fn sample(
2033 /// client: &Services
2034 /// ) -> Result<()> {
2035 /// let response = client.wait_operation()
2036 /// /* set fields */
2037 /// .send().await?;
2038 /// println!("response {:?}", response);
2039 /// Ok(())
2040 /// }
2041 /// ```
2042 pub fn wait_operation(&self) -> super::builder::services::WaitOperation {
2043 super::builder::services::WaitOperation::new(self.inner.clone())
2044 }
2045}
2046
2047/// Implements a client for the Cloud Run Admin API.
2048///
2049/// # Example
2050/// ```
2051/// # use google_cloud_run_v2::client::Tasks;
2052/// use google_cloud_gax::paginator::ItemPaginator as _;
2053/// async fn sample(
2054/// project_id: &str,
2055/// location_id: &str,
2056/// job_id: &str,
2057/// execution_id: &str,
2058/// ) -> anyhow::Result<()> {
2059/// let client = Tasks::builder().build().await?;
2060/// let mut list = client.list_tasks()
2061/// .set_parent(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}/executions/{execution_id}"))
2062/// .by_item();
2063/// while let Some(item) = list.next().await.transpose()? {
2064/// println!("{:?}", item);
2065/// }
2066/// Ok(())
2067/// }
2068/// ```
2069///
2070/// # Service Description
2071///
2072/// Cloud Run Task Control Plane API.
2073///
2074/// # Configuration
2075///
2076/// To configure `Tasks` use the `with_*` methods in the type returned
2077/// by [builder()][Tasks::builder]. The default configuration should
2078/// work for most applications. Common configuration changes include
2079///
2080/// * [with_endpoint()]: by default this client uses the global default endpoint
2081/// (`https://run.googleapis.com`). Applications using regional
2082/// endpoints or running in restricted networks (e.g. a network configured
2083// with [Private Google Access with VPC Service Controls]) may want to
2084/// override this default.
2085/// * [with_credentials()]: by default this client uses
2086/// [Application Default Credentials]. Applications using custom
2087/// authentication may need to override this default.
2088///
2089/// [with_endpoint()]: super::builder::tasks::ClientBuilder::with_endpoint
2090/// [with_credentials()]: super::builder::tasks::ClientBuilder::with_credentials
2091/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2092/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2093///
2094/// # Pooling and Cloning
2095///
2096/// `Tasks` holds a connection pool internally, it is advised to
2097/// create one and reuse it. You do not need to wrap `Tasks` in
2098/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2099/// already uses an `Arc` internally.
2100#[derive(Clone, Debug)]
2101pub struct Tasks {
2102 inner: std::sync::Arc<dyn super::stub::dynamic::Tasks>,
2103}
2104
2105impl Tasks {
2106 /// Returns a builder for [Tasks].
2107 ///
2108 /// ```
2109 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2110 /// # use google_cloud_run_v2::client::Tasks;
2111 /// let client = Tasks::builder().build().await?;
2112 /// # Ok(()) }
2113 /// ```
2114 pub fn builder() -> super::builder::tasks::ClientBuilder {
2115 crate::new_client_builder(super::builder::tasks::client::Factory)
2116 }
2117
2118 /// Creates a new client from the provided stub.
2119 ///
2120 /// The most common case for calling this function is in tests mocking the
2121 /// client's behavior.
2122 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2123 where
2124 T: super::stub::Tasks + 'static,
2125 {
2126 Self { inner: stub.into() }
2127 }
2128
2129 pub(crate) async fn new(
2130 config: gaxi::options::ClientConfig,
2131 ) -> crate::ClientBuilderResult<Self> {
2132 let inner = Self::build_inner(config).await?;
2133 Ok(Self { inner })
2134 }
2135
2136 async fn build_inner(
2137 conf: gaxi::options::ClientConfig,
2138 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Tasks>> {
2139 if gaxi::options::tracing_enabled(&conf) {
2140 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2141 }
2142 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2143 }
2144
2145 async fn build_transport(
2146 conf: gaxi::options::ClientConfig,
2147 ) -> crate::ClientBuilderResult<impl super::stub::Tasks> {
2148 super::transport::Tasks::new(conf).await
2149 }
2150
2151 async fn build_with_tracing(
2152 conf: gaxi::options::ClientConfig,
2153 ) -> crate::ClientBuilderResult<impl super::stub::Tasks> {
2154 Self::build_transport(conf)
2155 .await
2156 .map(super::tracing::Tasks::new)
2157 }
2158
2159 /// Gets information about a Task.
2160 ///
2161 /// # Example
2162 /// ```
2163 /// # use google_cloud_run_v2::client::Tasks;
2164 /// use google_cloud_run_v2::Result;
2165 /// async fn sample(
2166 /// client: &Tasks, project_id: &str, location_id: &str, job_id: &str, execution_id: &str, task_id: &str
2167 /// ) -> Result<()> {
2168 /// let response = client.get_task()
2169 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}/executions/{execution_id}/tasks/{task_id}"))
2170 /// .send().await?;
2171 /// println!("response {:?}", response);
2172 /// Ok(())
2173 /// }
2174 /// ```
2175 pub fn get_task(&self) -> super::builder::tasks::GetTask {
2176 super::builder::tasks::GetTask::new(self.inner.clone())
2177 }
2178
2179 /// Lists Tasks from an Execution of a Job.
2180 ///
2181 /// # Example
2182 /// ```
2183 /// # use google_cloud_run_v2::client::Tasks;
2184 /// use google_cloud_gax::paginator::ItemPaginator as _;
2185 /// use google_cloud_run_v2::Result;
2186 /// async fn sample(
2187 /// client: &Tasks, project_id: &str, location_id: &str, job_id: &str, execution_id: &str
2188 /// ) -> Result<()> {
2189 /// let mut list = client.list_tasks()
2190 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}/executions/{execution_id}"))
2191 /// .by_item();
2192 /// while let Some(item) = list.next().await.transpose()? {
2193 /// println!("{:?}", item);
2194 /// }
2195 /// Ok(())
2196 /// }
2197 /// ```
2198 pub fn list_tasks(&self) -> super::builder::tasks::ListTasks {
2199 super::builder::tasks::ListTasks::new(self.inner.clone())
2200 }
2201
2202 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2203 ///
2204 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2205 ///
2206 /// # Example
2207 /// ```
2208 /// # use google_cloud_run_v2::client::Tasks;
2209 /// use google_cloud_gax::paginator::ItemPaginator as _;
2210 /// use google_cloud_run_v2::Result;
2211 /// async fn sample(
2212 /// client: &Tasks
2213 /// ) -> Result<()> {
2214 /// let mut list = client.list_operations()
2215 /// /* set fields */
2216 /// .by_item();
2217 /// while let Some(item) = list.next().await.transpose()? {
2218 /// println!("{:?}", item);
2219 /// }
2220 /// Ok(())
2221 /// }
2222 /// ```
2223 pub fn list_operations(&self) -> super::builder::tasks::ListOperations {
2224 super::builder::tasks::ListOperations::new(self.inner.clone())
2225 }
2226
2227 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2228 ///
2229 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2230 ///
2231 /// # Example
2232 /// ```
2233 /// # use google_cloud_run_v2::client::Tasks;
2234 /// use google_cloud_run_v2::Result;
2235 /// async fn sample(
2236 /// client: &Tasks
2237 /// ) -> Result<()> {
2238 /// let response = client.get_operation()
2239 /// /* set fields */
2240 /// .send().await?;
2241 /// println!("response {:?}", response);
2242 /// Ok(())
2243 /// }
2244 /// ```
2245 pub fn get_operation(&self) -> super::builder::tasks::GetOperation {
2246 super::builder::tasks::GetOperation::new(self.inner.clone())
2247 }
2248
2249 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2250 ///
2251 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2252 ///
2253 /// # Example
2254 /// ```
2255 /// # use google_cloud_run_v2::client::Tasks;
2256 /// use google_cloud_run_v2::Result;
2257 /// async fn sample(
2258 /// client: &Tasks
2259 /// ) -> Result<()> {
2260 /// client.delete_operation()
2261 /// /* set fields */
2262 /// .send().await?;
2263 /// Ok(())
2264 /// }
2265 /// ```
2266 pub fn delete_operation(&self) -> super::builder::tasks::DeleteOperation {
2267 super::builder::tasks::DeleteOperation::new(self.inner.clone())
2268 }
2269
2270 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2271 ///
2272 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2273 ///
2274 /// # Example
2275 /// ```
2276 /// # use google_cloud_run_v2::client::Tasks;
2277 /// use google_cloud_run_v2::Result;
2278 /// async fn sample(
2279 /// client: &Tasks
2280 /// ) -> Result<()> {
2281 /// let response = client.wait_operation()
2282 /// /* set fields */
2283 /// .send().await?;
2284 /// println!("response {:?}", response);
2285 /// Ok(())
2286 /// }
2287 /// ```
2288 pub fn wait_operation(&self) -> super::builder::tasks::WaitOperation {
2289 super::builder::tasks::WaitOperation::new(self.inner.clone())
2290 }
2291}
2292
2293/// Implements a client for the Cloud Run Admin API.
2294///
2295/// # Example
2296/// ```
2297/// # use google_cloud_run_v2::client::WorkerPools;
2298/// use google_cloud_gax::paginator::ItemPaginator as _;
2299/// async fn sample(
2300/// project_id: &str,
2301/// location_id: &str,
2302/// ) -> anyhow::Result<()> {
2303/// let client = WorkerPools::builder().build().await?;
2304/// let mut list = client.list_worker_pools()
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///
2314/// # Service Description
2315///
2316/// Cloud Run WorkerPool Control Plane API.
2317///
2318/// # Configuration
2319///
2320/// To configure `WorkerPools` use the `with_*` methods in the type returned
2321/// by [builder()][WorkerPools::builder]. The default configuration should
2322/// work for most applications. Common configuration changes include
2323///
2324/// * [with_endpoint()]: by default this client uses the global default endpoint
2325/// (`https://run.googleapis.com`). Applications using regional
2326/// endpoints or running in restricted networks (e.g. a network configured
2327// with [Private Google Access with VPC Service Controls]) may want to
2328/// override this default.
2329/// * [with_credentials()]: by default this client uses
2330/// [Application Default Credentials]. Applications using custom
2331/// authentication may need to override this default.
2332///
2333/// [with_endpoint()]: super::builder::worker_pools::ClientBuilder::with_endpoint
2334/// [with_credentials()]: super::builder::worker_pools::ClientBuilder::with_credentials
2335/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2336/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2337///
2338/// # Pooling and Cloning
2339///
2340/// `WorkerPools` holds a connection pool internally, it is advised to
2341/// create one and reuse it. You do not need to wrap `WorkerPools` in
2342/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2343/// already uses an `Arc` internally.
2344#[derive(Clone, Debug)]
2345pub struct WorkerPools {
2346 inner: std::sync::Arc<dyn super::stub::dynamic::WorkerPools>,
2347}
2348
2349impl WorkerPools {
2350 /// Returns a builder for [WorkerPools].
2351 ///
2352 /// ```
2353 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
2354 /// # use google_cloud_run_v2::client::WorkerPools;
2355 /// let client = WorkerPools::builder().build().await?;
2356 /// # Ok(()) }
2357 /// ```
2358 pub fn builder() -> super::builder::worker_pools::ClientBuilder {
2359 crate::new_client_builder(super::builder::worker_pools::client::Factory)
2360 }
2361
2362 /// Creates a new client from the provided stub.
2363 ///
2364 /// The most common case for calling this function is in tests mocking the
2365 /// client's behavior.
2366 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
2367 where
2368 T: super::stub::WorkerPools + 'static,
2369 {
2370 Self { inner: stub.into() }
2371 }
2372
2373 pub(crate) async fn new(
2374 config: gaxi::options::ClientConfig,
2375 ) -> crate::ClientBuilderResult<Self> {
2376 let inner = Self::build_inner(config).await?;
2377 Ok(Self { inner })
2378 }
2379
2380 async fn build_inner(
2381 conf: gaxi::options::ClientConfig,
2382 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::WorkerPools>> {
2383 if gaxi::options::tracing_enabled(&conf) {
2384 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2385 }
2386 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2387 }
2388
2389 async fn build_transport(
2390 conf: gaxi::options::ClientConfig,
2391 ) -> crate::ClientBuilderResult<impl super::stub::WorkerPools> {
2392 super::transport::WorkerPools::new(conf).await
2393 }
2394
2395 async fn build_with_tracing(
2396 conf: gaxi::options::ClientConfig,
2397 ) -> crate::ClientBuilderResult<impl super::stub::WorkerPools> {
2398 Self::build_transport(conf)
2399 .await
2400 .map(super::tracing::WorkerPools::new)
2401 }
2402
2403 /// Creates a new WorkerPool in a given project and location.
2404 ///
2405 /// # Long running operations
2406 ///
2407 /// This method is used to start, and/or poll a [long-running Operation].
2408 /// The [Working with long-running operations] chapter in the [user guide]
2409 /// covers these operations in detail.
2410 ///
2411 /// [long-running operation]: https://google.aip.dev/151
2412 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2413 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2414 ///
2415 /// # Example
2416 /// ```
2417 /// # use google_cloud_run_v2::client::WorkerPools;
2418 /// use google_cloud_lro::Poller;
2419 /// use google_cloud_run_v2::model::WorkerPool;
2420 /// use google_cloud_run_v2::Result;
2421 /// async fn sample(
2422 /// client: &WorkerPools, project_id: &str, location_id: &str
2423 /// ) -> Result<()> {
2424 /// let response = client.create_worker_pool()
2425 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2426 /// .set_worker_pool(
2427 /// WorkerPool::new()/* set fields */
2428 /// )
2429 /// .poller().until_done().await?;
2430 /// println!("response {:?}", response);
2431 /// Ok(())
2432 /// }
2433 /// ```
2434 pub fn create_worker_pool(&self) -> super::builder::worker_pools::CreateWorkerPool {
2435 super::builder::worker_pools::CreateWorkerPool::new(self.inner.clone())
2436 }
2437
2438 /// Gets information about a WorkerPool.
2439 ///
2440 /// # Example
2441 /// ```
2442 /// # use google_cloud_run_v2::client::WorkerPools;
2443 /// use google_cloud_run_v2::Result;
2444 /// async fn sample(
2445 /// client: &WorkerPools, project_id: &str, location_id: &str, worker_pool_id: &str
2446 /// ) -> Result<()> {
2447 /// let response = client.get_worker_pool()
2448 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workerPools/{worker_pool_id}"))
2449 /// .send().await?;
2450 /// println!("response {:?}", response);
2451 /// Ok(())
2452 /// }
2453 /// ```
2454 pub fn get_worker_pool(&self) -> super::builder::worker_pools::GetWorkerPool {
2455 super::builder::worker_pools::GetWorkerPool::new(self.inner.clone())
2456 }
2457
2458 /// Lists WorkerPools. Results are sorted by creation time, descending.
2459 ///
2460 /// # Example
2461 /// ```
2462 /// # use google_cloud_run_v2::client::WorkerPools;
2463 /// use google_cloud_gax::paginator::ItemPaginator as _;
2464 /// use google_cloud_run_v2::Result;
2465 /// async fn sample(
2466 /// client: &WorkerPools, project_id: &str, location_id: &str
2467 /// ) -> Result<()> {
2468 /// let mut list = client.list_worker_pools()
2469 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2470 /// .by_item();
2471 /// while let Some(item) = list.next().await.transpose()? {
2472 /// println!("{:?}", item);
2473 /// }
2474 /// Ok(())
2475 /// }
2476 /// ```
2477 pub fn list_worker_pools(&self) -> super::builder::worker_pools::ListWorkerPools {
2478 super::builder::worker_pools::ListWorkerPools::new(self.inner.clone())
2479 }
2480
2481 /// Updates a WorkerPool.
2482 ///
2483 /// # Long running operations
2484 ///
2485 /// This method is used to start, and/or poll a [long-running Operation].
2486 /// The [Working with long-running operations] chapter in the [user guide]
2487 /// covers these operations in detail.
2488 ///
2489 /// [long-running operation]: https://google.aip.dev/151
2490 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2491 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2492 ///
2493 /// # Example
2494 /// ```
2495 /// # use google_cloud_run_v2::client::WorkerPools;
2496 /// use google_cloud_lro::Poller;
2497 /// # extern crate wkt as google_cloud_wkt;
2498 /// use google_cloud_wkt::FieldMask;
2499 /// use google_cloud_run_v2::model::WorkerPool;
2500 /// use google_cloud_run_v2::Result;
2501 /// async fn sample(
2502 /// client: &WorkerPools, project_id: &str, location_id: &str, worker_pool_id: &str
2503 /// ) -> Result<()> {
2504 /// let response = client.update_worker_pool()
2505 /// .set_worker_pool(
2506 /// WorkerPool::new().set_name(format!("projects/{project_id}/locations/{location_id}/workerPools/{worker_pool_id}"))/* set fields */
2507 /// )
2508 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2509 /// .poller().until_done().await?;
2510 /// println!("response {:?}", response);
2511 /// Ok(())
2512 /// }
2513 /// ```
2514 pub fn update_worker_pool(&self) -> super::builder::worker_pools::UpdateWorkerPool {
2515 super::builder::worker_pools::UpdateWorkerPool::new(self.inner.clone())
2516 }
2517
2518 /// Deletes a WorkerPool.
2519 ///
2520 /// # Long running operations
2521 ///
2522 /// This method is used to start, and/or poll a [long-running Operation].
2523 /// The [Working with long-running operations] chapter in the [user guide]
2524 /// covers these operations in detail.
2525 ///
2526 /// [long-running operation]: https://google.aip.dev/151
2527 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2528 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2529 ///
2530 /// # Example
2531 /// ```
2532 /// # use google_cloud_run_v2::client::WorkerPools;
2533 /// use google_cloud_lro::Poller;
2534 /// use google_cloud_run_v2::Result;
2535 /// async fn sample(
2536 /// client: &WorkerPools, project_id: &str, location_id: &str, worker_pool_id: &str
2537 /// ) -> Result<()> {
2538 /// let response = client.delete_worker_pool()
2539 /// .set_name(format!("projects/{project_id}/locations/{location_id}/workerPools/{worker_pool_id}"))
2540 /// .poller().until_done().await?;
2541 /// println!("response {:?}", response);
2542 /// Ok(())
2543 /// }
2544 /// ```
2545 pub fn delete_worker_pool(&self) -> super::builder::worker_pools::DeleteWorkerPool {
2546 super::builder::worker_pools::DeleteWorkerPool::new(self.inner.clone())
2547 }
2548
2549 /// Gets the IAM Access Control policy currently in effect for the given
2550 /// Cloud Run WorkerPool. This result does not include any inherited policies.
2551 ///
2552 /// # Example
2553 /// ```
2554 /// # use google_cloud_run_v2::client::WorkerPools;
2555 /// use google_cloud_run_v2::Result;
2556 /// async fn sample(
2557 /// client: &WorkerPools
2558 /// ) -> Result<()> {
2559 /// let response = client.get_iam_policy()
2560 /// /* set fields */
2561 /// .send().await?;
2562 /// println!("response {:?}", response);
2563 /// Ok(())
2564 /// }
2565 /// ```
2566 pub fn get_iam_policy(&self) -> super::builder::worker_pools::GetIamPolicy {
2567 super::builder::worker_pools::GetIamPolicy::new(self.inner.clone())
2568 }
2569
2570 /// Sets the IAM Access control policy for the specified WorkerPool. Overwrites
2571 /// any existing policy.
2572 ///
2573 /// # Example
2574 /// ```
2575 /// # use google_cloud_run_v2::client::WorkerPools;
2576 /// use google_cloud_run_v2::Result;
2577 /// async fn sample(
2578 /// client: &WorkerPools
2579 /// ) -> Result<()> {
2580 /// let response = client.set_iam_policy()
2581 /// /* set fields */
2582 /// .send().await?;
2583 /// println!("response {:?}", response);
2584 /// Ok(())
2585 /// }
2586 /// ```
2587 pub fn set_iam_policy(&self) -> super::builder::worker_pools::SetIamPolicy {
2588 super::builder::worker_pools::SetIamPolicy::new(self.inner.clone())
2589 }
2590
2591 /// Returns permissions that a caller has on the specified Project.
2592 ///
2593 /// There are no permissions required for making this API call.
2594 ///
2595 /// # Example
2596 /// ```
2597 /// # use google_cloud_run_v2::client::WorkerPools;
2598 /// use google_cloud_run_v2::Result;
2599 /// async fn sample(
2600 /// client: &WorkerPools
2601 /// ) -> Result<()> {
2602 /// let response = client.test_iam_permissions()
2603 /// /* set fields */
2604 /// .send().await?;
2605 /// println!("response {:?}", response);
2606 /// Ok(())
2607 /// }
2608 /// ```
2609 pub fn test_iam_permissions(&self) -> super::builder::worker_pools::TestIamPermissions {
2610 super::builder::worker_pools::TestIamPermissions::new(self.inner.clone())
2611 }
2612
2613 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2614 ///
2615 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2616 ///
2617 /// # Example
2618 /// ```
2619 /// # use google_cloud_run_v2::client::WorkerPools;
2620 /// use google_cloud_gax::paginator::ItemPaginator as _;
2621 /// use google_cloud_run_v2::Result;
2622 /// async fn sample(
2623 /// client: &WorkerPools
2624 /// ) -> Result<()> {
2625 /// let mut list = client.list_operations()
2626 /// /* set fields */
2627 /// .by_item();
2628 /// while let Some(item) = list.next().await.transpose()? {
2629 /// println!("{:?}", item);
2630 /// }
2631 /// Ok(())
2632 /// }
2633 /// ```
2634 pub fn list_operations(&self) -> super::builder::worker_pools::ListOperations {
2635 super::builder::worker_pools::ListOperations::new(self.inner.clone())
2636 }
2637
2638 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2639 ///
2640 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2641 ///
2642 /// # Example
2643 /// ```
2644 /// # use google_cloud_run_v2::client::WorkerPools;
2645 /// use google_cloud_run_v2::Result;
2646 /// async fn sample(
2647 /// client: &WorkerPools
2648 /// ) -> Result<()> {
2649 /// let response = client.get_operation()
2650 /// /* set fields */
2651 /// .send().await?;
2652 /// println!("response {:?}", response);
2653 /// Ok(())
2654 /// }
2655 /// ```
2656 pub fn get_operation(&self) -> super::builder::worker_pools::GetOperation {
2657 super::builder::worker_pools::GetOperation::new(self.inner.clone())
2658 }
2659
2660 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2661 ///
2662 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2663 ///
2664 /// # Example
2665 /// ```
2666 /// # use google_cloud_run_v2::client::WorkerPools;
2667 /// use google_cloud_run_v2::Result;
2668 /// async fn sample(
2669 /// client: &WorkerPools
2670 /// ) -> Result<()> {
2671 /// client.delete_operation()
2672 /// /* set fields */
2673 /// .send().await?;
2674 /// Ok(())
2675 /// }
2676 /// ```
2677 pub fn delete_operation(&self) -> super::builder::worker_pools::DeleteOperation {
2678 super::builder::worker_pools::DeleteOperation::new(self.inner.clone())
2679 }
2680
2681 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2682 ///
2683 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
2684 ///
2685 /// # Example
2686 /// ```
2687 /// # use google_cloud_run_v2::client::WorkerPools;
2688 /// use google_cloud_run_v2::Result;
2689 /// async fn sample(
2690 /// client: &WorkerPools
2691 /// ) -> Result<()> {
2692 /// let response = client.wait_operation()
2693 /// /* set fields */
2694 /// .send().await?;
2695 /// println!("response {:?}", response);
2696 /// Ok(())
2697 /// }
2698 /// ```
2699 pub fn wait_operation(&self) -> super::builder::worker_pools::WaitOperation {
2700 super::builder::worker_pools::WaitOperation::new(self.inner.clone())
2701 }
2702}