com.google.maps.fleetengine.v1.VehicleServiceClient Maven / Gradle / Ivy
Show all versions of google-maps-fleetengine Show documentation
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.maps.fleetengine.v1;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.maps.fleetengine.v1.stub.VehicleServiceStub;
import com.google.maps.fleetengine.v1.stub.VehicleServiceStubSettings;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: Vehicle management service.
*
* This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* CreateVehicleRequest request =
* CreateVehicleRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setVehicleId("vehicleId-1984135833")
* .setVehicle(Vehicle.newBuilder().build())
* .build();
* Vehicle response = vehicleServiceClient.createVehicle(request);
* }
* }
*
* Note: close() needs to be called on the VehicleServiceClient object to clean up resources such
* as threads. In the example above, try-with-resources is used, which automatically calls close().
*
*
* Methods
*
* Method
* Description
* Method Variants
*
*
* 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`:
*
* - `vehicleState`
*
- `supportedTripTypes`
*
- `maximumCapacity`
*
- `vehicleType`
*
* The following `Vehicle` fields are ignored when creating a `Vehicle`:
*
* - `name`
*
- `currentTrips`
*
- `availableCapacity`
*
- `current_route_segment`
*
- `current_route_segment_end_point`
*
- `current_route_segment_version`
*
- `current_route_segment_traffic`
*
- `route`
*
- `waypoints`
*
- `waypoints_version`
*
- `remaining_distance_meters`
*
- `remaining_time_seconds`
*
- `eta_to_next_waypoint`
*
- `navigation_status`
*
* All other fields are optional and used if provided.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* createVehicle(CreateVehicleRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* createVehicleCallable()
*
*
*
*
* GetVehicle
* Returns a vehicle from the Fleet Engine.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* getVehicle(GetVehicleRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* getVehicleCallable()
*
*
*
*
* 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:
*
* - `currentTrips`
*
- `availableCapacity`
*
- `current_route_segment_version`
*
- `waypoints_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.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* updateVehicle(UpdateVehicleRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* updateVehicleCallable()
*
*
*
*
* 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.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* updateVehicleAttributes(UpdateVehicleAttributesRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* updateVehicleAttributesCallable()
*
*
*
*
* ListVehicles
* Returns a paginated list of vehicles associated with a provider that match the request options.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* listVehicles(ListVehiclesRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* listVehiclesPagedCallable()
*
listVehiclesCallable()
*
*
*
*
* SearchVehicles
* Returns a list of vehicles that match the request options.
*
* Request object method variants only take one parameter, a request object, which must be constructed before the call.
*
* searchVehicles(SearchVehiclesRequest request)
*
* Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
*
* searchVehiclesCallable()
*
*
*
*
*
* See the individual methods for example code.
*
*
Many parameters require resource names to be formatted in a particular way. To assist with
* these names, this class includes a format method for each type of name, and additionally a parse
* method to extract the individual identifiers contained within names that are returned.
*
*
This class can be customized by passing in a custom instance of VehicleServiceSettings to
* create(). For example:
*
*
To customize credentials:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* VehicleServiceSettings vehicleServiceSettings =
* VehicleServiceSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create(vehicleServiceSettings);
* }
*
* To customize the endpoint:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* VehicleServiceSettings vehicleServiceSettings =
* VehicleServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
* VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create(vehicleServiceSettings);
* }
*
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class VehicleServiceClient implements BackgroundResource {
private final VehicleServiceSettings settings;
private final VehicleServiceStub stub;
/** Constructs an instance of VehicleServiceClient with default settings. */
public static final VehicleServiceClient create() throws IOException {
return create(VehicleServiceSettings.newBuilder().build());
}
/**
* Constructs an instance of VehicleServiceClient, using the given settings. The channels are
* created based on the settings passed in, or defaults for any settings that are not set.
*/
public static final VehicleServiceClient create(VehicleServiceSettings settings)
throws IOException {
return new VehicleServiceClient(settings);
}
/**
* Constructs an instance of VehicleServiceClient, using the given stub for making calls. This is
* for advanced usage - prefer using create(VehicleServiceSettings).
*/
public static final VehicleServiceClient create(VehicleServiceStub stub) {
return new VehicleServiceClient(stub);
}
/**
* Constructs an instance of VehicleServiceClient, using the given settings. This is protected so
* that it is easy to make a subclass, but otherwise, the static factory methods should be
* preferred.
*/
protected VehicleServiceClient(VehicleServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((VehicleServiceStubSettings) settings.getStubSettings()).createStub();
}
protected VehicleServiceClient(VehicleServiceStub stub) {
this.settings = null;
this.stub = stub;
}
public final VehicleServiceSettings getSettings() {
return settings;
}
public VehicleServiceStub getStub() {
return stub;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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`:
*
*
* - `vehicleState`
*
- `supportedTripTypes`
*
- `maximumCapacity`
*
- `vehicleType`
*
*
* The following `Vehicle` fields are ignored when creating a `Vehicle`:
*
*
* - `name`
*
- `currentTrips`
*
- `availableCapacity`
*
- `current_route_segment`
*
- `current_route_segment_end_point`
*
- `current_route_segment_version`
*
- `current_route_segment_traffic`
*
- `route`
*
- `waypoints`
*
- `waypoints_version`
*
- `remaining_distance_meters`
*
- `remaining_time_seconds`
*
- `eta_to_next_waypoint`
*
- `navigation_status`
*
*
* All other fields are optional and used if provided.
*
*
Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* CreateVehicleRequest request =
* CreateVehicleRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setVehicleId("vehicleId-1984135833")
* .setVehicle(Vehicle.newBuilder().build())
* .build();
* Vehicle response = vehicleServiceClient.createVehicle(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Vehicle createVehicle(CreateVehicleRequest request) {
return createVehicleCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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`:
*
*
* - `vehicleState`
*
- `supportedTripTypes`
*
- `maximumCapacity`
*
- `vehicleType`
*
*
* The following `Vehicle` fields are ignored when creating a `Vehicle`:
*
*
* - `name`
*
- `currentTrips`
*
- `availableCapacity`
*
- `current_route_segment`
*
- `current_route_segment_end_point`
*
- `current_route_segment_version`
*
- `current_route_segment_traffic`
*
- `route`
*
- `waypoints`
*
- `waypoints_version`
*
- `remaining_distance_meters`
*
- `remaining_time_seconds`
*
- `eta_to_next_waypoint`
*
- `navigation_status`
*
*
* All other fields are optional and used if provided.
*
*
Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* CreateVehicleRequest request =
* CreateVehicleRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setVehicleId("vehicleId-1984135833")
* .setVehicle(Vehicle.newBuilder().build())
* .build();
* ApiFuture future = vehicleServiceClient.createVehicleCallable().futureCall(request);
* // Do something.
* Vehicle response = future.get();
* }
* }
*/
public final UnaryCallable createVehicleCallable() {
return stub.createVehicleCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a vehicle from the Fleet Engine.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* GetVehicleRequest request =
* GetVehicleRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setName(VehicleName.of("[PROVIDER]", "[VEHICLE]").toString())
* .setCurrentRouteSegmentVersion(Timestamp.newBuilder().build())
* .setWaypointsVersion(Timestamp.newBuilder().build())
* .build();
* Vehicle response = vehicleServiceClient.getVehicle(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Vehicle getVehicle(GetVehicleRequest request) {
return getVehicleCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a vehicle from the Fleet Engine.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* GetVehicleRequest request =
* GetVehicleRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setName(VehicleName.of("[PROVIDER]", "[VEHICLE]").toString())
* .setCurrentRouteSegmentVersion(Timestamp.newBuilder().build())
* .setWaypointsVersion(Timestamp.newBuilder().build())
* .build();
* ApiFuture future = vehicleServiceClient.getVehicleCallable().futureCall(request);
* // Do something.
* Vehicle response = future.get();
* }
* }
*/
public final UnaryCallable getVehicleCallable() {
return stub.getVehicleCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
* - `currentTrips`
*
- `availableCapacity`
*
- `current_route_segment_version`
*
- `waypoints_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.
*
*
Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* UpdateVehicleRequest request =
* UpdateVehicleRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setName("name3373707")
* .setVehicle(Vehicle.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* Vehicle response = vehicleServiceClient.updateVehicle(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Vehicle updateVehicle(UpdateVehicleRequest request) {
return updateVehicleCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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:
*
*
* - `currentTrips`
*
- `availableCapacity`
*
- `current_route_segment_version`
*
- `waypoints_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.
*
*
Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* UpdateVehicleRequest request =
* UpdateVehicleRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setName("name3373707")
* .setVehicle(Vehicle.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture future = vehicleServiceClient.updateVehicleCallable().futureCall(request);
* // Do something.
* Vehicle response = future.get();
* }
* }
*/
public final UnaryCallable updateVehicleCallable() {
return stub.updateVehicleCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* UpdateVehicleAttributesRequest request =
* UpdateVehicleAttributesRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setName("name3373707")
* .addAllAttributes(new ArrayList())
* .build();
* UpdateVehicleAttributesResponse response =
* vehicleServiceClient.updateVehicleAttributes(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final UpdateVehicleAttributesResponse updateVehicleAttributes(
UpdateVehicleAttributesRequest request) {
return updateVehicleAttributesCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* 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.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* UpdateVehicleAttributesRequest request =
* UpdateVehicleAttributesRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setName("name3373707")
* .addAllAttributes(new ArrayList())
* .build();
* ApiFuture future =
* vehicleServiceClient.updateVehicleAttributesCallable().futureCall(request);
* // Do something.
* UpdateVehicleAttributesResponse response = future.get();
* }
* }
*/
public final UnaryCallable
updateVehicleAttributesCallable() {
return stub.updateVehicleAttributesCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a paginated list of vehicles associated with a provider that match the request options.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* ListVehiclesRequest request =
* ListVehiclesRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setMinimumCapacity(Int32Value.newBuilder().build())
* .addAllTripTypes(new ArrayList())
* .setMaximumStaleness(Duration.newBuilder().build())
* .addAllVehicleTypeCategories(new ArrayList())
* .addAllRequiredAttributes(new ArrayList())
* .addAllRequiredOneOfAttributes(new ArrayList())
* .addAllRequiredOneOfAttributeSets(new ArrayList())
* .setVehicleState(VehicleState.forNumber(0))
* .setOnTripOnly(true)
* .setFilter("filter-1274492040")
* .setViewport(Viewport.newBuilder().build())
* .build();
* for (Vehicle element : vehicleServiceClient.listVehicles(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListVehiclesPagedResponse listVehicles(ListVehiclesRequest request) {
return listVehiclesPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a paginated list of vehicles associated with a provider that match the request options.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* ListVehiclesRequest request =
* ListVehiclesRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setMinimumCapacity(Int32Value.newBuilder().build())
* .addAllTripTypes(new ArrayList())
* .setMaximumStaleness(Duration.newBuilder().build())
* .addAllVehicleTypeCategories(new ArrayList())
* .addAllRequiredAttributes(new ArrayList())
* .addAllRequiredOneOfAttributes(new ArrayList())
* .addAllRequiredOneOfAttributeSets(new ArrayList())
* .setVehicleState(VehicleState.forNumber(0))
* .setOnTripOnly(true)
* .setFilter("filter-1274492040")
* .setViewport(Viewport.newBuilder().build())
* .build();
* ApiFuture future =
* vehicleServiceClient.listVehiclesPagedCallable().futureCall(request);
* // Do something.
* for (Vehicle element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listVehiclesPagedCallable() {
return stub.listVehiclesPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a paginated list of vehicles associated with a provider that match the request options.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* ListVehiclesRequest request =
* ListVehiclesRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setMinimumCapacity(Int32Value.newBuilder().build())
* .addAllTripTypes(new ArrayList())
* .setMaximumStaleness(Duration.newBuilder().build())
* .addAllVehicleTypeCategories(new ArrayList())
* .addAllRequiredAttributes(new ArrayList())
* .addAllRequiredOneOfAttributes(new ArrayList())
* .addAllRequiredOneOfAttributeSets(new ArrayList())
* .setVehicleState(VehicleState.forNumber(0))
* .setOnTripOnly(true)
* .setFilter("filter-1274492040")
* .setViewport(Viewport.newBuilder().build())
* .build();
* while (true) {
* ListVehiclesResponse response = vehicleServiceClient.listVehiclesCallable().call(request);
* for (Vehicle element : response.getVehiclesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable listVehiclesCallable() {
return stub.listVehiclesCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of vehicles that match the request options.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* SearchVehiclesRequest request =
* SearchVehiclesRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setPickupPoint(TerminalLocation.newBuilder().build())
* .setDropoffPoint(TerminalLocation.newBuilder().build())
* .setPickupRadiusMeters(-254656044)
* .setCount(94851343)
* .setMinimumCapacity(518841803)
* .addAllTripTypes(new ArrayList())
* .setMaximumStaleness(Duration.newBuilder().build())
* .addAllVehicleTypes(new ArrayList())
* .addAllRequiredAttributes(new ArrayList())
* .addAllRequiredOneOfAttributes(new ArrayList())
* .addAllRequiredOneOfAttributeSets(new ArrayList())
* .setIncludeBackToBack(true)
* .setTripId("tripId-865466336")
* .setFilter("filter-1274492040")
* .build();
* SearchVehiclesResponse response = vehicleServiceClient.searchVehicles(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final SearchVehiclesResponse searchVehicles(SearchVehiclesRequest request) {
return searchVehiclesCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of vehicles that match the request options.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (VehicleServiceClient vehicleServiceClient = VehicleServiceClient.create()) {
* SearchVehiclesRequest request =
* SearchVehiclesRequest.newBuilder()
* .setHeader(RequestHeader.newBuilder().build())
* .setParent("parent-995424086")
* .setPickupPoint(TerminalLocation.newBuilder().build())
* .setDropoffPoint(TerminalLocation.newBuilder().build())
* .setPickupRadiusMeters(-254656044)
* .setCount(94851343)
* .setMinimumCapacity(518841803)
* .addAllTripTypes(new ArrayList())
* .setMaximumStaleness(Duration.newBuilder().build())
* .addAllVehicleTypes(new ArrayList())
* .addAllRequiredAttributes(new ArrayList())
* .addAllRequiredOneOfAttributes(new ArrayList())
* .addAllRequiredOneOfAttributeSets(new ArrayList())
* .setIncludeBackToBack(true)
* .setTripId("tripId-865466336")
* .setFilter("filter-1274492040")
* .build();
* ApiFuture future =
* vehicleServiceClient.searchVehiclesCallable().futureCall(request);
* // Do something.
* SearchVehiclesResponse response = future.get();
* }
* }
*/
public final UnaryCallable
searchVehiclesCallable() {
return stub.searchVehiclesCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListVehiclesPagedResponse
extends AbstractPagedListResponse<
ListVehiclesRequest,
ListVehiclesResponse,
Vehicle,
ListVehiclesPage,
ListVehiclesFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListVehiclesPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListVehiclesPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListVehiclesPagedResponse(ListVehiclesPage page) {
super(page, ListVehiclesFixedSizeCollection.createEmptyCollection());
}
}
public static class ListVehiclesPage
extends AbstractPage {
private ListVehiclesPage(
PageContext context,
ListVehiclesResponse response) {
super(context, response);
}
private static ListVehiclesPage createEmptyPage() {
return new ListVehiclesPage(null, null);
}
@Override
protected ListVehiclesPage createPage(
PageContext context,
ListVehiclesResponse response) {
return new ListVehiclesPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListVehiclesFixedSizeCollection
extends AbstractFixedSizeCollection<
ListVehiclesRequest,
ListVehiclesResponse,
Vehicle,
ListVehiclesPage,
ListVehiclesFixedSizeCollection> {
private ListVehiclesFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListVehiclesFixedSizeCollection createEmptyCollection() {
return new ListVehiclesFixedSizeCollection(null, 0);
}
@Override
protected ListVehiclesFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListVehiclesFixedSizeCollection(pages, collectionSize);
}
}
}