syntax = "proto3";

package hosting;
option go_package = "code.justin.tv/live/autohost/rpc/hosting";
import "google/protobuf/wrappers.proto";

service Hosting {
    // Fetches a user's autohost list.
    rpc GetAutohostList(GetAutohostListRequest) returns (GetAutohostListResponse);
    rpc SetAutohostList(SetAutohostListRequest) returns (SetAutohostListResponse);
    rpc AddToAutohostList(AddToAutohostListRequest) returns (AddToAutohostListResponse);
    rpc RemoveFromAutohostList(RemoveFromAutohostListRequest) returns (RemoveFromAutohostListResponse);

    rpc GetAutohostSettings(GetAutohostSettingsRequest) returns (GetAutohostSettingsResponse);
    rpc UpdateAutohostSettings(UpdateAutohostSettingsRequest) returns (UpdateAutohostSettingsResponse);

    rpc GetEndorsedChannels(GetEndorsedChannelsRequest) returns (GetEndorsedChannelsResponse);
}

message UserContext {
    string device_id = 1;
    string user_id = 2;
    string platform = 3;
    repeated string languages = 4;
    string country = 5;
}

message EndorsedChannel {
    string channel_id = 1;
    string model_tracking_id = 2;
}

message AutohostChannel {
    string channel_id = 1;
    string model_tracking_id = 2;
}

enum AutohostStrategy {
    AUTOHOST_STRATEGY_UNSET = 0;
    AUTOHOST_STRATEGY_ORDERED = 1;
    AUTOHOST_STRATEGY_RANDOM = 2;
}

message AutohostSettings {
    bool enabled = 1;
    bool team_host = 2;
    AutohostStrategy strategy = 3;
    bool deprioritize_vodcast = 4;
}

message GetAutohostListRequest {
    string source_id = 1;
    int64 limit = 2;
}

message GetAutohostListResponse {
    repeated string target_ids = 1;
}

message SetAutohostListRequest {
    string caller_id = 1;
    string source_id = 2;
    repeated string target_ids = 3;
}

message SetAutohostListResponse {
    repeated string target_ids = 1;
}

message AddToAutohostListRequest {
    string caller_id = 1;
    string source_id = 2;
    repeated string target_ids_to_add = 3;
}

message AddToAutohostListResponse {
    repeated string target_ids = 1;
}

message RemoveFromAutohostListRequest {
    string caller_id = 1;
    string source_id = 2;
    repeated string target_ids_to_remove = 3;
}

message RemoveFromAutohostListResponse {
    repeated string target_ids = 1;
}

message GetAutohostSettingsRequest {
    string caller_id = 1;
    string user_id = 2;
}

message GetAutohostSettingsResponse {
    AutohostSettings settings = 1;
}

message UpdateAutohostSettingsRequest {
    string caller_id = 1;
    string user_id = 2;
    google.protobuf.BoolValue enabled = 3;
    google.protobuf.BoolValue team_host = 4;
    AutohostStrategy strategy = 5;
    google.protobuf.BoolValue deprioritize_vodcast = 6;
}

message UpdateAutohostSettingsResponse {
    AutohostSettings settings = 1;
}

message GetEndorsedChannelsRequest {
    enum SortOrder {
        DEFAULT = 0;
        RECOMMENDED = 1;
    }

    UserContext user_context = 1;
    string target_channel_id = 2;
    int64 limit = 3;
    SortOrder sort_order = 4;
}

message GetEndorsedChannelsResponse {
    repeated EndorsedChannel endorsed_channels = 1;
}
