Skip to main content

google_cloud_api_serviceusage_v1/
builder.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
17pub mod service_usage {
18    use crate::Result;
19
20    /// A builder for [ServiceUsage][crate::client::ServiceUsage].
21    ///
22    /// ```
23    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24    /// # use google_cloud_api_serviceusage_v1::*;
25    /// # use builder::service_usage::ClientBuilder;
26    /// # use client::ServiceUsage;
27    /// let builder : ClientBuilder = ServiceUsage::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://serviceusage.googleapis.com")
30    ///     .build().await?;
31    /// # Ok(()) }
32    /// ```
33    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    /// Common implementation for [crate::client::ServiceUsage] request builders.
51    #[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    /// The request builder for [ServiceUsage::enable_service][crate::client::ServiceUsage::enable_service] calls.
74    ///
75    /// # Example
76    /// ```
77    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::EnableService;
78    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
79    /// use google_cloud_lro::Poller;
80    ///
81    /// let builder = prepare_request_builder();
82    /// let response = builder.poller().until_done().await?;
83    /// # Ok(()) }
84    ///
85    /// fn prepare_request_builder() -> EnableService {
86    ///   # panic!();
87    ///   // ... details omitted ...
88    /// }
89    /// ```
90    #[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        /// Sets the full request, replacing any prior values.
101        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        /// Sets all the options, replacing any prior values.
107        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
108            self.0.options = v.into();
109            self
110        }
111
112        /// Sends the request.
113        ///
114        /// # Long running operations
115        ///
116        /// This starts, but does not poll, a longrunning operation. More information
117        /// on [enable_service][crate::client::ServiceUsage::enable_service].
118        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        /// Creates a [Poller][google_cloud_lro::Poller] to work with `enable_service`.
126        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        /// Sets the value of [name][crate::model::EnableServiceRequest::name].
169        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    /// The request builder for [ServiceUsage::disable_service][crate::client::ServiceUsage::disable_service] calls.
183    ///
184    /// # Example
185    /// ```
186    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::DisableService;
187    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
188    /// use google_cloud_lro::Poller;
189    ///
190    /// let builder = prepare_request_builder();
191    /// let response = builder.poller().until_done().await?;
192    /// # Ok(()) }
193    ///
194    /// fn prepare_request_builder() -> DisableService {
195    ///   # panic!();
196    ///   // ... details omitted ...
197    /// }
198    /// ```
199    #[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        /// Sets the full request, replacing any prior values.
210        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        /// Sets all the options, replacing any prior values.
216        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
217            self.0.options = v.into();
218            self
219        }
220
221        /// Sends the request.
222        ///
223        /// # Long running operations
224        ///
225        /// This starts, but does not poll, a longrunning operation. More information
226        /// on [disable_service][crate::client::ServiceUsage::disable_service].
227        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        /// Creates a [Poller][google_cloud_lro::Poller] to work with `disable_service`.
235        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        /// Sets the value of [name][crate::model::DisableServiceRequest::name].
278        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        /// Sets the value of [disable_dependent_services][crate::model::DisableServiceRequest::disable_dependent_services].
284        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        /// Sets the value of [check_if_service_has_usage][crate::model::DisableServiceRequest::check_if_service_has_usage].
290        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    /// The request builder for [ServiceUsage::get_service][crate::client::ServiceUsage::get_service] calls.
309    ///
310    /// # Example
311    /// ```
312    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::GetService;
313    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
314    ///
315    /// let builder = prepare_request_builder();
316    /// let response = builder.send().await?;
317    /// # Ok(()) }
318    ///
319    /// fn prepare_request_builder() -> GetService {
320    ///   # panic!();
321    ///   // ... details omitted ...
322    /// }
323    /// ```
324    #[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        /// Sets the full request, replacing any prior values.
335        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        /// Sets all the options, replacing any prior values.
341        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
342            self.0.options = v.into();
343            self
344        }
345
346        /// Sends the request.
347        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        /// Sets the value of [name][crate::model::GetServiceRequest::name].
355        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    /// The request builder for [ServiceUsage::list_services][crate::client::ServiceUsage::list_services] calls.
369    ///
370    /// # Example
371    /// ```
372    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::ListServices;
373    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
374    /// use google_cloud_gax::paginator::ItemPaginator;
375    ///
376    /// let builder = prepare_request_builder();
377    /// let mut items = builder.by_item();
378    /// while let Some(result) = items.next().await {
379    ///   let item = result?;
380    /// }
381    /// # Ok(()) }
382    ///
383    /// fn prepare_request_builder() -> ListServices {
384    ///   # panic!();
385    ///   // ... details omitted ...
386    /// }
387    /// ```
388    #[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        /// Sets the full request, replacing any prior values.
399        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        /// Sets all the options, replacing any prior values.
405        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
406            self.0.options = v.into();
407            self
408        }
409
410        /// Sends the request.
411        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        /// Streams each page in the collection.
419        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        /// Streams each item in the collection.
434        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        /// Sets the value of [parent][crate::model::ListServicesRequest::parent].
445        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        /// Sets the value of [page_size][crate::model::ListServicesRequest::page_size].
451        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        /// Sets the value of [page_token][crate::model::ListServicesRequest::page_token].
457        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        /// Sets the value of [filter][crate::model::ListServicesRequest::filter].
463        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    /// The request builder for [ServiceUsage::batch_enable_services][crate::client::ServiceUsage::batch_enable_services] calls.
477    ///
478    /// # Example
479    /// ```
480    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::BatchEnableServices;
481    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
482    /// use google_cloud_lro::Poller;
483    ///
484    /// let builder = prepare_request_builder();
485    /// let response = builder.poller().until_done().await?;
486    /// # Ok(()) }
487    ///
488    /// fn prepare_request_builder() -> BatchEnableServices {
489    ///   # panic!();
490    ///   // ... details omitted ...
491    /// }
492    /// ```
493    #[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        /// Sets the full request, replacing any prior values.
504        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        /// Sets all the options, replacing any prior values.
513        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
514            self.0.options = v.into();
515            self
516        }
517
518        /// Sends the request.
519        ///
520        /// # Long running operations
521        ///
522        /// This starts, but does not poll, a longrunning operation. More information
523        /// on [batch_enable_services][crate::client::ServiceUsage::batch_enable_services].
524        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        /// Creates a [Poller][google_cloud_lro::Poller] to work with `batch_enable_services`.
532        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        /// Sets the value of [parent][crate::model::BatchEnableServicesRequest::parent].
575        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        /// Sets the value of [service_ids][crate::model::BatchEnableServicesRequest::service_ids].
581        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    /// The request builder for [ServiceUsage::batch_get_services][crate::client::ServiceUsage::batch_get_services] calls.
600    ///
601    /// # Example
602    /// ```
603    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::BatchGetServices;
604    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
605    ///
606    /// let builder = prepare_request_builder();
607    /// let response = builder.send().await?;
608    /// # Ok(()) }
609    ///
610    /// fn prepare_request_builder() -> BatchGetServices {
611    ///   # panic!();
612    ///   // ... details omitted ...
613    /// }
614    /// ```
615    #[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        /// Sets the full request, replacing any prior values.
626        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        /// Sets all the options, replacing any prior values.
635        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
636            self.0.options = v.into();
637            self
638        }
639
640        /// Sends the request.
641        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        /// Sets the value of [parent][crate::model::BatchGetServicesRequest::parent].
649        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        /// Sets the value of [names][crate::model::BatchGetServicesRequest::names].
655        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    /// The request builder for [ServiceUsage::list_operations][crate::client::ServiceUsage::list_operations] calls.
674    ///
675    /// # Example
676    /// ```
677    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::ListOperations;
678    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
679    /// use google_cloud_gax::paginator::ItemPaginator;
680    ///
681    /// let builder = prepare_request_builder();
682    /// let mut items = builder.by_item();
683    /// while let Some(result) = items.next().await {
684    ///   let item = result?;
685    /// }
686    /// # Ok(()) }
687    ///
688    /// fn prepare_request_builder() -> ListOperations {
689    ///   # panic!();
690    ///   // ... details omitted ...
691    /// }
692    /// ```
693    #[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        /// Sets the full request, replacing any prior values.
706        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        /// Sets all the options, replacing any prior values.
715        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
716            self.0.options = v.into();
717            self
718        }
719
720        /// Sends the request.
721        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        /// Streams each page in the collection.
729        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        /// Streams each item in the collection.
746        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        /// Sets the value of [name][google_cloud_longrunning::model::ListOperationsRequest::name].
757        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        /// Sets the value of [filter][google_cloud_longrunning::model::ListOperationsRequest::filter].
763        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        /// Sets the value of [page_size][google_cloud_longrunning::model::ListOperationsRequest::page_size].
769        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        /// Sets the value of [page_token][google_cloud_longrunning::model::ListOperationsRequest::page_token].
775        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        /// Sets the value of [return_partial_success][google_cloud_longrunning::model::ListOperationsRequest::return_partial_success].
781        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    /// The request builder for [ServiceUsage::get_operation][crate::client::ServiceUsage::get_operation] calls.
795    ///
796    /// # Example
797    /// ```
798    /// # use google_cloud_api_serviceusage_v1::builder::service_usage::GetOperation;
799    /// # async fn sample() -> google_cloud_api_serviceusage_v1::Result<()> {
800    ///
801    /// let builder = prepare_request_builder();
802    /// let response = builder.send().await?;
803    /// # Ok(()) }
804    ///
805    /// fn prepare_request_builder() -> GetOperation {
806    ///   # panic!();
807    ///   // ... details omitted ...
808    /// }
809    /// ```
810    #[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        /// Sets the full request, replacing any prior values.
821        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        /// Sets all the options, replacing any prior values.
830        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
831            self.0.options = v.into();
832            self
833        }
834
835        /// Sends the request.
836        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        /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
844        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}