syntax = "proto2"; import "extend.proto"; /** * Booking related messages. * * This file is really just an example. The data model is completely fictional. */ package com.pseudomuto.protokit.v1; option (com.pseudomuto.protokit.v1.extend_file) = true; /** * Service for handling vehicle bookings. */ service BookingService { option (com.pseudomuto.protokit.v1.extend_service) = true; /// Used to book a vehicle. Pass in a Booking and a BookingStatus will be returned. rpc BookVehicle (Booking) returns (BookingStatus) { option (com.pseudomuto.protokit.v1.extend_method) = true; }; } /** * Represents the status of a vehicle booking. */ message BookingStatus { /** * A flag for the status result. */ enum StatusCode { OK = 200; // OK result. BAD_REQUEST = 400; // BAD result. } required int32 id = 1; /// Unique booking status ID. required string description = 2; /// Booking status description. E.g. "Active". optional StatusCode status_code = 3; /// The status of this status? extensions 100 to max; } // File-level extension extend BookingStatus { /* The country the booking occurred in. */ optional string country = 100 [default = "china", (com.pseudomuto.protokit.v1.extend_field) = true]; } /** * The type of booking. */ enum BookingType { option (com.pseudomuto.protokit.v1.extend_enum) = true; IMMEDIATE = 100; // Immediate booking. FUTURE = 101 [(com.pseudomuto.protokit.v1.extend_enum_value) = true]; // Future booking. } /** * Represents the booking of a vehicle. * * Vehicles are some cool shit. But drive carefully! */ message Booking { option (com.pseudomuto.protokit.v1.extend_message) = true; required int32 vehicle_id = 1; /// ID of booked vehicle. required int32 customer_id = 2; /// Customer that booked the vehicle. required BookingStatus status = 3; /// Status of the booking. /** Has booking confirmation been sent? */ required bool confirmation_sent = 4; /** Has payment been received? */ optional bool payment_received = 5 [default = true, (com.pseudomuto.protokit.v1.extend_field) = true]; oneof things { int32 reference_num = 6; // the numeric reference number string reference_tag = 7; // the reference tag (string) } // Nested extentions are also a thing. extend BookingStatus { optional string optional_field_1 = 101; // An optional field to be used however you please. } }