Skip to main content

azisaba_graph/models/
create_api_key_201_response.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#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct CreateApiKey201Response {
16    /// The human-readable name of the API key.
17    #[serde(rename = "name")]
18    pub name: String,
19    /// The public identifier of the API key.
20    #[serde(rename = "publicId")]
21    pub public_id: String,
22    /// The scopes granted to the API key.
23    #[serde(rename = "scopes")]
24    pub scopes: std::collections::HashSet<Scopes>,
25    /// The date and time at which the API key was created.
26    #[serde(rename = "createdAt")]
27    pub created_at: chrono::DateTime<chrono::FixedOffset>,
28    /// The date and time at which the API key expires, or `null` if it does not expire.
29    #[serde(rename = "expiresAt", deserialize_with = "Option::deserialize")]
30    pub expires_at: Option<chrono::DateTime<chrono::FixedOffset>>,
31    /// The player linked to this API key, or `null` if the key is not linked to a player.
32    #[serde(rename = "playerId", deserialize_with = "Option::deserialize")]
33    pub player_id: Option<uuid::Uuid>,
34    /// The generated API key. This value is returned only once and must be stored securely by the client. 
35    #[serde(rename = "apiKey")]
36    pub api_key: String,
37}
38
39impl CreateApiKey201Response {
40    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 {
41        CreateApiKey201Response {
42            name,
43            public_id,
44            scopes,
45            created_at,
46            expires_at,
47            player_id,
48            api_key,
49        }
50    }
51}
52/// The scopes granted to the API key.
53#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
54pub enum Scopes {
55    #[serde(rename = "*")]
56    Star,
57    #[serde(rename = "api-keys:read")]
58    ApiKeysColonRead,
59    #[serde(rename = "api-keys:write")]
60    ApiKeysColonWrite,
61    #[serde(rename = "crawls:read")]
62    CrawlsColonRead,
63    #[serde(rename = "crawls:write")]
64    CrawlsColonWrite,
65    #[serde(rename = "emojis:read")]
66    EmojisColonRead,
67    #[serde(rename = "emojis:write")]
68    EmojisColonWrite,
69    #[serde(rename = "patch-notes:read")]
70    PatchNotesColonRead,
71    #[serde(rename = "patch-notes:write")]
72    PatchNotesColonWrite,
73    #[serde(rename = "players:read")]
74    PlayersColonRead,
75    #[serde(rename = "players:read-details")]
76    PlayersColonReadDetails,
77    #[serde(rename = "players:write")]
78    PlayersColonWrite,
79    #[serde(rename = "punishments:read")]
80    PunishmentsColonRead,
81    #[serde(rename = "punishments:write")]
82    PunishmentsColonWrite,
83    #[serde(rename = "stream:read")]
84    StreamColonRead,
85}
86
87impl Default for Scopes {
88    fn default() -> Scopes {
89        Self::Star
90    }
91}
92