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