/**
 * Messages describing manufacturers / vehicles.
 */
syntax = "proto3";

import "github.com/pseudomuto/protokit/fixtures/extend.proto";

package com.example;

option (com.pseudomuto.protokit.v1.extend_file) = true;

/**
 * The vehicle service.
 *
 * Manages vehicles and such...
 */
service VehicleService {
  option (com.pseudomuto.protokit.v1.extend_service) = true;

  // Returns the set of models.
  rpc GetModels(EmptyMessage) returns (stream Model);

  rpc AddModels(stream Model) returns (stream Model); // creates models

  /**
   * Looks up a vehicle by id.
   */
  rpc GetVehicle(FindVehicleById) returns (Vehicle) {
    option (com.pseudomuto.protokit.v1.extend_method) = true;
  };
}

/**
 * A request message for finding vehicles.
 */
message FindVehicleById {
  int32 id = 1; // The id of the vehicle to find.
}

/**
 * Represents a vehicle model.
 */
message Model {
  string id         = 1; // The unique model ID.
  string model_code = 2; // The car model code, e.g. "PZ003".
  string model_name = 3; // The car model name, e.g. "Z3".

  sint32 daily_hire_rate_dollars = 4; // Dollars per day.
  sint32 daily_hire_rate_cents   = 5; // Cents per day.

  Type type = 6; // The type of this model
}

// An empty message.
message EmptyMessage {
}

/**
 * @exclude
 * This comment won't be rendered
 */
message ExcludedMessage {
  string id   = 1; // the id of this message.
  string name = 2; // @exclude the name of this message

  /* @exclude the value of this message. */
  int32 value = 3;
}

// The type of model.
enum Type {
  option (com.pseudomuto.protokit.v1.extend_enum) = true;

  COUPE = 0; // The type is coupe.
  SEDAN = 1 [(com.pseudomuto.protokit.v1.extend_enum_value) = true]; // The type is sedan.
}

/**
 * Represents a manufacturer of cars.
 */
message Manufacturer {
  /**
   * Manufacturer category. A manufacturer may be either inhouse or external.
   */
  enum Category {
    CATEGORY_INHOUSE  = 0; // The manufacturer is inhouse.
    CATEGORY_EXTERNAL = 1; // The manufacturer is external.
  }

  int32 id       = 1; /** The unique manufacturer ID. */
  string code    = 2; // A manufacturer code, e.g. "DKL4P".
  string details = 3; // Manufacturer details (minimum orders etc.).

  /** Manufacturer category. */
  Category category = 4;
}

/**
 * Represents a vehicle that can be hired.
 */
message Vehicle {
  option (com.pseudomuto.protokit.v1.extend_message) = true;

  /**
   * Represents a vehicle category. E.g. "Sedan" or "Truck".
   */
  message Category {
    string code        = 1; /// Category code. E.g. "S".
    string description = 2; /// Category name. E.g. "Sedan".
  }

  message Engine {
    enum FuelType {
      FUEL_TYPE_UNSPECIFIED = 0;
      PETROL = 1;
      DIESEL = 2;
      ELECTRIC = 3;
    }
    message Stats {
      sint32 mpg = 1;
      sint32 bhp = 2;
      double zero_to_sixty_secs = 3;
    }
    FuelType fuel_type = 1;
    sint32 size_cc = 2; /** Size in cubic centimetres, if applicable. */
    Stats stats = 3;
  }

  int32 id          = 1; /** Unique vehicle ID. */
  Model model       = 2; /** Vehicle model. */
  string reg_number = 3 [(com.pseudomuto.protokit.v1.extend_field) = true]; /** Vehicle registration number. */
  sint32 mileage    = 4; /** Current vehicle mileage, if known. */
  Category category = 5; /** Vehicle category. */
  Engine engine     = 9; /** Vehicle engine. */


  // Doc comments for fields can come before or
  // after the field definition. And just like
  // comments for messages / enums, they can be
  // multi-paragraph:


  // rates
  repeated sint32 rates = 6;

  map<string, string> properties = 7; // bag of properties related to the vehicle.

  oneof travel {
	int32 kilometers = 8;
	int64 lightyears = 10;
  }

  oneof drivers {
	string human_name = 11;
	string cat_name = 12;
  }
}
