internetdata 2.11.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.14
 * 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>>,
    /// 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,
            trial_expired: None,
        }
    }
}