syntax = "proto3";

package code.justin.tv.ads.siosa.proto;
option go_package = "siosa";
import "google/protobuf/wrappers.proto";

service Siosa {
	rpc GetChannelAdProperties(ChannelId) returns (ChannelAdProperties) {}
	rpc SetChannelAdProperties(SetChannelAdPropertiesInput) returns (EmptyResponse) {}
	rpc GetVodAdProperties(VodId) returns (VodAdProperties) {}
	rpc SetVodAdProperties(VodId) returns (EmptyResponse) {}
	rpc GetGlobalAdProperties(EmptyInput) returns (GlobalAdProperties) {}
	rpc SetGlobalAdProperties(SetGlobalAdPropertiesInput) returns (EmptyResponse) {}
}

message GlobalAdProperties {
	repeated string country_whitelist = 1 [deprecated=true];
	repeated string pbyp_games_categories_whitelist = 2;
	bool pbyp_games_enabled = 3;
	int32 pbyp_max_ccv = 4;
	int32 pbyp_max_jitter_time = 5;
	int32 pbyp_max_warmup_time = 6;
	repeated string pbyp_games_categories_blacklist = 7;
	bool pbyp_non_games_enabled = 8;
	int32 pbyp_min_jitter_time = 9;
	int32 pbyp_max_tps = 10;
	bool pbyp_premium_content_enabled = 11;
	repeated string pbyp_channel_whitelist = 12;
	bool pbyp_kill_switch = 13;
	int32 pbyp_ramp_down_time = 14;
}

message SetGlobalAdPropertiesInput {
	StringListWrapper country_whitelist = 1 [deprecated=true];
	StringListWrapper pbyp_games_categories_whitelist = 2;
	google.protobuf.BoolValue pbyp_games_enabled = 3;
	google.protobuf.Int32Value pbyp_max_ccv = 4;
	google.protobuf.Int32Value pbyp_max_jitter_time = 5;
	google.protobuf.Int32Value pbyp_max_warmup_time = 6;
	StringListWrapper pbyp_games_categories_blacklist = 7;
	google.protobuf.BoolValue pbyp_non_games_enabled = 8;
	google.protobuf.Int32Value pbyp_min_jitter_time = 9;
	google.protobuf.Int32Value pbyp_max_tps = 10;
	google.protobuf.BoolValue pbyp_premium_content_enabled = 11;
	StringListWrapper pbyp_channel_whitelist = 12;
	google.protobuf.BoolValue pbyp_kill_switch = 13;
	google.protobuf.Int32Value pbyp_ramp_down_time = 14;
}

message StringListWrapper {
	repeated string Value = 1;
}

message EmptyInput {
}

message EmptyResponse {
}

message ChannelId {
	string channel_id = 1;
	string country = 2;
	string device_id = 3;
	string client_id = 4;
	string subdivision_code = 5;
}

message ChannelAdProperties {
	string channel_id = 1;

	AdProperties valid_responses = 2;
	repeated string unauthorized = 3;
}

message AdProperties {
	repeated AdProperty properties = 1;
}

message AdProperty {
	oneof property {
		bool prerolls_disabled = 1;
		bool postrolls_disabled = 2;

		int32 frequency = 3;
		int32 max_ad_break_length = 4;

		bool vod_ads_enabled = 5;
		string vod_archive_midrolls = 6;
		int32 vod_archive_midrolls_frequency = 7;
		int32 vod_archive_midrolls_break_length = 8;

		bool turbo_disabled = 9;
		string ad_server = 10 [deprecated=true];

		bool force_server_ads = 11;

		string program_id = 12 [deprecated=true];
		string partner = 13 [deprecated=true];
		string ad_server_default = 14;

		bool force_client_ads = 15;

		BountyBoardPixels bounty_board_pixels = 16 [deprecated=true];
		int32 required_age = 17;

		TrackingPixels tracking_pixels = 18;
		bool pbyp_disabled = 19;

		bool disable_prerolls_feature_enabled = 20;
		bool disable_prerolls_feature_admin_enabled = 21;
		DisablePrerollsFeatureValues disable_prerolls_feature_values = 22;
		Costreamers costreamers = 23;
		int32 disable_prerolls_feature_max_capacity = 24;
		bool disable_prerolls_feature_notifications_enabled = 25;

		bool auto_ads_enabled = 26;
		int32 auto_ads_length = 27;

		AdExperimentBuckets ad_experiment_buckets = 28;
		bool show_multiplayer_ads_to_subs = 29;

		bool guarantee_ads = 30;

		bool community_boost_product_eligible = 31;
		bool community_boost_all_disabled = 32;
		bool community_boost_earned_disabled = 33;
		bool community_boost_paid_disabled = 34;

		string campaign_type = 35;
	}
}

// This message is needed because all AdProperty fields must be in the oneof property
// oneof doesn't support repeated types
message Costreamers {
	repeated string ids = 1;
}

message BountyBoardPixels {
	option deprecated = true;
	repeated BountyBoardPixel pixels = 1;
}

message DisablePrerollsFeatureValues {
	map<int32, int32> values = 1;
}

message AdExperimentBuckets {
	map<string, string> buckets = 1;
}

message BountyBoardPixel {
	option deprecated = true;

	string type = 1;
	string origin = 2;
	int32 offset = 3;
	string url = 4;
}

message TrackingPixels {
	repeated TrackingPixel pixels = 1;
}

message TrackingPixel {
	string type = 1;
	string origin = 2;
	int32 offset = 3;
	string url = 4;
	string service = 5;
}

message SetChannelAdPropertiesInput{
	string channel_id = 1;
	repeated AdProperty input = 2;
	bool refresh = 3;
}

message VodId {
	string vod_id = 1;
}

message VodAdProperties {
}


// protoc --proto_path=$GOPATH/src:. --twirp_out=. --go_out=. ./rpc/siosa.proto
