Skip to main content

azisaba_graph/models/
punishment.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/// Punishment : Represents a punishment.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Punishment {
17    /// The unique identifier of the punishment.
18    #[serde(rename = "id")]
19    pub id: u64,
20    /// The target's name at the time the punishment was issued.
21    #[serde(rename = "targetName")]
22    pub target_name: String,
23    /// The target's UUID, or IP address for an IP-based punishment.
24    #[serde(rename = "target")]
25    pub target: String,
26    /// The type of punishment.
27    #[serde(rename = "type")]
28    pub r#type: Type,
29    /// The reason for the punishment.
30    #[serde(rename = "reason")]
31    pub reason: String,
32    /// The ID of the actor who issued the punishment.
33    #[serde(rename = "actorId")]
34    pub actor_id: uuid::Uuid,
35    /// The date and time at which the punishment was issued.
36    #[serde(rename = "createdAt")]
37    pub created_at: chrono::DateTime<chrono::FixedOffset>,
38    /// The date and time at which the punishment expires, or `null` if it does not expire.
39    #[serde(rename = "expiresAt", deserialize_with = "Option::deserialize")]
40    pub expires_at: Option<chrono::DateTime<chrono::FixedOffset>>,
41    /// The server on which the punishment was issued.
42    #[serde(rename = "server")]
43    pub server: String,
44    /// Whether the target has seen the punishment.
45    #[serde(rename = "seen")]
46    pub seen: bool,
47    /// Whether the punishment is currently active.
48    #[serde(rename = "active")]
49    pub active: bool,
50    /// The proofs attached to the punishment.
51    #[serde(rename = "proofs")]
52    pub proofs: Vec<models::Proof>,
53    #[serde(rename = "revocation", deserialize_with = "Option::deserialize")]
54    pub revocation: Option<Box<models::Revocation1>>,
55}
56
57impl Punishment {
58    /// Represents a punishment.
59    pub fn new(id: u64, target_name: String, target: String, r#type: Type, reason: String, actor_id: uuid::Uuid, created_at: chrono::DateTime<chrono::FixedOffset>, expires_at: Option<chrono::DateTime<chrono::FixedOffset>>, server: String, seen: bool, active: bool, proofs: Vec<models::Proof>, revocation: Option<models::Revocation1>) -> Punishment {
60        Punishment {
61            id,
62            target_name,
63            target,
64            r#type,
65            reason,
66            actor_id,
67            created_at,
68            expires_at,
69            server,
70            seen,
71            active,
72            proofs,
73            revocation: if let Some(x) = revocation {Some(Box::new(x))} else {None},
74        }
75    }
76}
77/// The type of punishment.
78#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
79pub enum Type {
80    #[serde(rename = "ban")]
81    Ban,
82    #[serde(rename = "tempBan")]
83    TempBan,
84    #[serde(rename = "ipBan")]
85    IpBan,
86    #[serde(rename = "tempIpBan")]
87    TempIpBan,
88    #[serde(rename = "mute")]
89    Mute,
90    #[serde(rename = "tempMute")]
91    TempMute,
92    #[serde(rename = "ipMute")]
93    IpMute,
94    #[serde(rename = "tempIpMute")]
95    TempIpMute,
96    #[serde(rename = "warning")]
97    Warning,
98    #[serde(rename = "caution")]
99    Caution,
100    #[serde(rename = "kick")]
101    Kick,
102    #[serde(rename = "note")]
103    Note,
104}
105
106impl Default for Type {
107    fn default() -> Type {
108        Self::Ban
109    }
110}
111