// A warehouse's stock: the service the grpc plugin's example calls.
syntax = "proto3";

package quillo.demo;

service Inventory {
  // One item by its SKU; NOT_FOUND when there is none.
  rpc GetItem (GetItemRequest) returns (Item);
  // Every item with at least `min_quantity` in stock, one message each.
  rpc ListItems (ListItemsRequest) returns (stream Item);
  // Adds stock; needs `authorization: Bearer demo-token` in the metadata.
  rpc Restock (RestockRequest) returns (Item);
  // Answers after `ms` milliseconds, to try deadlines with.
  rpc Slow (SlowRequest) returns (Item);
  // SKUs sent one by one, then a count of those found.
  rpc CountSkus (stream GetItemRequest) returns (Summary);
  // An item back for each SKU sent, as they come.
  rpc Watch (stream GetItemRequest) returns (stream Item);
}

message GetItemRequest { string sku = 1; }
message ListItemsRequest { int32 min_quantity = 1; }
message RestockRequest { string sku = 1; int32 add = 2; }
message SlowRequest { int32 ms = 1; }
message Summary { int32 found = 1; int32 missing = 2; }

enum Availability {
  AVAILABILITY_UNKNOWN = 0;
  IN_STOCK = 1;
  OUT_OF_STOCK = 2;
}

message Dimensions {
  float width_cm = 1;
  float height_cm = 2;
}

message Item {
  string sku = 1;
  string name = 2;
  double price = 3;
  int32 quantity = 4;
  repeated string tags = 5;
  Availability availability = 6;
  int64 updated_ms = 7;
  Dimensions size = 8;
}
