vpndetection 6.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 databases behind the answers.  Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key).  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.11.20
 * Contact: support@vpndetection.io
 * Generated by: https://openapi-generator.tech
 */

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

/// Download : One download ATTEMPT, refusals included - a denial is what answers \"it stopped working\", so they are listed rather than dropped.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Download {
    #[serde(rename = "dataset_id")]
    pub dataset_id: String,
    #[serde(rename = "format")]
    pub format: String,
    #[serde(rename = "outcome")]
    pub outcome: Outcome,
    /// The evaluation sample rather than the database itself.
    #[serde(rename = "sample")]
    pub sample: bool,
    /// A download of an Open database.
    #[serde(rename = "open")]
    pub open: bool,
    /// Object size at redirect time, NOT bytes delivered: the transfer is a presigned redirect straight to object storage, so we never observe it. int64 for the same reason as DatabaseFormatSize.bytes - it is the size of the same object.
    #[serde(rename = "bytes", deserialize_with = "Option::deserialize")]
    pub bytes: Option<i64>,
    #[serde(rename = "http_status", deserialize_with = "Option::deserialize")]
    pub http_status: Option<i32>,
    /// The key that made the request. Null when the org acted through the console rather than through a key.
    #[serde(rename = "apikey_id", deserialize_with = "Option::deserialize")]
    pub apikey_id: Option<String>,
    #[serde(rename = "client_ip", deserialize_with = "Option::deserialize")]
    pub client_ip: Option<String>,
    #[serde(rename = "user_agent", deserialize_with = "Option::deserialize")]
    pub user_agent: Option<String>,
    #[serde(rename = "created", deserialize_with = "crate::dates::date_time")]
    pub created: chrono::DateTime<chrono::FixedOffset>,
}

impl Download {
    /// One download ATTEMPT, refusals included - a denial is what answers \"it stopped working\", so they are listed rather than dropped.
    pub fn new(
        dataset_id: String,
        format: String,
        outcome: Outcome,
        sample: bool,
        open: bool,
        bytes: Option<i64>,
        http_status: Option<i32>,
        apikey_id: Option<String>,
        client_ip: Option<String>,
        user_agent: Option<String>,
        created: chrono::DateTime<chrono::FixedOffset>,
    ) -> Download {
        Download {
            dataset_id,
            format,
            outcome,
            sample,
            open,
            bytes,
            http_status,
            apikey_id,
            client_ip,
            user_agent,
            created,
        }
    }
}
///
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Outcome {
    #[serde(rename = "ok")]
    Ok,
    #[serde(rename = "unauthorized")]
    Unauthorized,
    #[serde(rename = "denied")]
    Denied,
    #[serde(rename = "expired")]
    Expired,
    #[serde(rename = "unknown")]
    Unknown,
    #[serde(rename = "unavailable")]
    Unavailable,
    /// A value this release was not built with, as the API served it.
    #[serde(untagged)]
    Other(String),
}

impl Default for Outcome {
    fn default() -> Outcome {
        Self::Ok
    }
}