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

syntax = "proto3";

package timelinedraftspackage;

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

service TimelineDraftsManager {
  rpc GetPopulatedTimelineDraftsByChannelId(GetPopulatedTimelineDraftsByChannelIdRequest) returns (GetPopulatedTimelineDraftsByChannelIdResponse) {}

  rpc UpdateTimelineDraftsBulk(UpdateTimelineDraftsBulkRequest) returns (UpdateTimelineDraftsBulkResponse) {}

  rpc DeleteTimelinesDraftInChannelByDates(DeleteTimelinesDraftInChannelByDatesRequest) returns (DeleteTimelinesDraftInChannelByDatesResponse) {}

  rpc GetLatestManuallyCreatedTimelineDraft(GetLatestManuallyCreatedTimelineDraftRequest) returns (GetLatestManuallyCreatedTimelineDraftResponse) {}

  rpc GetTimelineDraftsByChannelId(GetTimelineDraftsByChannelIdRequest) returns (GetTimelineDraftsByChannelIdResponse) {}

  rpc Create(CreateRequest) returns (CreateResponse) {}

  rpc GetTimelineDraftsLiteByChannelId(GetTimelineDraftsLiteByChannelIdRequest) returns (GetTimelineDraftsLiteByChannelIdResponse) {}
}

message CreateRequest {
  TimelineDraft document = 1;
}

message CreateResponse {
  TimelineDraft document = 1;
}

message GetPopulatedTimelineDraftsByChannelIdRequest {
  string channel_id = 1;
  int64 start = 2;
  int64 stop = 3;
}

message GetPopulatedTimelineDraftsByChannelIdResponse {
  repeated TimelineDraftPopulated documents = 1;
}

message Window {
  string start_date = 1;
  string end_date = 2;
  string id = 3;
  int32 current_screenings = 4;
  int32 screenings = 5;
}

message AvailabilityWindows {
  repeated Window _a_v_o_d = 1 [json_name = "AVOD"];
  repeated Window linear = 2;
}

message Source {
  string id = 1;
  string file = 2;
  string type = 3;
  string encryption = 4;
}

message SourcesClip {
  Clip clip = 1;
}

message ClipAuthor {
  string name = 1;
}

message Clip {
  string id = 1;
  string provider = 2;
  repeated Source sources = 3;
  string content_status = 4;
  ClipAuthor author = 5;
}

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

message Episode {
  string id = 1;
  EpisodeSeries series = 2;
  string name = 3;
  int32 allotment = 4;
  int32 duration = 5;
  bool published = 6;
  bool is_feed = 7;
  string status = 8;
  bool flagged = 9;
  int32 number = 10;
  int32 season = 11;
  int32 ad_pods_duration = 12;
  bool featured = 13;
  string first_aired = 14;
  AvailabilityWindows availability_windows = 15;
  repeated string region_filter = 16;
  string active_region = 17;
  string last_aired = 18;
  message NextTimeline {
    string id = 1;
    string start = 2;
    string channel = 3;
  }
  NextTimeline next_timeline = 19;
  string rating = 20;
}

message TimelineDraftPopulated {
  string id = 1;
  string start = 2;
  string stop = 3;
  Episode episode = 4;
  bool all_clips_ready = 5;
  bool is_available_now = 6;
  bool has_region_availability = 7;
  bool provider_is_jw_only = 8;
  bool provider_is_jw_mixed = 9;
  bool has_empty_sources = 10;
  bool has_linear_availability_windows = 11;
  bool has_linear_availability_window_for_date = 12;
  bool has_ad_pods = 13;
  bool fulfilled = 14;
  string author = 15;
  string manual_override_marker = 16;
  bool has_live_broadcast = 17;
}

message TimelineDraft {
  string id = 1;
  string created_at = 2;
  string updated_at = 3;
  string start = 4;
  string stop = 5;
  string episode = 6;
  string channel = 7;
  bool featured = 8;
  string manual_override_marker = 9;
}

message UpdateTimelineDraftsBulkRequest {
  repeated string delete_ids = 1;
  repeated TimelineDraft create_objects = 2;
}

message UpdateTimelineDraftsBulkResponse {}

message DeleteTimelinesDraftInChannelByDatesRequest {
  string start = 1;
  string end = 2;
  string channel_id = 3;
}

message DeleteTimelinesDraftInChannelByDatesResponse {
  int64 deleted_count = 1;
}

message GetLatestManuallyCreatedTimelineDraftRequest {
  string start = 1;
  string end = 2;
  string channel_id = 3;
}

message GetLatestManuallyCreatedTimelineDraftResponse {
  TimelineDraft document = 1;
}

message GetTimelineDraftsByChannelIdRequest {
  string channel_id = 1;
  string start = 2;
  string stop = 3;
}

message GetTimelineDraftsByChannelIdResponse {
  repeated TimelineDraft documents = 1;
}

message EpisodeLite {
  string id = 1;
  bool published = 2;
  bool featured = 3;
}

message TimelineDraftLite {
  string id = 1;
  string start = 2;
  string stop = 3;
  string manual_override_marker = 4;
  EpisodeLite episode = 5;
}

message GetTimelineDraftsLiteByChannelIdRequest {
  string channel_id = 1;
  int64 start = 2;
  int64 stop = 3;
}

message GetTimelineDraftsLiteByChannelIdResponse {
  repeated TimelineDraftLite documents = 1;
}
