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

syntax = "proto3";

package maincategoriespackage;

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

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

  // GetByIds (Unary)
  //
  rpc GetByIds(GetByIdsRequest) returns (GetByIdsResponse) {}

  // GetDocumentsUpdatedBetweenDates (Server Stream)
  //
  rpc GetDocumentsUpdatedBetweenDates(GetDocumentsUpdatedBetweenDatesRequest) returns (stream MainCategory) {}

  // CFeedsSyncDocuments (Server Stream)
  //
  rpc CFeedsSyncDocuments(CFeedsSyncDocumentsRequest) returns (stream MainCategory) {}

  // CFeedsSyncAllIds (Server Stream)
  //
  rpc CFeedsSyncAllIds(CFeedsSyncAllIdsRequest) returns (stream Id) {}

  rpc Create(CreateRequest) returns (CreateResponse) {}

  rpc UpdateFields(UpdateFieldsRequest) returns (UpdateFieldsResponse) {}

  rpc DeleteById(DeleteByIdRequest) returns (DeleteByIdResponse) {}

  rpc GetVodCategoriesList(GetVodCategoriesListRequest) returns (GetVodCategoriesListResponse) {}

  rpc GetChannelsList(GetChannelsListRequest) returns (GetChannelsListResponse) {}

  rpc SetOrderInChannelsList(SetOrderInChannelsListRequest) returns (SetOrderInChannelsListResponse) {}

  rpc SetOrderInVodList(SetOrderInVodListRequest) returns (SetOrderInVodListResponse) {}

  rpc GetAllPaged(GetAllPagedRequest) returns (GetAllPagedResponse) {}

  // SetMainCategoriesOrder (Unary)
  //
  rpc SetMainCategoriesOrder(SetMainCategoriesOrderRequest) returns (SetMainCategoriesOrderResponse) {}

  // BulkAssignVodsToMainCategories (Unary)
  //
  rpc BulkAssignVodsToMainCategories(BulkAssignVodsToMainCategoriesRequest) returns (BulkAssignVodsToMainCategoriesResponse) {}

  // BulkAssignChannelsToMainCategories (Unary)
  //
  rpc BulkAssignChannelsToMainCategories(BulkAssignChannelsToMainCategoriesRequest) returns (BulkAssignChannelsToMainCategoriesResponse) {}
}

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

message GetByIdResponse {
  MainCategory document = 1;
}

message GetByIdsRequest {
  repeated string ids = 1;
  repeated GetAllPagedSort sort = 2;
}

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

message GetByIdsResponse {
  repeated MainCategory documents = 1;
}

message CFeedsSyncAllIdsRequest {}

message Id {
  string id = 1;
}

message CFeedsSyncDocumentsRequest {
  // Expressed as a valid javascript Date, https://en.wikipedia.org/wiki/ISO_8601
  string last_run_at = 1;
}

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 MainCategory {
  string id = 1;
  string name = 2;
  int32 order = 3;
  Path svg_image_url = 4;
  Path png_image_url = 5;
  string created_at = 6;
  string updated_at = 7;
  string slug = 8;
  bool pluto_office_only = 9;
  string stacking_order = 10;
  Distribution distribution = 11;
  string active_region = 12;
  bool hide_main_category = 13;
}

message Distribution {
  repeated string app_names = 1;
  repeated string devices = 2;
}

message Path {
  string path = 1;
}

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

message CustomReference {
  string id = 1;
  string type = 2;
  string value = 3;
}

message VodCategory {
  string id = 1;
  string name = 2;
  string display_name = 3;
  int32 order = 4;
  bool enabled = 5;
  bool pluto_office_only = 6;
  string enabled_at = 7;
  string description = 8;
  RegionFilter region_filter = 9;
  RegionFilter distribution = 10;
  string intile_channel = 11;
  int32 intile_order = 12;
  Path icon_svg = 13;
  Path icon_png = 14;
  Path image_featured = 15;
  string created_at = 16;
  string updated_at = 17;
  string disabled_at = 18;
  string active_region = 19;
  bool kids_mode = 20;
  repeated Category categories = 21;
  repeated CustomReference custom_references = 22;
  bool archived = 23;
  bool hero_carousel = 24;
  int32 title_count = 25;

  message Path {
    string path = 1;
  }

  message RegionFilter {
    repeated string include = 1;
    repeated string exclude = 2;
  }
}

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

message RegionFilter {
  repeated string include = 1;
  repeated string exclude = 2;
}

message EpisodesQueue {
  string episode = 1;
  int32 order = 2;
}

message PrivateChannel {
  string created_by = 1;
  string subscriber_code = 2;
  string publisher_code = 3;
  string endpoint = 4;
  string stream_name = 5;
  string episode = 6;
  string series = 7;
  string clip = 8;
  string episode_name = 9;
  string subscriber_count = 10;
}

message ScheduledPublishing {
  string start = 1;
  string end = 2;
  bool active = 3;
}

message GracenoteIntegration {
  bool enabled = 1;
  string dynamic_clip = 2;
  string series_type = 3;
  string category = 4;
  string sub_category = 5;
  string genre = 6;
  string sub_genre = 7;
}

message SamsungChannelProperty {
  string id = 1;
  string channel = 2;
  string service_id = 3;
  bool intiles_enabled = 4;
  string region = 5;
}

message CustomReferenceValue {
  string id = 1;
  string type = 2;
  string value = 3;
}

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

message CfaasIntegrationResponse {
  bool enabled = 1;
  string clip_id = 2;
  SourceId source_id = 3;
  string category = 4;
  string sub_category = 5;
  string genre = 6;
  string sub_genre = 7;
}

message Channel {
  string id = 1;
  string created_at = 2;
  string updated_at = 3;
  string name = 4;
  string author = 5;
  string parent = 6;
  string hash = 7;
  int32 number = 8;
  int32 cohort_mask = 9;
  int32 access_code = 10;
  bool published = 11;
  string description = 12;
  string category = 13;
  repeated Category categories = 14;
  bool auto_schedule = 15;
  int32 auto_schedule_days = 16;
  string summary = 17;
  repeated string tags = 18;
  repeated string geo_targets = 19;
  bool kids_mode = 20;
  int32 featured = 21;
  string created = 22;
  string updated = 23;
  string visibility = 24;
  Image thumbnail = 25;
  Image featured_image = 26;
  Image partner_logo = 27;
  Image logo = 28;
  Image tile = 29;
  Image tile_grayscale = 30;
  Image browse = 31;
  Image background = 32;
  string notes = 33;
  string type = 34;
  string start = 35;
  string stop = 36;
  int32 redirect = 37;
  bool on_demand = 38;
  string on_demand_description = 39;
  bool archived = 40;
  string slug = 41;
  RegionFilter region_filter = 42;
  repeated int32 dma_distribution = 43;
  RegionFilter distribution = 44;
  repeated EpisodesQueue episodes_queue = 45;
  repeated string overlays = 46;
  bool direct_only = 47;
  bool live_broadcast = 48;
  bool has_sub_clips = 49;
  bool is_stitched = 50;
  bool render_interstitials = 51;
  bool pluto_office_only = 52;
  PrivateChannel private_channel = 53;
  ScheduledPublishing scheduled_publishing = 54;
  Image solid_logo_p_n_g = 55;
  Image color_logo_p_n_g = 56;
  Image solid_logo_s_v_g = 57;
  Image color_logo_s_v_g = 58;
  repeated string supported_channel_caption_languages = 59;
  string tmsid = 60;
  string active_region = 61; // not found in inf-lib-schemas
  int32 category_mask = 62; // not found in inf-lib-schemas
  string metadata_language = 63; // not found in inf-lib-schemas
  repeated string seo_aliases = 64;
  int32 chat_room_id = 65;
  bool chat_enabled = 66;
  GracenoteIntegration gracenote_integration = 67;
  // mongoose internal revision number; only generated when inserted via mongoose
  int64 v = 68;
  repeated SamsungChannelProperty samsung_channel_properties = 69;
  bool google_dai = 70;
  repeated CustomReferenceValue custom_references = 71;
  Image thumbnail_alt = 72;
  Image featured_image_alt = 73;
  Image logo_alt = 74;
  Image solid_logo_p_n_g_alt = 75;
  Image color_logo_p_n_g_alt = 76;
  Image solid_logo_s_v_g_alt = 77;
  Image color_logo_s_v_g_alt = 78;
  repeated MainCategory main_categories = 79;
  string auto_epg_source = 80;
  CfaasIntegrationResponse cfaas_integration = 81;
  bool logo_overlay_enable = 82;
  bool _is_d_a_s_h_ready_d_r_m = 83 [json_name = "_isDASHReadyDRM"];
  string status = 84;
  repeated string zip_code_distribution = 85;
}

message CreateRequest {
  MainCategory document = 1;
}

message CreateResponse {
  MainCategory document = 1;
}

message UpdateFieldsRequest {
  string id = 1;
  MainCategory document = 2;
  repeated string update_fields = 3;
}

message UpdateFieldsResponse {
  MainCategory document = 1;
}

message DeleteByIdRequest {
  string id = 1;
}

message DeleteByIdResponse {
  int64 deleted_count = 1;
}

message GetVodCategoriesListRequest {
  string id = 1;
  // how to order the list: "custom" or empty (default ordering)
  string order = 2;
  // how many results to return default 1000
  int32 limit = 3;
  // where to begin page default 0
  int32 offset = 4;
  // how to sort results
  repeated GetAllPagedSort sort = 5;
  repeated Filter filters = 6;
  repeated string projection = 7;
}

message GetVodCategoriesListResponse {
  repeated VodCategory documents = 1;
  string order = 2;
}

message GetChannelsListRequest {
  string id = 1;
  // how many results to return default 1000
  int32 limit = 2;
  // where to begin page default 0
  int32 offset = 3;
  // how to sort results
  repeated GetAllPagedSort sort = 4;
  repeated Filter filters = 5;
  // how to order the channels list: "custom" or "natural"
  string order = 6;
  repeated string projection = 7;
}

message GetChannelsListResponse {
  repeated Channel documents = 1;
  string order = 2;
}

message ChannelListOrder {
  string channel_id = 1;
}

message SetOrderInChannelsListRequest {
  repeated string channel_list_order = 1;
  string main_category_id = 2;
  string stacking_order = 3;
}

message ChannelOrderResponse {
  string id = 1;
  string created_at = 2;
  string updated_at = 3;
  string name = 4;
  string author = 5;
  string parent = 6;
  string hash = 7;
  int32 number = 8;
  int32 cohort_mask = 9;
  int32 access_code = 10;
  bool published = 11;
  string description = 12;
  string category = 13;
  repeated Category categories = 14;
  bool auto_schedule = 15;
  int32 auto_schedule_days = 16;
  string summary = 17;
  repeated string tags = 18;
  repeated string geo_targets = 19;
  bool kids_mode = 20;
  int32 featured = 21;
  string created = 22;
  string updated = 23;
  string visibility = 24;
  Image thumbnail = 25;
  Image featured_image = 26;
  Image partner_logo = 27;
  Image logo = 28;
  Image tile = 29;
  Image tile_grayscale = 30;
  Image browse = 31;
  Image background = 32;
  string notes = 33;
  string type = 34;
  string start = 35;
  string stop = 36;
  int32 redirect = 37;
  bool on_demand = 38;
  string on_demand_description = 39;
  bool archived = 40;
  string slug = 41;
  RegionFilter region_filter = 42;
  repeated int32 dma_distribution = 43;
  RegionFilter distribution = 44;
  repeated EpisodesQueue episodes_queue = 45;
  repeated string overlays = 46;
  bool direct_only = 47;
  bool live_broadcast = 48;
  bool has_sub_clips = 49;
  bool is_stitched = 50;
  bool render_interstitials = 51;
  bool pluto_office_only = 52;
  PrivateChannel private_channel = 53;
  ScheduledPublishing scheduled_publishing = 54;
  Image solid_logo_p_n_g = 55;
  Image color_logo_p_n_g = 56;
  Image solid_logo_s_v_g = 57;
  Image color_logo_s_v_g = 58;
  repeated string supported_channel_caption_languages = 59;
  string tmsid = 60;
  string active_region = 61;
  int32 category_mask = 62;
  string metadata_language = 63;
  repeated string seo_aliases = 64;
  int32 chat_room_id = 65;
  bool chat_enabled = 66;
  GracenoteIntegration gracenote_integration = 67;
  int64 v = 68;
  bool google_dai = 69;
  repeated CustomReferenceValue custom_references = 70;
  Image thumbnail_alt = 71;
  Image featured_image_alt = 72;
  Image logo_alt = 73;
  Image solid_logo_p_n_g_alt = 74;
  Image color_logo_p_n_g_alt = 75;
  Image solid_logo_s_v_g_alt = 76;
  Image color_logo_s_v_g_alt = 77;
  string auto_epg_source = 78;
  CfaasIntegrationResponse cfaas_integration = 79;
  bool logo_overlay_enable = 80;
  bool _is_d_a_s_h_ready_d_r_m = 81 [json_name = "_isDASHReadyDRM"];
  string status = 82;
}

message SetOrderInChannelsListResponse {
  repeated ChannelOrderResponse documents = 1;
}

message SetOrderInVodListRequest {
  repeated string vod_list_order = 1;
  string main_category_id = 2;
}

message SetOrderInVodListResponse {
  repeated VodCategory documents = 1;
}

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

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;
  // 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 = 4;
  repeated Filter filters = 5;
  repeated string projection = 6;
  // 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 = 7;
}

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

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 MainCategoryOrder {
  string id = 1;
  int32 order = 2;
}

message SetMainCategoriesOrderRequest {
  repeated MainCategoryOrder main_categories = 1;
  string active_region = 2;
}

message SetMainCategoriesOrderResponse {
  repeated MainCategoryOrder documents = 1;
}

message BulkVodsMainCategories {
  string vod_id = 1;
  string main_category_id = 2;
  string created_at = 3;
  string updated_at = 4;
}

message BulkChannelsMainCategories {
  string channel_id = 1;
  string main_category_id = 2;
  int32 order = 3;
  string created_at = 4;
  string updated_at = 5;
}

message BulkAssignVodsToMainCategoriesRequest {
  string main_category_id = 1;
  repeated string vod_ids = 2;
}

message BulkAssignVodsToMainCategoriesResponse {
  repeated BulkVodsMainCategories documents = 1;
}

message BulkAssignChannelsToMainCategoriesRequest {
  string main_category_id = 1;
  repeated string channel_ids = 2;
  string order = 3;
}

message BulkAssignChannelsToMainCategoriesResponse {
  repeated BulkChannelsMainCategories documents = 1;
}
