Skip to main content

google_maps_routeoptimization_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 [RouteOptimization][crate::client::RouteOptimization].
18pub mod route_optimization {
19    use crate::Result;
20
21    /// A builder for [RouteOptimization][crate::client::RouteOptimization].
22    ///
23    /// ```
24    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25    /// # use google_maps_routeoptimization_v1::*;
26    /// # use builder::route_optimization::ClientBuilder;
27    /// # use client::RouteOptimization;
28    /// let builder : ClientBuilder = RouteOptimization::builder();
29    /// let client = builder
30    ///     .with_endpoint("https://routeoptimization.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::RouteOptimization;
38        pub struct Factory;
39        impl crate::ClientFactory for Factory {
40            type Client = RouteOptimization;
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::RouteOptimization] 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::RouteOptimization>,
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::RouteOptimization>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: crate::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [RouteOptimization::optimize_tours][crate::client::RouteOptimization::optimize_tours] calls.
75    ///
76    /// # Example
77    /// ```
78    /// # use google_maps_routeoptimization_v1::builder::route_optimization::OptimizeTours;
79    /// # async fn sample() -> google_maps_routeoptimization_v1::Result<()> {
80    ///
81    /// let builder = prepare_request_builder();
82    /// let response = builder.send().await?;
83    /// # Ok(()) }
84    ///
85    /// fn prepare_request_builder() -> OptimizeTours {
86    ///   # panic!();
87    ///   // ... details omitted ...
88    /// }
89    /// ```
90    #[derive(Clone, Debug)]
91    pub struct OptimizeTours(RequestBuilder<crate::model::OptimizeToursRequest>);
92
93    impl OptimizeTours {
94        pub(crate) fn new(
95            stub: std::sync::Arc<dyn super::super::stub::dynamic::RouteOptimization>,
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::OptimizeToursRequest>>(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::OptimizeToursResponse> {
114            (*self.0.stub)
115                .optimize_tours(self.0.request, self.0.options)
116                .await
117                .map(crate::Response::into_body)
118        }
119
120        /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
121        ///
122        /// This is a **required** field for requests.
123        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
124            self.0.request.parent = v.into();
125            self
126        }
127
128        /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
129        pub fn set_timeout<T>(mut self, v: T) -> Self
130        where
131            T: std::convert::Into<wkt::Duration>,
132        {
133            self.0.request.timeout = std::option::Option::Some(v.into());
134            self
135        }
136
137        /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
138        pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
139        where
140            T: std::convert::Into<wkt::Duration>,
141        {
142            self.0.request.timeout = v.map(|x| x.into());
143            self
144        }
145
146        /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
147        pub fn set_model<T>(mut self, v: T) -> Self
148        where
149            T: std::convert::Into<crate::model::ShipmentModel>,
150        {
151            self.0.request.model = std::option::Option::Some(v.into());
152            self
153        }
154
155        /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
156        pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
157        where
158            T: std::convert::Into<crate::model::ShipmentModel>,
159        {
160            self.0.request.model = v.map(|x| x.into());
161            self
162        }
163
164        /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
165        pub fn set_solving_mode<T: Into<crate::model::optimize_tours_request::SolvingMode>>(
166            mut self,
167            v: T,
168        ) -> Self {
169            self.0.request.solving_mode = v.into();
170            self
171        }
172
173        /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
174        pub fn set_search_mode<T: Into<crate::model::optimize_tours_request::SearchMode>>(
175            mut self,
176            v: T,
177        ) -> Self {
178            self.0.request.search_mode = v.into();
179            self
180        }
181
182        /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
183        pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
184        where
185            T: std::iter::IntoIterator<Item = V>,
186            V: std::convert::Into<crate::model::ShipmentRoute>,
187        {
188            use std::iter::Iterator;
189            self.0.request.injected_first_solution_routes =
190                v.into_iter().map(|i| i.into()).collect();
191            self
192        }
193
194        /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
195        pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
196        where
197            T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
198        {
199            self.0.request.injected_solution_constraint = std::option::Option::Some(v.into());
200            self
201        }
202
203        /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
204        pub fn set_or_clear_injected_solution_constraint<T>(
205            mut self,
206            v: std::option::Option<T>,
207        ) -> Self
208        where
209            T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
210        {
211            self.0.request.injected_solution_constraint = v.map(|x| x.into());
212            self
213        }
214
215        /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
216        pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
217        where
218            T: std::iter::IntoIterator<Item = V>,
219            V: std::convert::Into<crate::model::ShipmentRoute>,
220        {
221            use std::iter::Iterator;
222            self.0.request.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
223            self
224        }
225
226        /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
227        pub fn set_interpret_injected_solutions_using_labels<T: Into<bool>>(
228            mut self,
229            v: T,
230        ) -> Self {
231            self.0.request.interpret_injected_solutions_using_labels = v.into();
232            self
233        }
234
235        /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
236        pub fn set_consider_road_traffic<T: Into<bool>>(mut self, v: T) -> Self {
237            self.0.request.consider_road_traffic = v.into();
238            self
239        }
240
241        /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
242        pub fn set_populate_polylines<T: Into<bool>>(mut self, v: T) -> Self {
243            self.0.request.populate_polylines = v.into();
244            self
245        }
246
247        /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
248        pub fn set_populate_transition_polylines<T: Into<bool>>(mut self, v: T) -> Self {
249            self.0.request.populate_transition_polylines = v.into();
250            self
251        }
252
253        /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
254        pub fn set_allow_large_deadline_despite_interruption_risk<T: Into<bool>>(
255            mut self,
256            v: T,
257        ) -> Self {
258            self.0
259                .request
260                .allow_large_deadline_despite_interruption_risk = v.into();
261            self
262        }
263
264        /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
265        pub fn set_use_geodesic_distances<T: Into<bool>>(mut self, v: T) -> Self {
266            self.0.request.use_geodesic_distances = v.into();
267            self
268        }
269
270        /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
271        pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
272        where
273            T: std::convert::Into<f64>,
274        {
275            self.0.request.geodesic_meters_per_second = std::option::Option::Some(v.into());
276            self
277        }
278
279        /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
280        pub fn set_or_clear_geodesic_meters_per_second<T>(
281            mut self,
282            v: std::option::Option<T>,
283        ) -> Self
284        where
285            T: std::convert::Into<f64>,
286        {
287            self.0.request.geodesic_meters_per_second = v.map(|x| x.into());
288            self
289        }
290
291        /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
292        pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
293        where
294            T: std::convert::Into<i32>,
295        {
296            self.0.request.max_validation_errors = std::option::Option::Some(v.into());
297            self
298        }
299
300        /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
301        pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
302        where
303            T: std::convert::Into<i32>,
304        {
305            self.0.request.max_validation_errors = v.map(|x| x.into());
306            self
307        }
308
309        /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
310        pub fn set_label<T: Into<std::string::String>>(mut self, v: T) -> Self {
311            self.0.request.label = v.into();
312            self
313        }
314    }
315
316    #[doc(hidden)]
317    impl crate::RequestBuilder for OptimizeTours {
318        fn request_options(&mut self) -> &mut crate::RequestOptions {
319            &mut self.0.options
320        }
321    }
322
323    /// The request builder for [RouteOptimization::batch_optimize_tours][crate::client::RouteOptimization::batch_optimize_tours] calls.
324    ///
325    /// # Example
326    /// ```
327    /// # use google_maps_routeoptimization_v1::builder::route_optimization::BatchOptimizeTours;
328    /// # async fn sample() -> google_maps_routeoptimization_v1::Result<()> {
329    /// use google_cloud_lro::Poller;
330    ///
331    /// let builder = prepare_request_builder();
332    /// let response = builder.poller().until_done().await?;
333    /// # Ok(()) }
334    ///
335    /// fn prepare_request_builder() -> BatchOptimizeTours {
336    ///   # panic!();
337    ///   // ... details omitted ...
338    /// }
339    /// ```
340    #[derive(Clone, Debug)]
341    pub struct BatchOptimizeTours(RequestBuilder<crate::model::BatchOptimizeToursRequest>);
342
343    impl BatchOptimizeTours {
344        pub(crate) fn new(
345            stub: std::sync::Arc<dyn super::super::stub::dynamic::RouteOptimization>,
346        ) -> Self {
347            Self(RequestBuilder::new(stub))
348        }
349
350        /// Sets the full request, replacing any prior values.
351        pub fn with_request<V: Into<crate::model::BatchOptimizeToursRequest>>(
352            mut self,
353            v: V,
354        ) -> Self {
355            self.0.request = v.into();
356            self
357        }
358
359        /// Sets all the options, replacing any prior values.
360        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
361            self.0.options = v.into();
362            self
363        }
364
365        /// Sends the request.
366        ///
367        /// # Long running operations
368        ///
369        /// This starts, but does not poll, a longrunning operation. More information
370        /// on [batch_optimize_tours][crate::client::RouteOptimization::batch_optimize_tours].
371        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
372            (*self.0.stub)
373                .batch_optimize_tours(self.0.request, self.0.options)
374                .await
375                .map(crate::Response::into_body)
376        }
377
378        /// Creates a [Poller][google_cloud_lro::Poller] to work with `batch_optimize_tours`.
379        pub fn poller(
380            self,
381        ) -> impl google_cloud_lro::Poller<
382            crate::model::BatchOptimizeToursResponse,
383            crate::model::BatchOptimizeToursMetadata,
384        > {
385            type Operation = google_cloud_lro::internal::Operation<
386                crate::model::BatchOptimizeToursResponse,
387                crate::model::BatchOptimizeToursMetadata,
388            >;
389            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
390            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
391            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
392            if let Some(ref mut details) = poller_options.tracing {
393                details.method_name = "google_maps_routeoptimization_v1::client::RouteOptimization::batch_optimize_tours::until_done";
394            }
395
396            let stub = self.0.stub.clone();
397            let mut options = self.0.options.clone();
398            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
399            let query = move |name| {
400                let stub = stub.clone();
401                let options = options.clone();
402                async {
403                    let op = GetOperation::new(stub)
404                        .set_name(name)
405                        .with_options(options)
406                        .send()
407                        .await?;
408                    Ok(Operation::new(op))
409                }
410            };
411
412            let start = move || async {
413                let op = self.send().await?;
414                Ok(Operation::new(op))
415            };
416
417            use google_cloud_lro::internal::PollerExt;
418            {
419                google_cloud_lro::internal::new_poller(
420                    polling_error_policy,
421                    polling_backoff_policy,
422                    start,
423                    query,
424                )
425            }
426            .with_options(poller_options)
427        }
428
429        /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
430        ///
431        /// This is a **required** field for requests.
432        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
433            self.0.request.parent = v.into();
434            self
435        }
436
437        /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
438        ///
439        /// This is a **required** field for requests.
440        pub fn set_model_configs<T, V>(mut self, v: T) -> Self
441        where
442            T: std::iter::IntoIterator<Item = V>,
443            V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
444        {
445            use std::iter::Iterator;
446            self.0.request.model_configs = v.into_iter().map(|i| i.into()).collect();
447            self
448        }
449    }
450
451    #[doc(hidden)]
452    impl crate::RequestBuilder for BatchOptimizeTours {
453        fn request_options(&mut self) -> &mut crate::RequestOptions {
454            &mut self.0.options
455        }
456    }
457
458    /// The request builder for [RouteOptimization::optimize_tours_long_running][crate::client::RouteOptimization::optimize_tours_long_running] calls.
459    ///
460    /// # Example
461    /// ```
462    /// # use google_maps_routeoptimization_v1::builder::route_optimization::OptimizeToursLongRunning;
463    /// # async fn sample() -> google_maps_routeoptimization_v1::Result<()> {
464    /// use google_cloud_lro::Poller;
465    ///
466    /// let builder = prepare_request_builder();
467    /// let response = builder.poller().until_done().await?;
468    /// # Ok(()) }
469    ///
470    /// fn prepare_request_builder() -> OptimizeToursLongRunning {
471    ///   # panic!();
472    ///   // ... details omitted ...
473    /// }
474    /// ```
475    #[derive(Clone, Debug)]
476    pub struct OptimizeToursLongRunning(RequestBuilder<crate::model::OptimizeToursRequest>);
477
478    impl OptimizeToursLongRunning {
479        pub(crate) fn new(
480            stub: std::sync::Arc<dyn super::super::stub::dynamic::RouteOptimization>,
481        ) -> Self {
482            Self(RequestBuilder::new(stub))
483        }
484
485        /// Sets the full request, replacing any prior values.
486        pub fn with_request<V: Into<crate::model::OptimizeToursRequest>>(mut self, v: V) -> Self {
487            self.0.request = v.into();
488            self
489        }
490
491        /// Sets all the options, replacing any prior values.
492        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
493            self.0.options = v.into();
494            self
495        }
496
497        /// Sends the request.
498        ///
499        /// # Long running operations
500        ///
501        /// This starts, but does not poll, a longrunning operation. More information
502        /// on [optimize_tours_long_running][crate::client::RouteOptimization::optimize_tours_long_running].
503        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
504            (*self.0.stub)
505                .optimize_tours_long_running(self.0.request, self.0.options)
506                .await
507                .map(crate::Response::into_body)
508        }
509
510        /// Creates a [Poller][google_cloud_lro::Poller] to work with `optimize_tours_long_running`.
511        pub fn poller(
512            self,
513        ) -> impl google_cloud_lro::Poller<
514            crate::model::OptimizeToursResponse,
515            crate::model::OptimizeToursLongRunningMetadata,
516        > {
517            type Operation = google_cloud_lro::internal::Operation<
518                crate::model::OptimizeToursResponse,
519                crate::model::OptimizeToursLongRunningMetadata,
520            >;
521            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
522            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
523            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
524            if let Some(ref mut details) = poller_options.tracing {
525                details.method_name = "google_maps_routeoptimization_v1::client::RouteOptimization::optimize_tours_long_running::until_done";
526            }
527
528            let stub = self.0.stub.clone();
529            let mut options = self.0.options.clone();
530            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
531            let query = move |name| {
532                let stub = stub.clone();
533                let options = options.clone();
534                async {
535                    let op = GetOperation::new(stub)
536                        .set_name(name)
537                        .with_options(options)
538                        .send()
539                        .await?;
540                    Ok(Operation::new(op))
541                }
542            };
543
544            let start = move || async {
545                let op = self.send().await?;
546                Ok(Operation::new(op))
547            };
548
549            use google_cloud_lro::internal::PollerExt;
550            {
551                google_cloud_lro::internal::new_poller(
552                    polling_error_policy,
553                    polling_backoff_policy,
554                    start,
555                    query,
556                )
557            }
558            .with_options(poller_options)
559        }
560
561        /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
562        ///
563        /// This is a **required** field for requests.
564        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
565            self.0.request.parent = v.into();
566            self
567        }
568
569        /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
570        pub fn set_timeout<T>(mut self, v: T) -> Self
571        where
572            T: std::convert::Into<wkt::Duration>,
573        {
574            self.0.request.timeout = std::option::Option::Some(v.into());
575            self
576        }
577
578        /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
579        pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
580        where
581            T: std::convert::Into<wkt::Duration>,
582        {
583            self.0.request.timeout = v.map(|x| x.into());
584            self
585        }
586
587        /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
588        pub fn set_model<T>(mut self, v: T) -> Self
589        where
590            T: std::convert::Into<crate::model::ShipmentModel>,
591        {
592            self.0.request.model = std::option::Option::Some(v.into());
593            self
594        }
595
596        /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
597        pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
598        where
599            T: std::convert::Into<crate::model::ShipmentModel>,
600        {
601            self.0.request.model = v.map(|x| x.into());
602            self
603        }
604
605        /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
606        pub fn set_solving_mode<T: Into<crate::model::optimize_tours_request::SolvingMode>>(
607            mut self,
608            v: T,
609        ) -> Self {
610            self.0.request.solving_mode = v.into();
611            self
612        }
613
614        /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
615        pub fn set_search_mode<T: Into<crate::model::optimize_tours_request::SearchMode>>(
616            mut self,
617            v: T,
618        ) -> Self {
619            self.0.request.search_mode = v.into();
620            self
621        }
622
623        /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
624        pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
625        where
626            T: std::iter::IntoIterator<Item = V>,
627            V: std::convert::Into<crate::model::ShipmentRoute>,
628        {
629            use std::iter::Iterator;
630            self.0.request.injected_first_solution_routes =
631                v.into_iter().map(|i| i.into()).collect();
632            self
633        }
634
635        /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
636        pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
637        where
638            T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
639        {
640            self.0.request.injected_solution_constraint = std::option::Option::Some(v.into());
641            self
642        }
643
644        /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
645        pub fn set_or_clear_injected_solution_constraint<T>(
646            mut self,
647            v: std::option::Option<T>,
648        ) -> Self
649        where
650            T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
651        {
652            self.0.request.injected_solution_constraint = v.map(|x| x.into());
653            self
654        }
655
656        /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
657        pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
658        where
659            T: std::iter::IntoIterator<Item = V>,
660            V: std::convert::Into<crate::model::ShipmentRoute>,
661        {
662            use std::iter::Iterator;
663            self.0.request.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
664            self
665        }
666
667        /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
668        pub fn set_interpret_injected_solutions_using_labels<T: Into<bool>>(
669            mut self,
670            v: T,
671        ) -> Self {
672            self.0.request.interpret_injected_solutions_using_labels = v.into();
673            self
674        }
675
676        /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
677        pub fn set_consider_road_traffic<T: Into<bool>>(mut self, v: T) -> Self {
678            self.0.request.consider_road_traffic = v.into();
679            self
680        }
681
682        /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
683        pub fn set_populate_polylines<T: Into<bool>>(mut self, v: T) -> Self {
684            self.0.request.populate_polylines = v.into();
685            self
686        }
687
688        /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
689        pub fn set_populate_transition_polylines<T: Into<bool>>(mut self, v: T) -> Self {
690            self.0.request.populate_transition_polylines = v.into();
691            self
692        }
693
694        /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
695        pub fn set_allow_large_deadline_despite_interruption_risk<T: Into<bool>>(
696            mut self,
697            v: T,
698        ) -> Self {
699            self.0
700                .request
701                .allow_large_deadline_despite_interruption_risk = v.into();
702            self
703        }
704
705        /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
706        pub fn set_use_geodesic_distances<T: Into<bool>>(mut self, v: T) -> Self {
707            self.0.request.use_geodesic_distances = v.into();
708            self
709        }
710
711        /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
712        pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
713        where
714            T: std::convert::Into<f64>,
715        {
716            self.0.request.geodesic_meters_per_second = std::option::Option::Some(v.into());
717            self
718        }
719
720        /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
721        pub fn set_or_clear_geodesic_meters_per_second<T>(
722            mut self,
723            v: std::option::Option<T>,
724        ) -> Self
725        where
726            T: std::convert::Into<f64>,
727        {
728            self.0.request.geodesic_meters_per_second = v.map(|x| x.into());
729            self
730        }
731
732        /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
733        pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
734        where
735            T: std::convert::Into<i32>,
736        {
737            self.0.request.max_validation_errors = std::option::Option::Some(v.into());
738            self
739        }
740
741        /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
742        pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
743        where
744            T: std::convert::Into<i32>,
745        {
746            self.0.request.max_validation_errors = v.map(|x| x.into());
747            self
748        }
749
750        /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
751        pub fn set_label<T: Into<std::string::String>>(mut self, v: T) -> Self {
752            self.0.request.label = v.into();
753            self
754        }
755    }
756
757    #[doc(hidden)]
758    impl crate::RequestBuilder for OptimizeToursLongRunning {
759        fn request_options(&mut self) -> &mut crate::RequestOptions {
760            &mut self.0.options
761        }
762    }
763
764    /// The request builder for [RouteOptimization::optimize_tours_uri][crate::client::RouteOptimization::optimize_tours_uri] calls.
765    ///
766    /// # Example
767    /// ```
768    /// # use google_maps_routeoptimization_v1::builder::route_optimization::OptimizeToursUri;
769    /// # async fn sample() -> google_maps_routeoptimization_v1::Result<()> {
770    /// use google_cloud_lro::Poller;
771    ///
772    /// let builder = prepare_request_builder();
773    /// let response = builder.poller().until_done().await?;
774    /// # Ok(()) }
775    ///
776    /// fn prepare_request_builder() -> OptimizeToursUri {
777    ///   # panic!();
778    ///   // ... details omitted ...
779    /// }
780    /// ```
781    #[derive(Clone, Debug)]
782    pub struct OptimizeToursUri(RequestBuilder<crate::model::OptimizeToursUriRequest>);
783
784    impl OptimizeToursUri {
785        pub(crate) fn new(
786            stub: std::sync::Arc<dyn super::super::stub::dynamic::RouteOptimization>,
787        ) -> Self {
788            Self(RequestBuilder::new(stub))
789        }
790
791        /// Sets the full request, replacing any prior values.
792        pub fn with_request<V: Into<crate::model::OptimizeToursUriRequest>>(
793            mut self,
794            v: V,
795        ) -> Self {
796            self.0.request = v.into();
797            self
798        }
799
800        /// Sets all the options, replacing any prior values.
801        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
802            self.0.options = v.into();
803            self
804        }
805
806        /// Sends the request.
807        ///
808        /// # Long running operations
809        ///
810        /// This starts, but does not poll, a longrunning operation. More information
811        /// on [optimize_tours_uri][crate::client::RouteOptimization::optimize_tours_uri].
812        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
813            (*self.0.stub)
814                .optimize_tours_uri(self.0.request, self.0.options)
815                .await
816                .map(crate::Response::into_body)
817        }
818
819        /// Creates a [Poller][google_cloud_lro::Poller] to work with `optimize_tours_uri`.
820        pub fn poller(
821            self,
822        ) -> impl google_cloud_lro::Poller<
823            crate::model::OptimizeToursUriResponse,
824            crate::model::OptimizeToursUriMetadata,
825        > {
826            type Operation = google_cloud_lro::internal::Operation<
827                crate::model::OptimizeToursUriResponse,
828                crate::model::OptimizeToursUriMetadata,
829            >;
830            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
831            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
832            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
833            if let Some(ref mut details) = poller_options.tracing {
834                details.method_name = "google_maps_routeoptimization_v1::client::RouteOptimization::optimize_tours_uri::until_done";
835            }
836
837            let stub = self.0.stub.clone();
838            let mut options = self.0.options.clone();
839            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
840            let query = move |name| {
841                let stub = stub.clone();
842                let options = options.clone();
843                async {
844                    let op = GetOperation::new(stub)
845                        .set_name(name)
846                        .with_options(options)
847                        .send()
848                        .await?;
849                    Ok(Operation::new(op))
850                }
851            };
852
853            let start = move || async {
854                let op = self.send().await?;
855                Ok(Operation::new(op))
856            };
857
858            use google_cloud_lro::internal::PollerExt;
859            {
860                google_cloud_lro::internal::new_poller(
861                    polling_error_policy,
862                    polling_backoff_policy,
863                    start,
864                    query,
865                )
866            }
867            .with_options(poller_options)
868        }
869
870        /// Sets the value of [parent][crate::model::OptimizeToursUriRequest::parent].
871        ///
872        /// This is a **required** field for requests.
873        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
874            self.0.request.parent = v.into();
875            self
876        }
877
878        /// Sets the value of [input][crate::model::OptimizeToursUriRequest::input].
879        ///
880        /// This is a **required** field for requests.
881        pub fn set_input<T>(mut self, v: T) -> Self
882        where
883            T: std::convert::Into<crate::model::Uri>,
884        {
885            self.0.request.input = std::option::Option::Some(v.into());
886            self
887        }
888
889        /// Sets or clears the value of [input][crate::model::OptimizeToursUriRequest::input].
890        ///
891        /// This is a **required** field for requests.
892        pub fn set_or_clear_input<T>(mut self, v: std::option::Option<T>) -> Self
893        where
894            T: std::convert::Into<crate::model::Uri>,
895        {
896            self.0.request.input = v.map(|x| x.into());
897            self
898        }
899
900        /// Sets the value of [output][crate::model::OptimizeToursUriRequest::output].
901        ///
902        /// This is a **required** field for requests.
903        pub fn set_output<T>(mut self, v: T) -> Self
904        where
905            T: std::convert::Into<crate::model::Uri>,
906        {
907            self.0.request.output = std::option::Option::Some(v.into());
908            self
909        }
910
911        /// Sets or clears the value of [output][crate::model::OptimizeToursUriRequest::output].
912        ///
913        /// This is a **required** field for requests.
914        pub fn set_or_clear_output<T>(mut self, v: std::option::Option<T>) -> Self
915        where
916            T: std::convert::Into<crate::model::Uri>,
917        {
918            self.0.request.output = v.map(|x| x.into());
919            self
920        }
921    }
922
923    #[doc(hidden)]
924    impl crate::RequestBuilder for OptimizeToursUri {
925        fn request_options(&mut self) -> &mut crate::RequestOptions {
926            &mut self.0.options
927        }
928    }
929
930    /// The request builder for [RouteOptimization::get_operation][crate::client::RouteOptimization::get_operation] calls.
931    ///
932    /// # Example
933    /// ```
934    /// # use google_maps_routeoptimization_v1::builder::route_optimization::GetOperation;
935    /// # async fn sample() -> google_maps_routeoptimization_v1::Result<()> {
936    ///
937    /// let builder = prepare_request_builder();
938    /// let response = builder.send().await?;
939    /// # Ok(()) }
940    ///
941    /// fn prepare_request_builder() -> GetOperation {
942    ///   # panic!();
943    ///   // ... details omitted ...
944    /// }
945    /// ```
946    #[derive(Clone, Debug)]
947    pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
948
949    impl GetOperation {
950        pub(crate) fn new(
951            stub: std::sync::Arc<dyn super::super::stub::dynamic::RouteOptimization>,
952        ) -> Self {
953            Self(RequestBuilder::new(stub))
954        }
955
956        /// Sets the full request, replacing any prior values.
957        pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
958            mut self,
959            v: V,
960        ) -> Self {
961            self.0.request = v.into();
962            self
963        }
964
965        /// Sets all the options, replacing any prior values.
966        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
967            self.0.options = v.into();
968            self
969        }
970
971        /// Sends the request.
972        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
973            (*self.0.stub)
974                .get_operation(self.0.request, self.0.options)
975                .await
976                .map(crate::Response::into_body)
977        }
978
979        /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
980        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
981            self.0.request.name = v.into();
982            self
983        }
984    }
985
986    #[doc(hidden)]
987    impl crate::RequestBuilder for GetOperation {
988        fn request_options(&mut self) -> &mut crate::RequestOptions {
989            &mut self.0.options
990        }
991    }
992}