/*
 * Created by johann.ortiz@pluto.tv on 04/03/2024.
 * Copyright (c) PlutoTV Inc 2024.
 */

syntax = "proto3";

package featuredgrouppackage;

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

service FeaturedGroupManager {
  // GetById (Unary)
  //
  rpc GetById(GetByIdRequest) returns (GetByIdResponse) {}

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

  // Create (Unary)
  //
  rpc Create(CreateRequest) returns (CreateResponse) {}

  // DeleteByIds (Unary)
  //
  rpc DeleteByIds(DeleteByIdsRequest) returns (DeleteByIdsResponse) {}

  // UpdateFields (Unary)
  //
  rpc UpdateFields(UpdateFieldsRequest) returns (UpdateFieldsResponse) {}

  // PublishFeaturedGroup (Unary)
  //
  rpc PublishFeaturedGroup(PublishFeaturedGroupRequest) returns (PublishFeaturedGroupResponse) {}

  // UnpublishFeaturedGroup (Unary)
  //
  rpc UnpublishFeaturedGroup(UnpublishFeaturedGroupRequest) returns (UnpublishFeaturedGroupResponse) {}

  // GetOneByFilter (Unary)
  //
  rpc GetOneByFilter(GetOneByFilterRequest) returns (GetOneByFilterResponse) {}
}

message GetByIdRequest {
  string id = 1;
  repeated string populated_projection = 2;
}

message GetByIdResponse {
  PopulatedFeaturedGroup document = 1;
}

message PopulatedFeaturedGroup {
  string id = 1;
  string slug = 2;
  bool published = 3;
  string name = 4;
  string author = 5;
  string active_region = 6;
  repeated string region_filter = 7;
  string start = 8;
  string end = 9;
  repeated PopulatedContentItem content_items = 10;
  string created_at = 11;
  string updated_at = 12;
}

message FeaturedGroup {
  string id = 1;
  string slug = 2;
  string name = 3;
  string author = 4;
  string active_region = 5;
  repeated string region_filter = 6;
  string start = 7;
  string end = 8;
  repeated ContentItem content_items = 9;
  string created_at = 10;
  string updated_at = 11;
  bool published = 12;
}

message GetAllPagedFeaturedGroup {
  string id = 1;
  string slug = 2;
  bool published = 3;
  string name = 4;
  string author = 5;
  string active_region = 6;
  repeated string region_filter = 7;
  string start = 8;
  string end = 9;
  repeated GetAllPagedContentItem content_items = 10;
  string created_at = 11;
  string updated_at = 12;
  string day = 13;
  repeated ConcurrentStartGroup concurrent_start_groups = 14;
}

message ConcurrentStartGroup {
  string id = 1;
  string name = 2;
}

message GetAllPagedContentItem {
  string content_type = 1;
  GetAllPagedContentPopulated content = 2;
  bool partner_grid = 3;
  string type = 4;
  string strategy = 5;
  string notes = 6;
}

message ContentItem {
  string content_type = 1;
  string content = 2;
  bool partner_grid = 3;
  string type = 4;
  string strategy = 5;
  string notes = 6;
}

message PopulatedContentItem {
  string content_type = 1;
  ContentPopulated content = 2;
  bool partner_grid = 3;
  string type = 4;
  string strategy = 5;
  string notes = 6;
}

message ContentPopulated {
  string id = 1;
  string name = 2;
  int32 number = 3;
  Image featured_image = 4;
  bool published = 5;
  string category = 6;
  repeated Category categories = 7;
}

message GetAllPagedContentPopulated {
  string id = 1;
  string name = 2;
  int32 number = 3;
  Image featured_image = 4;
  bool published = 5;
}

message Image {
  string path = 1;
  string title = 2;
}

message Category {
  string cat_id = 1;
  int32 order = 2;
  string name = 3;
}

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;
  // operator to filter by (values must be AND or OR)
  string operator = 4;
}

message GetAllPagedSort {
  // field to sort on
  string field = 1;
  // sort direction 1 | -1
  int32 value = 2;
}

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

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

message CreateRequest {
  FeaturedGroup document = 1;
}

message CreateResponse {
  FeaturedGroup document = 1;
}

message DeleteByIdsRequest {
  repeated string ids = 1;
}

message DeleteByIdsResponse {
  int64 deleted_count = 1;
}

message UpdateFieldsRequest {
  FeaturedGroup document = 2;
  repeated string update_fields = 3;
}

message UpdateFieldsResponse {
  FeaturedGroup document = 1;
}

message UpdateContentItem {
  string content_type = 1;
  string content = 2;
  bool partner_grid = 3;
  string type = 4;
  string strategy = 5;
  string notes = 6;
}

message PublishFeaturedGroupRequest {
  string id = 1;
}

message PublishFeaturedGroupResponse {
  FeaturedGroup document = 1;
}

message UnpublishFeaturedGroupRequest {
  string id = 1;
}

message UnpublishFeaturedGroupResponse {
  FeaturedGroup document = 1;
}

message GetOneByFilterRequest {
  string id = 1;
  repeated string exclude_ids = 2;
  string min_start_date = 3;
  repeated Filter filters = 4;
}

message GetOneByFilterResponse {
  GetOneByFilterFeaturedGroup document = 1;
}

message GetOneByFilterFeaturedGroup {
  string id = 1;
  string name = 2;
  repeated GetOneByFilterContentItem content_items = 3;
}

message GetOneByFilterContentItem {
  string content_id = 1;
  bool published = 2;
}
