Skip to main content

bitwarden_api_api/models/
event_type.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor};
12
13use crate::models;
14///
15#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16pub enum EventType {
17    User_LoggedIn,
18    User_ChangedPassword,
19    User_Updated2fa,
20    User_Disabled2fa,
21    User_Recovered2fa,
22    User_FailedLogIn,
23    User_FailedLogIn2fa,
24    User_ClientExportedVault,
25    User_UpdatedTempPassword,
26    User_MigratedKeyToKeyConnector,
27    User_RequestedDeviceApproval,
28    User_TdeOffboardingPasswordSet,
29    Cipher_Created,
30    Cipher_Updated,
31    Cipher_Deleted,
32    Cipher_AttachmentCreated,
33    Cipher_AttachmentDeleted,
34    Cipher_Shared,
35    Cipher_UpdatedCollections,
36    Cipher_ClientViewed,
37    Cipher_ClientToggledPasswordVisible,
38    Cipher_ClientToggledHiddenFieldVisible,
39    Cipher_ClientToggledCardCodeVisible,
40    Cipher_ClientCopiedPassword,
41    Cipher_ClientCopiedHiddenField,
42    Cipher_ClientCopiedCardCode,
43    Cipher_ClientAutofilled,
44    Cipher_SoftDeleted,
45    Cipher_Restored,
46    Cipher_ClientToggledCardNumberVisible,
47    Collection_Created,
48    Collection_Updated,
49    Collection_Deleted,
50    Group_Created,
51    Group_Updated,
52    Group_Deleted,
53    OrganizationUser_Invited,
54    OrganizationUser_Confirmed,
55    OrganizationUser_Updated,
56    OrganizationUser_Removed,
57    OrganizationUser_UpdatedGroups,
58    OrganizationUser_UnlinkedSso,
59    OrganizationUser_ResetPassword_Enroll,
60    OrganizationUser_ResetPassword_Withdraw,
61    OrganizationUser_AdminResetPassword,
62    OrganizationUser_ResetSsoLink,
63    OrganizationUser_FirstSsoLogin,
64    OrganizationUser_Revoked,
65    OrganizationUser_Restored,
66    OrganizationUser_ApprovedAuthRequest,
67    OrganizationUser_RejectedAuthRequest,
68    OrganizationUser_Deleted,
69    OrganizationUser_Left,
70    OrganizationUser_AutomaticallyConfirmed,
71    OrganizationUser_SelfRevoked,
72    OrganizationUser_AdminResetTwoFactor,
73    Organization_Updated,
74    Organization_PurgedVault,
75    Organization_ClientExportedVault,
76    Organization_VaultAccessed,
77    Organization_EnabledSso,
78    Organization_DisabledSso,
79    Organization_EnabledKeyConnector,
80    Organization_DisabledKeyConnector,
81    Organization_SponsorshipsSynced,
82    Organization_CollectionManagement_Updated,
83    Organization_CollectionManagement_LimitCollectionCreationEnabled,
84    Organization_CollectionManagement_LimitCollectionCreationDisabled,
85    Organization_CollectionManagement_LimitCollectionDeletionEnabled,
86    Organization_CollectionManagement_LimitCollectionDeletionDisabled,
87    Organization_CollectionManagement_LimitItemDeletionEnabled,
88    Organization_CollectionManagement_LimitItemDeletionDisabled,
89    Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsEnabled,
90    Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled,
91    Organization_ItemOrganization_Accepted,
92    Organization_ItemOrganization_Declined,
93    Organization_AutoConfirmEnabled_Admin,
94    Organization_AutoConfirmDisabled_Admin,
95    Organization_AutoConfirmEnabled_Portal,
96    Organization_AutoConfirmDisabled_Portal,
97    Policy_Updated,
98    ProviderUser_Invited,
99    ProviderUser_Confirmed,
100    ProviderUser_Updated,
101    ProviderUser_Removed,
102    ProviderOrganization_Created,
103    ProviderOrganization_Added,
104    ProviderOrganization_Removed,
105    ProviderOrganization_VaultAccessed,
106    OrganizationDomain_Added,
107    OrganizationDomain_Removed,
108    OrganizationDomain_Verified,
109    OrganizationDomain_NotVerified,
110    Secret_Retrieved,
111    Secret_Created,
112    Secret_Edited,
113    Secret_Deleted,
114    Secret_Permanently_Deleted,
115    Secret_Restored,
116    Project_Retrieved,
117    Project_Created,
118    Project_Edited,
119    Project_Deleted,
120    ServiceAccount_UserAdded,
121    ServiceAccount_UserRemoved,
122    ServiceAccount_GroupAdded,
123    ServiceAccount_GroupRemoved,
124    ServiceAccount_Created,
125    ServiceAccount_Deleted,
126
127    /// Unknown value returned from the server. This is used to handle forward compatibility.
128    __Unknown(i64),
129}
130
131impl EventType {
132    pub fn as_i64(&self) -> i64 {
133        match self {
134            Self::User_LoggedIn => 1000,
135            Self::User_ChangedPassword => 1001,
136            Self::User_Updated2fa => 1002,
137            Self::User_Disabled2fa => 1003,
138            Self::User_Recovered2fa => 1004,
139            Self::User_FailedLogIn => 1005,
140            Self::User_FailedLogIn2fa => 1006,
141            Self::User_ClientExportedVault => 1007,
142            Self::User_UpdatedTempPassword => 1008,
143            Self::User_MigratedKeyToKeyConnector => 1009,
144            Self::User_RequestedDeviceApproval => 1010,
145            Self::User_TdeOffboardingPasswordSet => 1011,
146            Self::Cipher_Created => 1100,
147            Self::Cipher_Updated => 1101,
148            Self::Cipher_Deleted => 1102,
149            Self::Cipher_AttachmentCreated => 1103,
150            Self::Cipher_AttachmentDeleted => 1104,
151            Self::Cipher_Shared => 1105,
152            Self::Cipher_UpdatedCollections => 1106,
153            Self::Cipher_ClientViewed => 1107,
154            Self::Cipher_ClientToggledPasswordVisible => 1108,
155            Self::Cipher_ClientToggledHiddenFieldVisible => 1109,
156            Self::Cipher_ClientToggledCardCodeVisible => 1110,
157            Self::Cipher_ClientCopiedPassword => 1111,
158            Self::Cipher_ClientCopiedHiddenField => 1112,
159            Self::Cipher_ClientCopiedCardCode => 1113,
160            Self::Cipher_ClientAutofilled => 1114,
161            Self::Cipher_SoftDeleted => 1115,
162            Self::Cipher_Restored => 1116,
163            Self::Cipher_ClientToggledCardNumberVisible => 1117,
164            Self::Collection_Created => 1300,
165            Self::Collection_Updated => 1301,
166            Self::Collection_Deleted => 1302,
167            Self::Group_Created => 1400,
168            Self::Group_Updated => 1401,
169            Self::Group_Deleted => 1402,
170            Self::OrganizationUser_Invited => 1500,
171            Self::OrganizationUser_Confirmed => 1501,
172            Self::OrganizationUser_Updated => 1502,
173            Self::OrganizationUser_Removed => 1503,
174            Self::OrganizationUser_UpdatedGroups => 1504,
175            Self::OrganizationUser_UnlinkedSso => 1505,
176            Self::OrganizationUser_ResetPassword_Enroll => 1506,
177            Self::OrganizationUser_ResetPassword_Withdraw => 1507,
178            Self::OrganizationUser_AdminResetPassword => 1508,
179            Self::OrganizationUser_ResetSsoLink => 1509,
180            Self::OrganizationUser_FirstSsoLogin => 1510,
181            Self::OrganizationUser_Revoked => 1511,
182            Self::OrganizationUser_Restored => 1512,
183            Self::OrganizationUser_ApprovedAuthRequest => 1513,
184            Self::OrganizationUser_RejectedAuthRequest => 1514,
185            Self::OrganizationUser_Deleted => 1515,
186            Self::OrganizationUser_Left => 1516,
187            Self::OrganizationUser_AutomaticallyConfirmed => 1517,
188            Self::OrganizationUser_SelfRevoked => 1518,
189            Self::OrganizationUser_AdminResetTwoFactor => 1519,
190            Self::Organization_Updated => 1600,
191            Self::Organization_PurgedVault => 1601,
192            Self::Organization_ClientExportedVault => 1602,
193            Self::Organization_VaultAccessed => 1603,
194            Self::Organization_EnabledSso => 1604,
195            Self::Organization_DisabledSso => 1605,
196            Self::Organization_EnabledKeyConnector => 1606,
197            Self::Organization_DisabledKeyConnector => 1607,
198            Self::Organization_SponsorshipsSynced => 1608,
199            Self::Organization_CollectionManagement_Updated => 1609,
200            Self::Organization_CollectionManagement_LimitCollectionCreationEnabled => 1610,
201            Self::Organization_CollectionManagement_LimitCollectionCreationDisabled => 1611,
202            Self::Organization_CollectionManagement_LimitCollectionDeletionEnabled => 1612,
203            Self::Organization_CollectionManagement_LimitCollectionDeletionDisabled => 1613,
204            Self::Organization_CollectionManagement_LimitItemDeletionEnabled => 1614,
205            Self::Organization_CollectionManagement_LimitItemDeletionDisabled => 1615,
206            Self::Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsEnabled => 1616,
207            Self::Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled => 1617,
208            Self::Organization_ItemOrganization_Accepted => 1618,
209            Self::Organization_ItemOrganization_Declined => 1619,
210            Self::Organization_AutoConfirmEnabled_Admin => 1620,
211            Self::Organization_AutoConfirmDisabled_Admin => 1621,
212            Self::Organization_AutoConfirmEnabled_Portal => 1622,
213            Self::Organization_AutoConfirmDisabled_Portal => 1623,
214            Self::Policy_Updated => 1700,
215            Self::ProviderUser_Invited => 1800,
216            Self::ProviderUser_Confirmed => 1801,
217            Self::ProviderUser_Updated => 1802,
218            Self::ProviderUser_Removed => 1803,
219            Self::ProviderOrganization_Created => 1900,
220            Self::ProviderOrganization_Added => 1901,
221            Self::ProviderOrganization_Removed => 1902,
222            Self::ProviderOrganization_VaultAccessed => 1903,
223            Self::OrganizationDomain_Added => 2000,
224            Self::OrganizationDomain_Removed => 2001,
225            Self::OrganizationDomain_Verified => 2002,
226            Self::OrganizationDomain_NotVerified => 2003,
227            Self::Secret_Retrieved => 2100,
228            Self::Secret_Created => 2101,
229            Self::Secret_Edited => 2102,
230            Self::Secret_Deleted => 2103,
231            Self::Secret_Permanently_Deleted => 2104,
232            Self::Secret_Restored => 2105,
233            Self::Project_Retrieved => 2200,
234            Self::Project_Created => 2201,
235            Self::Project_Edited => 2202,
236            Self::Project_Deleted => 2203,
237            Self::ServiceAccount_UserAdded => 2300,
238            Self::ServiceAccount_UserRemoved => 2301,
239            Self::ServiceAccount_GroupAdded => 2302,
240            Self::ServiceAccount_GroupRemoved => 2303,
241            Self::ServiceAccount_Created => 2304,
242            Self::ServiceAccount_Deleted => 2305,
243            Self::__Unknown(v) => *v,
244        }
245    }
246
247    pub fn from_i64(value: i64) -> Self {
248        match value {
249            1000 => Self::User_LoggedIn,
250            1001 => Self::User_ChangedPassword,
251            1002 => Self::User_Updated2fa,
252            1003 => Self::User_Disabled2fa,
253            1004 => Self::User_Recovered2fa,
254            1005 => Self::User_FailedLogIn,
255            1006 => Self::User_FailedLogIn2fa,
256            1007 => Self::User_ClientExportedVault,
257            1008 => Self::User_UpdatedTempPassword,
258            1009 => Self::User_MigratedKeyToKeyConnector,
259            1010 => Self::User_RequestedDeviceApproval,
260            1011 => Self::User_TdeOffboardingPasswordSet,
261            1100 => Self::Cipher_Created,
262            1101 => Self::Cipher_Updated,
263            1102 => Self::Cipher_Deleted,
264            1103 => Self::Cipher_AttachmentCreated,
265            1104 => Self::Cipher_AttachmentDeleted,
266            1105 => Self::Cipher_Shared,
267            1106 => Self::Cipher_UpdatedCollections,
268            1107 => Self::Cipher_ClientViewed,
269            1108 => Self::Cipher_ClientToggledPasswordVisible,
270            1109 => Self::Cipher_ClientToggledHiddenFieldVisible,
271            1110 => Self::Cipher_ClientToggledCardCodeVisible,
272            1111 => Self::Cipher_ClientCopiedPassword,
273            1112 => Self::Cipher_ClientCopiedHiddenField,
274            1113 => Self::Cipher_ClientCopiedCardCode,
275            1114 => Self::Cipher_ClientAutofilled,
276            1115 => Self::Cipher_SoftDeleted,
277            1116 => Self::Cipher_Restored,
278            1117 => Self::Cipher_ClientToggledCardNumberVisible,
279            1300 => Self::Collection_Created,
280            1301 => Self::Collection_Updated,
281            1302 => Self::Collection_Deleted,
282            1400 => Self::Group_Created,
283            1401 => Self::Group_Updated,
284            1402 => Self::Group_Deleted,
285            1500 => Self::OrganizationUser_Invited,
286            1501 => Self::OrganizationUser_Confirmed,
287            1502 => Self::OrganizationUser_Updated,
288            1503 => Self::OrganizationUser_Removed,
289            1504 => Self::OrganizationUser_UpdatedGroups,
290            1505 => Self::OrganizationUser_UnlinkedSso,
291            1506 => Self::OrganizationUser_ResetPassword_Enroll,
292            1507 => Self::OrganizationUser_ResetPassword_Withdraw,
293            1508 => Self::OrganizationUser_AdminResetPassword,
294            1509 => Self::OrganizationUser_ResetSsoLink,
295            1510 => Self::OrganizationUser_FirstSsoLogin,
296            1511 => Self::OrganizationUser_Revoked,
297            1512 => Self::OrganizationUser_Restored,
298            1513 => Self::OrganizationUser_ApprovedAuthRequest,
299            1514 => Self::OrganizationUser_RejectedAuthRequest,
300            1515 => Self::OrganizationUser_Deleted,
301            1516 => Self::OrganizationUser_Left,
302            1517 => Self::OrganizationUser_AutomaticallyConfirmed,
303            1518 => Self::OrganizationUser_SelfRevoked,
304            1519 => Self::OrganizationUser_AdminResetTwoFactor,
305            1600 => Self::Organization_Updated,
306            1601 => Self::Organization_PurgedVault,
307            1602 => Self::Organization_ClientExportedVault,
308            1603 => Self::Organization_VaultAccessed,
309            1604 => Self::Organization_EnabledSso,
310            1605 => Self::Organization_DisabledSso,
311            1606 => Self::Organization_EnabledKeyConnector,
312            1607 => Self::Organization_DisabledKeyConnector,
313            1608 => Self::Organization_SponsorshipsSynced,
314            1609 => Self::Organization_CollectionManagement_Updated,
315            1610 => Self::Organization_CollectionManagement_LimitCollectionCreationEnabled,
316            1611 => Self::Organization_CollectionManagement_LimitCollectionCreationDisabled,
317            1612 => Self::Organization_CollectionManagement_LimitCollectionDeletionEnabled,
318            1613 => Self::Organization_CollectionManagement_LimitCollectionDeletionDisabled,
319            1614 => Self::Organization_CollectionManagement_LimitItemDeletionEnabled,
320            1615 => Self::Organization_CollectionManagement_LimitItemDeletionDisabled,
321            1616 => {
322                Self::Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsEnabled
323            }
324            1617 => {
325                Self::Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled
326            }
327            1618 => Self::Organization_ItemOrganization_Accepted,
328            1619 => Self::Organization_ItemOrganization_Declined,
329            1620 => Self::Organization_AutoConfirmEnabled_Admin,
330            1621 => Self::Organization_AutoConfirmDisabled_Admin,
331            1622 => Self::Organization_AutoConfirmEnabled_Portal,
332            1623 => Self::Organization_AutoConfirmDisabled_Portal,
333            1700 => Self::Policy_Updated,
334            1800 => Self::ProviderUser_Invited,
335            1801 => Self::ProviderUser_Confirmed,
336            1802 => Self::ProviderUser_Updated,
337            1803 => Self::ProviderUser_Removed,
338            1900 => Self::ProviderOrganization_Created,
339            1901 => Self::ProviderOrganization_Added,
340            1902 => Self::ProviderOrganization_Removed,
341            1903 => Self::ProviderOrganization_VaultAccessed,
342            2000 => Self::OrganizationDomain_Added,
343            2001 => Self::OrganizationDomain_Removed,
344            2002 => Self::OrganizationDomain_Verified,
345            2003 => Self::OrganizationDomain_NotVerified,
346            2100 => Self::Secret_Retrieved,
347            2101 => Self::Secret_Created,
348            2102 => Self::Secret_Edited,
349            2103 => Self::Secret_Deleted,
350            2104 => Self::Secret_Permanently_Deleted,
351            2105 => Self::Secret_Restored,
352            2200 => Self::Project_Retrieved,
353            2201 => Self::Project_Created,
354            2202 => Self::Project_Edited,
355            2203 => Self::Project_Deleted,
356            2300 => Self::ServiceAccount_UserAdded,
357            2301 => Self::ServiceAccount_UserRemoved,
358            2302 => Self::ServiceAccount_GroupAdded,
359            2303 => Self::ServiceAccount_GroupRemoved,
360            2304 => Self::ServiceAccount_Created,
361            2305 => Self::ServiceAccount_Deleted,
362            v => Self::__Unknown(v),
363        }
364    }
365}
366
367impl serde::Serialize for EventType {
368    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
369        serializer.serialize_i64(self.as_i64())
370    }
371}
372
373impl<'de> serde::Deserialize<'de> for EventType {
374    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
375        struct EventTypeVisitor;
376
377        impl Visitor<'_> for EventTypeVisitor {
378            type Value = EventType;
379
380            fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
381                f.write_str("an integer")
382            }
383
384            fn visit_i64<E: serde::de::Error>(self, v: i64) -> Result<Self::Value, E> {
385                Ok(EventType::from_i64(v))
386            }
387
388            fn visit_u64<E: serde::de::Error>(self, v: u64) -> Result<Self::Value, E> {
389                Ok(EventType::from_i64(v as i64))
390            }
391        }
392
393        deserializer.deserialize_i64(EventTypeVisitor)
394    }
395}
396
397impl std::fmt::Display for EventType {
398    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
399        write!(f, "{}", self.as_i64())
400    }
401}
402impl Default for EventType {
403    fn default() -> EventType {
404        Self::User_LoggedIn
405    }
406}