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