// Copyright 2021 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
//
//     http://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.

syntax = "proto3";

package maps.fleetengine.v1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/maps/fleetengine/v1/fleetengine.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";

option go_package = "google.golang.org/genproto/googleapis/maps/fleetengine/v1;fleetengine";
option java_multiple_files = true;
option java_outer_classname = "Vehicles";
option java_package = "google.maps.fleetengine.v1";
option objc_class_prefix = "CFE";

// Vehicle metadata.
message Vehicle {
  option (google.api.resource) = {
    type: "fleetengine.googleapis.com/Vehicle"
    pattern: "providers/{provider}/vehicles/{vehicle}"
  };

  // Types of vehicles that may be filtered for in SearchVehicles.
  message VehicleType {
    // Vehicle type categories
    enum Category {
      // Default, used for unspecified or unrecognized vehicle types.
      UNKNOWN = 0;

      // An automobile.
      AUTO = 1;

      // Any vehicle that acts as a taxi.
      TAXI = 2;

      // Generally, a vehicle with a large storage capacity.
      TRUCK = 3;

      // A motorcycle, moped, or other two-wheeled vehicle
      TWO_WHEELER = 4;
    }

    // Vehicle type category
    Category category = 1;
  }

  // The unique name for this vehicle.
  // The format is providers/{provider}/vehicles/{vehicle}
  string name = 1;

  // The vehicle state.
  VehicleState vehicle_state = 2;

  // Supported trip types.
  repeated TripType supported_trip_types = 3;

  // List of IDs for trips in progress.
  repeated string current_trips = 4;

  // Last reported location of the vehicle.
  VehicleLocation last_location = 5;

  // Maximum capacity of the vehicle.  This is the total numbers of riders
  // on trips this vehicle can contain.  The driver is not considered in
  // this value.  This value must be greater than or equal to one.
  int32 maximum_capacity = 6;

  // The current available capacity of the vehicle.  This is the
  // maximum_capacity minus the current number of riders.
  int32 available_capacity = 7;

  // List of vehicle service attributes.
  repeated VehicleAttribute attributes = 8;

  // The type of this Vehicle.  Can be filtered during SearchVehicles.  Also
  // influences ETA and route calculations.
  VehicleType vehicle_type = 9;

  // License plate information for the vehicle.
  LicensePlate license_plate = 10;

  // Deprecated. Use vehicle.waypoint instead.
  repeated TerminalLocation route = 12 [deprecated = true];

  // The polyline specifying the route the driver app intends to take to
  // the next waypoint. Your driver app updates this every time a waypoint is
  // passed or the driver reroutes. This list is also returned in
  // Trip.current_route_segment for all active trips assigned to the vehicle.
  // Note: This field is intended only for use by the Driver SDK.
  string current_route_segment = 20;

  // Time when current_route_segment was set. This field is ignored in
  // UpdateVehicleRequests as it is calculated by the server. It should be
  // stored by client and passed in to future requests to prevent returning
  // routes to first way point that haven't changed.
  google.protobuf.Timestamp current_route_segment_version = 15;

  // The waypoint where current_route_segment ends. This can be supplied by
  // drivers on UpdateVehicle calls either as a full trip waypoint, a waypoint
  // latlnt, or as a the last latlng of the current_route_segment. FleetEngine
  // will then do its best to interpolate to an actual waypoint if it is not
  // fully specified. This field is ignored in UpdateVehicle calls unless
  // current_route_segment is also specified.
  TripWaypoint current_route_segment_end_point = 24;

  // The remaining driving distance for the 'current_route_segment'. This field
  // facilitates journey sharing between the Driver app and the Consumer app.
  // This value is updated by the Driver SDK. Fleet Engine does not update it.
  // This field is also returned in Trip.remaining_distance_meters for all
  // active trips assigned to the vehicle. The value is unspecified if the
  // `Vehicle.current_route_segment` field is empty, or if the Driver app has
  // not updated its value.
  google.protobuf.Int32Value remaining_distance_meters = 18;

  // The ETA to the next waypoint that is the first entry in Vehicle.waypoint
  // field. This field facilitates journey sharing between a Driver app and a
  // Consumer app and is updated by the Driver SDK, and Fleet Engine does not
  // update it. This field is also returned in Trip.eta_to_first_waypoint for
  // all active trips assigned to the vehicle. The value is unspecified if the
  // Vehicle.waypoint field is empty, or the Driver app has not updated its
  // value.
  google.protobuf.Timestamp eta_to_first_waypoint = 19;

  // The remaining driving time for the 'current_route_segment'. This field
  // facilitates journey sharing between the Driver app and the Consumer app.
  // This value is updated by the Driver SDK. Fleet Engine does not update it.
  // The value is unspecified if the `Vehicle.current_route_segment` field is
  // empty, or if the Driver app has not updated its value. This value should
  // match eta_to_first_waypoint - current_time if all parties are using the
  // same clock. This field is currently write-only and will not yet be
  // populated in Vehicle's get/update/search operations. When updating a
  // vehicle, if you update both eta_to_first_waypoint and
  // remaining_time_seconds in the same request, then only
  // remaining_time_seconds is considered.
  google.protobuf.Int32Value remaining_time_seconds = 25;

  // The remaining set of waypoints assigned to this Vehicle.
  repeated TripWaypoint waypoints = 22;

  // Last time the waypoints was updated. Client should cache
  // this value and pass it in GetVehicleRequest to ensure the
  // waypoints.path_to_waypoint is only returned if it is updated
  google.protobuf.Timestamp waypoints_version = 16;

  // Indicates if the driver accepts back-to-back rides. If
  // `true`, services include the vehicle for back-to-back matches.
  // If `false`, services exclude the vehicle from back-to-back matches.
  // Default value is `false`.
  bool back_to_back_enabled = 23;

  // Vehicle's navigation status.
  NavigationStatus navigation_status = 26;

  // Information about various device settings. This is internal debug only
  // field, not included in the response.
  DeviceSettings device_settings = 27;
}

// Information about the device's battery.
message BatteryInfo {
  // Status of the battery, whether full or charging etc.
  BatteryStatus battery_status = 1;

  // Status of battery power source.
  PowerSource power_source = 2;

  // Current battery percentage [0-100].
  float battery_percentage = 3;
}

// Information about various settings on the device.
message DeviceSettings {
  // How location features are set to behave on the device when battery saver is
  // on.
  LocationPowerSaveMode location_power_save_mode = 1;

  // Whether the device is currently in power save mode.
  bool is_power_save_mode = 2;

  // Whether the device is in an interactive state.
  bool is_interactive = 3;

  // Information about the battery state.
  BatteryInfo battery_info = 4;
}

// The license plate information of the Vehicle.  This is used to support
// congestion pricing restrictions in certain areas.  To avoid storing
// personally-identifiable information, only the minimum information
// about the license plate is stored as part of the entity.
message LicensePlate {
  // Required. CLDR Country/Region Code.  For example, "US" for United States,
  // or "IN" for India.
  string country_code = 1 [(google.api.field_behavior) = REQUIRED];

  // The last digit of the license plate or "-1" to denote no numeric value
  // present in the license plate.
  //
  // * "ABC 1234" -> "4"
  // * "AB 123 CD" -> "3"
  // * "ABCDEF" -> "-1"
  string last_character = 2;
}

// The state of a Vehicle.
enum VehicleState {
  // Default, used for unspecified or unrecognized vehicle states.
  UNKNOWN_VEHICLE_STATE = 0;

  // The vehicle is not accepting new trips.
  OFFLINE = 1;

  // The vehicle is accepting new trips.
  ONLINE = 2;
}

// How location features are set to behave on the device when battery saver is
// on.
// (https://developer.android.com/reference/android/os/PowerManager#getLocationPowerSaveMode())
enum LocationPowerSaveMode {
  // Undefined LocationPowerSaveMode
  UNKNOWN_LOCATION_POWER_SAVE_MODE = 0;

  // Either the location providers shouldn't be affected by battery saver, or
  // battery saver is off.
  LOCATION_MODE_NO_CHANGE = 1;

  // The GPS based location provider should be disabled when battery saver is on
  // and the device is non-interactive.
  LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF = 2;

  // All location providers should be disabled when battery saver is on and the
  // device is non-interactive.
  LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF = 3;

  // All the location providers will be kept available, but location fixes
  // should only be provided to foreground apps.
  LOCATION_MODE_FOREGROUND_ONLY = 4;

  // Location will not be turned off, but LocationManager will throttle all
  // requests to providers when the device is non-interactive.
  LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF = 5;
}

// Status of the battery, whether full or charging etc.
enum BatteryStatus {
  // Battery status unknown.
  UNKNOWN_BATTERY_STATUS = 0;

  // Battery is being charged.
  BATTERY_STATUS_CHARGING = 1;

  // Battery is discharging.
  BATTERY_STATUS_DISCHARGING = 2;

  // Battery is full.
  BATTERY_STATUS_FULL = 3;

  // Battery is not charging.
  BATTERY_STATUS_NOT_CHARGING = 4;

  // Battery is low on power.
  BATTERY_STATUS_POWER_LOW = 5;
}

// Type of the charger being used to charge the battery.
enum PowerSource {
  // Power source unknown.
  UNKNOWN_POWER_SOURCE = 0;

  // Power source is an AC charger.
  POWER_SOURCE_AC = 1;

  // Power source is a USB port.
  POWER_SOURCE_USB = 2;

  // Power source is wireless.
  POWER_SOURCE_WIRELESS = 3;

  // Battery is unplugged.
  POWER_SOURCE_UNPLUGGED = 4;
}
