Skip to main content

azisaba_graph/models/
api_key.rs

1/*
2 * Azisaba Graph API
3 *
4 * An API for connecting and sharing data across the Azisaba Network.
5 *
6 * The version of the OpenAPI document: 0.0.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// ApiKey : Represents an API key.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct ApiKey {
17    /// The human-readable name of the API key.
18    #[serde(rename = "name")]
19    pub name: String,
20    /// The public identifier of the API key.
21    #[serde(rename = "publicId")]
22    pub public_id: String,
23    /// The scopes granted to the API key.
24    #[serde(rename = "scopes")]
25    pub scopes: std::collections::HashSet<Scopes>,
26    /// The date and time at which the API key was created.
27    #[serde(rename = "createdAt")]
28    pub created_at: chrono::DateTime<chrono::FixedOffset>,
29    /// The date and time at which the API key expires, or `null` if it does not expire.
30    #[serde(rename = "expiresAt", deserialize_with = "Option::deserialize")]
31    pub expires_at: Option<chrono::DateTime<chrono::FixedOffset>>,
32    /// The player linked to this API key, or `null` if the key is not linked to a player.
33    #[serde(rename = "playerId", deserialize_with = "Option::deserialize")]
34    pub player_id: Option<uuid::Uuid>,
35}
36
37impl ApiKey {
38    /// Represents an API key.
39    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>) -> ApiKey {
40        ApiKey {
41            name,
42            public_id,
43            scopes,
44            created_at,
45            expires_at,
46            player_id,
47        }
48    }
49}
50/// The scopes granted to the API key.
51#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
52pub enum Scopes {
53    #[serde(rename = "*")]
54    Star,
55    #[serde(rename = "api-keys:read")]
56    ApiKeysColonRead,
57    #[serde(rename = "api-keys:write")]
58    ApiKeysColonWrite,
59    #[serde(rename = "crawls:read")]
60    CrawlsColonRead,
61    #[serde(rename = "crawls:write")]
62    CrawlsColonWrite,
63    #[serde(rename = "emojis:read")]
64    EmojisColonRead,
65    #[serde(rename = "emojis:write")]
66    EmojisColonWrite,
67    #[serde(rename = "patch-notes:read")]
68    PatchNotesColonRead,
69    #[serde(rename = "patch-notes:write")]
70    PatchNotesColonWrite,
71    #[serde(rename = "players:read")]
72    PlayersColonRead,
73    #[serde(rename = "players:read-details")]
74    PlayersColonReadDetails,
75    #[serde(rename = "players:write")]
76    PlayersColonWrite,
77    #[serde(rename = "punishments:read")]
78    PunishmentsColonRead,
79    #[serde(rename = "punishments:write")]
80    PunishmentsColonWrite,
81    #[serde(rename = "stream:read")]
82    StreamColonRead,
83}
84
85impl Default for Scopes {
86    fn default() -> Scopes {
87        Self::Star
88    }
89}
90