google_cloud_api_serviceusage_v1/
builder.rs1pub mod service_usage {
18 use crate::Result;
19
20 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35 pub(crate) mod client {
36 use super::super::super::client::ServiceUsage;
37 pub struct Factory;
38 impl crate::ClientFactory for Factory {
39 type Client = ServiceUsage;
40 type Credentials = gaxi::options::Credentials;
41 async fn build(
42 self,
43 config: gaxi::options::ClientConfig,
44 ) -> crate::ClientBuilderResult<Self::Client> {
45 Self::Client::new(config).await
46 }
47 }
48 }
49
50 #[derive(Clone, Debug)]
52 pub(crate) struct RequestBuilder<R: std::default::Default> {
53 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
54 request: R,
55 options: crate::RequestOptions,
56 }
57
58 impl<R> RequestBuilder<R>
59 where
60 R: std::default::Default,
61 {
62 pub(crate) fn new(
63 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
64 ) -> Self {
65 Self {
66 stub,
67 request: R::default(),
68 options: crate::RequestOptions::default(),
69 }
70 }
71 }
72
73 #[derive(Clone, Debug)]
91 pub struct EnableService(RequestBuilder<crate::model::EnableServiceRequest>);
92
93 impl EnableService {
94 pub(crate) fn new(
95 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
96 ) -> Self {
97 Self(RequestBuilder::new(stub))
98 }
99
100 pub fn with_request<V: Into<crate::model::EnableServiceRequest>>(mut self, v: V) -> Self {
102 self.0.request = v.into();
103 self
104 }
105
106 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
108 self.0.options = v.into();
109 self
110 }
111
112 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
119 (*self.0.stub)
120 .enable_service(self.0.request, self.0.options)
121 .await
122 .map(crate::Response::into_body)
123 }
124
125 pub fn poller(
127 self,
128 ) -> impl google_cloud_lro::Poller<
129 crate::model::EnableServiceResponse,
130 crate::model::OperationMetadata,
131 > {
132 type Operation = google_cloud_lro::internal::Operation<
133 crate::model::EnableServiceResponse,
134 crate::model::OperationMetadata,
135 >;
136 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
137 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
138
139 let stub = self.0.stub.clone();
140 let mut options = self.0.options.clone();
141 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
142 let query = move |name| {
143 let stub = stub.clone();
144 let options = options.clone();
145 async {
146 let op = GetOperation::new(stub)
147 .set_name(name)
148 .with_options(options)
149 .send()
150 .await?;
151 Ok(Operation::new(op))
152 }
153 };
154
155 let start = move || async {
156 let op = self.send().await?;
157 Ok(Operation::new(op))
158 };
159
160 google_cloud_lro::internal::new_poller(
161 polling_error_policy,
162 polling_backoff_policy,
163 start,
164 query,
165 )
166 }
167
168 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
170 self.0.request.name = v.into();
171 self
172 }
173 }
174
175 #[doc(hidden)]
176 impl crate::RequestBuilder for EnableService {
177 fn request_options(&mut self) -> &mut crate::RequestOptions {
178 &mut self.0.options
179 }
180 }
181
182 #[derive(Clone, Debug)]
200 pub struct DisableService(RequestBuilder<crate::model::DisableServiceRequest>);
201
202 impl DisableService {
203 pub(crate) fn new(
204 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
205 ) -> Self {
206 Self(RequestBuilder::new(stub))
207 }
208
209 pub fn with_request<V: Into<crate::model::DisableServiceRequest>>(mut self, v: V) -> Self {
211 self.0.request = v.into();
212 self
213 }
214
215 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
217 self.0.options = v.into();
218 self
219 }
220
221 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
228 (*self.0.stub)
229 .disable_service(self.0.request, self.0.options)
230 .await
231 .map(crate::Response::into_body)
232 }
233
234 pub fn poller(
236 self,
237 ) -> impl google_cloud_lro::Poller<
238 crate::model::DisableServiceResponse,
239 crate::model::OperationMetadata,
240 > {
241 type Operation = google_cloud_lro::internal::Operation<
242 crate::model::DisableServiceResponse,
243 crate::model::OperationMetadata,
244 >;
245 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
246 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
247
248 let stub = self.0.stub.clone();
249 let mut options = self.0.options.clone();
250 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
251 let query = move |name| {
252 let stub = stub.clone();
253 let options = options.clone();
254 async {
255 let op = GetOperation::new(stub)
256 .set_name(name)
257 .with_options(options)
258 .send()
259 .await?;
260 Ok(Operation::new(op))
261 }
262 };
263
264 let start = move || async {
265 let op = self.send().await?;
266 Ok(Operation::new(op))
267 };
268
269 google_cloud_lro::internal::new_poller(
270 polling_error_policy,
271 polling_backoff_policy,
272 start,
273 query,
274 )
275 }
276
277 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
279 self.0.request.name = v.into();
280 self
281 }
282
283 pub fn set_disable_dependent_services<T: Into<bool>>(mut self, v: T) -> Self {
285 self.0.request.disable_dependent_services = v.into();
286 self
287 }
288
289 pub fn set_check_if_service_has_usage<
291 T: Into<crate::model::disable_service_request::CheckIfServiceHasUsage>,
292 >(
293 mut self,
294 v: T,
295 ) -> Self {
296 self.0.request.check_if_service_has_usage = v.into();
297 self
298 }
299 }
300
301 #[doc(hidden)]
302 impl crate::RequestBuilder for DisableService {
303 fn request_options(&mut self) -> &mut crate::RequestOptions {
304 &mut self.0.options
305 }
306 }
307
308 #[derive(Clone, Debug)]
325 pub struct GetService(RequestBuilder<crate::model::GetServiceRequest>);
326
327 impl GetService {
328 pub(crate) fn new(
329 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
330 ) -> Self {
331 Self(RequestBuilder::new(stub))
332 }
333
334 pub fn with_request<V: Into<crate::model::GetServiceRequest>>(mut self, v: V) -> Self {
336 self.0.request = v.into();
337 self
338 }
339
340 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
342 self.0.options = v.into();
343 self
344 }
345
346 pub async fn send(self) -> Result<crate::model::Service> {
348 (*self.0.stub)
349 .get_service(self.0.request, self.0.options)
350 .await
351 .map(crate::Response::into_body)
352 }
353
354 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
356 self.0.request.name = v.into();
357 self
358 }
359 }
360
361 #[doc(hidden)]
362 impl crate::RequestBuilder for GetService {
363 fn request_options(&mut self) -> &mut crate::RequestOptions {
364 &mut self.0.options
365 }
366 }
367
368 #[derive(Clone, Debug)]
389 pub struct ListServices(RequestBuilder<crate::model::ListServicesRequest>);
390
391 impl ListServices {
392 pub(crate) fn new(
393 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
394 ) -> Self {
395 Self(RequestBuilder::new(stub))
396 }
397
398 pub fn with_request<V: Into<crate::model::ListServicesRequest>>(mut self, v: V) -> Self {
400 self.0.request = v.into();
401 self
402 }
403
404 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
406 self.0.options = v.into();
407 self
408 }
409
410 pub async fn send(self) -> Result<crate::model::ListServicesResponse> {
412 (*self.0.stub)
413 .list_services(self.0.request, self.0.options)
414 .await
415 .map(crate::Response::into_body)
416 }
417
418 pub fn by_page(
420 self,
421 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListServicesResponse, crate::Error>
422 {
423 use std::clone::Clone;
424 let token = self.0.request.page_token.clone();
425 let execute = move |token: String| {
426 let mut builder = self.clone();
427 builder.0.request = builder.0.request.set_page_token(token);
428 builder.send()
429 };
430 google_cloud_gax::paginator::internal::new_paginator(token, execute)
431 }
432
433 pub fn by_item(
435 self,
436 ) -> impl google_cloud_gax::paginator::ItemPaginator<
437 crate::model::ListServicesResponse,
438 crate::Error,
439 > {
440 use google_cloud_gax::paginator::Paginator;
441 self.by_page().items()
442 }
443
444 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
446 self.0.request.parent = v.into();
447 self
448 }
449
450 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
452 self.0.request.page_size = v.into();
453 self
454 }
455
456 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
458 self.0.request.page_token = v.into();
459 self
460 }
461
462 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
464 self.0.request.filter = v.into();
465 self
466 }
467 }
468
469 #[doc(hidden)]
470 impl crate::RequestBuilder for ListServices {
471 fn request_options(&mut self) -> &mut crate::RequestOptions {
472 &mut self.0.options
473 }
474 }
475
476 #[derive(Clone, Debug)]
494 pub struct BatchEnableServices(RequestBuilder<crate::model::BatchEnableServicesRequest>);
495
496 impl BatchEnableServices {
497 pub(crate) fn new(
498 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
499 ) -> Self {
500 Self(RequestBuilder::new(stub))
501 }
502
503 pub fn with_request<V: Into<crate::model::BatchEnableServicesRequest>>(
505 mut self,
506 v: V,
507 ) -> Self {
508 self.0.request = v.into();
509 self
510 }
511
512 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
514 self.0.options = v.into();
515 self
516 }
517
518 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
525 (*self.0.stub)
526 .batch_enable_services(self.0.request, self.0.options)
527 .await
528 .map(crate::Response::into_body)
529 }
530
531 pub fn poller(
533 self,
534 ) -> impl google_cloud_lro::Poller<
535 crate::model::BatchEnableServicesResponse,
536 crate::model::OperationMetadata,
537 > {
538 type Operation = google_cloud_lro::internal::Operation<
539 crate::model::BatchEnableServicesResponse,
540 crate::model::OperationMetadata,
541 >;
542 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
543 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
544
545 let stub = self.0.stub.clone();
546 let mut options = self.0.options.clone();
547 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
548 let query = move |name| {
549 let stub = stub.clone();
550 let options = options.clone();
551 async {
552 let op = GetOperation::new(stub)
553 .set_name(name)
554 .with_options(options)
555 .send()
556 .await?;
557 Ok(Operation::new(op))
558 }
559 };
560
561 let start = move || async {
562 let op = self.send().await?;
563 Ok(Operation::new(op))
564 };
565
566 google_cloud_lro::internal::new_poller(
567 polling_error_policy,
568 polling_backoff_policy,
569 start,
570 query,
571 )
572 }
573
574 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
576 self.0.request.parent = v.into();
577 self
578 }
579
580 pub fn set_service_ids<T, V>(mut self, v: T) -> Self
582 where
583 T: std::iter::IntoIterator<Item = V>,
584 V: std::convert::Into<std::string::String>,
585 {
586 use std::iter::Iterator;
587 self.0.request.service_ids = v.into_iter().map(|i| i.into()).collect();
588 self
589 }
590 }
591
592 #[doc(hidden)]
593 impl crate::RequestBuilder for BatchEnableServices {
594 fn request_options(&mut self) -> &mut crate::RequestOptions {
595 &mut self.0.options
596 }
597 }
598
599 #[derive(Clone, Debug)]
616 pub struct BatchGetServices(RequestBuilder<crate::model::BatchGetServicesRequest>);
617
618 impl BatchGetServices {
619 pub(crate) fn new(
620 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
621 ) -> Self {
622 Self(RequestBuilder::new(stub))
623 }
624
625 pub fn with_request<V: Into<crate::model::BatchGetServicesRequest>>(
627 mut self,
628 v: V,
629 ) -> Self {
630 self.0.request = v.into();
631 self
632 }
633
634 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
636 self.0.options = v.into();
637 self
638 }
639
640 pub async fn send(self) -> Result<crate::model::BatchGetServicesResponse> {
642 (*self.0.stub)
643 .batch_get_services(self.0.request, self.0.options)
644 .await
645 .map(crate::Response::into_body)
646 }
647
648 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
650 self.0.request.parent = v.into();
651 self
652 }
653
654 pub fn set_names<T, V>(mut self, v: T) -> Self
656 where
657 T: std::iter::IntoIterator<Item = V>,
658 V: std::convert::Into<std::string::String>,
659 {
660 use std::iter::Iterator;
661 self.0.request.names = v.into_iter().map(|i| i.into()).collect();
662 self
663 }
664 }
665
666 #[doc(hidden)]
667 impl crate::RequestBuilder for BatchGetServices {
668 fn request_options(&mut self) -> &mut crate::RequestOptions {
669 &mut self.0.options
670 }
671 }
672
673 #[derive(Clone, Debug)]
694 pub struct ListOperations(
695 RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
696 );
697
698 impl ListOperations {
699 pub(crate) fn new(
700 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
701 ) -> Self {
702 Self(RequestBuilder::new(stub))
703 }
704
705 pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
707 mut self,
708 v: V,
709 ) -> Self {
710 self.0.request = v.into();
711 self
712 }
713
714 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
716 self.0.options = v.into();
717 self
718 }
719
720 pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
722 (*self.0.stub)
723 .list_operations(self.0.request, self.0.options)
724 .await
725 .map(crate::Response::into_body)
726 }
727
728 pub fn by_page(
730 self,
731 ) -> impl google_cloud_gax::paginator::Paginator<
732 google_cloud_longrunning::model::ListOperationsResponse,
733 crate::Error,
734 > {
735 use std::clone::Clone;
736 let token = self.0.request.page_token.clone();
737 let execute = move |token: String| {
738 let mut builder = self.clone();
739 builder.0.request = builder.0.request.set_page_token(token);
740 builder.send()
741 };
742 google_cloud_gax::paginator::internal::new_paginator(token, execute)
743 }
744
745 pub fn by_item(
747 self,
748 ) -> impl google_cloud_gax::paginator::ItemPaginator<
749 google_cloud_longrunning::model::ListOperationsResponse,
750 crate::Error,
751 > {
752 use google_cloud_gax::paginator::Paginator;
753 self.by_page().items()
754 }
755
756 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
758 self.0.request.name = v.into();
759 self
760 }
761
762 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
764 self.0.request.filter = v.into();
765 self
766 }
767
768 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
770 self.0.request.page_size = v.into();
771 self
772 }
773
774 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
776 self.0.request.page_token = v.into();
777 self
778 }
779
780 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
782 self.0.request.return_partial_success = v.into();
783 self
784 }
785 }
786
787 #[doc(hidden)]
788 impl crate::RequestBuilder for ListOperations {
789 fn request_options(&mut self) -> &mut crate::RequestOptions {
790 &mut self.0.options
791 }
792 }
793
794 #[derive(Clone, Debug)]
811 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
812
813 impl GetOperation {
814 pub(crate) fn new(
815 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
816 ) -> Self {
817 Self(RequestBuilder::new(stub))
818 }
819
820 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
822 mut self,
823 v: V,
824 ) -> Self {
825 self.0.request = v.into();
826 self
827 }
828
829 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
831 self.0.options = v.into();
832 self
833 }
834
835 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
837 (*self.0.stub)
838 .get_operation(self.0.request, self.0.options)
839 .await
840 .map(crate::Response::into_body)
841 }
842
843 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
845 self.0.request.name = v.into();
846 self
847 }
848 }
849
850 #[doc(hidden)]
851 impl crate::RequestBuilder for GetOperation {
852 fn request_options(&mut self) -> &mut crate::RequestOptions {
853 &mut self.0.options
854 }
855 }
856}