syntax = "proto3";

package highlight.v1;

import "types.proto";
import "google/protobuf/descriptor.proto";

message Product {
  string id = 1;
  string name = 2;
  Category category = 3;
  repeated Product related = 4;
}

message Catalog {
  string title = 1;
  repeated Product products = 2;
  Category default_category = 3;
}

service ProductService {
  rpc GetProduct(GetProductRequest) returns (GetProductResponse);
  rpc ListProducts(ListProductsRequest) returns (ListProductsResponse);
  rpc StreamProducts(stream StreamProductsRequest) returns (stream StreamProductsResponse);
  rpc UploadProducts(stream UploadProductsRequest) returns (UploadProductsResponse);
  rpc DownloadProducts(DownloadProductsRequest) returns (stream DownloadProductsResponse);
}

message GetProductRequest {
  string product_id = 1;
}

message GetProductResponse {
  Product product = 1;
}

message ListProductsRequest {
  string catalog_name = 1;
}

message ListProductsResponse {
  repeated Product products = 1;
}

message StreamProductsRequest {
  string query = 1;
}

message StreamProductsResponse {
  Product product = 1;
}

message UploadProductsRequest {
  Product product = 1;
}

message UploadProductsResponse {
  int32 uploaded_count = 1;
}

message DownloadProductsRequest {
  string filter = 1;
}

message DownloadProductsResponse {
  Product product = 1;
}

message Order {
  message Item {
    string product_id = 1;
    int32 quantity = 2;
  }
  repeated Item items = 1;
  enum Status {
    STATUS_UNSPECIFIED = 0;
    STATUS_PENDING = 1;
    STATUS_SHIPPED = 2;
  }
  Status status = 2;
  oneof payment {
    string credit_card = 3;
    string paypal_email = 4;
  }
}

message Outer {
  message Inner {
    string title = 1;
  }
  message Container {
    Inner inner = 1;
  }
  Container data = 1;
}

extend google.protobuf.MessageOptions {
  optional string custom_message_option = 50001;
}

message WithExtension {
  option (custom_message_option) = "test";
  string field = 1;
}

message Metadata {
  string key = 1;
  string value = 2;
}

message FullyQualifiedReferenceTest {
  Metadata short_reference = 1;
  highlight.v1.Metadata qualified_reference = 2;
}

message MapFieldsTest {
  map<string, int32> attributes = 1;
  map<string, Product> product_map = 2;
  map<int32, Metadata> metadata_by_id = 3;
}
