google_cloud_api_serviceusage_v1/
builder.rs1pub mod service_usage {
19 use crate::Result;
20
21 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::ServiceUsage;
38 pub struct Factory;
39 impl crate::ClientFactory for Factory {
40 type Client = ServiceUsage;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> crate::ClientBuilderResult<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 #[derive(Clone, Debug)]
53 pub(crate) struct RequestBuilder<R: std::default::Default> {
54 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
55 request: R,
56 options: crate::RequestOptions,
57 }
58
59 impl<R> RequestBuilder<R>
60 where
61 R: std::default::Default,
62 {
63 pub(crate) fn new(
64 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: crate::RequestOptions::default(),
70 }
71 }
72 }
73
74 #[derive(Clone, Debug)]
92 pub struct EnableService(RequestBuilder<crate::model::EnableServiceRequest>);
93
94 impl EnableService {
95 pub(crate) fn new(
96 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
97 ) -> Self {
98 Self(RequestBuilder::new(stub))
99 }
100
101 pub fn with_request<V: Into<crate::model::EnableServiceRequest>>(mut self, v: V) -> Self {
103 self.0.request = v.into();
104 self
105 }
106
107 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
109 self.0.options = v.into();
110 self
111 }
112
113 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
120 (*self.0.stub)
121 .enable_service(self.0.request, self.0.options)
122 .await
123 .map(crate::Response::into_body)
124 }
125
126 pub fn poller(
128 self,
129 ) -> impl google_cloud_lro::Poller<
130 crate::model::EnableServiceResponse,
131 crate::model::OperationMetadata,
132 > {
133 type Operation = google_cloud_lro::internal::Operation<
134 crate::model::EnableServiceResponse,
135 crate::model::OperationMetadata,
136 >;
137 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
138 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
139 let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
140 if let Some(ref mut details) = poller_options.tracing {
141 details.method_name = "google_cloud_api_serviceusage_v1::client::ServiceUsage::enable_service::until_done";
142 }
143
144 let stub = self.0.stub.clone();
145 let mut options = self.0.options.clone();
146 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
147 let query = move |name| {
148 let stub = stub.clone();
149 let options = options.clone();
150 async {
151 let op = GetOperation::new(stub)
152 .set_name(name)
153 .with_options(options)
154 .send()
155 .await?;
156 Ok(Operation::new(op))
157 }
158 };
159
160 let start = move || async {
161 let op = self.send().await?;
162 Ok(Operation::new(op))
163 };
164
165 use google_cloud_lro::internal::PollerExt;
166 {
167 google_cloud_lro::internal::new_poller(
168 polling_error_policy,
169 polling_backoff_policy,
170 start,
171 query,
172 )
173 }
174 .with_options(poller_options)
175 }
176
177 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
179 self.0.request.name = v.into();
180 self
181 }
182 }
183
184 #[doc(hidden)]
185 impl crate::RequestBuilder for EnableService {
186 fn request_options(&mut self) -> &mut crate::RequestOptions {
187 &mut self.0.options
188 }
189 }
190
191 #[derive(Clone, Debug)]
209 pub struct DisableService(RequestBuilder<crate::model::DisableServiceRequest>);
210
211 impl DisableService {
212 pub(crate) fn new(
213 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
214 ) -> Self {
215 Self(RequestBuilder::new(stub))
216 }
217
218 pub fn with_request<V: Into<crate::model::DisableServiceRequest>>(mut self, v: V) -> Self {
220 self.0.request = v.into();
221 self
222 }
223
224 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
226 self.0.options = v.into();
227 self
228 }
229
230 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
237 (*self.0.stub)
238 .disable_service(self.0.request, self.0.options)
239 .await
240 .map(crate::Response::into_body)
241 }
242
243 pub fn poller(
245 self,
246 ) -> impl google_cloud_lro::Poller<
247 crate::model::DisableServiceResponse,
248 crate::model::OperationMetadata,
249 > {
250 type Operation = google_cloud_lro::internal::Operation<
251 crate::model::DisableServiceResponse,
252 crate::model::OperationMetadata,
253 >;
254 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
255 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
256 let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
257 if let Some(ref mut details) = poller_options.tracing {
258 details.method_name = "google_cloud_api_serviceusage_v1::client::ServiceUsage::disable_service::until_done";
259 }
260
261 let stub = self.0.stub.clone();
262 let mut options = self.0.options.clone();
263 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
264 let query = move |name| {
265 let stub = stub.clone();
266 let options = options.clone();
267 async {
268 let op = GetOperation::new(stub)
269 .set_name(name)
270 .with_options(options)
271 .send()
272 .await?;
273 Ok(Operation::new(op))
274 }
275 };
276
277 let start = move || async {
278 let op = self.send().await?;
279 Ok(Operation::new(op))
280 };
281
282 use google_cloud_lro::internal::PollerExt;
283 {
284 google_cloud_lro::internal::new_poller(
285 polling_error_policy,
286 polling_backoff_policy,
287 start,
288 query,
289 )
290 }
291 .with_options(poller_options)
292 }
293
294 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
296 self.0.request.name = v.into();
297 self
298 }
299
300 pub fn set_disable_dependent_services<T: Into<bool>>(mut self, v: T) -> Self {
302 self.0.request.disable_dependent_services = v.into();
303 self
304 }
305
306 pub fn set_check_if_service_has_usage<
308 T: Into<crate::model::disable_service_request::CheckIfServiceHasUsage>,
309 >(
310 mut self,
311 v: T,
312 ) -> Self {
313 self.0.request.check_if_service_has_usage = v.into();
314 self
315 }
316 }
317
318 #[doc(hidden)]
319 impl crate::RequestBuilder for DisableService {
320 fn request_options(&mut self) -> &mut crate::RequestOptions {
321 &mut self.0.options
322 }
323 }
324
325 #[derive(Clone, Debug)]
342 pub struct GetService(RequestBuilder<crate::model::GetServiceRequest>);
343
344 impl GetService {
345 pub(crate) fn new(
346 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
347 ) -> Self {
348 Self(RequestBuilder::new(stub))
349 }
350
351 pub fn with_request<V: Into<crate::model::GetServiceRequest>>(mut self, v: V) -> Self {
353 self.0.request = v.into();
354 self
355 }
356
357 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
359 self.0.options = v.into();
360 self
361 }
362
363 pub async fn send(self) -> Result<crate::model::Service> {
365 (*self.0.stub)
366 .get_service(self.0.request, self.0.options)
367 .await
368 .map(crate::Response::into_body)
369 }
370
371 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
373 self.0.request.name = v.into();
374 self
375 }
376 }
377
378 #[doc(hidden)]
379 impl crate::RequestBuilder for GetService {
380 fn request_options(&mut self) -> &mut crate::RequestOptions {
381 &mut self.0.options
382 }
383 }
384
385 #[derive(Clone, Debug)]
406 pub struct ListServices(RequestBuilder<crate::model::ListServicesRequest>);
407
408 impl ListServices {
409 pub(crate) fn new(
410 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
411 ) -> Self {
412 Self(RequestBuilder::new(stub))
413 }
414
415 pub fn with_request<V: Into<crate::model::ListServicesRequest>>(mut self, v: V) -> Self {
417 self.0.request = v.into();
418 self
419 }
420
421 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
423 self.0.options = v.into();
424 self
425 }
426
427 pub async fn send(self) -> Result<crate::model::ListServicesResponse> {
429 (*self.0.stub)
430 .list_services(self.0.request, self.0.options)
431 .await
432 .map(crate::Response::into_body)
433 }
434
435 pub fn by_page(
437 self,
438 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListServicesResponse, crate::Error>
439 {
440 use std::clone::Clone;
441 let token = self.0.request.page_token.clone();
442 let execute = move |token: String| {
443 let mut builder = self.clone();
444 builder.0.request = builder.0.request.set_page_token(token);
445 builder.send()
446 };
447 google_cloud_gax::paginator::internal::new_paginator(token, execute)
448 }
449
450 pub fn by_item(
452 self,
453 ) -> impl google_cloud_gax::paginator::ItemPaginator<
454 crate::model::ListServicesResponse,
455 crate::Error,
456 > {
457 use google_cloud_gax::paginator::Paginator;
458 self.by_page().items()
459 }
460
461 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
463 self.0.request.parent = v.into();
464 self
465 }
466
467 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
469 self.0.request.page_size = v.into();
470 self
471 }
472
473 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
475 self.0.request.page_token = v.into();
476 self
477 }
478
479 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
481 self.0.request.filter = v.into();
482 self
483 }
484 }
485
486 #[doc(hidden)]
487 impl crate::RequestBuilder for ListServices {
488 fn request_options(&mut self) -> &mut crate::RequestOptions {
489 &mut self.0.options
490 }
491 }
492
493 #[derive(Clone, Debug)]
511 pub struct BatchEnableServices(RequestBuilder<crate::model::BatchEnableServicesRequest>);
512
513 impl BatchEnableServices {
514 pub(crate) fn new(
515 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
516 ) -> Self {
517 Self(RequestBuilder::new(stub))
518 }
519
520 pub fn with_request<V: Into<crate::model::BatchEnableServicesRequest>>(
522 mut self,
523 v: V,
524 ) -> Self {
525 self.0.request = v.into();
526 self
527 }
528
529 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
531 self.0.options = v.into();
532 self
533 }
534
535 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
542 (*self.0.stub)
543 .batch_enable_services(self.0.request, self.0.options)
544 .await
545 .map(crate::Response::into_body)
546 }
547
548 pub fn poller(
550 self,
551 ) -> impl google_cloud_lro::Poller<
552 crate::model::BatchEnableServicesResponse,
553 crate::model::OperationMetadata,
554 > {
555 type Operation = google_cloud_lro::internal::Operation<
556 crate::model::BatchEnableServicesResponse,
557 crate::model::OperationMetadata,
558 >;
559 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
560 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
561 let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
562 if let Some(ref mut details) = poller_options.tracing {
563 details.method_name = "google_cloud_api_serviceusage_v1::client::ServiceUsage::batch_enable_services::until_done";
564 }
565
566 let stub = self.0.stub.clone();
567 let mut options = self.0.options.clone();
568 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
569 let query = move |name| {
570 let stub = stub.clone();
571 let options = options.clone();
572 async {
573 let op = GetOperation::new(stub)
574 .set_name(name)
575 .with_options(options)
576 .send()
577 .await?;
578 Ok(Operation::new(op))
579 }
580 };
581
582 let start = move || async {
583 let op = self.send().await?;
584 Ok(Operation::new(op))
585 };
586
587 use google_cloud_lro::internal::PollerExt;
588 {
589 google_cloud_lro::internal::new_poller(
590 polling_error_policy,
591 polling_backoff_policy,
592 start,
593 query,
594 )
595 }
596 .with_options(poller_options)
597 }
598
599 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
601 self.0.request.parent = v.into();
602 self
603 }
604
605 pub fn set_service_ids<T, V>(mut self, v: T) -> Self
607 where
608 T: std::iter::IntoIterator<Item = V>,
609 V: std::convert::Into<std::string::String>,
610 {
611 use std::iter::Iterator;
612 self.0.request.service_ids = v.into_iter().map(|i| i.into()).collect();
613 self
614 }
615 }
616
617 #[doc(hidden)]
618 impl crate::RequestBuilder for BatchEnableServices {
619 fn request_options(&mut self) -> &mut crate::RequestOptions {
620 &mut self.0.options
621 }
622 }
623
624 #[derive(Clone, Debug)]
641 pub struct BatchGetServices(RequestBuilder<crate::model::BatchGetServicesRequest>);
642
643 impl BatchGetServices {
644 pub(crate) fn new(
645 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
646 ) -> Self {
647 Self(RequestBuilder::new(stub))
648 }
649
650 pub fn with_request<V: Into<crate::model::BatchGetServicesRequest>>(
652 mut self,
653 v: V,
654 ) -> Self {
655 self.0.request = v.into();
656 self
657 }
658
659 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
661 self.0.options = v.into();
662 self
663 }
664
665 pub async fn send(self) -> Result<crate::model::BatchGetServicesResponse> {
667 (*self.0.stub)
668 .batch_get_services(self.0.request, self.0.options)
669 .await
670 .map(crate::Response::into_body)
671 }
672
673 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
675 self.0.request.parent = v.into();
676 self
677 }
678
679 pub fn set_names<T, V>(mut self, v: T) -> Self
681 where
682 T: std::iter::IntoIterator<Item = V>,
683 V: std::convert::Into<std::string::String>,
684 {
685 use std::iter::Iterator;
686 self.0.request.names = v.into_iter().map(|i| i.into()).collect();
687 self
688 }
689 }
690
691 #[doc(hidden)]
692 impl crate::RequestBuilder for BatchGetServices {
693 fn request_options(&mut self) -> &mut crate::RequestOptions {
694 &mut self.0.options
695 }
696 }
697
698 #[derive(Clone, Debug)]
719 pub struct ListOperations(
720 RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
721 );
722
723 impl ListOperations {
724 pub(crate) fn new(
725 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
726 ) -> Self {
727 Self(RequestBuilder::new(stub))
728 }
729
730 pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
732 mut self,
733 v: V,
734 ) -> Self {
735 self.0.request = v.into();
736 self
737 }
738
739 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
741 self.0.options = v.into();
742 self
743 }
744
745 pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
747 (*self.0.stub)
748 .list_operations(self.0.request, self.0.options)
749 .await
750 .map(crate::Response::into_body)
751 }
752
753 pub fn by_page(
755 self,
756 ) -> impl google_cloud_gax::paginator::Paginator<
757 google_cloud_longrunning::model::ListOperationsResponse,
758 crate::Error,
759 > {
760 use std::clone::Clone;
761 let token = self.0.request.page_token.clone();
762 let execute = move |token: String| {
763 let mut builder = self.clone();
764 builder.0.request = builder.0.request.set_page_token(token);
765 builder.send()
766 };
767 google_cloud_gax::paginator::internal::new_paginator(token, execute)
768 }
769
770 pub fn by_item(
772 self,
773 ) -> impl google_cloud_gax::paginator::ItemPaginator<
774 google_cloud_longrunning::model::ListOperationsResponse,
775 crate::Error,
776 > {
777 use google_cloud_gax::paginator::Paginator;
778 self.by_page().items()
779 }
780
781 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
783 self.0.request.name = v.into();
784 self
785 }
786
787 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
789 self.0.request.filter = v.into();
790 self
791 }
792
793 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
795 self.0.request.page_size = v.into();
796 self
797 }
798
799 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
801 self.0.request.page_token = v.into();
802 self
803 }
804
805 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
807 self.0.request.return_partial_success = v.into();
808 self
809 }
810 }
811
812 #[doc(hidden)]
813 impl crate::RequestBuilder for ListOperations {
814 fn request_options(&mut self) -> &mut crate::RequestOptions {
815 &mut self.0.options
816 }
817 }
818
819 #[derive(Clone, Debug)]
836 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
837
838 impl GetOperation {
839 pub(crate) fn new(
840 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
841 ) -> Self {
842 Self(RequestBuilder::new(stub))
843 }
844
845 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
847 mut self,
848 v: V,
849 ) -> Self {
850 self.0.request = v.into();
851 self
852 }
853
854 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
856 self.0.options = v.into();
857 self
858 }
859
860 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
862 (*self.0.stub)
863 .get_operation(self.0.request, self.0.options)
864 .await
865 .map(crate::Response::into_body)
866 }
867
868 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
870 self.0.request.name = v.into();
871 self
872 }
873 }
874
875 #[doc(hidden)]
876 impl crate::RequestBuilder for GetOperation {
877 fn request_options(&mut self) -> &mut crate::RequestOptions {
878 &mut self.0.options
879 }
880 }
881}