pub struct VehicleService { /* private fields */ }Expand description
Implements a client for the Local Rides and Deliveries API.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
async fn sample(
parent: &str,
) -> anyhow::Result<()> {
let client = VehicleService::builder().build().await?;
let mut list = client.list_vehicles()
.set_parent(parent)
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}§Service Description
Vehicle management service.
§Configuration
To configure VehicleService use the with_* methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://fleetengine.googleapis.com). Applications using regional endpoints or running in restricted networks (e.g. a network configured with Private Google Access with VPC Service Controls) may want to override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
VehicleService holds a connection pool internally, it is advised to
create one and reuse it. You do not need to wrap VehicleService in
an Rc or Arc to reuse it, because it
already uses an Arc internally.
Implementations§
Source§impl VehicleService
impl VehicleService
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for VehicleService.
let client = VehicleService::builder().build().await?;Sourcepub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: VehicleService + 'static,
pub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: VehicleService + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn create_vehicle(&self) -> CreateVehicle
pub fn create_vehicle(&self) -> CreateVehicle
Instantiates a new vehicle associated with an on-demand rideshare or
deliveries provider. Each Vehicle must have a unique vehicle ID.
The following Vehicle fields are required when creating a Vehicle:
vehicleStatesupportedTripTypesmaximumCapacityvehicleType
The following Vehicle fields are ignored when creating a Vehicle:
namecurrentTripsavailableCapacitycurrent_route_segmentcurrent_route_segment_end_pointcurrent_route_segment_versioncurrent_route_segment_trafficroutewaypointswaypoints_versionremaining_distance_metersremaining_time_secondseta_to_next_waypointnavigation_status
All other fields are optional and used if provided.
§Example
use google_maps_fleetengine_v1::model::Vehicle;
use google_maps_fleetengine_v1::Result;
async fn sample(
client: &VehicleService, parent: &str
) -> Result<()> {
let response = client.create_vehicle()
.set_parent(parent)
.set_vehicle_id("vehicle_id_value")
.set_vehicle(
Vehicle::new()/* set fields */
)
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn get_vehicle(&self) -> GetVehicle
pub fn get_vehicle(&self) -> GetVehicle
Returns a vehicle from the Fleet Engine.
§Example
use google_maps_fleetengine_v1::Result;
async fn sample(
client: &VehicleService, provider_id: &str, vehicle_id: &str
) -> Result<()> {
let response = client.get_vehicle()
.set_name(format!("providers/{provider_id}/vehicles/{vehicle_id}"))
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn delete_vehicle(&self) -> DeleteVehicle
pub fn delete_vehicle(&self) -> DeleteVehicle
Deletes a Vehicle from the Fleet Engine.
Returns FAILED_PRECONDITION if the Vehicle has active Trips. assigned to it.
§Example
use google_maps_fleetengine_v1::Result;
async fn sample(
client: &VehicleService, provider_id: &str, vehicle_id: &str
) -> Result<()> {
client.delete_vehicle()
.set_name(format!("providers/{provider_id}/vehicles/{vehicle_id}"))
.send().await?;
Ok(())
}Sourcepub fn update_vehicle(&self) -> UpdateVehicle
pub fn update_vehicle(&self) -> UpdateVehicle
Writes updated vehicle data to the Fleet Engine.
When updating a Vehicle, the following fields cannot be updated since
they are managed by the server:
currentTripsavailableCapacitycurrent_route_segment_versionwaypoints_version
The vehicle name also cannot be updated.
If the attributes field is updated, all the vehicle’s attributes are
replaced with the attributes provided in the request. If you want to update
only some attributes, see the UpdateVehicleAttributes method. Likewise,
the waypoints field can be updated, but must contain all the waypoints
currently on the vehicle, and no other waypoints.
§Example
use google_cloud_wkt::FieldMask;
use google_maps_fleetengine_v1::model::Vehicle;
use google_maps_fleetengine_v1::Result;
async fn sample(
client: &VehicleService, provider_id: &str, vehicle_id: &str
) -> Result<()> {
let response = client.update_vehicle()
.set_vehicle(
Vehicle::new().set_name(format!("providers/{provider_id}/vehicles/{vehicle_id}"))/* set fields */
)
.set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn update_vehicle_attributes(&self) -> UpdateVehicleAttributes
pub fn update_vehicle_attributes(&self) -> UpdateVehicleAttributes
Partially updates a vehicle’s attributes.
Only the attributes mentioned in the request will be updated, other
attributes will NOT be altered. Note: this is different in UpdateVehicle,
where the whole attributes field will be replaced by the one in
UpdateVehicleRequest, attributes not in the request would be removed.
§Example
use google_maps_fleetengine_v1::Result;
async fn sample(
client: &VehicleService
) -> Result<()> {
let response = client.update_vehicle_attributes()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn list_vehicles(&self) -> ListVehicles
pub fn list_vehicles(&self) -> ListVehicles
Returns a paginated list of vehicles associated with a provider that match the request options.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
use google_maps_fleetengine_v1::Result;
async fn sample(
client: &VehicleService, parent: &str
) -> Result<()> {
let mut list = client.list_vehicles()
.set_parent(parent)
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}Sourcepub fn search_vehicles(&self) -> SearchVehicles
pub fn search_vehicles(&self) -> SearchVehicles
Returns a list of vehicles that match the request options.
§Example
use google_maps_fleetengine_v1::Result;
async fn sample(
client: &VehicleService
) -> Result<()> {
let response = client.search_vehicles()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Trait Implementations§
Source§impl Clone for VehicleService
impl Clone for VehicleService
Source§fn clone(&self) -> VehicleService
fn clone(&self) -> VehicleService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more