use serde::Deserialize;
use super::common::{GeoPoint, Network, Carrier};

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AsnInfoResponse {
    pub asn: Option<String>,
    pub asn_numeric: Option<i64>,
    pub organisation: Option<String>,
    pub name: Option<String>,
    pub registry: Option<String>,
    pub registered_country: Option<String>,
    pub rank: Option<i32>,
    pub rank_text: Option<String>,
    pub total_ipv4_addresses: Option<i64>,
    pub total_ipv4_prefixes: Option<i32>,
    pub total_ipv6_prefixes: Option<i32>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AsnPeer {
    pub asn: Option<String>,
    pub asn_numeric: Option<i64>,
    pub organisation: Option<String>,
    pub registered_country: Option<String>,
    pub rank: Option<i32>,
    pub rank_text: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AsnInfoFullResponse {
    pub asn: Option<String>,
    pub asn_numeric: Option<i64>,
    pub organisation: Option<String>,
    pub name: Option<String>,
    pub registry: Option<String>,
    pub registered_country: Option<String>,
    pub rank: Option<i32>,
    pub rank_text: Option<String>,
    pub total_ipv4_addresses: Option<i64>,
    pub total_ipv4_prefixes: Option<i32>,
    pub total_ipv6_prefixes: Option<i32>,
    pub total_receiving_from: Option<i32>,
    pub total_transit_to: Option<i32>,
    pub receiving_from: Option<Vec<AsnPeer>>,
    pub transit_to: Option<Vec<AsnPeer>>,
    pub confidence_area: Option<Vec<GeoPoint>>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NetworkByIpResponse {
    pub ip: Option<String>,
    pub registry: Option<String>,
    pub registry_status: Option<String>,
    pub registered_country: Option<String>,
    pub registered_country_name: Option<String>,
    pub organisation: Option<String>,
    pub is_reachable_globally: Option<bool>,
    pub is_bogon: Option<bool>,
    pub bgp_prefix: Option<String>,
    pub bgp_prefix_network_address: Option<String>,
    pub bgp_prefix_last_address: Option<String>,
    pub total_addresses: Option<i64>,
    pub carriers: Option<Vec<Carrier>>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BgpPrefix {
    pub bgp_prefix: Option<String>,
    pub bgp_prefix_network_address: Option<String>,
    pub bgp_prefix_last_address: Option<String>,
    pub total_addresses: Option<i64>,
    pub allocation_date: Option<String>,
    pub is_bogon: Option<bool>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct PrefixesListResponse {
    pub asn: Option<String>,
    pub total: Option<i32>,
    pub prefixes: Option<Vec<BgpPrefix>>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NetworkByCidrResponse {
    pub cidr: Option<String>,
    pub parent: Option<String>,
    pub network: Option<Network>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AsnRankEntry {
    pub asn: Option<String>,
    pub asn_numeric: Option<i64>,
    pub organisation: Option<String>,
    pub registered_country: Option<String>,
    pub rank: Option<i32>,
    pub rank_text: Option<String>,
    pub total_ipv4_addresses: Option<i64>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct AsnRankListResponse {
    pub total: Option<i32>,
    pub asns: Option<Vec<AsnRankEntry>>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TorExitNode {
    pub ip: Option<String>,
    pub country_code: Option<String>,
    pub country_name: Option<String>,
    pub asn: Option<String>,
    pub organisation: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct TorExitNodesResponse {
    pub total: Option<i32>,
    pub nodes: Option<Vec<TorExitNode>>,
}
