/*
 * Created by jonathan.jesperson@pluto.tv on 01/22/2021.
 * Copyright (c) PlutoTV Inc 2021.
 */

syntax = "proto3";

package ratingdescriptorpackage;

option go_package = "github.com/Pluto-tv/service-dal/golang_client";
option java_package = "tv.pluto.ip.dal.ratingdescriptor";

service RatingDescriptorManager {
  // GetDocumentsUpdatedBetweenDates (Server Stream)
  //
  rpc GetDocumentsUpdatedBetweenDates(GetDocumentsUpdatedBetweenDatesRequest) returns (stream RatingDescriptor) {}

  // GetAllPaged (Unary)
  //
  rpc GetAllPaged(GetAllPagedRequest) returns (GetAllPagedResponse) {}
}

message GetDocumentsUpdatedBetweenDatesRequest {
  // Expressed as a valid javascript Date, https://en.wikipedia.org/wiki/ISO_8601
  string updated_at_min = 1;
  // Expressed as a valid javascript Date, https://en.wikipedia.org/wiki/ISO_8601
  string updated_at_max = 2;
}

message RatingDescriptor {
  string id = 1;
  string display_name = 2;
  string label = 3;
  string region = 4;
  string slug = 5;
  string created_at = 6;
  string updated_at = 7;
}

message GetAllPagedRequest {
  // how many results to return default 1000
  int32 limit = 1;
  // where to begin page default 0
  int32 offset = 2;
  // how to sort results
  repeated GetAllPagedSort sort = 3;
  repeated Filter filters = 4;
  // when set to true the `total count` metadata will not be calculated
  // this can save some performance as count is additional query
  bool disable_total_count = 5;
  // when set to true the `name` value will be sent to MongoDB as regex expression
  // when set to false the `name` value will be sent to MongoDB as a literal string
  bool enable_regex = 6;
}

message Filter {
  // field to filter on
  string field = 1;
  // value for the filter
  string value = 2;
  // type of the filter string (default), number, bool
  string type = 3;
}
message GetAllPagedSort {
  // field to sort on
  string field = 1;
  // sort direction 1 | -1
  int32 value = 2;
}

message Metadata {
  int32 current_offset = 1;
  int32 total_items = 2;
}

message GetAllPagedResponse {
  repeated RatingDescriptor documents = 1;
  Metadata metadata = 2;
}
