オンデマンドの乗車用に Fleet Engine で車両を作成するには、CreateVehicleRequest を使用して CreateVehicle エンドポイントを使用します。このエンドポイントには、Fleet Engine オンデマンド管理者ロールを持つアカウントが必要です。
オンデマンドの乗車車両のフィールド
オンデマンドの乗車用に車両を作成する場合は、必須フィールドを設定する必要があります。また、特定の車両フィールドが Fleet Engine の他の機能に与える影響についても理解しておく必要があります。詳しくは、車両フィールドを更新するをご覧ください。
オンデマンド乗車に必要なフィールド
vehicle_state: デフォルトは不明ですが、ONLINE または OFFLINE に設定する必要があります。車両状態フィールドの設定については、車両フィールドを更新するをご覧ください。supported_trip_types: デフォルトは不明ですが、SHARED、EXCLUSIVE、またはその両方に設定する必要があります。詳しくは、オンデマンド乗車ガイドの乗車タイプをご覧ください。maximum_capacity: 車両が乗車させることができる乗客の数。運転手は含まれません(定義上)。vehicle_type: 値はAUTO、TAXI、TRUCK、TWO_WHEELER、BICYCLE、PEDESTRIANです。車両検索で車両をフィルタするために使用できます。これは、到着予定時刻とルートの計算にも影響します。Fleet Engine は、次の車両タイプ グループに基づいて、移動手段に対応するルートと移動時間の計算を提供します。AUTO、TAXI、TRUCK: たとえば、高速道路。TWO_WHEELER: たとえば、二輪車が通行できないルートは返されません。BICYCLE: 自転車専用道路など。PEDESTRIAN: 歩行者専用の橋や歩道など。
その他のフィールド
車両の作成時に設定できるその他のフィールドについては、車両フィールドを更新するをご覧ください。
車両の作成例
CreateVehicle から返される値は、作成された Vehicle エンティティです。
Java
static final String PROJECT_ID = "project-id";
VehicleServiceBlockingStub vehicleService =
    VehicleService.newBlockingStub(channel);
String parent = "providers/" + PROJECT_ID;
Vehicle vehicle = Vehicle.newBuilder()
    .setVehicleState(VehicleState.OFFLINE)  // Initial state
    .addSupportedTripTypes(TripType.EXCLUSIVE)
    .setMaximumCapacity(4)
    .setVehicleType(VehicleType.newBuilder().setCategory(VehicleType.Category.AUTO))
    .addAttributes(VehicleAttribute.newBuilder()
        .setKey("on_trip").setValue("false"))  // Opaque to the Fleet Engine
    // Add .setBackToBackEnabled(true) to make this vehicle eligible for trip
    // matching while even if it is on a trip.  By default this is disabled.
    .build();
CreateVehicleRequest createVehicleRequest =
    CreateVehicleRequest.newBuilder()  // no need for the header
        .setParent(parent)
        .setVehicleId("vid-8241890")  // Vehicle ID assigned by Rideshare or Delivery Provider
        .setVehicle(vehicle)  // Initial state
        .build();
// In this case, the Vehicle is being created in the OFFLINE state and
// no initial position is being provided.  When the Driver App checks
// in with the Rideshare or Delivery Provider, the state can be set to ONLINE and
// the Driver App will update the Vehicle Location.
try {
  Vehicle createdVehicle =
      vehicleService.createVehicle(createVehicleRequest);
} catch (StatusRuntimeException e) {
  Status s = e.getStatus();
  switch (s.getCode()) {
    case ALREADY_EXISTS:
      break;
    case PERMISSION_DENIED:
      break;
  }
  return;
}
// If no Exception, Vehicle created successfully.
REST
curl -X POST \
  "https://fleetengine.googleapis.com/v1/providers/project-id/vehicles?vehicleId=vid-8241890" \
  -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" \
  --data-binary @- << EOM
{
    "vehicleState": "OFFLINE",
    "supportedTripTypes": ["EXCLUSIVE"],
    "maximumCapacity": 4,
    "vehicleType": {"category": "AUTO"},
    "attributes": [{"key": "on_trip", "value": "false"}]
}
EOMproviders.vehicles.create リファレンスをご覧ください。