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
140 let stub = self.0.stub.clone();
141 let mut options = self.0.options.clone();
142 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
143 let query = move |name| {
144 let stub = stub.clone();
145 let options = options.clone();
146 async {
147 let op = GetOperation::new(stub)
148 .set_name(name)
149 .with_options(options)
150 .send()
151 .await?;
152 Ok(Operation::new(op))
153 }
154 };
155
156 let start = move || async {
157 let op = self.send().await?;
158 Ok(Operation::new(op))
159 };
160
161 google_cloud_lro::internal::new_poller(
162 polling_error_policy,
163 polling_backoff_policy,
164 start,
165 query,
166 )
167 }
168
169 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
171 self.0.request.name = v.into();
172 self
173 }
174 }
175
176 #[doc(hidden)]
177 impl crate::RequestBuilder for EnableService {
178 fn request_options(&mut self) -> &mut crate::RequestOptions {
179 &mut self.0.options
180 }
181 }
182
183 #[derive(Clone, Debug)]
201 pub struct DisableService(RequestBuilder<crate::model::DisableServiceRequest>);
202
203 impl DisableService {
204 pub(crate) fn new(
205 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
206 ) -> Self {
207 Self(RequestBuilder::new(stub))
208 }
209
210 pub fn with_request<V: Into<crate::model::DisableServiceRequest>>(mut self, v: V) -> Self {
212 self.0.request = v.into();
213 self
214 }
215
216 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
218 self.0.options = v.into();
219 self
220 }
221
222 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
229 (*self.0.stub)
230 .disable_service(self.0.request, self.0.options)
231 .await
232 .map(crate::Response::into_body)
233 }
234
235 pub fn poller(
237 self,
238 ) -> impl google_cloud_lro::Poller<
239 crate::model::DisableServiceResponse,
240 crate::model::OperationMetadata,
241 > {
242 type Operation = google_cloud_lro::internal::Operation<
243 crate::model::DisableServiceResponse,
244 crate::model::OperationMetadata,
245 >;
246 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
247 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
248
249 let stub = self.0.stub.clone();
250 let mut options = self.0.options.clone();
251 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
252 let query = move |name| {
253 let stub = stub.clone();
254 let options = options.clone();
255 async {
256 let op = GetOperation::new(stub)
257 .set_name(name)
258 .with_options(options)
259 .send()
260 .await?;
261 Ok(Operation::new(op))
262 }
263 };
264
265 let start = move || async {
266 let op = self.send().await?;
267 Ok(Operation::new(op))
268 };
269
270 google_cloud_lro::internal::new_poller(
271 polling_error_policy,
272 polling_backoff_policy,
273 start,
274 query,
275 )
276 }
277
278 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
280 self.0.request.name = v.into();
281 self
282 }
283
284 pub fn set_disable_dependent_services<T: Into<bool>>(mut self, v: T) -> Self {
286 self.0.request.disable_dependent_services = v.into();
287 self
288 }
289
290 pub fn set_check_if_service_has_usage<
292 T: Into<crate::model::disable_service_request::CheckIfServiceHasUsage>,
293 >(
294 mut self,
295 v: T,
296 ) -> Self {
297 self.0.request.check_if_service_has_usage = v.into();
298 self
299 }
300 }
301
302 #[doc(hidden)]
303 impl crate::RequestBuilder for DisableService {
304 fn request_options(&mut self) -> &mut crate::RequestOptions {
305 &mut self.0.options
306 }
307 }
308
309 #[derive(Clone, Debug)]
326 pub struct GetService(RequestBuilder<crate::model::GetServiceRequest>);
327
328 impl GetService {
329 pub(crate) fn new(
330 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
331 ) -> Self {
332 Self(RequestBuilder::new(stub))
333 }
334
335 pub fn with_request<V: Into<crate::model::GetServiceRequest>>(mut self, v: V) -> Self {
337 self.0.request = v.into();
338 self
339 }
340
341 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
343 self.0.options = v.into();
344 self
345 }
346
347 pub async fn send(self) -> Result<crate::model::Service> {
349 (*self.0.stub)
350 .get_service(self.0.request, self.0.options)
351 .await
352 .map(crate::Response::into_body)
353 }
354
355 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
357 self.0.request.name = v.into();
358 self
359 }
360 }
361
362 #[doc(hidden)]
363 impl crate::RequestBuilder for GetService {
364 fn request_options(&mut self) -> &mut crate::RequestOptions {
365 &mut self.0.options
366 }
367 }
368
369 #[derive(Clone, Debug)]
390 pub struct ListServices(RequestBuilder<crate::model::ListServicesRequest>);
391
392 impl ListServices {
393 pub(crate) fn new(
394 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
395 ) -> Self {
396 Self(RequestBuilder::new(stub))
397 }
398
399 pub fn with_request<V: Into<crate::model::ListServicesRequest>>(mut self, v: V) -> Self {
401 self.0.request = v.into();
402 self
403 }
404
405 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
407 self.0.options = v.into();
408 self
409 }
410
411 pub async fn send(self) -> Result<crate::model::ListServicesResponse> {
413 (*self.0.stub)
414 .list_services(self.0.request, self.0.options)
415 .await
416 .map(crate::Response::into_body)
417 }
418
419 pub fn by_page(
421 self,
422 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListServicesResponse, crate::Error>
423 {
424 use std::clone::Clone;
425 let token = self.0.request.page_token.clone();
426 let execute = move |token: String| {
427 let mut builder = self.clone();
428 builder.0.request = builder.0.request.set_page_token(token);
429 builder.send()
430 };
431 google_cloud_gax::paginator::internal::new_paginator(token, execute)
432 }
433
434 pub fn by_item(
436 self,
437 ) -> impl google_cloud_gax::paginator::ItemPaginator<
438 crate::model::ListServicesResponse,
439 crate::Error,
440 > {
441 use google_cloud_gax::paginator::Paginator;
442 self.by_page().items()
443 }
444
445 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
447 self.0.request.parent = v.into();
448 self
449 }
450
451 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
453 self.0.request.page_size = v.into();
454 self
455 }
456
457 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
459 self.0.request.page_token = v.into();
460 self
461 }
462
463 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
465 self.0.request.filter = v.into();
466 self
467 }
468 }
469
470 #[doc(hidden)]
471 impl crate::RequestBuilder for ListServices {
472 fn request_options(&mut self) -> &mut crate::RequestOptions {
473 &mut self.0.options
474 }
475 }
476
477 #[derive(Clone, Debug)]
495 pub struct BatchEnableServices(RequestBuilder<crate::model::BatchEnableServicesRequest>);
496
497 impl BatchEnableServices {
498 pub(crate) fn new(
499 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
500 ) -> Self {
501 Self(RequestBuilder::new(stub))
502 }
503
504 pub fn with_request<V: Into<crate::model::BatchEnableServicesRequest>>(
506 mut self,
507 v: V,
508 ) -> Self {
509 self.0.request = v.into();
510 self
511 }
512
513 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
515 self.0.options = v.into();
516 self
517 }
518
519 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
526 (*self.0.stub)
527 .batch_enable_services(self.0.request, self.0.options)
528 .await
529 .map(crate::Response::into_body)
530 }
531
532 pub fn poller(
534 self,
535 ) -> impl google_cloud_lro::Poller<
536 crate::model::BatchEnableServicesResponse,
537 crate::model::OperationMetadata,
538 > {
539 type Operation = google_cloud_lro::internal::Operation<
540 crate::model::BatchEnableServicesResponse,
541 crate::model::OperationMetadata,
542 >;
543 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
544 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
545
546 let stub = self.0.stub.clone();
547 let mut options = self.0.options.clone();
548 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
549 let query = move |name| {
550 let stub = stub.clone();
551 let options = options.clone();
552 async {
553 let op = GetOperation::new(stub)
554 .set_name(name)
555 .with_options(options)
556 .send()
557 .await?;
558 Ok(Operation::new(op))
559 }
560 };
561
562 let start = move || async {
563 let op = self.send().await?;
564 Ok(Operation::new(op))
565 };
566
567 google_cloud_lro::internal::new_poller(
568 polling_error_policy,
569 polling_backoff_policy,
570 start,
571 query,
572 )
573 }
574
575 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
577 self.0.request.parent = v.into();
578 self
579 }
580
581 pub fn set_service_ids<T, V>(mut self, v: T) -> Self
583 where
584 T: std::iter::IntoIterator<Item = V>,
585 V: std::convert::Into<std::string::String>,
586 {
587 use std::iter::Iterator;
588 self.0.request.service_ids = v.into_iter().map(|i| i.into()).collect();
589 self
590 }
591 }
592
593 #[doc(hidden)]
594 impl crate::RequestBuilder for BatchEnableServices {
595 fn request_options(&mut self) -> &mut crate::RequestOptions {
596 &mut self.0.options
597 }
598 }
599
600 #[derive(Clone, Debug)]
617 pub struct BatchGetServices(RequestBuilder<crate::model::BatchGetServicesRequest>);
618
619 impl BatchGetServices {
620 pub(crate) fn new(
621 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
622 ) -> Self {
623 Self(RequestBuilder::new(stub))
624 }
625
626 pub fn with_request<V: Into<crate::model::BatchGetServicesRequest>>(
628 mut self,
629 v: V,
630 ) -> Self {
631 self.0.request = v.into();
632 self
633 }
634
635 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
637 self.0.options = v.into();
638 self
639 }
640
641 pub async fn send(self) -> Result<crate::model::BatchGetServicesResponse> {
643 (*self.0.stub)
644 .batch_get_services(self.0.request, self.0.options)
645 .await
646 .map(crate::Response::into_body)
647 }
648
649 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
651 self.0.request.parent = v.into();
652 self
653 }
654
655 pub fn set_names<T, V>(mut self, v: T) -> Self
657 where
658 T: std::iter::IntoIterator<Item = V>,
659 V: std::convert::Into<std::string::String>,
660 {
661 use std::iter::Iterator;
662 self.0.request.names = v.into_iter().map(|i| i.into()).collect();
663 self
664 }
665 }
666
667 #[doc(hidden)]
668 impl crate::RequestBuilder for BatchGetServices {
669 fn request_options(&mut self) -> &mut crate::RequestOptions {
670 &mut self.0.options
671 }
672 }
673
674 #[derive(Clone, Debug)]
695 pub struct ListOperations(
696 RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
697 );
698
699 impl ListOperations {
700 pub(crate) fn new(
701 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
702 ) -> Self {
703 Self(RequestBuilder::new(stub))
704 }
705
706 pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
708 mut self,
709 v: V,
710 ) -> Self {
711 self.0.request = v.into();
712 self
713 }
714
715 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
717 self.0.options = v.into();
718 self
719 }
720
721 pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
723 (*self.0.stub)
724 .list_operations(self.0.request, self.0.options)
725 .await
726 .map(crate::Response::into_body)
727 }
728
729 pub fn by_page(
731 self,
732 ) -> impl google_cloud_gax::paginator::Paginator<
733 google_cloud_longrunning::model::ListOperationsResponse,
734 crate::Error,
735 > {
736 use std::clone::Clone;
737 let token = self.0.request.page_token.clone();
738 let execute = move |token: String| {
739 let mut builder = self.clone();
740 builder.0.request = builder.0.request.set_page_token(token);
741 builder.send()
742 };
743 google_cloud_gax::paginator::internal::new_paginator(token, execute)
744 }
745
746 pub fn by_item(
748 self,
749 ) -> impl google_cloud_gax::paginator::ItemPaginator<
750 google_cloud_longrunning::model::ListOperationsResponse,
751 crate::Error,
752 > {
753 use google_cloud_gax::paginator::Paginator;
754 self.by_page().items()
755 }
756
757 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
759 self.0.request.name = v.into();
760 self
761 }
762
763 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
765 self.0.request.filter = v.into();
766 self
767 }
768
769 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
771 self.0.request.page_size = v.into();
772 self
773 }
774
775 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
777 self.0.request.page_token = v.into();
778 self
779 }
780
781 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
783 self.0.request.return_partial_success = v.into();
784 self
785 }
786 }
787
788 #[doc(hidden)]
789 impl crate::RequestBuilder for ListOperations {
790 fn request_options(&mut self) -> &mut crate::RequestOptions {
791 &mut self.0.options
792 }
793 }
794
795 #[derive(Clone, Debug)]
812 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
813
814 impl GetOperation {
815 pub(crate) fn new(
816 stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceUsage>,
817 ) -> Self {
818 Self(RequestBuilder::new(stub))
819 }
820
821 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
823 mut self,
824 v: V,
825 ) -> Self {
826 self.0.request = v.into();
827 self
828 }
829
830 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
832 self.0.options = v.into();
833 self
834 }
835
836 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
838 (*self.0.stub)
839 .get_operation(self.0.request, self.0.options)
840 .await
841 .map(crate::Response::into_body)
842 }
843
844 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
846 self.0.request.name = v.into();
847 self
848 }
849 }
850
851 #[doc(hidden)]
852 impl crate::RequestBuilder for GetOperation {
853 fn request_options(&mut self) -> &mut crate::RequestOptions {
854 &mut self.0.options
855 }
856 }
857}