Skip to main content

azisaba_graph/models/
create_api_key_request.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 CreateApiKeyRequest {
16    /// The human-readable name of the API key.
17    #[serde(rename = "name")]
18    pub name: String,
19    /// The scopes required for the new API key. The API key used to make the request must be authorized to delegate each requested scope. 
20    #[serde(rename = "scopes")]
21    pub scopes: std::collections::HashSet<Scopes>,
22    /// The date and time at which the API key expires, or `null` if it does not expire.
23    #[serde(rename = "expiresAt", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
24    pub expires_at: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
25    /// The player linked to this API key, or `null` if the key is not linked to a player.
26    #[serde(rename = "playerId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
27    pub player_id: Option<Option<uuid::Uuid>>,
28}
29
30impl CreateApiKeyRequest {
31    pub fn new(name: String, scopes: std::collections::HashSet<Scopes>) -> CreateApiKeyRequest {
32        CreateApiKeyRequest {
33            name,
34            scopes,
35            expires_at: None,
36            player_id: None,
37        }
38    }
39}
40/// The scopes required for the new API key. The API key used to make the request must be authorized to delegate each requested scope. 
41#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
42pub enum Scopes {
43    #[serde(rename = "*")]
44    Star,
45    #[serde(rename = "api-keys:read")]
46    ApiKeysColonRead,
47    #[serde(rename = "api-keys:write")]
48    ApiKeysColonWrite,
49    #[serde(rename = "crawls:read")]
50    CrawlsColonRead,
51    #[serde(rename = "crawls:write")]
52    CrawlsColonWrite,
53    #[serde(rename = "emojis:read")]
54    EmojisColonRead,
55    #[serde(rename = "emojis:write")]
56    EmojisColonWrite,
57    #[serde(rename = "patch-notes:read")]
58    PatchNotesColonRead,
59    #[serde(rename = "patch-notes:write")]
60    PatchNotesColonWrite,
61    #[serde(rename = "players:read")]
62    PlayersColonRead,
63    #[serde(rename = "players:read-details")]
64    PlayersColonReadDetails,
65    #[serde(rename = "players:write")]
66    PlayersColonWrite,
67    #[serde(rename = "punishments:read")]
68    PunishmentsColonRead,
69    #[serde(rename = "punishments:write")]
70    PunishmentsColonWrite,
71    #[serde(rename = "stream:read")]
72    StreamColonRead,
73}
74
75impl Default for Scopes {
76    fn default() -> Scopes {
77        Self::Star
78    }
79}
80