internetdata 2.9.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.13
 * Contact: support@internetdata.io
 * Generated by: https://openapi-generator.tech
 */

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

/// LookupResponse : What every database says about one address.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LookupResponse {
    /// The address looked up, as parsed: `::ffff:a.b.c.d` answers as `a.b.c.d`.
    #[serde(rename = "ip")]
    pub ip: String,
    /// Reserved space, answered from the address alone.
    #[serde(rename = "is_bogon")]
    pub is_bogon: bool,
    /// In VPN IP: a VPN service's server. Paid plans and the trial.
    #[serde(rename = "is_vpn", skip_serializing_if = "Option::is_none")]
    pub is_vpn: Option<bool>,
    /// In Tor IP: a Tor exit.
    #[serde(rename = "is_tor")]
    pub is_tor: bool,
    /// In Relay IP: an anonymizing relay such as iCloud Private Relay.
    #[serde(rename = "is_relay")]
    pub is_relay: bool,
    /// In Residential Proxy IP's 90-day window: a residential proxy exit. Paid plans and the trial.
    #[serde(rename = "is_resproxy", skip_serializing_if = "Option::is_none")]
    pub is_resproxy: Option<bool>,
    /// In Datacenter Proxy IP's 90-day window. Paid plans and the trial.
    #[serde(rename = "is_dcproxy", skip_serializing_if = "Option::is_none")]
    pub is_dcproxy: Option<bool>,
    /// In Mobile Proxy IP's 90-day window. Paid plans and the trial.
    #[serde(rename = "is_mobproxy", skip_serializing_if = "Option::is_none")]
    pub is_mobproxy: Option<bool>,
    /// In Public Proxy IP: a public proxy listens here, or its traffic left from here. Paid plans and the trial.
    #[serde(rename = "is_pubproxy", skip_serializing_if = "Option::is_none")]
    pub is_pubproxy: Option<bool>,
    /// In Hosting IP: a hosting or cloud network. Paid plans and the trial.
    #[serde(rename = "is_hosting", skip_serializing_if = "Option::is_none")]
    pub is_hosting: Option<bool>,
    /// In CDN IP: a content delivery network. Paid plans and the trial.
    #[serde(rename = "is_cdn", skip_serializing_if = "Option::is_none")]
    pub is_cdn: Option<bool>,
    /// In Anycast IP: announced from many places at once.
    #[serde(rename = "is_anycast")]
    pub is_anycast: bool,
    /// In Carrier IP: a mobile carrier's address space.
    #[serde(rename = "is_carrier")]
    pub is_carrier: bool,
    /// In Satellite IP: a satellite operator's address space.
    #[serde(rename = "is_satellite")]
    pub is_satellite: bool,
    /// In SSH IP: an SSH server answered here.
    #[serde(rename = "is_ssh")]
    pub is_ssh: bool,
    /// In SMTP IP: a mail server answered here.
    #[serde(rename = "is_smtp")]
    pub is_smtp: bool,
    /// In Web IP: a web server answered here on port 80 or 443.
    #[serde(rename = "is_web")]
    pub is_web: bool,
    /// In DNS Resolver IP: an open DNS resolver answered here.
    #[serde(rename = "is_dns_resolver")]
    pub is_dns_resolver: bool,
    /// In BitTorrent IP: a BitTorrent client was seen here in the last 90 days.
    #[serde(rename = "is_bittorrent")]
    pub is_bittorrent: bool,
    /// VPN IP's row, `{}` when `is_vpn` is false. Paid plans and the trial.
    #[serde(rename = "vpn", skip_serializing_if = "Option::is_none")]
    pub vpn: Option<Box<models::ClassDetail>>,
    /// Tor IP's row, `{}` when `is_tor` is false.
    #[serde(rename = "tor")]
    pub tor: Box<models::ClassDetail>,
    /// Relay IP's row, `{}` when `is_relay` is false.
    #[serde(rename = "relay")]
    pub relay: Box<models::ClassDetail>,
    /// `{}` when `is_resproxy` is false. Paid plans and the trial.
    #[serde(rename = "resproxy", skip_serializing_if = "Option::is_none")]
    pub resproxy: Option<Box<models::ProxyDetail>>,
    /// `{}` when `is_dcproxy` is false. Paid plans and the trial.
    #[serde(rename = "dcproxy", skip_serializing_if = "Option::is_none")]
    pub dcproxy: Option<Box<models::ProxyDetail>>,
    /// `{}` when `is_mobproxy` is false. Paid plans and the trial.
    #[serde(rename = "mobproxy", skip_serializing_if = "Option::is_none")]
    pub mobproxy: Option<Box<models::ProxyDetail>>,
    /// `{}` when `is_pubproxy` is false. Paid plans and the trial.
    #[serde(rename = "pubproxy", skip_serializing_if = "Option::is_none")]
    pub pubproxy: Option<Box<models::PubproxyDetail>>,
    /// `{}` when `is_hosting` is false. Paid plans and the trial.
    #[serde(rename = "hosting", skip_serializing_if = "Option::is_none")]
    pub hosting: Option<Box<models::ClassDetail>>,
    /// `{}` when `is_cdn` is false. Paid plans and the trial.
    #[serde(rename = "cdn", skip_serializing_if = "Option::is_none")]
    pub cdn: Option<Box<models::ClassDetail>>,
    /// `{}` when `is_carrier` is false. Paid plans and the trial.
    #[serde(rename = "carrier", skip_serializing_if = "Option::is_none")]
    pub carrier: Option<Box<models::CarrierDetail>>,
    /// `{}` when `is_satellite` is false. Paid plans and the trial.
    #[serde(rename = "satellite", skip_serializing_if = "Option::is_none")]
    pub satellite: Option<Box<models::SatelliteDetail>>,
    /// `{}` when `is_ssh` is false. Paid plans and the trial.
    #[serde(rename = "ssh", skip_serializing_if = "Option::is_none")]
    pub ssh: Option<Box<models::SshDetail>>,
    /// `{}` when `is_smtp` is false. Paid plans and the trial.
    #[serde(rename = "smtp", skip_serializing_if = "Option::is_none")]
    pub smtp: Option<Box<models::SmtpDetail>>,
    /// A row per port that answered, lowest first; `[]` when `is_web` is false. Paid plans and the trial.
    #[serde(rename = "web", skip_serializing_if = "Option::is_none")]
    pub web: Option<Vec<models::WebDetail>>,
    /// `{}` when `is_dns_resolver` is false. Paid plans and the trial.
    #[serde(rename = "dns_resolver", skip_serializing_if = "Option::is_none")]
    pub dns_resolver: Option<Box<models::DnsResolverDetail>>,
    /// `{}` when `is_bittorrent` is false. Paid plans and the trial.
    #[serde(rename = "bittorrent", skip_serializing_if = "Option::is_none")]
    pub bittorrent: Option<Box<models::BitTorrentDetail>>,
    #[serde(rename = "location")]
    pub location: Box<models::Location>,
    #[serde(rename = "asn")]
    pub asn: Box<models::Asn>,
    #[serde(rename = "company")]
    pub company: Box<models::Company>,
    /// The name the address's reverse DNS (PTR) record points to in IP RDNS, empty when it has none.
    #[serde(rename = "hostname")]
    pub hostname: String,
    #[serde(rename = "abuse")]
    pub abuse: Box<models::AbuseContact>,
    #[serde(rename = "whois", skip_serializing_if = "Option::is_none")]
    pub whois: Option<Box<models::Whois>>,
    #[serde(rename = "rwhois", skip_serializing_if = "Option::is_none")]
    pub rwhois: Option<Box<models::Rwhois>>,
    #[serde(rename = "hosted_domains", skip_serializing_if = "Option::is_none")]
    pub hosted_domains: Option<Box<models::HostedDomains>>,
    /// 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 LookupResponse {
    /// What every database says about one address.
    pub fn new(
        ip: String,
        is_bogon: bool,
        is_tor: bool,
        is_relay: bool,
        is_anycast: bool,
        is_carrier: bool,
        is_satellite: bool,
        is_ssh: bool,
        is_smtp: bool,
        is_web: bool,
        is_dns_resolver: bool,
        is_bittorrent: bool,
        tor: models::ClassDetail,
        relay: models::ClassDetail,
        location: models::Location,
        asn: models::Asn,
        company: models::Company,
        hostname: String,
        abuse: models::AbuseContact,
    ) -> LookupResponse {
        LookupResponse {
            ip,
            is_bogon,
            is_vpn: None,
            is_tor,
            is_relay,
            is_resproxy: None,
            is_dcproxy: None,
            is_mobproxy: None,
            is_pubproxy: None,
            is_hosting: None,
            is_cdn: None,
            is_anycast,
            is_carrier,
            is_satellite,
            is_ssh,
            is_smtp,
            is_web,
            is_dns_resolver,
            is_bittorrent,
            vpn: None,
            tor: Box::new(tor),
            relay: Box::new(relay),
            resproxy: None,
            dcproxy: None,
            mobproxy: None,
            pubproxy: None,
            hosting: None,
            cdn: None,
            carrier: None,
            satellite: None,
            ssh: None,
            smtp: None,
            web: None,
            dns_resolver: None,
            bittorrent: None,
            location: Box::new(location),
            asn: Box::new(asn),
            company: Box::new(company),
            hostname,
            abuse: Box::new(abuse),
            whois: None,
            rwhois: None,
            hosted_domains: None,
            trial_expired: None,
        }
    }
}