internetdata 2.5.1

The official Rust client library for the InternetData API: download and verify the published IP intelligence databases.
Documentation
/*
 * InternetData API
 *
 * The InternetData API: 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.10.09
 * Contact: support@internetdata.io
 * Generated by: https://openapi-generator.tech
 */

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

/// Download : One download ATTEMPT, refusals included.
#[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,
    /// Taken under the Open license rather than one of your licenses: an Open database downloaded while your organization held no license in term for it.
    #[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 how much of it was taken.
    #[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 it could not be resolved.
    #[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")]
    pub created: chrono::DateTime<chrono::FixedOffset>,
}

impl Download {
    /// One download ATTEMPT, refusals included.
    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, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
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,
}

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