syntax = "proto3";

service ApplePlays {
  rpc Get (GetRequest) returns (GetReply);
  rpc Put (PutRequest) returns (PutReply);
  rpc Delete (DeleteRequest) returns (DeleteReply);
  rpc Batch (BatchRequest) returns (BatchReply);
  rpc Iterator (IteratorRequest) returns (stream IteratorReply);
  rpc TrackByCountry (TrackByCountryRequest) returns (TrackByCountryReply);
}

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

message PutReply {}

message GetRequest {
  string key = 1;
}

message GetReply {
  string value = 1;
}

message DeleteRequest {
  string key = 1;
}

message DeleteReply {}

message BatchRequest {
  repeated Operation operations = 1;

  message Operation {
    string type = 1;
    string key = 2;
    string value = 3;
  }
}

message BatchReply {}

message IteratorRequest {
  optional bool keys = 1;
  optional bool values = 2;
  optional string gte = 3;
  optional string lte = 4;
  optional sint32 limit = 5;
  optional bool reverse = 6;
}

message IteratorReply {
  optional string key = 1;
  optional string value = 2;
}

message TrackByCountryRequest {
  required string isrc = 1;
  required string start_date = 2;
  required string end_date = 3;
  optional string licensor = 4;
}

message TrackByCountryReply {
  repeated TrackByCountryData data = 1;

  message TrackByCountryData {
    string date = 1;
    string country_code = 2;
    int32 streams = 3;
    int32 source_0 = 4;
    int32 source_1 = 5;
    int32 source_2 = 6;
    int32 source_3 = 7;
    int32 source_4 = 8;
    int32 container_type_0 = 9;
    int32 container_type_1 = 10;
    int32 container_type_2 = 11;
    int32 container_type_3 = 12;
    int32 container_type_4 = 13;
    int32 container_subtype_0 = 14;
    int32 container_subtype_1 = 15;
    int32 container_subtype_2 = 16;
    int32 container_subtype_3 = 17;
    int32 container_subtype_4 = 18;
    int32 container_subtype_5 = 19;
    int32 container_subtype_6 = 20;
    int32 container_subtype_7 = 21;
    int32 container_subtype_8 = 22;
    int32 end_reason_0 = 23;
    int32 end_reason_1 = 24;
    int32 end_reason_2 = 25;
    int32 offline_0 = 26;
    int32 offline_1 = 27;
  }
}