Skip to content

Commit 30afbd1

Browse files
committed
refactor(Push-v2): add protobuf docs
1 parent 38cb8ca commit 30afbd1

File tree

1 file changed

+126
-10
lines changed

1 file changed

+126
-10
lines changed

push-v2.md

+126-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Events are sent in bulk and should only be rejected in case you have issues pars
1111

1212
Events are sent at-least once, meaning there might be duplicates.
1313

14-
## Event types
14+
## Event types - JSON
1515

1616
There's two different event types; vehicle events and admin events.
1717

@@ -1256,15 +1256,6 @@ Example:
12561256

12571257
#### car_service_booking
12581258

1259-
##### BookingStatus enum
1260-
1261-
| Value | Description |
1262-
|----------|-------------|
1263-
| `NEW` | The booking is newly created. |
1264-
| `CHANGED`| The booking has been modified. |
1265-
| `CANCELLED` | The booking has been cancelled. |
1266-
1267-
12681259
Represents a car service booking record with the status of the booking and the appointment date.
12691260

12701261
| Name | Type | Unit/Format | Example | Description | Nullable |
@@ -1304,6 +1295,131 @@ Example:
13041295
]
13051296
```
13061297

1298+
## Event types - Protobuf
1299+
1300+
Sending events via Protobuf is also supported. Vehicle event types follow a similar structure to their JSON counterparts.
1301+
1302+
- Syntax: `"proto3"`
1303+
- Timestamps: `google.protobuf.Timestamp`,
1304+
- For a Pub/Sub example, refer to the [Google Cloud Pub/Sub documentation](https://cloud.google.com/pubsub/docs/samples/pubsub-subscribe-proto-messages#pubsub_subscribe_proto_messages-cpp).
1305+
1306+
#### Vehicle event types
1307+
1308+
1309+
Besides the `google.protobuf.Timestamp`, Protobuf files are self-contained. The base structure of most vehicle event types follows the following message definition:
1310+
```proto
1311+
message GenericVehicleEventType {
1312+
string type = 1; // String enum describing event type, see types below
1313+
int64 id = 2; // An auto incrementing ID, not unique per event since each shard has their own counter
1314+
int64 vehicle_id = 4; // ID of the associated vehicle
1315+
google.protobuf.Timestamp time = 5; // Timestamp
1316+
}
1317+
```
1318+
1319+
Note on `google.protobuf.Timestamp`: This is a requirement but if you encounter issues with Schema creations, it can be replaced to be a self contained message.
1320+
This is a known limitation of Pub/Sub topic schema creation [Google Cloud Pub/Sub documentation](https://cloud.google.com/pubsub/docs/schemas#schema-info).
1321+
```proto
1322+
message GenericVehicleEventType {
1323+
string type = 1; // String enum describing event type, see types below
1324+
int64 id = 2; // An auto incrementing ID, not unique per event since each shard has their own counter
1325+
int64 vehicle_id = 4; // ID of the associated vehicle
1326+
message Timestamp {
1327+
// Represents seconds of UTC time since Unix epoch
1328+
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
1329+
// 9999-12-31T23:59:59Z inclusive.
1330+
int64 seconds = 1;
1331+
1332+
// Non-negative fractions of a second at nanosecond resolution. Negative
1333+
// second values with fractions must still have non-negative nanos values
1334+
// that count forward in time. Must be from 0 to 999,999,999
1335+
// inclusive.
1336+
int32 nanos = 2;
1337+
}
1338+
Timestamp time = 5;
1339+
}
1340+
```
1341+
1342+
1343+
1344+
1345+
### CanOdometerKm
1346+
The odometer from the CAN of the vehicle in kilometers
1347+
```proto
1348+
syntax = "proto3";
1349+
1350+
package cc.protobuf.vehicle.v1;
1351+
1352+
import "google/protobuf/timestamp.proto";
1353+
1354+
message CanOdometerKm {
1355+
string type = 1; // Message type "can_odometer_km"
1356+
int64 id = 2; // Unique identifier for the reading
1357+
int64 value = 3; // Odometer value (in kilometers)
1358+
int64 vehicle_id = 4; // ID of the associated vehicle
1359+
google.protobuf.Timestamp time = 5; // Timestamp
1360+
}
1361+
```
1362+
1363+
1364+
1365+
### CanNextServiceKm
1366+
Kilometers until next service
1367+
```proto
1368+
syntax = "proto3";
1369+
1370+
package cc.protobuf.vehicle.v1;
1371+
1372+
import "google/protobuf/timestamp.proto";
1373+
1374+
message CanNextServiceKm {
1375+
string type = 1; // Message type "can_next_service_km"
1376+
int64 id = 2; // Unique identifier for the service entry
1377+
int64 value = 3; // Remaining kilometers until the next service
1378+
int64 vehicle_id = 4; // ID of the associated vehicle
1379+
google.protobuf.Timestamp time = 5; // Timestamp
1380+
}
1381+
```
1382+
1383+
1384+
### CarServiceBookings
1385+
Represents a car service booking record with the status of the booking and the appointment date.
1386+
See [BookingStatus](#bookingstatus-enum) for possible `booking_status` values
1387+
```proto
1388+
syntax = "proto3";
1389+
1390+
package cc.protobuf.booking.v1;
1391+
1392+
import "google/protobuf/timestamp.proto";
1393+
1394+
message CarServiceBooking {
1395+
int64 id = 1; // Unique identifier for the car service booking record
1396+
string booking_source = 2; // Source of the booking
1397+
string booking_id = 3; // Booking ID from the booking system
1398+
string booking_status = 4; // Booking status
1399+
string booking_dealer = 5; // Dealer number, KVPS or similar for the booking
1400+
int64 vehicle_id = 6; // ID of the associated vehicle
1401+
string vin = 7; // Vehicle identification number
1402+
int64 fleet_id = 8; // Fleet ID (optional)
1403+
string fleet_external_reference = 9; // Fleet external reference (optional)
1404+
string reason_key = 10; // Reason key for booking (optional)
1405+
string reason_text = 11; // Reason text for booking (optional)
1406+
int64 workshop_id = 12; // Workshop ID (optional)
1407+
google.protobuf.Timestamp appointment_date = 13; // Timestamp of the booking in UTC
1408+
google.protobuf.Timestamp created_date = 14; // Timestamp of the record creation in UTC
1409+
}
1410+
```
1411+
1412+
1413+
## Enum Types
1414+
1415+
### BookingStatus
1416+
1417+
| Value | Description |
1418+
|----------|-------------|
1419+
| `NEW` | The booking is newly created. |
1420+
| `CHANGED`| The booking has been modified. |
1421+
| `CANCELLED` | The booking has been cancelled. |
1422+
13071423

13081424
## Managing vehicle data streams
13091425

0 commit comments

Comments
 (0)