option java_package = "ru.yandex.webmaster3.proto.link.internal";

message LinksCommon {
    message HttpCodeInfo {
        optional int32 http_code                    = 1;
        optional int64 count                        = 2;
    }

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

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

    message TciInfo {
        optional int32 tci_from                     = 1;
        optional int32 tci_to                       = 2;
        optional int64 count                        = 3;
    }
}

message HostLinkStatisticsProto {
    message ExternalLinkStatistics {
        optional int64 total_url_count              = 1;
        optional int64 total_host_count             = 2;
        optional int64 new_url_count                = 3;
        optional int64 new_host_count               = 4;
        optional int64 gone_url_count               = 5;
        optional int64 gone_host_count              = 6;

        repeated LinksCommon.TciInfo tci_info      = 20;
        repeated LinksCommon.HttpCodeInfo http_code_info = 21;
        repeated LinksCommon.TldInfo tld_info       = 22;
        repeated LinksCommon.HostTciCounterInfo tci_detailed_info = 23;
    }

    message InternalLinkStatistics {
        optional int64 total_url_count              = 1;

        repeated LinksCommon.HttpCodeInfo http_code_info = 20;
    }

    optional ExternalLinkStatistics external_link_statistics = 1;
    optional InternalLinkStatistics internal_link_statistics = 2;

    optional int64 preparat_current_timestamp       = 3;
    optional int64 preparat_previous_timestamp      = 4;
}

message LinkHistory {
    message TciDate {
        optional uint32 preparat_timestamp          = 1;
        repeated LinksCommon.HostTciCounterInfo tci_info = 2;
    }

    message TciHistory {
        optional uint32 min_timestamp               = 1;
        optional uint32 max_timestamp               = 2;

        repeated TciDate dates                      = 3;
    }

    message TldDate {
        optional uint32 preparat_timestamp          = 1;
        repeated LinksCommon.TldInfo tld_info       = 2;
    }

    message TldHistory {
        optional uint32 min_timestamp               = 1;
        optional uint32 max_timestamp               = 2;

        repeated TldDate dates                      = 3;
    }

    message HttpDate {
        optional uint32 preparat_timestamp          = 1;
        repeated LinksCommon.HttpCodeInfo http_info = 2;
    }

    message HttpHistory {
        optional uint32 min_timestamp               = 1;
        optional uint32 max_timestamp               = 2;

        repeated HttpDate dates                     = 3;
    }
}
