google_cloud_api_cloudquotas_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 cloud_quotas {
18    use crate::Result;
19
20    /// A builder for [CloudQuotas][crate::client::CloudQuotas].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_api_cloudquotas_v1::*;
25    /// # use builder::cloud_quotas::ClientBuilder;
26    /// # use client::CloudQuotas;
27    /// let builder : ClientBuilder = CloudQuotas::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://cloudquotas.googleapis.com")
30    ///     .build().await?;
31    /// # gax::client_builder::Result::<()>::Ok(()) });
32    /// ```
33    pub type ClientBuilder =
34        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36    pub(crate) mod client {
37        use super::super::super::client::CloudQuotas;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = CloudQuotas;
41            type Credentials = gaxi::options::Credentials;
42            async fn build(
43                self,
44                config: gaxi::options::ClientConfig,
45            ) -> gax::client_builder::Result<Self::Client> {
46                Self::Client::new(config).await
47            }
48        }
49    }
50
51    /// Common implementation for [crate::client::CloudQuotas] request builders.
52    #[derive(Clone, Debug)]
53    pub(crate) struct RequestBuilder<R: std::default::Default> {
54        stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
55        request: R,
56        options: gax::options::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::CloudQuotas>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: gax::options::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [CloudQuotas::list_quota_infos][crate::client::CloudQuotas::list_quota_infos] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_api_cloudquotas_v1::builder;
79    /// use builder::cloud_quotas::ListQuotaInfos;
80    /// # tokio_test::block_on(async {
81    /// use gax::paginator::ItemPaginator;
82    ///
83    /// let builder = prepare_request_builder();
84    /// let mut items = builder.by_item();
85    /// while let Some(result) = items.next().await {
86    ///   let item = result?;
87    /// }
88    /// # gax::Result::<()>::Ok(()) });
89    ///
90    /// fn prepare_request_builder() -> ListQuotaInfos {
91    ///   # panic!();
92    ///   // ... details omitted ...
93    /// }
94    /// ```
95    #[derive(Clone, Debug)]
96    pub struct ListQuotaInfos(RequestBuilder<crate::model::ListQuotaInfosRequest>);
97
98    impl ListQuotaInfos {
99        pub(crate) fn new(
100            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
101        ) -> Self {
102            Self(RequestBuilder::new(stub))
103        }
104
105        /// Sets the full request, replacing any prior values.
106        pub fn with_request<V: Into<crate::model::ListQuotaInfosRequest>>(mut self, v: V) -> Self {
107            self.0.request = v.into();
108            self
109        }
110
111        /// Sets all the options, replacing any prior values.
112        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
113            self.0.options = v.into();
114            self
115        }
116
117        /// Sends the request.
118        pub async fn send(self) -> Result<crate::model::ListQuotaInfosResponse> {
119            (*self.0.stub)
120                .list_quota_infos(self.0.request, self.0.options)
121                .await
122                .map(gax::response::Response::into_body)
123        }
124
125        /// Streams each page in the collection.
126        pub fn by_page(
127            self,
128        ) -> impl gax::paginator::Paginator<crate::model::ListQuotaInfosResponse, gax::error::Error>
129        {
130            use std::clone::Clone;
131            let token = self.0.request.page_token.clone();
132            let execute = move |token: String| {
133                let mut builder = self.clone();
134                builder.0.request = builder.0.request.set_page_token(token);
135                builder.send()
136            };
137            gax::paginator::internal::new_paginator(token, execute)
138        }
139
140        /// Streams each item in the collection.
141        pub fn by_item(
142            self,
143        ) -> impl gax::paginator::ItemPaginator<crate::model::ListQuotaInfosResponse, gax::error::Error>
144        {
145            use gax::paginator::Paginator;
146            self.by_page().items()
147        }
148
149        /// Sets the value of [parent][crate::model::ListQuotaInfosRequest::parent].
150        ///
151        /// This is a **required** field for requests.
152        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
153            self.0.request.parent = v.into();
154            self
155        }
156
157        /// Sets the value of [page_size][crate::model::ListQuotaInfosRequest::page_size].
158        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
159            self.0.request.page_size = v.into();
160            self
161        }
162
163        /// Sets the value of [page_token][crate::model::ListQuotaInfosRequest::page_token].
164        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
165            self.0.request.page_token = v.into();
166            self
167        }
168    }
169
170    #[doc(hidden)]
171    impl gax::options::internal::RequestBuilder for ListQuotaInfos {
172        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
173            &mut self.0.options
174        }
175    }
176
177    /// The request builder for [CloudQuotas::get_quota_info][crate::client::CloudQuotas::get_quota_info] calls.
178    ///
179    /// # Example
180    /// ```no_run
181    /// # use google_cloud_api_cloudquotas_v1::builder;
182    /// use builder::cloud_quotas::GetQuotaInfo;
183    /// # tokio_test::block_on(async {
184    ///
185    /// let builder = prepare_request_builder();
186    /// let response = builder.send().await?;
187    /// # gax::Result::<()>::Ok(()) });
188    ///
189    /// fn prepare_request_builder() -> GetQuotaInfo {
190    ///   # panic!();
191    ///   // ... details omitted ...
192    /// }
193    /// ```
194    #[derive(Clone, Debug)]
195    pub struct GetQuotaInfo(RequestBuilder<crate::model::GetQuotaInfoRequest>);
196
197    impl GetQuotaInfo {
198        pub(crate) fn new(
199            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
200        ) -> Self {
201            Self(RequestBuilder::new(stub))
202        }
203
204        /// Sets the full request, replacing any prior values.
205        pub fn with_request<V: Into<crate::model::GetQuotaInfoRequest>>(mut self, v: V) -> Self {
206            self.0.request = v.into();
207            self
208        }
209
210        /// Sets all the options, replacing any prior values.
211        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
212            self.0.options = v.into();
213            self
214        }
215
216        /// Sends the request.
217        pub async fn send(self) -> Result<crate::model::QuotaInfo> {
218            (*self.0.stub)
219                .get_quota_info(self.0.request, self.0.options)
220                .await
221                .map(gax::response::Response::into_body)
222        }
223
224        /// Sets the value of [name][crate::model::GetQuotaInfoRequest::name].
225        ///
226        /// This is a **required** field for requests.
227        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
228            self.0.request.name = v.into();
229            self
230        }
231    }
232
233    #[doc(hidden)]
234    impl gax::options::internal::RequestBuilder for GetQuotaInfo {
235        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
236            &mut self.0.options
237        }
238    }
239
240    /// The request builder for [CloudQuotas::list_quota_preferences][crate::client::CloudQuotas::list_quota_preferences] calls.
241    ///
242    /// # Example
243    /// ```no_run
244    /// # use google_cloud_api_cloudquotas_v1::builder;
245    /// use builder::cloud_quotas::ListQuotaPreferences;
246    /// # tokio_test::block_on(async {
247    /// use gax::paginator::ItemPaginator;
248    ///
249    /// let builder = prepare_request_builder();
250    /// let mut items = builder.by_item();
251    /// while let Some(result) = items.next().await {
252    ///   let item = result?;
253    /// }
254    /// # gax::Result::<()>::Ok(()) });
255    ///
256    /// fn prepare_request_builder() -> ListQuotaPreferences {
257    ///   # panic!();
258    ///   // ... details omitted ...
259    /// }
260    /// ```
261    #[derive(Clone, Debug)]
262    pub struct ListQuotaPreferences(RequestBuilder<crate::model::ListQuotaPreferencesRequest>);
263
264    impl ListQuotaPreferences {
265        pub(crate) fn new(
266            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
267        ) -> Self {
268            Self(RequestBuilder::new(stub))
269        }
270
271        /// Sets the full request, replacing any prior values.
272        pub fn with_request<V: Into<crate::model::ListQuotaPreferencesRequest>>(
273            mut self,
274            v: V,
275        ) -> Self {
276            self.0.request = v.into();
277            self
278        }
279
280        /// Sets all the options, replacing any prior values.
281        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
282            self.0.options = v.into();
283            self
284        }
285
286        /// Sends the request.
287        pub async fn send(self) -> Result<crate::model::ListQuotaPreferencesResponse> {
288            (*self.0.stub)
289                .list_quota_preferences(self.0.request, self.0.options)
290                .await
291                .map(gax::response::Response::into_body)
292        }
293
294        /// Streams each page in the collection.
295        pub fn by_page(
296            self,
297        ) -> impl gax::paginator::Paginator<crate::model::ListQuotaPreferencesResponse, gax::error::Error>
298        {
299            use std::clone::Clone;
300            let token = self.0.request.page_token.clone();
301            let execute = move |token: String| {
302                let mut builder = self.clone();
303                builder.0.request = builder.0.request.set_page_token(token);
304                builder.send()
305            };
306            gax::paginator::internal::new_paginator(token, execute)
307        }
308
309        /// Streams each item in the collection.
310        pub fn by_item(
311            self,
312        ) -> impl gax::paginator::ItemPaginator<
313            crate::model::ListQuotaPreferencesResponse,
314            gax::error::Error,
315        > {
316            use gax::paginator::Paginator;
317            self.by_page().items()
318        }
319
320        /// Sets the value of [parent][crate::model::ListQuotaPreferencesRequest::parent].
321        ///
322        /// This is a **required** field for requests.
323        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
324            self.0.request.parent = v.into();
325            self
326        }
327
328        /// Sets the value of [page_size][crate::model::ListQuotaPreferencesRequest::page_size].
329        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
330            self.0.request.page_size = v.into();
331            self
332        }
333
334        /// Sets the value of [page_token][crate::model::ListQuotaPreferencesRequest::page_token].
335        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
336            self.0.request.page_token = v.into();
337            self
338        }
339
340        /// Sets the value of [filter][crate::model::ListQuotaPreferencesRequest::filter].
341        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
342            self.0.request.filter = v.into();
343            self
344        }
345
346        /// Sets the value of [order_by][crate::model::ListQuotaPreferencesRequest::order_by].
347        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
348            self.0.request.order_by = v.into();
349            self
350        }
351    }
352
353    #[doc(hidden)]
354    impl gax::options::internal::RequestBuilder for ListQuotaPreferences {
355        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
356            &mut self.0.options
357        }
358    }
359
360    /// The request builder for [CloudQuotas::get_quota_preference][crate::client::CloudQuotas::get_quota_preference] calls.
361    ///
362    /// # Example
363    /// ```no_run
364    /// # use google_cloud_api_cloudquotas_v1::builder;
365    /// use builder::cloud_quotas::GetQuotaPreference;
366    /// # tokio_test::block_on(async {
367    ///
368    /// let builder = prepare_request_builder();
369    /// let response = builder.send().await?;
370    /// # gax::Result::<()>::Ok(()) });
371    ///
372    /// fn prepare_request_builder() -> GetQuotaPreference {
373    ///   # panic!();
374    ///   // ... details omitted ...
375    /// }
376    /// ```
377    #[derive(Clone, Debug)]
378    pub struct GetQuotaPreference(RequestBuilder<crate::model::GetQuotaPreferenceRequest>);
379
380    impl GetQuotaPreference {
381        pub(crate) fn new(
382            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
383        ) -> Self {
384            Self(RequestBuilder::new(stub))
385        }
386
387        /// Sets the full request, replacing any prior values.
388        pub fn with_request<V: Into<crate::model::GetQuotaPreferenceRequest>>(
389            mut self,
390            v: V,
391        ) -> Self {
392            self.0.request = v.into();
393            self
394        }
395
396        /// Sets all the options, replacing any prior values.
397        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
398            self.0.options = v.into();
399            self
400        }
401
402        /// Sends the request.
403        pub async fn send(self) -> Result<crate::model::QuotaPreference> {
404            (*self.0.stub)
405                .get_quota_preference(self.0.request, self.0.options)
406                .await
407                .map(gax::response::Response::into_body)
408        }
409
410        /// Sets the value of [name][crate::model::GetQuotaPreferenceRequest::name].
411        ///
412        /// This is a **required** field for requests.
413        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
414            self.0.request.name = v.into();
415            self
416        }
417    }
418
419    #[doc(hidden)]
420    impl gax::options::internal::RequestBuilder for GetQuotaPreference {
421        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
422            &mut self.0.options
423        }
424    }
425
426    /// The request builder for [CloudQuotas::create_quota_preference][crate::client::CloudQuotas::create_quota_preference] calls.
427    ///
428    /// # Example
429    /// ```no_run
430    /// # use google_cloud_api_cloudquotas_v1::builder;
431    /// use builder::cloud_quotas::CreateQuotaPreference;
432    /// # tokio_test::block_on(async {
433    ///
434    /// let builder = prepare_request_builder();
435    /// let response = builder.send().await?;
436    /// # gax::Result::<()>::Ok(()) });
437    ///
438    /// fn prepare_request_builder() -> CreateQuotaPreference {
439    ///   # panic!();
440    ///   // ... details omitted ...
441    /// }
442    /// ```
443    #[derive(Clone, Debug)]
444    pub struct CreateQuotaPreference(RequestBuilder<crate::model::CreateQuotaPreferenceRequest>);
445
446    impl CreateQuotaPreference {
447        pub(crate) fn new(
448            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
449        ) -> Self {
450            Self(RequestBuilder::new(stub))
451        }
452
453        /// Sets the full request, replacing any prior values.
454        pub fn with_request<V: Into<crate::model::CreateQuotaPreferenceRequest>>(
455            mut self,
456            v: V,
457        ) -> Self {
458            self.0.request = v.into();
459            self
460        }
461
462        /// Sets all the options, replacing any prior values.
463        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
464            self.0.options = v.into();
465            self
466        }
467
468        /// Sends the request.
469        pub async fn send(self) -> Result<crate::model::QuotaPreference> {
470            (*self.0.stub)
471                .create_quota_preference(self.0.request, self.0.options)
472                .await
473                .map(gax::response::Response::into_body)
474        }
475
476        /// Sets the value of [parent][crate::model::CreateQuotaPreferenceRequest::parent].
477        ///
478        /// This is a **required** field for requests.
479        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
480            self.0.request.parent = v.into();
481            self
482        }
483
484        /// Sets the value of [quota_preference_id][crate::model::CreateQuotaPreferenceRequest::quota_preference_id].
485        pub fn set_quota_preference_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
486            self.0.request.quota_preference_id = v.into();
487            self
488        }
489
490        /// Sets the value of [quota_preference][crate::model::CreateQuotaPreferenceRequest::quota_preference].
491        ///
492        /// This is a **required** field for requests.
493        pub fn set_quota_preference<T>(mut self, v: T) -> Self
494        where
495            T: std::convert::Into<crate::model::QuotaPreference>,
496        {
497            self.0.request.quota_preference = std::option::Option::Some(v.into());
498            self
499        }
500
501        /// Sets or clears the value of [quota_preference][crate::model::CreateQuotaPreferenceRequest::quota_preference].
502        ///
503        /// This is a **required** field for requests.
504        pub fn set_or_clear_quota_preference<T>(mut self, v: std::option::Option<T>) -> Self
505        where
506            T: std::convert::Into<crate::model::QuotaPreference>,
507        {
508            self.0.request.quota_preference = v.map(|x| x.into());
509            self
510        }
511
512        /// Sets the value of [ignore_safety_checks][crate::model::CreateQuotaPreferenceRequest::ignore_safety_checks].
513        pub fn set_ignore_safety_checks<T, V>(mut self, v: T) -> Self
514        where
515            T: std::iter::IntoIterator<Item = V>,
516            V: std::convert::Into<crate::model::QuotaSafetyCheck>,
517        {
518            use std::iter::Iterator;
519            self.0.request.ignore_safety_checks = v.into_iter().map(|i| i.into()).collect();
520            self
521        }
522    }
523
524    #[doc(hidden)]
525    impl gax::options::internal::RequestBuilder for CreateQuotaPreference {
526        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
527            &mut self.0.options
528        }
529    }
530
531    /// The request builder for [CloudQuotas::update_quota_preference][crate::client::CloudQuotas::update_quota_preference] calls.
532    ///
533    /// # Example
534    /// ```no_run
535    /// # use google_cloud_api_cloudquotas_v1::builder;
536    /// use builder::cloud_quotas::UpdateQuotaPreference;
537    /// # tokio_test::block_on(async {
538    ///
539    /// let builder = prepare_request_builder();
540    /// let response = builder.send().await?;
541    /// # gax::Result::<()>::Ok(()) });
542    ///
543    /// fn prepare_request_builder() -> UpdateQuotaPreference {
544    ///   # panic!();
545    ///   // ... details omitted ...
546    /// }
547    /// ```
548    #[derive(Clone, Debug)]
549    pub struct UpdateQuotaPreference(RequestBuilder<crate::model::UpdateQuotaPreferenceRequest>);
550
551    impl UpdateQuotaPreference {
552        pub(crate) fn new(
553            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
554        ) -> Self {
555            Self(RequestBuilder::new(stub))
556        }
557
558        /// Sets the full request, replacing any prior values.
559        pub fn with_request<V: Into<crate::model::UpdateQuotaPreferenceRequest>>(
560            mut self,
561            v: V,
562        ) -> Self {
563            self.0.request = v.into();
564            self
565        }
566
567        /// Sets all the options, replacing any prior values.
568        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
569            self.0.options = v.into();
570            self
571        }
572
573        /// Sends the request.
574        pub async fn send(self) -> Result<crate::model::QuotaPreference> {
575            (*self.0.stub)
576                .update_quota_preference(self.0.request, self.0.options)
577                .await
578                .map(gax::response::Response::into_body)
579        }
580
581        /// Sets the value of [update_mask][crate::model::UpdateQuotaPreferenceRequest::update_mask].
582        pub fn set_update_mask<T>(mut self, v: T) -> Self
583        where
584            T: std::convert::Into<wkt::FieldMask>,
585        {
586            self.0.request.update_mask = std::option::Option::Some(v.into());
587            self
588        }
589
590        /// Sets or clears the value of [update_mask][crate::model::UpdateQuotaPreferenceRequest::update_mask].
591        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
592        where
593            T: std::convert::Into<wkt::FieldMask>,
594        {
595            self.0.request.update_mask = v.map(|x| x.into());
596            self
597        }
598
599        /// Sets the value of [quota_preference][crate::model::UpdateQuotaPreferenceRequest::quota_preference].
600        ///
601        /// This is a **required** field for requests.
602        pub fn set_quota_preference<T>(mut self, v: T) -> Self
603        where
604            T: std::convert::Into<crate::model::QuotaPreference>,
605        {
606            self.0.request.quota_preference = std::option::Option::Some(v.into());
607            self
608        }
609
610        /// Sets or clears the value of [quota_preference][crate::model::UpdateQuotaPreferenceRequest::quota_preference].
611        ///
612        /// This is a **required** field for requests.
613        pub fn set_or_clear_quota_preference<T>(mut self, v: std::option::Option<T>) -> Self
614        where
615            T: std::convert::Into<crate::model::QuotaPreference>,
616        {
617            self.0.request.quota_preference = v.map(|x| x.into());
618            self
619        }
620
621        /// Sets the value of [allow_missing][crate::model::UpdateQuotaPreferenceRequest::allow_missing].
622        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
623            self.0.request.allow_missing = v.into();
624            self
625        }
626
627        /// Sets the value of [validate_only][crate::model::UpdateQuotaPreferenceRequest::validate_only].
628        pub fn set_validate_only<T: Into<bool>>(mut self, v: T) -> Self {
629            self.0.request.validate_only = v.into();
630            self
631        }
632
633        /// Sets the value of [ignore_safety_checks][crate::model::UpdateQuotaPreferenceRequest::ignore_safety_checks].
634        pub fn set_ignore_safety_checks<T, V>(mut self, v: T) -> Self
635        where
636            T: std::iter::IntoIterator<Item = V>,
637            V: std::convert::Into<crate::model::QuotaSafetyCheck>,
638        {
639            use std::iter::Iterator;
640            self.0.request.ignore_safety_checks = v.into_iter().map(|i| i.into()).collect();
641            self
642        }
643    }
644
645    #[doc(hidden)]
646    impl gax::options::internal::RequestBuilder for UpdateQuotaPreference {
647        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
648            &mut self.0.options
649        }
650    }
651}