Skip to main content

google_cloud_api_servicecontrol_v2/
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_controller {
18    use crate::Result;
19
20    /// A builder for [ServiceController][crate::client::ServiceController].
21    ///
22    /// ```
23    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24    /// # use google_cloud_api_servicecontrol_v2::*;
25    /// # use builder::service_controller::ClientBuilder;
26    /// # use client::ServiceController;
27    /// let builder : ClientBuilder = ServiceController::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://servicecontrol.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::ServiceController;
37        pub struct Factory;
38        impl crate::ClientFactory for Factory {
39            type Client = ServiceController;
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::ServiceController] 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::ServiceController>,
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::ServiceController>,
64        ) -> Self {
65            Self {
66                stub,
67                request: R::default(),
68                options: crate::RequestOptions::default(),
69            }
70        }
71    }
72
73    /// The request builder for [ServiceController::check][crate::client::ServiceController::check] calls.
74    ///
75    /// # Example
76    /// ```
77    /// # use google_cloud_api_servicecontrol_v2::builder::service_controller::Check;
78    /// # async fn sample() -> google_cloud_api_servicecontrol_v2::Result<()> {
79    ///
80    /// let builder = prepare_request_builder();
81    /// let response = builder.send().await?;
82    /// # Ok(()) }
83    ///
84    /// fn prepare_request_builder() -> Check {
85    ///   # panic!();
86    ///   // ... details omitted ...
87    /// }
88    /// ```
89    #[derive(Clone, Debug)]
90    pub struct Check(RequestBuilder<crate::model::CheckRequest>);
91
92    impl Check {
93        pub(crate) fn new(
94            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
95        ) -> Self {
96            Self(RequestBuilder::new(stub))
97        }
98
99        /// Sets the full request, replacing any prior values.
100        pub fn with_request<V: Into<crate::model::CheckRequest>>(mut self, v: V) -> Self {
101            self.0.request = v.into();
102            self
103        }
104
105        /// Sets all the options, replacing any prior values.
106        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
107            self.0.options = v.into();
108            self
109        }
110
111        /// Sends the request.
112        pub async fn send(self) -> Result<crate::model::CheckResponse> {
113            (*self.0.stub)
114                .check(self.0.request, self.0.options)
115                .await
116                .map(crate::Response::into_body)
117        }
118
119        /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
120        pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
121            self.0.request.service_name = v.into();
122            self
123        }
124
125        /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
126        pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
127            self.0.request.service_config_id = v.into();
128            self
129        }
130
131        /// Sets the value of [attributes][crate::model::CheckRequest::attributes].
132        pub fn set_attributes<T>(mut self, v: T) -> Self
133        where
134            T: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
135        {
136            self.0.request.attributes = std::option::Option::Some(v.into());
137            self
138        }
139
140        /// Sets or clears the value of [attributes][crate::model::CheckRequest::attributes].
141        pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
142        where
143            T: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
144        {
145            self.0.request.attributes = v.map(|x| x.into());
146            self
147        }
148
149        /// Sets the value of [resources][crate::model::CheckRequest::resources].
150        pub fn set_resources<T, V>(mut self, v: T) -> Self
151        where
152            T: std::iter::IntoIterator<Item = V>,
153            V: std::convert::Into<crate::model::ResourceInfo>,
154        {
155            use std::iter::Iterator;
156            self.0.request.resources = v.into_iter().map(|i| i.into()).collect();
157            self
158        }
159
160        /// Sets the value of [flags][crate::model::CheckRequest::flags].
161        pub fn set_flags<T: Into<std::string::String>>(mut self, v: T) -> Self {
162            self.0.request.flags = v.into();
163            self
164        }
165    }
166
167    #[doc(hidden)]
168    impl crate::RequestBuilder for Check {
169        fn request_options(&mut self) -> &mut crate::RequestOptions {
170            &mut self.0.options
171        }
172    }
173
174    /// The request builder for [ServiceController::report][crate::client::ServiceController::report] calls.
175    ///
176    /// # Example
177    /// ```
178    /// # use google_cloud_api_servicecontrol_v2::builder::service_controller::Report;
179    /// # async fn sample() -> google_cloud_api_servicecontrol_v2::Result<()> {
180    ///
181    /// let builder = prepare_request_builder();
182    /// let response = builder.send().await?;
183    /// # Ok(()) }
184    ///
185    /// fn prepare_request_builder() -> Report {
186    ///   # panic!();
187    ///   // ... details omitted ...
188    /// }
189    /// ```
190    #[derive(Clone, Debug)]
191    pub struct Report(RequestBuilder<crate::model::ReportRequest>);
192
193    impl Report {
194        pub(crate) fn new(
195            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServiceController>,
196        ) -> Self {
197            Self(RequestBuilder::new(stub))
198        }
199
200        /// Sets the full request, replacing any prior values.
201        pub fn with_request<V: Into<crate::model::ReportRequest>>(mut self, v: V) -> Self {
202            self.0.request = v.into();
203            self
204        }
205
206        /// Sets all the options, replacing any prior values.
207        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
208            self.0.options = v.into();
209            self
210        }
211
212        /// Sends the request.
213        pub async fn send(self) -> Result<crate::model::ReportResponse> {
214            (*self.0.stub)
215                .report(self.0.request, self.0.options)
216                .await
217                .map(crate::Response::into_body)
218        }
219
220        /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
221        pub fn set_service_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
222            self.0.request.service_name = v.into();
223            self
224        }
225
226        /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
227        pub fn set_service_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
228            self.0.request.service_config_id = v.into();
229            self
230        }
231
232        /// Sets the value of [operations][crate::model::ReportRequest::operations].
233        pub fn set_operations<T, V>(mut self, v: T) -> Self
234        where
235            T: std::iter::IntoIterator<Item = V>,
236            V: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
237        {
238            use std::iter::Iterator;
239            self.0.request.operations = v.into_iter().map(|i| i.into()).collect();
240            self
241        }
242    }
243
244    #[doc(hidden)]
245    impl crate::RequestBuilder for Report {
246        fn request_options(&mut self) -> &mut crate::RequestOptions {
247            &mut self.0.options
248        }
249    }
250}