internetdata 1.0.0

The official Rust client library for the InternetData API: download and verify the published IP intelligence databases.
Documentation
/*
 * InternetData API
 *
 * The InternetData API. Please see https://docs.internetdata.io/api for more details.
 *
 * The version of the OpenAPI document: 2026.09.04
 * Contact: dev@internetdata.io
 * Generated by: https://openapi-generator.tech
 */

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

/// Database : One database FAMILY, with your organization's licence beside it. A licence covers the family, while a download names a specific version, so the ids passed to `download` and `checksum` come from `versions`.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Database {
    /// The family, e.g. `vpn_ip`. What a licence is held against.
    #[serde(rename = "base")]
    pub base: String,
    #[serde(rename = "name")]
    pub name: String,
    /// One line on what the newest version contains.
    #[serde(rename = "summary")]
    pub summary: String,
    /// `licensed` is a live grant, `expired` one whose term has ended, and `unlicensed` a database published but never bought.
    #[serde(rename = "standing")]
    pub standing: Standing,
    /// What your licence permits you to do with the data. Null when there is no licence.
    #[serde(rename = "redistribution", deserialize_with = "Option::deserialize")]
    pub redistribution: Option<Redistribution>,
    #[serde(rename = "starts", deserialize_with = "Option::deserialize")]
    pub starts: Option<chrono::DateTime<chrono::FixedOffset>>,
    /// Null when the licence has no end date, or when there is none.
    #[serde(rename = "expires", deserialize_with = "Option::deserialize")]
    pub expires: Option<chrono::DateTime<chrono::FixedOffset>>,
    /// Every published version of this family, oldest first. Old versions are frozen rather than migrated, so both stay downloadable.
    #[serde(rename = "versions")]
    pub versions: Vec<models::DatabaseVersion>,
}

impl Database {
    /// One database FAMILY, with your organization's licence beside it. A licence covers the family, while a download names a specific version, so the ids passed to `download` and `checksum` come from `versions`.
    pub fn new(
        base: String,
        name: String,
        summary: String,
        standing: Standing,
        redistribution: Option<Redistribution>,
        starts: Option<chrono::DateTime<chrono::FixedOffset>>,
        expires: Option<chrono::DateTime<chrono::FixedOffset>>,
        versions: Vec<models::DatabaseVersion>,
    ) -> Database {
        Database { base, name, summary, standing, redistribution, starts, expires, versions }
    }
}
/// `licensed` is a live grant, `expired` one whose term has ended, and `unlicensed` a database published but never bought.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Standing {
    #[serde(rename = "licensed")]
    Licensed,
    #[serde(rename = "expired")]
    Expired,
    #[serde(rename = "unlicensed")]
    Unlicensed,
}

impl Default for Standing {
    fn default() -> Standing {
        Self::Licensed
    }
}
/// What your licence permits you to do with the data. Null when there is no licence.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Redistribution {
    #[serde(rename = "evaluation")]
    Evaluation,
    #[serde(rename = "internal")]
    Internal,
    #[serde(rename = "redistribute")]
    Redistribute,
}

impl Default for Redistribution {
    fn default() -> Redistribution {
        Self::Evaluation
    }
}