syntax = "proto3";

import "google/protobuf/timestamp.proto";
package code.justin.tv.commerce.prometheus;
option go_package = "prometheus";

// Supported Endpoints

service Prometheus {
    rpc HealthCheck (HealthCheckReq) returns (HealthCheckResp) {};
    rpc ElasticsearchPing (ElasticsearchPingReq) returns (ElasticsearchPingResp) {};
    rpc PublishEvent (PublishEventReq) returns (PublishEventResp) {};
    rpc PublishEvents (PublishEventsReq) returns (PublishEventsResp) {};
    rpc Search (SearchReq) returns (SearchResp) {};
    rpc GetEventSubtypes (GetEventSubtypesReq) returns (GetEventSubtypesResp) {};
    rpc GenerateSearchReport (GenerateSearchReportReq) returns (GenerateSearchReportResp) {};
}

message HealthCheckReq {
}

message HealthCheckResp {
    string response = 1;
}

message ElasticsearchPingReq {
}

message ElasticsearchPingResp {
    string response = 1;
}

message PublishEventReq {
    string event_type = 1;
    EventSubType event_sub_type = 2;
    string event_id = 3;
    google.protobuf.Timestamp event_time = 4;
    string user_id = 5;
    string channel_id = 6;
    string gift_recipient_id = 7;
    int64  bits_amount = 8;
    float  currency_amount = 9;
    string currency_code = 10;
    string order_id = 11;
    string payment_service = 12;
    string payment_gateway = 13;
    string purchase_order_state = 14;
    string message = 15;
    string admin_user = 16;
    string admin_message = 17;
    string extension_id = 18;
    string extension_sku = 19;
    string extension_creator_id = 20;
    string extension_creator_login = 21;
    string anonymous_state = 22;
    int64  amount = 23;
    int64  bits_balance = 24;
    string country_code = 25;
    string city = 26;
    string postal_code = 27;
    string poll_id = 28;
    string poll_choice_id = 29;
    string hold_id = 30;
}

message PublishEventResp {
    string response = 1;
}

message PublishEventsReq {
    repeated PublishEventReq events = 1;
}

message PublishEventsResp {
    string response = 1;
}

message EventSubTypes {
    repeated EventSubType event_sub_types = 1;
}

message SearchReq {
    string event_type = 1;
    oneof sub_type_filter {
        EventSubType event_sub_type = 2;
        EventSubTypes event_sub_types_wrapper = 43;
    }
    string event_id = 3;
    google.protobuf.Timestamp start_event_time = 4;
    google.protobuf.Timestamp end_event_time = 5;
    string user_id = 6;
    string user_login = 7;
    string channel_id = 8;
    string channel_login = 9;
    string gift_recipient_id = 10;
    string gift_recipient_login = 11;
    int64  lower_bits_amount = 12;
    int64  upper_bits_amount = 13;
    float  lower_currency_amount = 14;
    float  upper_currency_amount = 15;
    string currency_code = 16;
    string order_id = 17;
    string purchase_order_state = 18;
    string payment_service = 19;
    string payment_gateway = 20;
    string message = 21;
    string admin_user = 22;
    string admin_message = 23;
    string extension_id = 24;
    string extension_sku = 25;
    string extension_creator_id = 26;
    string extension_creator_login = 27;
    SortBy sort_by = 28;
    SortDirection sort_direction = 29;
    int64 limit = 30;
    int64 offset = 31;
    string anonymous_state = 32;
    int64 lower_amount = 34;
    int64 upper_amount = 35;
    int64 lower_bits_balance = 36;
    int64 upper_bits_balance = 37;
    string country_code = 38;
    string city = 39;
    string postal_code = 40;
    string poll_id = 41;
    string poll_choice_id = 42;
    string hold_id = 44;
}

message Event {
    string event_type = 1;
    EventSubType event_sub_type = 2;
    string event_id = 3;
    google.protobuf.Timestamp event_time = 4;
    string user_id = 5;
    string user_login = 6;
    string channel_id = 7;
    string channel_login = 8;
    string gift_recipient_id = 9;
    string gift_recipient_login = 10;
    int64  bits_amount = 11;
    float  currency_amount = 12;
    string currency_code = 13;
    string order_id = 14;
    string purchase_order_state = 15;
    string payment_service = 16;
    string payment_gateway = 17;
    string message = 18;
    string admin_user = 19;
    string admin_message = 20;
    string extension_id = 25;
    string extension_sku = 26;
    string extension_creator_id = 27;
    string extension_creator_login = 28;
    string anonymous_state = 29;
    int64  amount = 30;
    int64  bits_balance = 31;
    string country_code = 32;
    string city = 33;
    string postal_code = 34;
    string poll_id = 35;
    string poll_choice_id = 36;
    string hold_id = 37;
}

message SearchResp {
    repeated Event events = 1;
    int64 total = 2;
}

message GetEventSubtypesReq {}

message GetEventSubtypesResp {
    repeated EventSubType eventSubtypes = 1;
}

message GenerateSearchReportReq {
    SearchReq searchReq = 1;
}

message GenerateSearchReportResp {
    string reportS3URL = 1;
    int64 total = 2;
}

enum SortBy {
    EVENT_TIME = 0;
    EVENT_TYPE = 1;
    EVENT_ID = 2;
    ORDER_ID = 3;
    USER_ID = 4;
    USER_LOGIN = 5;
    CHANNEL_ID = 6;
    CHANNEL_LOGIN = 7;
    GIFT_RECIPIENT_ID = 8;
    GIFT_RECIPIENT_LOGIN = 9;
    BITS_AMOUNT = 10;
    CURRENCY_AMOUNT = 11;
    CURRENCY_CODE = 12;
    MESSAGE = 13;
    PURCHASE_ORDER_STATE = 14;
    PAYMENT_SERVICE = 15;
    PAYMENT_GATEWAY = 16;
    EXTENSION_ID = 17;
    EXTENSION_SKU = 18;
    EXTENSION_CREATOR_ID = 19;
    EXTENSION_CREATOR_LOGIN = 20;
    AMOUNT = 21;
    BITS_BALANCE = 22;
    COUNTRY_CODE = 23;
    CITY = 24;
    POSTAL_CODE = 25;
    POLL_ID = 26;
    POLL_CHOICE_ID = 27;
    HOLD_ID = 28;
}

enum SortDirection {
    ASCENDING = 0;
    DESCENDING = 1;
}

enum EventSubType {
    ALL = 0;
    GiveBitsToBroadcaster = 1;
    UseBitsOnExtension = 2;
    AddBitsToCustomerAccountAds = 3;
    AddBitsToCustomerAccountPurchase = 4;
    AddBitsToCustomerAccountAdmin = 5;
    RemoveBitsFromCustomerAccountAdmin = 6;
    CustomerBitsRevoke = 7;
    CustomerBitsChargeback = 8;
    AddToken = 9;
    UseToken = 10;
    AddTokenAdmin = 11;
    RemoveTokenAdmin = 12;
    AcquireBitsBadgeNotification = 13;
    DismissBitsBadgeNotification = 14;
    ShareBitsBadgeNotification = 15;
    UseBitsOnPoll = 16;
    CreateHold = 17;
    ReleaseHold = 18;
}
