Skip to main content

google_maps_addressvalidation_v1/
builder.rs

1// Copyright 2026 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
17/// Request and client builders for [AddressValidation][crate::client::AddressValidation].
18pub mod address_validation {
19    use crate::Result;
20
21    /// A builder for [AddressValidation][crate::client::AddressValidation].
22    ///
23    /// ```
24    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25    /// # use google_maps_addressvalidation_v1::*;
26    /// # use builder::address_validation::ClientBuilder;
27    /// # use client::AddressValidation;
28    /// let builder : ClientBuilder = AddressValidation::builder();
29    /// let client = builder
30    ///     .with_endpoint("https://addressvalidation.googleapis.com")
31    ///     .build().await?;
32    /// # Ok(()) }
33    /// ```
34    pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36    pub(crate) mod client {
37        use super::super::super::client::AddressValidation;
38        pub struct Factory;
39        impl crate::ClientFactory for Factory {
40            type Client = AddressValidation;
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    /// Common implementation for [crate::client::AddressValidation] 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::AddressValidation>,
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::AddressValidation>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: crate::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [AddressValidation::validate_address][crate::client::AddressValidation::validate_address] calls.
75    ///
76    /// # Example
77    /// ```
78    /// # use google_maps_addressvalidation_v1::builder::address_validation::ValidateAddress;
79    /// # async fn sample() -> google_maps_addressvalidation_v1::Result<()> {
80    ///
81    /// let builder = prepare_request_builder();
82    /// let response = builder.send().await?;
83    /// # Ok(()) }
84    ///
85    /// fn prepare_request_builder() -> ValidateAddress {
86    ///   # panic!();
87    ///   // ... details omitted ...
88    /// }
89    /// ```
90    #[derive(Clone, Debug)]
91    pub struct ValidateAddress(RequestBuilder<crate::model::ValidateAddressRequest>);
92
93    impl ValidateAddress {
94        pub(crate) fn new(
95            stub: std::sync::Arc<dyn super::super::stub::dynamic::AddressValidation>,
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::ValidateAddressRequest>>(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        pub async fn send(self) -> Result<crate::model::ValidateAddressResponse> {
114            (*self.0.stub)
115                .validate_address(self.0.request, self.0.options)
116                .await
117                .map(crate::Response::into_body)
118        }
119
120        /// Sets the value of [address][crate::model::ValidateAddressRequest::address].
121        ///
122        /// This is a **required** field for requests.
123        pub fn set_address<T>(mut self, v: T) -> Self
124        where
125            T: std::convert::Into<google_cloud_type::model::PostalAddress>,
126        {
127            self.0.request.address = std::option::Option::Some(v.into());
128            self
129        }
130
131        /// Sets or clears the value of [address][crate::model::ValidateAddressRequest::address].
132        ///
133        /// This is a **required** field for requests.
134        pub fn set_or_clear_address<T>(mut self, v: std::option::Option<T>) -> Self
135        where
136            T: std::convert::Into<google_cloud_type::model::PostalAddress>,
137        {
138            self.0.request.address = v.map(|x| x.into());
139            self
140        }
141
142        /// Sets the value of [previous_response_id][crate::model::ValidateAddressRequest::previous_response_id].
143        pub fn set_previous_response_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
144            self.0.request.previous_response_id = v.into();
145            self
146        }
147
148        /// Sets the value of [enable_usps_cass][crate::model::ValidateAddressRequest::enable_usps_cass].
149        pub fn set_enable_usps_cass<T: Into<bool>>(mut self, v: T) -> Self {
150            self.0.request.enable_usps_cass = v.into();
151            self
152        }
153
154        /// Sets the value of [session_token][crate::model::ValidateAddressRequest::session_token].
155        pub fn set_session_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
156            self.0.request.session_token = v.into();
157            self
158        }
159    }
160
161    #[doc(hidden)]
162    impl crate::RequestBuilder for ValidateAddress {
163        fn request_options(&mut self) -> &mut crate::RequestOptions {
164            &mut self.0.options
165        }
166    }
167
168    /// The request builder for [AddressValidation::provide_validation_feedback][crate::client::AddressValidation::provide_validation_feedback] calls.
169    ///
170    /// # Example
171    /// ```
172    /// # use google_maps_addressvalidation_v1::builder::address_validation::ProvideValidationFeedback;
173    /// # async fn sample() -> google_maps_addressvalidation_v1::Result<()> {
174    ///
175    /// let builder = prepare_request_builder();
176    /// let response = builder.send().await?;
177    /// # Ok(()) }
178    ///
179    /// fn prepare_request_builder() -> ProvideValidationFeedback {
180    ///   # panic!();
181    ///   // ... details omitted ...
182    /// }
183    /// ```
184    #[derive(Clone, Debug)]
185    pub struct ProvideValidationFeedback(
186        RequestBuilder<crate::model::ProvideValidationFeedbackRequest>,
187    );
188
189    impl ProvideValidationFeedback {
190        pub(crate) fn new(
191            stub: std::sync::Arc<dyn super::super::stub::dynamic::AddressValidation>,
192        ) -> Self {
193            Self(RequestBuilder::new(stub))
194        }
195
196        /// Sets the full request, replacing any prior values.
197        pub fn with_request<V: Into<crate::model::ProvideValidationFeedbackRequest>>(
198            mut self,
199            v: V,
200        ) -> Self {
201            self.0.request = v.into();
202            self
203        }
204
205        /// Sets all the options, replacing any prior values.
206        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
207            self.0.options = v.into();
208            self
209        }
210
211        /// Sends the request.
212        pub async fn send(self) -> Result<crate::model::ProvideValidationFeedbackResponse> {
213            (*self.0.stub)
214                .provide_validation_feedback(self.0.request, self.0.options)
215                .await
216                .map(crate::Response::into_body)
217        }
218
219        /// Sets the value of [conclusion][crate::model::ProvideValidationFeedbackRequest::conclusion].
220        ///
221        /// This is a **required** field for requests.
222        pub fn set_conclusion<
223            T: Into<crate::model::provide_validation_feedback_request::ValidationConclusion>,
224        >(
225            mut self,
226            v: T,
227        ) -> Self {
228            self.0.request.conclusion = v.into();
229            self
230        }
231
232        /// Sets the value of [response_id][crate::model::ProvideValidationFeedbackRequest::response_id].
233        ///
234        /// This is a **required** field for requests.
235        pub fn set_response_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
236            self.0.request.response_id = v.into();
237            self
238        }
239    }
240
241    #[doc(hidden)]
242    impl crate::RequestBuilder for ProvideValidationFeedback {
243        fn request_options(&mut self) -> &mut crate::RequestOptions {
244            &mut self.0.options
245        }
246    }
247}