import "wmconsole/version3/protos/common.proto";

package NWebmaster.proto.links;
option java_package = "ru.yandex.webmaster3.proto";

message LinksMessage {
    required ApplicationInfo application_info   = 1;
    required MessageInfo message_info           = 2;

    repeated LinksInfo links                    = 100;
}

message LinksInfo {
    optional string hostname                        = 1;
    optional int64 external_links_count             = 2;
    optional int64 external_hosts_count             = 3;
    optional int64 new_external_links_count         = 4;
    optional int64 new_external_hosts_count         = 5;
    optional int64 gone_external_links_count        = 6;
    optional int64 gone_external_hosts_count        = 7;

    optional int64 internal_links_count             = 20;
    optional int64 new_internal_links_count         = 21;
    optional int64 gone_internal_links_count        = 22;

    repeated LinkHttpInfo internal_links_http_codes         = 100;
    repeated HostTciInfo external_hosts_tci                 = 101;
    repeated LinkHttpInfo external_links_http_codes         = 102;
    repeated HostTciCounterInfo external_hosts_tci_counters = 103;
    repeated HostIksInfo external_hosts_iks                 = 104;
    repeated HostIksCounterInfo external_hosts_iks_counters = 105;

    repeated TldInfo external_links_tld_count       = 120;
}

message LinkHttpInfo {
    required int32 http_code                    = 1;
    required int64 count                        = 2;
}

message TldInfo { //empty domain = UNKNOWN_TLD
    required string tld_name    = 1;
    required int64 count        = 2;
}

enum TciLevelId {
    TCI_LEVEL_0_10                              = 10;
    TCI_LEVEL_10_20                             = 20;
    TCI_LEVEL_20_50                             = 30;
    TCI_LEVEL_50_100                            = 40;
    TCI_LEVEL_100_250                           = 50;
    TCI_LEVEL_250_500                           = 60;
    TCI_LEVEL_500_1000                          = 70;
    TCI_LEVEL_1000_INF                          = 80;
}

message HostTciInfo {
    required TciLevelId tci_level               = 1;
    required int64 count                        = 2;
}

message HostTciCounterInfo {
    required int32 tci                          = 1;
    required int64 count                        = 2;
}

enum IksLevelId {
    IKS_LEVEL_0_10                              = 10;
    IKS_LEVEL_10_20                             = 20;
    IKS_LEVEL_20_50                             = 30;
    IKS_LEVEL_50_100                            = 40;
    IKS_LEVEL_100_250                           = 50;
    IKS_LEVEL_250_500                           = 60;
    IKS_LEVEL_500_1000                          = 70;
    IKS_LEVEL_1000_INF                          = 80;
}

message HostIksInfo {
    required IksLevelId iks_level               = 1;
    required int64 count                        = 2;
}

message HostIksCounterInfo {
    required uint32 iks                          = 1;
    required int64 count                        = 2;
}

message RawLinkInfo {
    required bool internal              = 1; //source owner == dest owner
    optional string target_host         = 2;
    optional string target_path         = 3;
    optional uint32 target_http_code    = 4;
    optional int64  target_last_access  = 5;
    optional string source_host         = 6;
    optional string source_path         = 7;
    optional uint32 source_tci          = 8;
    optional int64  source_last_access  = 9;
    optional string text                = 10;
    optional int64  link_date           = 11;
    optional uint32 source_iks          = 12;
    optional int64  timestamp           = 100;
}
