Skip to main content

google_maps_fleetengine_v1/
client.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#![allow(rustdoc::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Local Rides and Deliveries API.
22///
23/// # Example
24/// ```
25/// # use google_maps_fleetengine_v1::client::TripService;
26/// async fn sample(
27///    provider_id: &str,
28///    trip_id: &str,
29/// ) -> anyhow::Result<()> {
30///     let client = TripService::builder().build().await?;
31///     let response = client.get_trip()
32///         .set_name(format!("providers/{provider_id}/trips/{trip_id}"))
33///         .send().await?;
34///     println!("response {:?}", response);
35///     Ok(())
36/// }
37/// ```
38///
39/// # Service Description
40///
41/// Trip management service.
42///
43/// # Configuration
44///
45/// To configure `TripService` use the `with_*` methods in the type returned
46/// by [builder()][TripService::builder]. The default configuration should
47/// work for most applications. Common configuration changes include
48///
49/// * [with_endpoint()]: by default this client uses the global default endpoint
50///   (`https://fleetengine.googleapis.com`). Applications using regional
51///   endpoints or running in restricted networks (e.g. a network configured
52///   with [Private Google Access with VPC Service Controls]) may want to
53///   override this default.
54/// * [with_credentials()]: by default this client uses
55///   [Application Default Credentials]. Applications using custom
56///   authentication may need to override this default.
57///
58/// [with_endpoint()]: super::builder::trip_service::ClientBuilder::with_endpoint
59/// [with_credentials()]: super::builder::trip_service::ClientBuilder::with_credentials
60/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
61/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
62///
63/// # Pooling and Cloning
64///
65/// `TripService` holds a connection pool internally, it is advised to
66/// create one and reuse it. You do not need to wrap `TripService` in
67/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
68/// already uses an `Arc` internally.
69#[derive(Clone, Debug)]
70pub struct TripService {
71    inner: std::sync::Arc<dyn super::stub::dynamic::TripService>,
72}
73
74impl TripService {
75    /// Returns a builder for [TripService].
76    ///
77    /// ```
78    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
79    /// # use google_maps_fleetengine_v1::client::TripService;
80    /// let client = TripService::builder().build().await?;
81    /// # Ok(()) }
82    /// ```
83    pub fn builder() -> super::builder::trip_service::ClientBuilder {
84        crate::new_client_builder(super::builder::trip_service::client::Factory)
85    }
86
87    /// Creates a new client from the provided stub.
88    ///
89    /// The most common case for calling this function is in tests mocking the
90    /// client's behavior.
91    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
92    where
93        T: super::stub::TripService + 'static,
94    {
95        Self { inner: stub.into() }
96    }
97
98    pub(crate) async fn new(
99        config: gaxi::options::ClientConfig,
100    ) -> crate::ClientBuilderResult<Self> {
101        let inner = Self::build_inner(config).await?;
102        Ok(Self { inner })
103    }
104
105    async fn build_inner(
106        conf: gaxi::options::ClientConfig,
107    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::TripService>> {
108        if gaxi::options::tracing_enabled(&conf) {
109            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
110        }
111        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
112    }
113
114    async fn build_transport(
115        conf: gaxi::options::ClientConfig,
116    ) -> crate::ClientBuilderResult<impl super::stub::TripService> {
117        super::transport::TripService::new(conf).await
118    }
119
120    async fn build_with_tracing(
121        conf: gaxi::options::ClientConfig,
122    ) -> crate::ClientBuilderResult<impl super::stub::TripService> {
123        Self::build_transport(conf)
124            .await
125            .map(super::tracing::TripService::new)
126    }
127
128    /// Creates a trip in the Fleet Engine and returns the new trip.
129    ///
130    /// # Example
131    /// ```
132    /// # use google_maps_fleetengine_v1::client::TripService;
133    /// use google_maps_fleetengine_v1::model::Trip;
134    /// use google_maps_fleetengine_v1::Result;
135    /// async fn sample(
136    ///    client: &TripService, provider_id: &str, trip_id: &str
137    /// ) -> Result<()> {
138    ///     let response = client.create_trip()
139    ///         .set_parent(format!("providers/{provider_id}/trips/{trip_id}"))
140    ///         .set_trip_id("trip_id_value")
141    ///         .set_trip(
142    ///             Trip::new()/* set fields */
143    ///         )
144    ///         .send().await?;
145    ///     println!("response {:?}", response);
146    ///     Ok(())
147    /// }
148    /// ```
149    pub fn create_trip(&self) -> super::builder::trip_service::CreateTrip {
150        super::builder::trip_service::CreateTrip::new(self.inner.clone())
151    }
152
153    /// Get information about a single trip.
154    ///
155    /// # Example
156    /// ```
157    /// # use google_maps_fleetengine_v1::client::TripService;
158    /// use google_maps_fleetengine_v1::Result;
159    /// async fn sample(
160    ///    client: &TripService, provider_id: &str, trip_id: &str
161    /// ) -> Result<()> {
162    ///     let response = client.get_trip()
163    ///         .set_name(format!("providers/{provider_id}/trips/{trip_id}"))
164    ///         .send().await?;
165    ///     println!("response {:?}", response);
166    ///     Ok(())
167    /// }
168    /// ```
169    pub fn get_trip(&self) -> super::builder::trip_service::GetTrip {
170        super::builder::trip_service::GetTrip::new(self.inner.clone())
171    }
172
173    /// Deletes a single Trip.
174    ///
175    /// Returns FAILED_PRECONDITION if the Trip is active and assigned to a
176    /// vehicle.
177    ///
178    /// # Example
179    /// ```
180    /// # use google_maps_fleetengine_v1::client::TripService;
181    /// use google_maps_fleetengine_v1::Result;
182    /// async fn sample(
183    ///    client: &TripService, provider_id: &str, trip_id: &str
184    /// ) -> Result<()> {
185    ///     client.delete_trip()
186    ///         .set_name(format!("providers/{provider_id}/trips/{trip_id}"))
187    ///         .send().await?;
188    ///     Ok(())
189    /// }
190    /// ```
191    pub fn delete_trip(&self) -> super::builder::trip_service::DeleteTrip {
192        super::builder::trip_service::DeleteTrip::new(self.inner.clone())
193    }
194
195    /// Report billable trip usage.
196    ///
197    /// # Example
198    /// ```
199    /// # use google_maps_fleetengine_v1::client::TripService;
200    /// use google_maps_fleetengine_v1::Result;
201    /// async fn sample(
202    ///    client: &TripService
203    /// ) -> Result<()> {
204    ///     client.report_billable_trip()
205    ///         /* set fields */
206    ///         .send().await?;
207    ///     Ok(())
208    /// }
209    /// ```
210    pub fn report_billable_trip(&self) -> super::builder::trip_service::ReportBillableTrip {
211        super::builder::trip_service::ReportBillableTrip::new(self.inner.clone())
212    }
213
214    /// Get all the trips for a specific vehicle.
215    ///
216    /// # Example
217    /// ```
218    /// # use google_maps_fleetengine_v1::client::TripService;
219    /// use google_cloud_gax::paginator::ItemPaginator as _;
220    /// use google_maps_fleetengine_v1::Result;
221    /// async fn sample(
222    ///    client: &TripService
223    /// ) -> Result<()> {
224    ///     let mut list = client.search_trips()
225    ///         /* set fields */
226    ///         .by_item();
227    ///     while let Some(item) = list.next().await.transpose()? {
228    ///         println!("{:?}", item);
229    ///     }
230    ///     Ok(())
231    /// }
232    /// ```
233    pub fn search_trips(&self) -> super::builder::trip_service::SearchTrips {
234        super::builder::trip_service::SearchTrips::new(self.inner.clone())
235    }
236
237    /// Updates trip data.
238    ///
239    /// # Example
240    /// ```
241    /// # use google_maps_fleetengine_v1::client::TripService;
242    /// # extern crate wkt as google_cloud_wkt;
243    /// use google_cloud_wkt::FieldMask;
244    /// use google_maps_fleetengine_v1::model::Trip;
245    /// use google_maps_fleetengine_v1::Result;
246    /// async fn sample(
247    ///    client: &TripService, provider_id: &str, trip_id: &str
248    /// ) -> Result<()> {
249    ///     let response = client.update_trip()
250    ///         .set_trip(
251    ///             Trip::new().set_name(format!("providers/{provider_id}/trips/{trip_id}"))/* set fields */
252    ///         )
253    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
254    ///         .send().await?;
255    ///     println!("response {:?}", response);
256    ///     Ok(())
257    /// }
258    /// ```
259    pub fn update_trip(&self) -> super::builder::trip_service::UpdateTrip {
260        super::builder::trip_service::UpdateTrip::new(self.inner.clone())
261    }
262}
263
264/// Implements a client for the Local Rides and Deliveries API.
265///
266/// # Example
267/// ```
268/// # use google_maps_fleetengine_v1::client::VehicleService;
269/// use google_cloud_gax::paginator::ItemPaginator as _;
270/// async fn sample(
271///    parent: &str,
272/// ) -> anyhow::Result<()> {
273///     let client = VehicleService::builder().build().await?;
274///     let mut list = client.list_vehicles()
275///         .set_parent(parent)
276///         .by_item();
277///     while let Some(item) = list.next().await.transpose()? {
278///         println!("{:?}", item);
279///     }
280///     Ok(())
281/// }
282/// ```
283///
284/// # Service Description
285///
286/// Vehicle management service.
287///
288/// # Configuration
289///
290/// To configure `VehicleService` use the `with_*` methods in the type returned
291/// by [builder()][VehicleService::builder]. The default configuration should
292/// work for most applications. Common configuration changes include
293///
294/// * [with_endpoint()]: by default this client uses the global default endpoint
295///   (`https://fleetengine.googleapis.com`). Applications using regional
296///   endpoints or running in restricted networks (e.g. a network configured
297///   with [Private Google Access with VPC Service Controls]) may want to
298///   override this default.
299/// * [with_credentials()]: by default this client uses
300///   [Application Default Credentials]. Applications using custom
301///   authentication may need to override this default.
302///
303/// [with_endpoint()]: super::builder::vehicle_service::ClientBuilder::with_endpoint
304/// [with_credentials()]: super::builder::vehicle_service::ClientBuilder::with_credentials
305/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
306/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
307///
308/// # Pooling and Cloning
309///
310/// `VehicleService` holds a connection pool internally, it is advised to
311/// create one and reuse it. You do not need to wrap `VehicleService` in
312/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
313/// already uses an `Arc` internally.
314#[derive(Clone, Debug)]
315pub struct VehicleService {
316    inner: std::sync::Arc<dyn super::stub::dynamic::VehicleService>,
317}
318
319impl VehicleService {
320    /// Returns a builder for [VehicleService].
321    ///
322    /// ```
323    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
324    /// # use google_maps_fleetengine_v1::client::VehicleService;
325    /// let client = VehicleService::builder().build().await?;
326    /// # Ok(()) }
327    /// ```
328    pub fn builder() -> super::builder::vehicle_service::ClientBuilder {
329        crate::new_client_builder(super::builder::vehicle_service::client::Factory)
330    }
331
332    /// Creates a new client from the provided stub.
333    ///
334    /// The most common case for calling this function is in tests mocking the
335    /// client's behavior.
336    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
337    where
338        T: super::stub::VehicleService + 'static,
339    {
340        Self { inner: stub.into() }
341    }
342
343    pub(crate) async fn new(
344        config: gaxi::options::ClientConfig,
345    ) -> crate::ClientBuilderResult<Self> {
346        let inner = Self::build_inner(config).await?;
347        Ok(Self { inner })
348    }
349
350    async fn build_inner(
351        conf: gaxi::options::ClientConfig,
352    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::VehicleService>> {
353        if gaxi::options::tracing_enabled(&conf) {
354            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
355        }
356        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
357    }
358
359    async fn build_transport(
360        conf: gaxi::options::ClientConfig,
361    ) -> crate::ClientBuilderResult<impl super::stub::VehicleService> {
362        super::transport::VehicleService::new(conf).await
363    }
364
365    async fn build_with_tracing(
366        conf: gaxi::options::ClientConfig,
367    ) -> crate::ClientBuilderResult<impl super::stub::VehicleService> {
368        Self::build_transport(conf)
369            .await
370            .map(super::tracing::VehicleService::new)
371    }
372
373    /// Instantiates a new vehicle associated with an on-demand rideshare or
374    /// deliveries provider. Each `Vehicle` must have a unique vehicle ID.
375    ///
376    /// The following `Vehicle` fields are required when creating a `Vehicle`:
377    ///
378    /// * `vehicleState`
379    /// * `supportedTripTypes`
380    /// * `maximumCapacity`
381    /// * `vehicleType`
382    ///
383    /// The following `Vehicle` fields are ignored when creating a `Vehicle`:
384    ///
385    /// * `name`
386    /// * `currentTrips`
387    /// * `availableCapacity`
388    /// * `current_route_segment`
389    /// * `current_route_segment_end_point`
390    /// * `current_route_segment_version`
391    /// * `current_route_segment_traffic`
392    /// * `route`
393    /// * `waypoints`
394    /// * `waypoints_version`
395    /// * `remaining_distance_meters`
396    /// * `remaining_time_seconds`
397    /// * `eta_to_next_waypoint`
398    /// * `navigation_status`
399    ///
400    /// All other fields are optional and used if provided.
401    ///
402    /// # Example
403    /// ```
404    /// # use google_maps_fleetengine_v1::client::VehicleService;
405    /// use google_maps_fleetengine_v1::model::Vehicle;
406    /// use google_maps_fleetengine_v1::Result;
407    /// async fn sample(
408    ///    client: &VehicleService, parent: &str
409    /// ) -> Result<()> {
410    ///     let response = client.create_vehicle()
411    ///         .set_parent(parent)
412    ///         .set_vehicle_id("vehicle_id_value")
413    ///         .set_vehicle(
414    ///             Vehicle::new()/* set fields */
415    ///         )
416    ///         .send().await?;
417    ///     println!("response {:?}", response);
418    ///     Ok(())
419    /// }
420    /// ```
421    pub fn create_vehicle(&self) -> super::builder::vehicle_service::CreateVehicle {
422        super::builder::vehicle_service::CreateVehicle::new(self.inner.clone())
423    }
424
425    /// Returns a vehicle from the Fleet Engine.
426    ///
427    /// # Example
428    /// ```
429    /// # use google_maps_fleetengine_v1::client::VehicleService;
430    /// use google_maps_fleetengine_v1::Result;
431    /// async fn sample(
432    ///    client: &VehicleService, provider_id: &str, vehicle_id: &str
433    /// ) -> Result<()> {
434    ///     let response = client.get_vehicle()
435    ///         .set_name(format!("providers/{provider_id}/vehicles/{vehicle_id}"))
436    ///         .send().await?;
437    ///     println!("response {:?}", response);
438    ///     Ok(())
439    /// }
440    /// ```
441    pub fn get_vehicle(&self) -> super::builder::vehicle_service::GetVehicle {
442        super::builder::vehicle_service::GetVehicle::new(self.inner.clone())
443    }
444
445    /// Deletes a Vehicle from the Fleet Engine.
446    ///
447    /// Returns FAILED_PRECONDITION if the Vehicle has active Trips.
448    /// assigned to it.
449    ///
450    /// # Example
451    /// ```
452    /// # use google_maps_fleetengine_v1::client::VehicleService;
453    /// use google_maps_fleetengine_v1::Result;
454    /// async fn sample(
455    ///    client: &VehicleService, provider_id: &str, vehicle_id: &str
456    /// ) -> Result<()> {
457    ///     client.delete_vehicle()
458    ///         .set_name(format!("providers/{provider_id}/vehicles/{vehicle_id}"))
459    ///         .send().await?;
460    ///     Ok(())
461    /// }
462    /// ```
463    pub fn delete_vehicle(&self) -> super::builder::vehicle_service::DeleteVehicle {
464        super::builder::vehicle_service::DeleteVehicle::new(self.inner.clone())
465    }
466
467    /// Writes updated vehicle data to the Fleet Engine.
468    ///
469    /// When updating a `Vehicle`, the following fields cannot be updated since
470    /// they are managed by the server:
471    ///
472    /// * `currentTrips`
473    /// * `availableCapacity`
474    /// * `current_route_segment_version`
475    /// * `waypoints_version`
476    ///
477    /// The vehicle `name` also cannot be updated.
478    ///
479    /// If the `attributes` field is updated, **all** the vehicle's attributes are
480    /// replaced with the attributes provided in the request. If you want to update
481    /// only some attributes, see the `UpdateVehicleAttributes` method. Likewise,
482    /// the `waypoints` field can be updated, but must contain all the waypoints
483    /// currently on the vehicle, and no other waypoints.
484    ///
485    /// # Example
486    /// ```
487    /// # use google_maps_fleetengine_v1::client::VehicleService;
488    /// # extern crate wkt as google_cloud_wkt;
489    /// use google_cloud_wkt::FieldMask;
490    /// use google_maps_fleetengine_v1::model::Vehicle;
491    /// use google_maps_fleetengine_v1::Result;
492    /// async fn sample(
493    ///    client: &VehicleService, provider_id: &str, vehicle_id: &str
494    /// ) -> Result<()> {
495    ///     let response = client.update_vehicle()
496    ///         .set_vehicle(
497    ///             Vehicle::new().set_name(format!("providers/{provider_id}/vehicles/{vehicle_id}"))/* set fields */
498    ///         )
499    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
500    ///         .send().await?;
501    ///     println!("response {:?}", response);
502    ///     Ok(())
503    /// }
504    /// ```
505    pub fn update_vehicle(&self) -> super::builder::vehicle_service::UpdateVehicle {
506        super::builder::vehicle_service::UpdateVehicle::new(self.inner.clone())
507    }
508
509    /// Partially updates a vehicle's attributes.
510    /// Only the attributes mentioned in the request will be updated, other
511    /// attributes will NOT be altered. Note: this is different in `UpdateVehicle`,
512    /// where the whole `attributes` field will be replaced by the one in
513    /// `UpdateVehicleRequest`, attributes not in the request would be removed.
514    ///
515    /// # Example
516    /// ```
517    /// # use google_maps_fleetengine_v1::client::VehicleService;
518    /// use google_maps_fleetengine_v1::Result;
519    /// async fn sample(
520    ///    client: &VehicleService
521    /// ) -> Result<()> {
522    ///     let response = client.update_vehicle_attributes()
523    ///         /* set fields */
524    ///         .send().await?;
525    ///     println!("response {:?}", response);
526    ///     Ok(())
527    /// }
528    /// ```
529    pub fn update_vehicle_attributes(
530        &self,
531    ) -> super::builder::vehicle_service::UpdateVehicleAttributes {
532        super::builder::vehicle_service::UpdateVehicleAttributes::new(self.inner.clone())
533    }
534
535    /// Returns a paginated list of vehicles associated with
536    /// a provider that match the request options.
537    ///
538    /// # Example
539    /// ```
540    /// # use google_maps_fleetengine_v1::client::VehicleService;
541    /// use google_cloud_gax::paginator::ItemPaginator as _;
542    /// use google_maps_fleetengine_v1::Result;
543    /// async fn sample(
544    ///    client: &VehicleService, parent: &str
545    /// ) -> Result<()> {
546    ///     let mut list = client.list_vehicles()
547    ///         .set_parent(parent)
548    ///         .by_item();
549    ///     while let Some(item) = list.next().await.transpose()? {
550    ///         println!("{:?}", item);
551    ///     }
552    ///     Ok(())
553    /// }
554    /// ```
555    pub fn list_vehicles(&self) -> super::builder::vehicle_service::ListVehicles {
556        super::builder::vehicle_service::ListVehicles::new(self.inner.clone())
557    }
558
559    /// Returns a list of vehicles that match the request options.
560    ///
561    /// # Example
562    /// ```
563    /// # use google_maps_fleetengine_v1::client::VehicleService;
564    /// use google_maps_fleetengine_v1::Result;
565    /// async fn sample(
566    ///    client: &VehicleService
567    /// ) -> Result<()> {
568    ///     let response = client.search_vehicles()
569    ///         /* set fields */
570    ///         .send().await?;
571    ///     println!("response {:?}", response);
572    ///     Ok(())
573    /// }
574    /// ```
575    pub fn search_vehicles(&self) -> super::builder::vehicle_service::SearchVehicles {
576        super::builder::vehicle_service::SearchVehicles::new(self.inner.clone())
577    }
578}