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
19use crate::Result;
20use std::sync::Arc;
21
22/// Implements a client for the Cloud Run Admin API.
23///
24/// # Example
25/// ```
26/// # tokio_test::block_on(async {
27/// # use google_cloud_run_v2::client::Builds;
28/// let client = Builds::builder().build().await?;
29/// // use `client` to make requests to the {Codec.APITitle}}.
30/// # gax::Result::<()>::Ok(()) });
31/// ```
32///
33/// # Service Description
34///
35/// Cloud Run Build Control Plane API
36///
37/// # Configuration
38///
39/// To configure `Builds` use the `with_*` methods in the type returned
40/// by [builder()][Builds::builder]. The default configuration should
41/// work for most applications. Common configuration changes include
42///
43/// * [with_endpoint()]: by default this client uses the global default endpoint
44///   (`https://run.googleapis.com`). Applications using regional
45///   endpoints or running in restricted networks (e.g. a network configured
46//    with [Private Google Access with VPC Service Controls]) may want to
47///   override this default.
48/// * [with_credentials()]: by default this client uses
49///   [Application Default Credentials]. Applications using custom
50///   authentication may need to override this default.
51///
52/// [with_endpoint()]: super::builder::builds::ClientBuilder::with_endpoint
53/// [with_credentials()]: super::builder::builds::ClientBuilder::credentials
54/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
55/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
56///
57/// # Pooling and Cloning
58///
59/// `Builds` holds a connection pool internally, it is advised to
60/// create one and the reuse it.  You do not need to wrap `Builds` in
61/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
62/// internally.
63#[derive(Clone, Debug)]
64pub struct Builds {
65    inner: Arc<dyn super::stub::dynamic::Builds>,
66}
67
68impl Builds {
69    /// Returns a builder for [Builds].
70    ///
71    /// ```
72    /// # tokio_test::block_on(async {
73    /// # use google_cloud_run_v2::client::Builds;
74    /// let client = Builds::builder().build().await?;
75    /// # gax::Result::<()>::Ok(()) });
76    /// ```
77    pub fn builder() -> super::builder::builds::ClientBuilder {
78        gax::client_builder::internal::new_builder(super::builder::builds::client::Factory)
79    }
80
81    /// Creates a new client from the provided stub.
82    ///
83    /// The most common case for calling this function is in tests mocking the
84    /// client's behavior.
85    pub fn from_stub<T>(stub: T) -> Self
86    where
87        T: super::stub::Builds + 'static,
88    {
89        Self {
90            inner: Arc::new(stub),
91        }
92    }
93
94    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
95        let inner = Self::build_inner(config).await?;
96        Ok(Self { inner })
97    }
98
99    async fn build_inner(
100        conf: gaxi::options::ClientConfig,
101    ) -> Result<Arc<dyn super::stub::dynamic::Builds>> {
102        if gaxi::options::tracing_enabled(&conf) {
103            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
104        }
105        Ok(Arc::new(Self::build_transport(conf).await?))
106    }
107
108    async fn build_transport(
109        conf: gaxi::options::ClientConfig,
110    ) -> Result<impl super::stub::Builds> {
111        super::transport::Builds::new(conf).await
112    }
113
114    async fn build_with_tracing(
115        conf: gaxi::options::ClientConfig,
116    ) -> Result<impl super::stub::Builds> {
117        Self::build_transport(conf)
118            .await
119            .map(super::tracing::Builds::new)
120    }
121
122    /// Submits a build in a given project.
123    pub fn submit_build(
124        &self,
125        parent: impl Into<std::string::String>,
126    ) -> super::builder::builds::SubmitBuild {
127        super::builder::builds::SubmitBuild::new(self.inner.clone()).set_parent(parent.into())
128    }
129
130    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
131    ///
132    /// [google.longrunning.Operations]: longrunning::client::Operations
133    pub fn list_operations(
134        &self,
135        name: impl Into<std::string::String>,
136    ) -> super::builder::builds::ListOperations {
137        super::builder::builds::ListOperations::new(self.inner.clone()).set_name(name.into())
138    }
139
140    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
141    ///
142    /// [google.longrunning.Operations]: longrunning::client::Operations
143    pub fn get_operation(
144        &self,
145        name: impl Into<std::string::String>,
146    ) -> super::builder::builds::GetOperation {
147        super::builder::builds::GetOperation::new(self.inner.clone()).set_name(name.into())
148    }
149
150    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
151    ///
152    /// [google.longrunning.Operations]: longrunning::client::Operations
153    pub fn delete_operation(
154        &self,
155        name: impl Into<std::string::String>,
156    ) -> super::builder::builds::DeleteOperation {
157        super::builder::builds::DeleteOperation::new(self.inner.clone()).set_name(name.into())
158    }
159
160    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
161    ///
162    /// [google.longrunning.Operations]: longrunning::client::Operations
163    pub fn wait_operation(
164        &self,
165        name: impl Into<std::string::String>,
166    ) -> super::builder::builds::WaitOperation {
167        super::builder::builds::WaitOperation::new(self.inner.clone()).set_name(name.into())
168    }
169}
170
171/// Implements a client for the Cloud Run Admin API.
172///
173/// # Example
174/// ```
175/// # tokio_test::block_on(async {
176/// # use google_cloud_run_v2::client::Executions;
177/// let client = Executions::builder().build().await?;
178/// // use `client` to make requests to the {Codec.APITitle}}.
179/// # gax::Result::<()>::Ok(()) });
180/// ```
181///
182/// # Service Description
183///
184/// Cloud Run Execution Control Plane API.
185///
186/// # Configuration
187///
188/// To configure `Executions` use the `with_*` methods in the type returned
189/// by [builder()][Executions::builder]. The default configuration should
190/// work for most applications. Common configuration changes include
191///
192/// * [with_endpoint()]: by default this client uses the global default endpoint
193///   (`https://run.googleapis.com`). Applications using regional
194///   endpoints or running in restricted networks (e.g. a network configured
195//    with [Private Google Access with VPC Service Controls]) may want to
196///   override this default.
197/// * [with_credentials()]: by default this client uses
198///   [Application Default Credentials]. Applications using custom
199///   authentication may need to override this default.
200///
201/// [with_endpoint()]: super::builder::executions::ClientBuilder::with_endpoint
202/// [with_credentials()]: super::builder::executions::ClientBuilder::credentials
203/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
204/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
205///
206/// # Pooling and Cloning
207///
208/// `Executions` holds a connection pool internally, it is advised to
209/// create one and the reuse it.  You do not need to wrap `Executions` in
210/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
211/// internally.
212#[derive(Clone, Debug)]
213pub struct Executions {
214    inner: Arc<dyn super::stub::dynamic::Executions>,
215}
216
217impl Executions {
218    /// Returns a builder for [Executions].
219    ///
220    /// ```
221    /// # tokio_test::block_on(async {
222    /// # use google_cloud_run_v2::client::Executions;
223    /// let client = Executions::builder().build().await?;
224    /// # gax::Result::<()>::Ok(()) });
225    /// ```
226    pub fn builder() -> super::builder::executions::ClientBuilder {
227        gax::client_builder::internal::new_builder(super::builder::executions::client::Factory)
228    }
229
230    /// Creates a new client from the provided stub.
231    ///
232    /// The most common case for calling this function is in tests mocking the
233    /// client's behavior.
234    pub fn from_stub<T>(stub: T) -> Self
235    where
236        T: super::stub::Executions + 'static,
237    {
238        Self {
239            inner: Arc::new(stub),
240        }
241    }
242
243    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
244        let inner = Self::build_inner(config).await?;
245        Ok(Self { inner })
246    }
247
248    async fn build_inner(
249        conf: gaxi::options::ClientConfig,
250    ) -> Result<Arc<dyn super::stub::dynamic::Executions>> {
251        if gaxi::options::tracing_enabled(&conf) {
252            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
253        }
254        Ok(Arc::new(Self::build_transport(conf).await?))
255    }
256
257    async fn build_transport(
258        conf: gaxi::options::ClientConfig,
259    ) -> Result<impl super::stub::Executions> {
260        super::transport::Executions::new(conf).await
261    }
262
263    async fn build_with_tracing(
264        conf: gaxi::options::ClientConfig,
265    ) -> Result<impl super::stub::Executions> {
266        Self::build_transport(conf)
267            .await
268            .map(super::tracing::Executions::new)
269    }
270
271    /// Gets information about an Execution.
272    pub fn get_execution(
273        &self,
274        name: impl Into<std::string::String>,
275    ) -> super::builder::executions::GetExecution {
276        super::builder::executions::GetExecution::new(self.inner.clone()).set_name(name.into())
277    }
278
279    /// Lists Executions from a Job. Results are sorted by creation time,
280    /// descending.
281    pub fn list_executions(
282        &self,
283        parent: impl Into<std::string::String>,
284    ) -> super::builder::executions::ListExecutions {
285        super::builder::executions::ListExecutions::new(self.inner.clone())
286            .set_parent(parent.into())
287    }
288
289    /// Deletes an Execution.
290    ///
291    /// # Long running operations
292    ///
293    /// This method is used to start, and/or poll a [long-running Operation].
294    /// The [Working with long-running operations] chapter in the [user guide]
295    /// covers these operations in detail.
296    ///
297    /// [long-running operation]: https://google.aip.dev/151
298    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
299    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
300    pub fn delete_execution(
301        &self,
302        name: impl Into<std::string::String>,
303    ) -> super::builder::executions::DeleteExecution {
304        super::builder::executions::DeleteExecution::new(self.inner.clone()).set_name(name.into())
305    }
306
307    /// Cancels an Execution.
308    ///
309    /// # Long running operations
310    ///
311    /// This method is used to start, and/or poll a [long-running Operation].
312    /// The [Working with long-running operations] chapter in the [user guide]
313    /// covers these operations in detail.
314    ///
315    /// [long-running operation]: https://google.aip.dev/151
316    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
317    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
318    pub fn cancel_execution(
319        &self,
320        name: impl Into<std::string::String>,
321    ) -> super::builder::executions::CancelExecution {
322        super::builder::executions::CancelExecution::new(self.inner.clone()).set_name(name.into())
323    }
324
325    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
326    ///
327    /// [google.longrunning.Operations]: longrunning::client::Operations
328    pub fn list_operations(
329        &self,
330        name: impl Into<std::string::String>,
331    ) -> super::builder::executions::ListOperations {
332        super::builder::executions::ListOperations::new(self.inner.clone()).set_name(name.into())
333    }
334
335    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
336    ///
337    /// [google.longrunning.Operations]: longrunning::client::Operations
338    pub fn get_operation(
339        &self,
340        name: impl Into<std::string::String>,
341    ) -> super::builder::executions::GetOperation {
342        super::builder::executions::GetOperation::new(self.inner.clone()).set_name(name.into())
343    }
344
345    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
346    ///
347    /// [google.longrunning.Operations]: longrunning::client::Operations
348    pub fn delete_operation(
349        &self,
350        name: impl Into<std::string::String>,
351    ) -> super::builder::executions::DeleteOperation {
352        super::builder::executions::DeleteOperation::new(self.inner.clone()).set_name(name.into())
353    }
354
355    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
356    ///
357    /// [google.longrunning.Operations]: longrunning::client::Operations
358    pub fn wait_operation(
359        &self,
360        name: impl Into<std::string::String>,
361    ) -> super::builder::executions::WaitOperation {
362        super::builder::executions::WaitOperation::new(self.inner.clone()).set_name(name.into())
363    }
364}
365
366/// Implements a client for the Cloud Run Admin API.
367///
368/// # Example
369/// ```
370/// # tokio_test::block_on(async {
371/// # use google_cloud_run_v2::client::Jobs;
372/// let client = Jobs::builder().build().await?;
373/// // use `client` to make requests to the {Codec.APITitle}}.
374/// # gax::Result::<()>::Ok(()) });
375/// ```
376///
377/// # Service Description
378///
379/// Cloud Run Job Control Plane API.
380///
381/// # Configuration
382///
383/// To configure `Jobs` use the `with_*` methods in the type returned
384/// by [builder()][Jobs::builder]. The default configuration should
385/// work for most applications. Common configuration changes include
386///
387/// * [with_endpoint()]: by default this client uses the global default endpoint
388///   (`https://run.googleapis.com`). Applications using regional
389///   endpoints or running in restricted networks (e.g. a network configured
390//    with [Private Google Access with VPC Service Controls]) may want to
391///   override this default.
392/// * [with_credentials()]: by default this client uses
393///   [Application Default Credentials]. Applications using custom
394///   authentication may need to override this default.
395///
396/// [with_endpoint()]: super::builder::jobs::ClientBuilder::with_endpoint
397/// [with_credentials()]: super::builder::jobs::ClientBuilder::credentials
398/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
399/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
400///
401/// # Pooling and Cloning
402///
403/// `Jobs` holds a connection pool internally, it is advised to
404/// create one and the reuse it.  You do not need to wrap `Jobs` in
405/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
406/// internally.
407#[derive(Clone, Debug)]
408pub struct Jobs {
409    inner: Arc<dyn super::stub::dynamic::Jobs>,
410}
411
412impl Jobs {
413    /// Returns a builder for [Jobs].
414    ///
415    /// ```
416    /// # tokio_test::block_on(async {
417    /// # use google_cloud_run_v2::client::Jobs;
418    /// let client = Jobs::builder().build().await?;
419    /// # gax::Result::<()>::Ok(()) });
420    /// ```
421    pub fn builder() -> super::builder::jobs::ClientBuilder {
422        gax::client_builder::internal::new_builder(super::builder::jobs::client::Factory)
423    }
424
425    /// Creates a new client from the provided stub.
426    ///
427    /// The most common case for calling this function is in tests mocking the
428    /// client's behavior.
429    pub fn from_stub<T>(stub: T) -> Self
430    where
431        T: super::stub::Jobs + 'static,
432    {
433        Self {
434            inner: Arc::new(stub),
435        }
436    }
437
438    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
439        let inner = Self::build_inner(config).await?;
440        Ok(Self { inner })
441    }
442
443    async fn build_inner(
444        conf: gaxi::options::ClientConfig,
445    ) -> Result<Arc<dyn super::stub::dynamic::Jobs>> {
446        if gaxi::options::tracing_enabled(&conf) {
447            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
448        }
449        Ok(Arc::new(Self::build_transport(conf).await?))
450    }
451
452    async fn build_transport(conf: gaxi::options::ClientConfig) -> Result<impl super::stub::Jobs> {
453        super::transport::Jobs::new(conf).await
454    }
455
456    async fn build_with_tracing(
457        conf: gaxi::options::ClientConfig,
458    ) -> Result<impl super::stub::Jobs> {
459        Self::build_transport(conf)
460            .await
461            .map(super::tracing::Jobs::new)
462    }
463
464    /// Creates a Job.
465    ///
466    /// # Long running operations
467    ///
468    /// This method is used to start, and/or poll a [long-running Operation].
469    /// The [Working with long-running operations] chapter in the [user guide]
470    /// covers these operations in detail.
471    ///
472    /// [long-running operation]: https://google.aip.dev/151
473    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
474    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
475    pub fn create_job(
476        &self,
477        parent: impl Into<std::string::String>,
478    ) -> super::builder::jobs::CreateJob {
479        super::builder::jobs::CreateJob::new(self.inner.clone()).set_parent(parent.into())
480    }
481
482    /// Gets information about a Job.
483    pub fn get_job(&self, name: impl Into<std::string::String>) -> super::builder::jobs::GetJob {
484        super::builder::jobs::GetJob::new(self.inner.clone()).set_name(name.into())
485    }
486
487    /// Lists Jobs. Results are sorted by creation time, descending.
488    pub fn list_jobs(
489        &self,
490        parent: impl Into<std::string::String>,
491    ) -> super::builder::jobs::ListJobs {
492        super::builder::jobs::ListJobs::new(self.inner.clone()).set_parent(parent.into())
493    }
494
495    /// Updates a Job.
496    ///
497    /// # Long running operations
498    ///
499    /// This method is used to start, and/or poll a [long-running Operation].
500    /// The [Working with long-running operations] chapter in the [user guide]
501    /// covers these operations in detail.
502    ///
503    /// [long-running operation]: https://google.aip.dev/151
504    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
505    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
506    pub fn update_job(&self, job: impl Into<crate::model::Job>) -> super::builder::jobs::UpdateJob {
507        super::builder::jobs::UpdateJob::new(self.inner.clone()).set_job(job.into())
508    }
509
510    /// Deletes a Job.
511    ///
512    /// # Long running operations
513    ///
514    /// This method is used to start, and/or poll a [long-running Operation].
515    /// The [Working with long-running operations] chapter in the [user guide]
516    /// covers these operations in detail.
517    ///
518    /// [long-running operation]: https://google.aip.dev/151
519    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
520    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
521    pub fn delete_job(
522        &self,
523        name: impl Into<std::string::String>,
524    ) -> super::builder::jobs::DeleteJob {
525        super::builder::jobs::DeleteJob::new(self.inner.clone()).set_name(name.into())
526    }
527
528    /// Triggers creation of a new Execution of this Job.
529    ///
530    /// # Long running operations
531    ///
532    /// This method is used to start, and/or poll a [long-running Operation].
533    /// The [Working with long-running operations] chapter in the [user guide]
534    /// covers these operations in detail.
535    ///
536    /// [long-running operation]: https://google.aip.dev/151
537    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
538    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
539    pub fn run_job(&self, name: impl Into<std::string::String>) -> super::builder::jobs::RunJob {
540        super::builder::jobs::RunJob::new(self.inner.clone()).set_name(name.into())
541    }
542
543    /// Gets the IAM Access Control policy currently in effect for the given Job.
544    /// This result does not include any inherited policies.
545    pub fn get_iam_policy(
546        &self,
547        resource: impl Into<std::string::String>,
548    ) -> super::builder::jobs::GetIamPolicy {
549        super::builder::jobs::GetIamPolicy::new(self.inner.clone()).set_resource(resource.into())
550    }
551
552    /// Sets the IAM Access control policy for the specified Job. Overwrites
553    /// any existing policy.
554    pub fn set_iam_policy(
555        &self,
556        resource: impl Into<std::string::String>,
557    ) -> super::builder::jobs::SetIamPolicy {
558        super::builder::jobs::SetIamPolicy::new(self.inner.clone()).set_resource(resource.into())
559    }
560
561    /// Returns permissions that a caller has on the specified Project.
562    ///
563    /// There are no permissions required for making this API call.
564    pub fn test_iam_permissions(
565        &self,
566        resource: impl Into<std::string::String>,
567    ) -> super::builder::jobs::TestIamPermissions {
568        super::builder::jobs::TestIamPermissions::new(self.inner.clone())
569            .set_resource(resource.into())
570    }
571
572    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
573    ///
574    /// [google.longrunning.Operations]: longrunning::client::Operations
575    pub fn list_operations(
576        &self,
577        name: impl Into<std::string::String>,
578    ) -> super::builder::jobs::ListOperations {
579        super::builder::jobs::ListOperations::new(self.inner.clone()).set_name(name.into())
580    }
581
582    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
583    ///
584    /// [google.longrunning.Operations]: longrunning::client::Operations
585    pub fn get_operation(
586        &self,
587        name: impl Into<std::string::String>,
588    ) -> super::builder::jobs::GetOperation {
589        super::builder::jobs::GetOperation::new(self.inner.clone()).set_name(name.into())
590    }
591
592    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
593    ///
594    /// [google.longrunning.Operations]: longrunning::client::Operations
595    pub fn delete_operation(
596        &self,
597        name: impl Into<std::string::String>,
598    ) -> super::builder::jobs::DeleteOperation {
599        super::builder::jobs::DeleteOperation::new(self.inner.clone()).set_name(name.into())
600    }
601
602    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
603    ///
604    /// [google.longrunning.Operations]: longrunning::client::Operations
605    pub fn wait_operation(
606        &self,
607        name: impl Into<std::string::String>,
608    ) -> super::builder::jobs::WaitOperation {
609        super::builder::jobs::WaitOperation::new(self.inner.clone()).set_name(name.into())
610    }
611}
612
613/// Implements a client for the Cloud Run Admin API.
614///
615/// # Example
616/// ```
617/// # tokio_test::block_on(async {
618/// # use google_cloud_run_v2::client::Revisions;
619/// let client = Revisions::builder().build().await?;
620/// // use `client` to make requests to the {Codec.APITitle}}.
621/// # gax::Result::<()>::Ok(()) });
622/// ```
623///
624/// # Service Description
625///
626/// Cloud Run Revision Control Plane API.
627///
628/// # Configuration
629///
630/// To configure `Revisions` use the `with_*` methods in the type returned
631/// by [builder()][Revisions::builder]. The default configuration should
632/// work for most applications. Common configuration changes include
633///
634/// * [with_endpoint()]: by default this client uses the global default endpoint
635///   (`https://run.googleapis.com`). Applications using regional
636///   endpoints or running in restricted networks (e.g. a network configured
637//    with [Private Google Access with VPC Service Controls]) may want to
638///   override this default.
639/// * [with_credentials()]: by default this client uses
640///   [Application Default Credentials]. Applications using custom
641///   authentication may need to override this default.
642///
643/// [with_endpoint()]: super::builder::revisions::ClientBuilder::with_endpoint
644/// [with_credentials()]: super::builder::revisions::ClientBuilder::credentials
645/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
646/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
647///
648/// # Pooling and Cloning
649///
650/// `Revisions` holds a connection pool internally, it is advised to
651/// create one and the reuse it.  You do not need to wrap `Revisions` in
652/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
653/// internally.
654#[derive(Clone, Debug)]
655pub struct Revisions {
656    inner: Arc<dyn super::stub::dynamic::Revisions>,
657}
658
659impl Revisions {
660    /// Returns a builder for [Revisions].
661    ///
662    /// ```
663    /// # tokio_test::block_on(async {
664    /// # use google_cloud_run_v2::client::Revisions;
665    /// let client = Revisions::builder().build().await?;
666    /// # gax::Result::<()>::Ok(()) });
667    /// ```
668    pub fn builder() -> super::builder::revisions::ClientBuilder {
669        gax::client_builder::internal::new_builder(super::builder::revisions::client::Factory)
670    }
671
672    /// Creates a new client from the provided stub.
673    ///
674    /// The most common case for calling this function is in tests mocking the
675    /// client's behavior.
676    pub fn from_stub<T>(stub: T) -> Self
677    where
678        T: super::stub::Revisions + 'static,
679    {
680        Self {
681            inner: Arc::new(stub),
682        }
683    }
684
685    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
686        let inner = Self::build_inner(config).await?;
687        Ok(Self { inner })
688    }
689
690    async fn build_inner(
691        conf: gaxi::options::ClientConfig,
692    ) -> Result<Arc<dyn super::stub::dynamic::Revisions>> {
693        if gaxi::options::tracing_enabled(&conf) {
694            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
695        }
696        Ok(Arc::new(Self::build_transport(conf).await?))
697    }
698
699    async fn build_transport(
700        conf: gaxi::options::ClientConfig,
701    ) -> Result<impl super::stub::Revisions> {
702        super::transport::Revisions::new(conf).await
703    }
704
705    async fn build_with_tracing(
706        conf: gaxi::options::ClientConfig,
707    ) -> Result<impl super::stub::Revisions> {
708        Self::build_transport(conf)
709            .await
710            .map(super::tracing::Revisions::new)
711    }
712
713    /// Gets information about a Revision.
714    pub fn get_revision(
715        &self,
716        name: impl Into<std::string::String>,
717    ) -> super::builder::revisions::GetRevision {
718        super::builder::revisions::GetRevision::new(self.inner.clone()).set_name(name.into())
719    }
720
721    /// Lists Revisions from a given Service, or from a given location.  Results
722    /// are sorted by creation time, descending.
723    pub fn list_revisions(
724        &self,
725        parent: impl Into<std::string::String>,
726    ) -> super::builder::revisions::ListRevisions {
727        super::builder::revisions::ListRevisions::new(self.inner.clone()).set_parent(parent.into())
728    }
729
730    /// Deletes a Revision.
731    ///
732    /// # Long running operations
733    ///
734    /// This method is used to start, and/or poll a [long-running Operation].
735    /// The [Working with long-running operations] chapter in the [user guide]
736    /// covers these operations in detail.
737    ///
738    /// [long-running operation]: https://google.aip.dev/151
739    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
740    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
741    pub fn delete_revision(
742        &self,
743        name: impl Into<std::string::String>,
744    ) -> super::builder::revisions::DeleteRevision {
745        super::builder::revisions::DeleteRevision::new(self.inner.clone()).set_name(name.into())
746    }
747
748    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
749    ///
750    /// [google.longrunning.Operations]: longrunning::client::Operations
751    pub fn list_operations(
752        &self,
753        name: impl Into<std::string::String>,
754    ) -> super::builder::revisions::ListOperations {
755        super::builder::revisions::ListOperations::new(self.inner.clone()).set_name(name.into())
756    }
757
758    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
759    ///
760    /// [google.longrunning.Operations]: longrunning::client::Operations
761    pub fn get_operation(
762        &self,
763        name: impl Into<std::string::String>,
764    ) -> super::builder::revisions::GetOperation {
765        super::builder::revisions::GetOperation::new(self.inner.clone()).set_name(name.into())
766    }
767
768    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
769    ///
770    /// [google.longrunning.Operations]: longrunning::client::Operations
771    pub fn delete_operation(
772        &self,
773        name: impl Into<std::string::String>,
774    ) -> super::builder::revisions::DeleteOperation {
775        super::builder::revisions::DeleteOperation::new(self.inner.clone()).set_name(name.into())
776    }
777
778    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
779    ///
780    /// [google.longrunning.Operations]: longrunning::client::Operations
781    pub fn wait_operation(
782        &self,
783        name: impl Into<std::string::String>,
784    ) -> super::builder::revisions::WaitOperation {
785        super::builder::revisions::WaitOperation::new(self.inner.clone()).set_name(name.into())
786    }
787}
788
789/// Implements a client for the Cloud Run Admin API.
790///
791/// # Example
792/// ```
793/// # tokio_test::block_on(async {
794/// # use google_cloud_run_v2::client::Services;
795/// let client = Services::builder().build().await?;
796/// // use `client` to make requests to the {Codec.APITitle}}.
797/// # gax::Result::<()>::Ok(()) });
798/// ```
799///
800/// # Service Description
801///
802/// Cloud Run Service Control Plane API
803///
804/// # Configuration
805///
806/// To configure `Services` use the `with_*` methods in the type returned
807/// by [builder()][Services::builder]. The default configuration should
808/// work for most applications. Common configuration changes include
809///
810/// * [with_endpoint()]: by default this client uses the global default endpoint
811///   (`https://run.googleapis.com`). Applications using regional
812///   endpoints or running in restricted networks (e.g. a network configured
813//    with [Private Google Access with VPC Service Controls]) may want to
814///   override this default.
815/// * [with_credentials()]: by default this client uses
816///   [Application Default Credentials]. Applications using custom
817///   authentication may need to override this default.
818///
819/// [with_endpoint()]: super::builder::services::ClientBuilder::with_endpoint
820/// [with_credentials()]: super::builder::services::ClientBuilder::credentials
821/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
822/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
823///
824/// # Pooling and Cloning
825///
826/// `Services` holds a connection pool internally, it is advised to
827/// create one and the reuse it.  You do not need to wrap `Services` in
828/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
829/// internally.
830#[derive(Clone, Debug)]
831pub struct Services {
832    inner: Arc<dyn super::stub::dynamic::Services>,
833}
834
835impl Services {
836    /// Returns a builder for [Services].
837    ///
838    /// ```
839    /// # tokio_test::block_on(async {
840    /// # use google_cloud_run_v2::client::Services;
841    /// let client = Services::builder().build().await?;
842    /// # gax::Result::<()>::Ok(()) });
843    /// ```
844    pub fn builder() -> super::builder::services::ClientBuilder {
845        gax::client_builder::internal::new_builder(super::builder::services::client::Factory)
846    }
847
848    /// Creates a new client from the provided stub.
849    ///
850    /// The most common case for calling this function is in tests mocking the
851    /// client's behavior.
852    pub fn from_stub<T>(stub: T) -> Self
853    where
854        T: super::stub::Services + 'static,
855    {
856        Self {
857            inner: Arc::new(stub),
858        }
859    }
860
861    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
862        let inner = Self::build_inner(config).await?;
863        Ok(Self { inner })
864    }
865
866    async fn build_inner(
867        conf: gaxi::options::ClientConfig,
868    ) -> Result<Arc<dyn super::stub::dynamic::Services>> {
869        if gaxi::options::tracing_enabled(&conf) {
870            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
871        }
872        Ok(Arc::new(Self::build_transport(conf).await?))
873    }
874
875    async fn build_transport(
876        conf: gaxi::options::ClientConfig,
877    ) -> Result<impl super::stub::Services> {
878        super::transport::Services::new(conf).await
879    }
880
881    async fn build_with_tracing(
882        conf: gaxi::options::ClientConfig,
883    ) -> Result<impl super::stub::Services> {
884        Self::build_transport(conf)
885            .await
886            .map(super::tracing::Services::new)
887    }
888
889    /// Creates a new Service in a given project and location.
890    ///
891    /// # Long running operations
892    ///
893    /// This method is used to start, and/or poll a [long-running Operation].
894    /// The [Working with long-running operations] chapter in the [user guide]
895    /// covers these operations in detail.
896    ///
897    /// [long-running operation]: https://google.aip.dev/151
898    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
899    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
900    pub fn create_service(
901        &self,
902        parent: impl Into<std::string::String>,
903    ) -> super::builder::services::CreateService {
904        super::builder::services::CreateService::new(self.inner.clone()).set_parent(parent.into())
905    }
906
907    /// Gets information about a Service.
908    pub fn get_service(
909        &self,
910        name: impl Into<std::string::String>,
911    ) -> super::builder::services::GetService {
912        super::builder::services::GetService::new(self.inner.clone()).set_name(name.into())
913    }
914
915    /// Lists Services. Results are sorted by creation time, descending.
916    pub fn list_services(
917        &self,
918        parent: impl Into<std::string::String>,
919    ) -> super::builder::services::ListServices {
920        super::builder::services::ListServices::new(self.inner.clone()).set_parent(parent.into())
921    }
922
923    /// Updates a Service.
924    ///
925    /// # Long running operations
926    ///
927    /// This method is used to start, and/or poll a [long-running Operation].
928    /// The [Working with long-running operations] chapter in the [user guide]
929    /// covers these operations in detail.
930    ///
931    /// [long-running operation]: https://google.aip.dev/151
932    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
933    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
934    pub fn update_service(
935        &self,
936        service: impl Into<crate::model::Service>,
937    ) -> super::builder::services::UpdateService {
938        super::builder::services::UpdateService::new(self.inner.clone()).set_service(service.into())
939    }
940
941    /// Deletes a Service.
942    /// This will cause the Service to stop serving traffic and will delete all
943    /// revisions.
944    ///
945    /// # Long running operations
946    ///
947    /// This method is used to start, and/or poll a [long-running Operation].
948    /// The [Working with long-running operations] chapter in the [user guide]
949    /// covers these operations in detail.
950    ///
951    /// [long-running operation]: https://google.aip.dev/151
952    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
953    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
954    pub fn delete_service(
955        &self,
956        name: impl Into<std::string::String>,
957    ) -> super::builder::services::DeleteService {
958        super::builder::services::DeleteService::new(self.inner.clone()).set_name(name.into())
959    }
960
961    /// Gets the IAM Access Control policy currently in effect for the given
962    /// Cloud Run Service. This result does not include any inherited policies.
963    pub fn get_iam_policy(
964        &self,
965        resource: impl Into<std::string::String>,
966    ) -> super::builder::services::GetIamPolicy {
967        super::builder::services::GetIamPolicy::new(self.inner.clone())
968            .set_resource(resource.into())
969    }
970
971    /// Sets the IAM Access control policy for the specified Service. Overwrites
972    /// any existing policy.
973    pub fn set_iam_policy(
974        &self,
975        resource: impl Into<std::string::String>,
976    ) -> super::builder::services::SetIamPolicy {
977        super::builder::services::SetIamPolicy::new(self.inner.clone())
978            .set_resource(resource.into())
979    }
980
981    /// Returns permissions that a caller has on the specified Project.
982    ///
983    /// There are no permissions required for making this API call.
984    pub fn test_iam_permissions(
985        &self,
986        resource: impl Into<std::string::String>,
987    ) -> super::builder::services::TestIamPermissions {
988        super::builder::services::TestIamPermissions::new(self.inner.clone())
989            .set_resource(resource.into())
990    }
991
992    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
993    ///
994    /// [google.longrunning.Operations]: longrunning::client::Operations
995    pub fn list_operations(
996        &self,
997        name: impl Into<std::string::String>,
998    ) -> super::builder::services::ListOperations {
999        super::builder::services::ListOperations::new(self.inner.clone()).set_name(name.into())
1000    }
1001
1002    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1003    ///
1004    /// [google.longrunning.Operations]: longrunning::client::Operations
1005    pub fn get_operation(
1006        &self,
1007        name: impl Into<std::string::String>,
1008    ) -> super::builder::services::GetOperation {
1009        super::builder::services::GetOperation::new(self.inner.clone()).set_name(name.into())
1010    }
1011
1012    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1013    ///
1014    /// [google.longrunning.Operations]: longrunning::client::Operations
1015    pub fn delete_operation(
1016        &self,
1017        name: impl Into<std::string::String>,
1018    ) -> super::builder::services::DeleteOperation {
1019        super::builder::services::DeleteOperation::new(self.inner.clone()).set_name(name.into())
1020    }
1021
1022    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1023    ///
1024    /// [google.longrunning.Operations]: longrunning::client::Operations
1025    pub fn wait_operation(
1026        &self,
1027        name: impl Into<std::string::String>,
1028    ) -> super::builder::services::WaitOperation {
1029        super::builder::services::WaitOperation::new(self.inner.clone()).set_name(name.into())
1030    }
1031}
1032
1033/// Implements a client for the Cloud Run Admin API.
1034///
1035/// # Example
1036/// ```
1037/// # tokio_test::block_on(async {
1038/// # use google_cloud_run_v2::client::Tasks;
1039/// let client = Tasks::builder().build().await?;
1040/// // use `client` to make requests to the {Codec.APITitle}}.
1041/// # gax::Result::<()>::Ok(()) });
1042/// ```
1043///
1044/// # Service Description
1045///
1046/// Cloud Run Task Control Plane API.
1047///
1048/// # Configuration
1049///
1050/// To configure `Tasks` use the `with_*` methods in the type returned
1051/// by [builder()][Tasks::builder]. The default configuration should
1052/// work for most applications. Common configuration changes include
1053///
1054/// * [with_endpoint()]: by default this client uses the global default endpoint
1055///   (`https://run.googleapis.com`). Applications using regional
1056///   endpoints or running in restricted networks (e.g. a network configured
1057//    with [Private Google Access with VPC Service Controls]) may want to
1058///   override this default.
1059/// * [with_credentials()]: by default this client uses
1060///   [Application Default Credentials]. Applications using custom
1061///   authentication may need to override this default.
1062///
1063/// [with_endpoint()]: super::builder::tasks::ClientBuilder::with_endpoint
1064/// [with_credentials()]: super::builder::tasks::ClientBuilder::credentials
1065/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1066/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1067///
1068/// # Pooling and Cloning
1069///
1070/// `Tasks` holds a connection pool internally, it is advised to
1071/// create one and the reuse it.  You do not need to wrap `Tasks` in
1072/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
1073/// internally.
1074#[derive(Clone, Debug)]
1075pub struct Tasks {
1076    inner: Arc<dyn super::stub::dynamic::Tasks>,
1077}
1078
1079impl Tasks {
1080    /// Returns a builder for [Tasks].
1081    ///
1082    /// ```
1083    /// # tokio_test::block_on(async {
1084    /// # use google_cloud_run_v2::client::Tasks;
1085    /// let client = Tasks::builder().build().await?;
1086    /// # gax::Result::<()>::Ok(()) });
1087    /// ```
1088    pub fn builder() -> super::builder::tasks::ClientBuilder {
1089        gax::client_builder::internal::new_builder(super::builder::tasks::client::Factory)
1090    }
1091
1092    /// Creates a new client from the provided stub.
1093    ///
1094    /// The most common case for calling this function is in tests mocking the
1095    /// client's behavior.
1096    pub fn from_stub<T>(stub: T) -> Self
1097    where
1098        T: super::stub::Tasks + 'static,
1099    {
1100        Self {
1101            inner: Arc::new(stub),
1102        }
1103    }
1104
1105    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
1106        let inner = Self::build_inner(config).await?;
1107        Ok(Self { inner })
1108    }
1109
1110    async fn build_inner(
1111        conf: gaxi::options::ClientConfig,
1112    ) -> Result<Arc<dyn super::stub::dynamic::Tasks>> {
1113        if gaxi::options::tracing_enabled(&conf) {
1114            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
1115        }
1116        Ok(Arc::new(Self::build_transport(conf).await?))
1117    }
1118
1119    async fn build_transport(conf: gaxi::options::ClientConfig) -> Result<impl super::stub::Tasks> {
1120        super::transport::Tasks::new(conf).await
1121    }
1122
1123    async fn build_with_tracing(
1124        conf: gaxi::options::ClientConfig,
1125    ) -> Result<impl super::stub::Tasks> {
1126        Self::build_transport(conf)
1127            .await
1128            .map(super::tracing::Tasks::new)
1129    }
1130
1131    /// Gets information about a Task.
1132    pub fn get_task(&self, name: impl Into<std::string::String>) -> super::builder::tasks::GetTask {
1133        super::builder::tasks::GetTask::new(self.inner.clone()).set_name(name.into())
1134    }
1135
1136    /// Lists Tasks from an Execution of a Job.
1137    pub fn list_tasks(
1138        &self,
1139        parent: impl Into<std::string::String>,
1140    ) -> super::builder::tasks::ListTasks {
1141        super::builder::tasks::ListTasks::new(self.inner.clone()).set_parent(parent.into())
1142    }
1143
1144    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1145    ///
1146    /// [google.longrunning.Operations]: longrunning::client::Operations
1147    pub fn list_operations(
1148        &self,
1149        name: impl Into<std::string::String>,
1150    ) -> super::builder::tasks::ListOperations {
1151        super::builder::tasks::ListOperations::new(self.inner.clone()).set_name(name.into())
1152    }
1153
1154    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1155    ///
1156    /// [google.longrunning.Operations]: longrunning::client::Operations
1157    pub fn get_operation(
1158        &self,
1159        name: impl Into<std::string::String>,
1160    ) -> super::builder::tasks::GetOperation {
1161        super::builder::tasks::GetOperation::new(self.inner.clone()).set_name(name.into())
1162    }
1163
1164    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1165    ///
1166    /// [google.longrunning.Operations]: longrunning::client::Operations
1167    pub fn delete_operation(
1168        &self,
1169        name: impl Into<std::string::String>,
1170    ) -> super::builder::tasks::DeleteOperation {
1171        super::builder::tasks::DeleteOperation::new(self.inner.clone()).set_name(name.into())
1172    }
1173
1174    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1175    ///
1176    /// [google.longrunning.Operations]: longrunning::client::Operations
1177    pub fn wait_operation(
1178        &self,
1179        name: impl Into<std::string::String>,
1180    ) -> super::builder::tasks::WaitOperation {
1181        super::builder::tasks::WaitOperation::new(self.inner.clone()).set_name(name.into())
1182    }
1183}