google_cloud_api_servicecontrol_v1/
builders.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 quota_controller {
18    use crate::Result;
19    use std::sync::Arc;
20
21    /// Common implementation for [crate::client::QuotaController] request builders.
22    #[derive(Clone, Debug)]
23    pub struct RequestBuilder<R: std::default::Default> {
24        stub: Arc<dyn crate::stubs::dynamic::QuotaController>,
25        request: R,
26        options: gax::options::RequestOptions,
27    }
28
29    impl<R> RequestBuilder<R>
30    where
31        R: std::default::Default,
32    {
33        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::QuotaController>) -> Self {
34            Self {
35                stub,
36                request: R::default(),
37                options: gax::options::RequestOptions::default(),
38            }
39        }
40    }
41
42    /// The request builder for a QuotaController::allocate_quota call.
43    #[derive(Clone, Debug)]
44    pub struct AllocateQuota(RequestBuilder<crate::model::AllocateQuotaRequest>);
45
46    impl AllocateQuota {
47        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::QuotaController>) -> Self {
48            Self(RequestBuilder::new(stub))
49        }
50
51        /// Sets the full request, replacing any prior values.
52        pub fn with_request<V: Into<crate::model::AllocateQuotaRequest>>(mut self, v: V) -> Self {
53            self.0.request = v.into();
54            self
55        }
56
57        /// Sets all the options, replacing any prior values.
58        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
59            self.0.options = v.into();
60            self
61        }
62
63        /// Sends the request.
64        pub async fn send(self) -> Result<crate::model::AllocateQuotaResponse> {
65            (*self.0.stub)
66                .allocate_quota(self.0.request, self.0.options)
67                .await
68        }
69
70        /// Sets the value of [service_name][crate::model::AllocateQuotaRequest::service_name].
71        pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
72            self.0.request.service_name = v.into();
73            self
74        }
75
76        /// Sets the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
77        pub fn set_allocate_operation<
78            T: Into<std::option::Option<crate::model::QuotaOperation>>,
79        >(
80            mut self,
81            v: T,
82        ) -> Self {
83            self.0.request.allocate_operation = v.into();
84            self
85        }
86
87        /// Sets the value of [service_config_id][crate::model::AllocateQuotaRequest::service_config_id].
88        pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
89            self.0.request.service_config_id = v.into();
90            self
91        }
92    }
93
94    impl gax::options::RequestBuilder for AllocateQuota {
95        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
96            &mut self.0.options
97        }
98    }
99}
100
101pub mod service_controller {
102    use crate::Result;
103    use std::sync::Arc;
104
105    /// Common implementation for [crate::client::ServiceController] request builders.
106    #[derive(Clone, Debug)]
107    pub struct RequestBuilder<R: std::default::Default> {
108        stub: Arc<dyn crate::stubs::dynamic::ServiceController>,
109        request: R,
110        options: gax::options::RequestOptions,
111    }
112
113    impl<R> RequestBuilder<R>
114    where
115        R: std::default::Default,
116    {
117        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceController>) -> Self {
118            Self {
119                stub,
120                request: R::default(),
121                options: gax::options::RequestOptions::default(),
122            }
123        }
124    }
125
126    /// The request builder for a ServiceController::check call.
127    #[derive(Clone, Debug)]
128    pub struct Check(RequestBuilder<crate::model::CheckRequest>);
129
130    impl Check {
131        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceController>) -> Self {
132            Self(RequestBuilder::new(stub))
133        }
134
135        /// Sets the full request, replacing any prior values.
136        pub fn with_request<V: Into<crate::model::CheckRequest>>(mut self, v: V) -> Self {
137            self.0.request = v.into();
138            self
139        }
140
141        /// Sets all the options, replacing any prior values.
142        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
143            self.0.options = v.into();
144            self
145        }
146
147        /// Sends the request.
148        pub async fn send(self) -> Result<crate::model::CheckResponse> {
149            (*self.0.stub).check(self.0.request, self.0.options).await
150        }
151
152        /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
153        pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
154            self.0.request.service_name = v.into();
155            self
156        }
157
158        /// Sets the value of [operation][crate::model::CheckRequest::operation].
159        pub fn set_operation<T: Into<std::option::Option<crate::model::Operation>>>(
160            mut self,
161            v: T,
162        ) -> Self {
163            self.0.request.operation = v.into();
164            self
165        }
166
167        /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
168        pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
169            self.0.request.service_config_id = v.into();
170            self
171        }
172    }
173
174    impl gax::options::RequestBuilder for Check {
175        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
176            &mut self.0.options
177        }
178    }
179
180    /// The request builder for a ServiceController::report call.
181    #[derive(Clone, Debug)]
182    pub struct Report(RequestBuilder<crate::model::ReportRequest>);
183
184    impl Report {
185        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ServiceController>) -> Self {
186            Self(RequestBuilder::new(stub))
187        }
188
189        /// Sets the full request, replacing any prior values.
190        pub fn with_request<V: Into<crate::model::ReportRequest>>(mut self, v: V) -> Self {
191            self.0.request = v.into();
192            self
193        }
194
195        /// Sets all the options, replacing any prior values.
196        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
197            self.0.options = v.into();
198            self
199        }
200
201        /// Sends the request.
202        pub async fn send(self) -> Result<crate::model::ReportResponse> {
203            (*self.0.stub).report(self.0.request, self.0.options).await
204        }
205
206        /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
207        pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
208            self.0.request.service_name = v.into();
209            self
210        }
211
212        /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
213        pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
214            self.0.request.service_config_id = v.into();
215            self
216        }
217
218        /// Sets the value of [operations][crate::model::ReportRequest::operations].
219        pub fn set_operations<T, V>(mut self, v: T) -> Self
220        where
221            T: std::iter::IntoIterator<Item = V>,
222            V: std::convert::Into<crate::model::Operation>,
223        {
224            use std::iter::Iterator;
225            self.0.request.operations = v.into_iter().map(|i| i.into()).collect();
226            self
227        }
228    }
229
230    impl gax::options::RequestBuilder for Report {
231        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
232            &mut self.0.options
233        }
234    }
235}