vpndetection 1.2.0

The official Rust client library for the VPNDetection API: anonymity detection covering VPNs, residential proxies, Tor nodes, hosting servers, CDNs and relays.
Documentation
/*
 * VPNDetection API
 *
 * The VPNDetection API: classify any IP address, and download the datasets behind the answers.  See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
 *
 * The version of the OpenAPI document: 2026.09.09
 * Contact: support@vpndetection.io
 * Generated by: https://openapi-generator.tech
 */

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

/// LookupResponse : The union of every plan's answer. Only `ip` and `is_vpn` are guaranteed; each remaining field is present when your plan includes it, and absent otherwise. A client that must work across plans should treat an absent flag as unknown rather than as `false`.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LookupResponse {
    /// The address that was looked up, normalized.
    #[serde(rename = "ip")]
    pub ip: String,
    /// Whether the address is VPN infrastructure. Keys off presence in the VPN dataset, so an unattributed range with no provider is still `true`.
    #[serde(rename = "is_vpn")]
    pub is_vpn: bool,
    /// Whether the address belongs to a hosting or cloud provider. Starter and above.
    #[serde(rename = "is_hosting", skip_serializing_if = "Option::is_none")]
    pub is_hosting: Option<bool>,
    /// Whether the address is a privacy relay egress. Starter and above.
    #[serde(rename = "is_relay", skip_serializing_if = "Option::is_none")]
    pub is_relay: Option<bool>,
    /// Whether the address is a Tor node. Starter and above.
    #[serde(rename = "is_tor", skip_serializing_if = "Option::is_none")]
    pub is_tor: Option<bool>,
    /// Whether the address belongs to a CDN. Starter and above.
    #[serde(rename = "is_cdn", skip_serializing_if = "Option::is_none")]
    pub is_cdn: Option<bool>,
    /// Whether the address was seen in a residential proxy pool. Max only.
    #[serde(rename = "is_resproxy", skip_serializing_if = "Option::is_none")]
    pub is_resproxy: Option<bool>,
    /// Whether the address was seen in a datacenter proxy pool. Max only.
    #[serde(rename = "is_dcproxy", skip_serializing_if = "Option::is_none")]
    pub is_dcproxy: Option<bool>,
    /// Whether the address was seen in a mobile proxy pool. Max only.
    #[serde(rename = "is_mobproxy", skip_serializing_if = "Option::is_none")]
    pub is_mobproxy: Option<bool>,
    /// Detail for `is_vpn`. Empty when `is_vpn` is false. Starter and above.
    #[serde(rename = "vpn", skip_serializing_if = "Option::is_none")]
    pub vpn: Option<Box<models::VpnDetail>>,
    /// Detail for `is_hosting`. Empty when false. Scale and above.
    #[serde(rename = "hosting", skip_serializing_if = "Option::is_none")]
    pub hosting: Option<Box<models::ClassDetail>>,
    /// Detail for `is_relay`. Empty when false. Scale and above.
    #[serde(rename = "relay", skip_serializing_if = "Option::is_none")]
    pub relay: Option<Box<models::ClassDetail>>,
    /// Detail for `is_tor`. Empty when false. Scale and above. The tor dataset carries no provider, so `provider` is always an empty string.
    #[serde(rename = "tor", skip_serializing_if = "Option::is_none")]
    pub tor: Option<Box<models::ClassDetail>>,
    /// Detail for `is_cdn`. Empty when false. Scale and above.
    #[serde(rename = "cdn", skip_serializing_if = "Option::is_none")]
    pub cdn: Option<Box<models::ClassDetail>>,
    /// Detail for `is_resproxy`. Empty when false. Max only.
    #[serde(rename = "resproxy", skip_serializing_if = "Option::is_none")]
    pub resproxy: Option<Box<models::ProxyDetail>>,
    /// Detail for `is_dcproxy`. Empty when false. Max only.
    #[serde(rename = "dcproxy", skip_serializing_if = "Option::is_none")]
    pub dcproxy: Option<Box<models::ProxyDetail>>,
    /// Detail for `is_mobproxy`. Empty when false. Max only.
    #[serde(rename = "mobproxy", skip_serializing_if = "Option::is_none")]
    pub mobproxy: Option<Box<models::ProxyDetail>>,
}

impl LookupResponse {
    /// The union of every plan's answer. Only `ip` and `is_vpn` are guaranteed; each remaining field is present when your plan includes it, and absent otherwise. A client that must work across plans should treat an absent flag as unknown rather than as `false`.
    pub fn new(ip: String, is_vpn: bool) -> LookupResponse {
        LookupResponse {
            ip,
            is_vpn,
            is_hosting: None,
            is_relay: None,
            is_tor: None,
            is_cdn: None,
            is_resproxy: None,
            is_dcproxy: None,
            is_mobproxy: None,
            vpn: None,
            hosting: None,
            relay: None,
            tor: None,
            cdn: None,
            resproxy: None,
            dcproxy: None,
            mobproxy: None,
        }
    }
}