internetdata 2.12.0

The official Rust client library for the InternetData API: look up IP addresses, AS numbers and domains, and download the IP intelligence databases.
Documentation
/*
 * InternetData API
 *
 * The InternetData API: look up what every database InternetData publishes says about an IP address, an AS or a domain, download the databases your organization is licensed for, and manage the account behind them.  See https://docs.internetdata.io for guides and https://github.com/internetdata for the official client libraries.
 *
 * The version of the OpenAPI document: 2026.11.15
 * Contact: support@internetdata.io
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// AsnLookupResponse : What every database says about one AS.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AsnLookupResponse {
    /// The AS number.
    #[serde(rename = "asn")]
    pub asn: i32,
    /// Its operator.
    #[serde(rename = "name")]
    pub name: String,
    /// The country its registry assigned it to.
    #[serde(rename = "country")]
    pub country: String,
    /// The registry that allocated it.
    #[serde(rename = "registry")]
    pub registry: String,
    /// When.
    #[serde(rename = "allocated")]
    pub allocated: String,
    /// Its operator's domain.
    #[serde(rename = "domain")]
    pub domain: String,
    /// The kind of network it runs. Paid plans and the trial.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,
    /// IPv4 addresses it announces. Paid plans and the trial.
    #[serde(rename = "num_ips", skip_serializing_if = "Option::is_none")]
    pub num_ips: Option<i32>,
    /// IPv4 prefixes it announces. Paid plans and the trial.
    #[serde(rename = "num_prefixes4", skip_serializing_if = "Option::is_none")]
    pub num_prefixes4: Option<i32>,
    /// IPv6 prefixes it announces. Paid plans and the trial.
    #[serde(rename = "num_prefixes6", skip_serializing_if = "Option::is_none")]
    pub num_prefixes6: Option<i32>,
    /// Its announcements RPKI calls valid. Paid plans and the trial.
    #[serde(rename = "rpki_valid", skip_serializing_if = "Option::is_none")]
    pub rpki_valid: Option<i32>,
    /// Invalid. Paid plans and the trial.
    #[serde(rename = "rpki_invalid", skip_serializing_if = "Option::is_none")]
    pub rpki_invalid: Option<i32>,
    /// With no RPKI record. Paid plans and the trial.
    #[serde(rename = "rpki_not_found", skip_serializing_if = "Option::is_none")]
    pub rpki_not_found: Option<i32>,
    /// Its ASN Whois record, every column, empty where the registry states nothing. Paid plans and the trial.
    #[serde(rename = "whois", skip_serializing_if = "Option::is_none")]
    pub whois: Option<std::collections::HashMap<String, String>>,
    /// What it announces, IPv4 then IPv6, up to 20000 a family. Paid plans and the trial.
    #[serde(rename = "prefixes", skip_serializing_if = "Option::is_none")]
    pub prefixes: Option<Vec<models::AsnPrefix>>,
    /// Its rank in ASN Extended, by customer cone, 1 the largest; `0` for an AS seen in no AS path. Paid plans and the trial.
    #[serde(rename = "rank", skip_serializing_if = "Option::is_none")]
    pub rank: Option<i32>,
    /// Whether it is one of the transit-free networks at the top of the hierarchy, which get transit from no one and peer with each other. Paid plans and the trial.
    #[serde(rename = "tier1", skip_serializing_if = "Option::is_none")]
    pub tier1: Option<bool>,
    /// How many AS numbers it gets transit from. Paid plans and the trial.
    #[serde(rename = "num_upstreams", skip_serializing_if = "Option::is_none")]
    pub num_upstreams: Option<i32>,
    /// Those AS numbers, ascending, up to 20000. Paid plans and the trial.
    #[serde(rename = "upstreams", skip_serializing_if = "Option::is_none")]
    pub upstreams: Option<Vec<i32>>,
    /// How many AS numbers it exchanges its own and its customers' routes with. Paid plans and the trial.
    #[serde(rename = "num_peers", skip_serializing_if = "Option::is_none")]
    pub num_peers: Option<i32>,
    /// Those AS numbers, ascending, up to 20000. Paid plans and the trial.
    #[serde(rename = "peers", skip_serializing_if = "Option::is_none")]
    pub peers: Option<Vec<i32>>,
    /// How many AS numbers it provides transit to. Paid plans and the trial.
    #[serde(rename = "num_downstreams", skip_serializing_if = "Option::is_none")]
    pub num_downstreams: Option<i32>,
    /// Those AS numbers, ascending, up to 20000. Paid plans and the trial.
    #[serde(rename = "downstreams", skip_serializing_if = "Option::is_none")]
    pub downstreams: Option<Vec<i32>>,
    #[serde(rename = "hosted_domains", skip_serializing_if = "Option::is_none")]
    pub hosted_domains: Option<Box<models::AsnHostedDomains>>,
    /// On every answer to a key on the free plan, and on no other: `false` while the day's trial of every field lasts, `true` once the answer has Unlimited's fields.
    #[serde(rename = "trial_expired", skip_serializing_if = "Option::is_none")]
    pub trial_expired: Option<bool>,
}

impl AsnLookupResponse {
    /// What every database says about one AS.
    pub fn new(
        asn: i32,
        name: String,
        country: String,
        registry: String,
        allocated: String,
        domain: String,
    ) -> AsnLookupResponse {
        AsnLookupResponse {
            asn,
            name,
            country,
            registry,
            allocated,
            domain,
            r#type: None,
            num_ips: None,
            num_prefixes4: None,
            num_prefixes6: None,
            rpki_valid: None,
            rpki_invalid: None,
            rpki_not_found: None,
            whois: None,
            prefixes: None,
            rank: None,
            tier1: None,
            num_upstreams: None,
            upstreams: None,
            num_peers: None,
            peers: None,
            num_downstreams: None,
            downstreams: None,
            hosted_domains: None,
            trial_expired: None,
        }
    }
}