azisaba-graph 0.1.0-rc.3

An API for connecting and sharing data across Azisaba Network.
Documentation
/*
 * Azisaba Graph API
 *
 * An API for connecting and sharing data across Azisaba Network.
 *
 * The version of the OpenAPI document: 0.0.1
 * 
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateApiKey201Response {
    /// The human-readable name of the API key.
    #[serde(rename = "name")]
    pub name: String,
    /// The public identifier of the API key.
    #[serde(rename = "publicId")]
    pub public_id: String,
    /// The scopes granted to the API key.
    #[serde(rename = "scopes")]
    pub scopes: std::collections::HashSet<Scopes>,
    /// The date and time at which the API key was created.
    #[serde(rename = "createdAt")]
    pub created_at: chrono::DateTime<chrono::FixedOffset>,
    /// The date and time at which the API key expires, or `null` if it does not expire.
    #[serde(rename = "expiresAt", deserialize_with = "Option::deserialize")]
    pub expires_at: Option<chrono::DateTime<chrono::FixedOffset>>,
    /// The player linked to this API key, or `null` if the key is not linked to a player.
    #[serde(rename = "playerId", deserialize_with = "Option::deserialize")]
    pub player_id: Option<uuid::Uuid>,
    /// The generated API key. This value is returned only once and must be stored securely by the client. 
    #[serde(rename = "apiKey")]
    pub api_key: String,
}

impl CreateApiKey201Response {
    pub fn new(name: String, public_id: String, scopes: std::collections::HashSet<Scopes>, created_at: chrono::DateTime<chrono::FixedOffset>, expires_at: Option<chrono::DateTime<chrono::FixedOffset>>, player_id: Option<uuid::Uuid>, api_key: String) -> CreateApiKey201Response {
        CreateApiKey201Response {
            name,
            public_id,
            scopes,
            created_at,
            expires_at,
            player_id,
            api_key,
        }
    }
}
/// The scopes granted to the API key.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Scopes {
    #[serde(rename = "*")]
    Star,
    #[serde(rename = "api-keys:read")]
    ApiKeysColonRead,
    #[serde(rename = "api-keys:write")]
    ApiKeysColonWrite,
    #[serde(rename = "crawls:read")]
    CrawlsColonRead,
    #[serde(rename = "crawls:write")]
    CrawlsColonWrite,
    #[serde(rename = "patch-notes:read")]
    PatchNotesColonRead,
    #[serde(rename = "patch-notes:write")]
    PatchNotesColonWrite,
    #[serde(rename = "players:read")]
    PlayersColonRead,
    #[serde(rename = "players:read-details")]
    PlayersColonReadDetails,
    #[serde(rename = "players:write")]
    PlayersColonWrite,
    #[serde(rename = "punishments:read")]
    PunishmentsColonRead,
    #[serde(rename = "punishments:write")]
    PunishmentsColonWrite,
}

impl Default for Scopes {
    fn default() -> Scopes {
        Self::Star
    }
}