syntax = "proto3"; option csharp_namespace = "vestige.api.v1"; package vestige.api.v1; import "google/protobuf/timestamp.proto"; service ApiService { rpc GetAssets (GetAssetsRequest) returns (GetAssetsReply); rpc GetAssetStatuses (GetAssetStatusRequest) returns (GetAssetStatusReply); rpc GetAssetExtendedProperties (GetAssetExtendedPropertiesRequest) returns (GetAssetExtendedPropertiesReply); rpc GetAssetDiagnosticTroubleCodeDailyBuckets (GetAssetDiagnosticTroubleCodeDailyBucketsRequest) returns (GetAssetDiagnosticTroubleCodeDailyBucketsReply); rpc GetDrivers (GetDriversRequest) returns (GetDriversReply); rpc PushDriverAssignment (PushDriverAssignmentRequest) returns (PushDriverAssignmentReply); rpc UnassignVehicle (UnassignVehicleRequest) returns (UnassignVehicleReply); rpc UnassignDriver (UnassignDriverRequest) returns (UnassignDriverReply); rpc GetDriverCoachingWorklist (GetDriverCoachingWorklistRequest) returns (GetDriverCoachingWorklistReply); rpc GetFleetSafeDriving (GetFleetSafeDrivingRequest) returns (GetFleetSafeDrivingReply); } message GetAssetsRequest{} message GetAssetsReply{ repeated Asset Assets = 1; message Asset{ string Id = 1; string Name = 2; } } message GetAssetStatusRequest{ string AssetId = 1; repeated AssetStatusTypes StatusTypes = 2; } message GetAssetStatusReply{ optional OdometerStatus Odometer = 1; optional IgnitionStatus Ignition = 2; optional LocationStatus Location = 3; optional EngineOnDurationStatus EngineOnDuration = 4; optional EngineBatteryLevelStatus EngineBatteryLevel = 5; message OdometerStatus{ google.protobuf.Timestamp Date = 1; double Value = 2; //kilometers } message EngineOnDurationStatus{ google.protobuf.Timestamp Date = 1; double Value = 2; //hours } message IgnitionStatus{ google.protobuf.Timestamp Date = 1; bool Value = 2; } message LocationStatus{ google.protobuf.Timestamp Date = 1; string Address = 2; optional double Latitude = 3; optional double Longitude = 4; optional double Speed = 5; //km/h string DisplayName = 6; } message EngineBatteryLevelStatus{ google.protobuf.Timestamp Date = 1; double Value = 2; //volts } } enum AssetStatusTypes { NONE = 0; ODOMETER = 1; IGNITION = 2; LOCATION = 3; ENGINEONDURATION = 4; ENGINEBATTERYLEVEL = 5; } message GetAssetExtendedPropertiesRequest{ string AssetId = 1; repeated string Keys = 2; } message GetAssetExtendedPropertiesReply{ repeated AssetExtendedProperty Properties = 1; } message AssetExtendedProperty{ string Key = 1; string Value = 2; } message GetAssetDiagnosticTroubleCodeDailyBucketsRequest{ string AssetId = 1; string FromDate = 2; string ToDate = 3; } message GetAssetDiagnosticTroubleCodeDailyBucketsReply{ repeated GetAssetDiagnosticTroubleCodeDailyBucketsReplyItem Items = 1; message GetAssetDiagnosticTroubleCodeDailyBucketsReplyItem{ string Date = 1; repeated Code Codes = 2; message Code{ string Code = 1; } } } //GetAssets omits drivers, so this is where a driver's Id comes from. message GetDriversRequest{} message GetDriversReply{ repeated Driver Drivers = 1; message Driver{ string Id = 1; string Name = 2; } } message PushDriverAssignmentRequest{ string VehicleId = 1; //Id from GetAssets string DriverId = 2; //Id from GetDrivers google.protobuf.Timestamp Date = 3; //when the driver took the vehicle; whole seconds, sub-second is rejected } message PushDriverAssignmentReply{ bool Accepted = 1; //queued for processing, not yet applied } //Unassignment is one-sided, so there are two separate calls rather than one with optional fields. //UnassignVehicle says the vehicle has no driver; it does not say where its previous driver went. //UnassignDriver says the driver has no vehicle; it does not say who now has the vehicle they left. message UnassignVehicleRequest{ string VehicleId = 1; //Id from GetAssets google.protobuf.Timestamp Date = 2; //whole seconds, sub-second is rejected } message UnassignVehicleReply{ bool Accepted = 1; //queued for processing, not yet applied } message UnassignDriverRequest{ string DriverId = 1; //Id from GetDrivers google.protobuf.Timestamp Date = 2; //whole seconds, sub-second is rejected } message UnassignDriverReply{ bool Accepted = 1; //queued for processing, not yet applied } //Driver Coaching. PREVIEW: every account gets the same sample fleet, not its own data, and every //reply says so in SampleData. For trying an integration, not for building on. //Who has to move next. Values carry the enum's name because proto3 enum values share one scope. enum DriverCoachingQueue { DRIVER_COACHING_QUEUE_ALL = 0; //in a request: all three DRIVER_COACHING_QUEUE_WAITING_ON_YOU = 1; //a manager: a review, or a dispute to answer DRIVER_COACHING_QUEUE_WAITING_ON_DRIVERS = 2; //the driver: released, not yet acknowledged or disputed DRIVER_COACHING_QUEUE_WAITING_ON_ASSIGNMENT = 3; //nobody: the driver assignment window is still open } message GetDriverCoachingWorklistRequest{ DriverCoachingQueue Queue = 1; //leave out for all three string DriverId = 2; //optional: only this driver's items } //Soonest deadline first within each queue; queues in the order of the enum. No date window: the //oldest item waiting is the most urgent. message GetDriverCoachingWorklistReply{ bool SampleData = 1; //true: the sample fleet, not this account's data repeated Item Items = 2; message Item{ string EventId = 1; DriverCoachingQueue Queue = 2; string Status = 3; //PendingReview, Disputed, Released or Settling google.protobuf.Timestamp OccurredAt = 4; optional google.protobuf.Timestamp DueAt = 5; //when the wait runs out string DriverId = 6; string DriverName = 7; string VehicleId = 8; string VehicleName = 9; string EventTypeId = 10; //e.g. harsh-brake string EventTypeName = 11; //e.g. Harsh Brake string Address = 12; double Speed = 13; //km/h int32 RepetitionCount = 14; //same-type events by this driver inside the policy window, this one included bool FootageAvailable = 15; optional google.protobuf.Timestamp DisputedAt = 16; string DisputeComment = 17; //the driver's words, when disputed } } message GetFleetSafeDrivingRequest{ string Period = 1; //"last30" (the default) or a calendar month as "yyyy-MM" } //The Fleet safe driving card on the Fleet Safety dashboard. Rates are safety events per 1,000 miles, //as the bands are defined; lower is better. message GetFleetSafeDrivingReply{ bool SampleData = 1; //true: the sample fleet, not this account's data Window Period = 2; optional double SafetyEventsPer1000Miles = 3; //missing when the fleet drove too little to quote one optional Band FleetBand = 4; repeated Band Bands = 5; //all five, best first; empty until the account sets its limits optional NextBand Next = 6; //missing in the best band int32 SafetyEvents = 7; double Distance = 8; //km double DistanceMiles = 9; optional int64 MilesBetweenSafetyEvents = 10; int32 DriversRated = 11; int32 DriversTotal = 12; //the rest drove too little in the window to be rated repeated TrendWeek Trend = 13; //the last eight weeks, oldest first; does not follow Period optional double TrendChange = 14; //the newer half of Trend against the older half; negative is better message Window{ string Key = 1; //last30 or yyyy-MM string Label = 2; //e.g. "Last 30 days" string FromDate = 3; //yyyy-MM-dd string ToDate = 4; //yyyy-MM-dd int32 Days = 5; bool MonthToDate = 6; //the month is still running } message Band{ string Key = 1; //top, upper, middle, lower or bottom: the position, which never changes string Name = 2; //what the account calls it, e.g. Five Star optional double UpperLimit = 3; //safety events per 1,000 miles; missing for the bottom band } message NextBand{ string Key = 1; string Name = 2; double Gap = 3; //how much lower the rate must go, per 1,000 miles } message TrendWeek{ string WeekOf = 1; //yyyy-MM-dd, the day the week starts int32 SafetyEvents = 2; double DistanceMiles = 3; optional double SafetyEventsPer1000Miles = 4; int32 Pending = 5; //events still waiting on a decision; above zero, the week can still rise } }