Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-6169] Explore potential approach for unknown value in enums #595

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub enum Algorithm {
ES384 = -35,
EdDSA = -8,
ES256 = -7,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for Algorithm {
Expand All @@ -43,6 +46,7 @@ impl ToString for Algorithm {
Self::ES384 => String::from("-35"),
Self::EdDSA => String::from("-8"),
Self::ES256 => String::from("-7"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/auth_request_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub enum AuthRequestType {
AuthenticateAndUnlock = 0,
Unlock = 1,
AdminApproval = 2,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for AuthRequestType {
Expand All @@ -25,6 +28,7 @@ impl ToString for AuthRequestType {
Self::AuthenticateAndUnlock => String::from("0"),
Self::Unlock => String::from("1"),
Self::AdminApproval => String::from("2"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/cipher_reprompt_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum CipherRepromptType {
None = 0,
Password = 1,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for CipherRepromptType {
fn to_string(&self) -> String {
match self {
Self::None => String::from("0"),
Self::Password => String::from("1"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/cipher_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub enum CipherType {
SecureNote = 2,
Card = 3,
Identity = 4,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for CipherType {
Expand All @@ -27,6 +30,7 @@ impl ToString for CipherType {
Self::SecureNote => String::from("2"),
Self::Card => String::from("3"),
Self::Identity => String::from("4"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/device_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ pub enum DeviceType {
WindowsCLI = 23,
MacOsCLI = 24,
LinuxCLI = 25,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for DeviceType {
Expand Down Expand Up @@ -71,6 +74,7 @@ impl ToString for DeviceType {
Self::WindowsCLI => String::from("23"),
Self::MacOsCLI => String::from("24"),
Self::LinuxCLI => String::from("25"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub enum EmergencyAccessStatusType {
Confirmed = 2,
RecoveryInitiated = 3,
RecoveryApproved = 4,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for EmergencyAccessStatusType {
Expand All @@ -29,6 +32,7 @@ impl ToString for EmergencyAccessStatusType {
Self::Confirmed => String::from("2"),
Self::RecoveryInitiated => String::from("3"),
Self::RecoveryApproved => String::from("4"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/emergency_access_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum EmergencyAccessType {
View = 0,
Takeover = 1,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for EmergencyAccessType {
fn to_string(&self) -> String {
match self {
Self::View => String::from("0"),
Self::Takeover => String::from("1"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/event_system_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum EventSystemUser {
SCIM = 1,
DomainVerification = 2,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for EventSystemUser {
fn to_string(&self) -> String {
match self {
Self::SCIM => String::from("1"),
Self::DomainVerification => String::from("2"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/event_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ pub enum EventType {
OrganizationDomain_Verified = 2002,
OrganizationDomain_NotVerified = 2003,
Secret_Retrieved = 2100,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for EventType {
Expand Down Expand Up @@ -167,6 +170,7 @@ impl ToString for EventType {
Self::OrganizationDomain_Verified => String::from("2002"),
Self::OrganizationDomain_NotVerified => String::from("2003"),
Self::Secret_Retrieved => String::from("2100"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/field_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub enum FieldType {
Hidden = 1,
Boolean = 2,
Linked = 3,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for FieldType {
Expand All @@ -27,6 +30,7 @@ impl ToString for FieldType {
Self::Hidden => String::from("1"),
Self::Boolean => String::from("2"),
Self::Linked => String::from("3"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/file_upload_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum FileUploadType {
Direct = 0,
Azure = 1,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for FileUploadType {
fn to_string(&self) -> String {
match self {
Self::Direct => String::from("0"),
Self::Azure => String::from("1"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pub enum GlobalEquivalentDomainsType {
TakeawayEU = 88,
Atlassian = 89,
Pinterest = 90,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for GlobalEquivalentDomainsType {
Expand Down Expand Up @@ -201,6 +204,7 @@ impl ToString for GlobalEquivalentDomainsType {
Self::TakeawayEU => String::from("88"),
Self::Atlassian => String::from("89"),
Self::Pinterest => String::from("90"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/kdf_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum KdfType {
PBKDF2_SHA256 = 0,
Argon2id = 1,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for KdfType {
fn to_string(&self) -> String {
match self {
Self::PBKDF2_SHA256 => String::from("0"),
Self::Argon2id => String::from("1"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/license_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum LicenseType {
User = 0,
Organization = 1,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for LicenseType {
fn to_string(&self) -> String {
match self {
Self::User => String::from("0"),
Self::Organization => String::from("1"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/member_decryption_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub enum MemberDecryptionType {
MasterPassword = 0,
KeyConnector = 1,
TrustedDeviceEncryption = 2,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for MemberDecryptionType {
Expand All @@ -25,6 +28,7 @@ impl ToString for MemberDecryptionType {
Self::MasterPassword => String::from("0"),
Self::KeyConnector => String::from("1"),
Self::TrustedDeviceEncryption => String::from("2"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum OpenIdConnectRedirectBehavior {
RedirectGet = 0,
FormPost = 1,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for OpenIdConnectRedirectBehavior {
fn to_string(&self) -> String {
match self {
Self::RedirectGet => String::from("0"),
Self::FormPost => String::from("1"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub enum OrganizationApiKeyType {
Default = 0,
BillingSync = 1,
Scim = 2,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for OrganizationApiKeyType {
Expand All @@ -25,6 +28,7 @@ impl ToString for OrganizationApiKeyType {
Self::Default => String::from("0"),
Self::BillingSync => String::from("1"),
Self::Scim => String::from("2"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
pub enum OrganizationConnectionType {
CloudBillingSync = 1,
Scim = 2,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for OrganizationConnectionType {
fn to_string(&self) -> String {
match self {
Self::CloudBillingSync => String::from("1"),
Self::Scim => String::from("2"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub enum OrganizationUserStatusType {
Accepted = 1,
Confirmed = 2,
Revoked = -1,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for OrganizationUserStatusType {
Expand All @@ -27,6 +30,7 @@ impl ToString for OrganizationUserStatusType {
Self::Accepted => String::from("1"),
Self::Confirmed => String::from("2"),
Self::Revoked => String::from("-1"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/organization_user_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub enum OrganizationUserType {
User = 2,
Manager = 3,
Custom = 4,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for OrganizationUserType {
Expand All @@ -29,6 +32,7 @@ impl ToString for OrganizationUserType {
Self::User => String::from("2"),
Self::Manager => String::from("3"),
Self::Custom => String::from("4"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/payment_method_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pub enum PaymentMethodType {
WireTransfer = 5,
Check = 8,
None = 255,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for PaymentMethodType {
Expand All @@ -35,6 +38,7 @@ impl ToString for PaymentMethodType {
Self::WireTransfer => String::from("5"),
Self::Check => String::from("8"),
Self::None => String::from("255"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/plan_sponsorship_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
)]
pub enum PlanSponsorshipType {
FamiliesForEnterprise = 0,

#[serde(other)]
UnknownValue = -1337,
}

impl ToString for PlanSponsorshipType {
fn to_string(&self) -> String {
match self {
Self::FamiliesForEnterprise => String::from("0"),
Self::UnknownValue => String::from("UnknownValue"),
}
}
}
Expand Down
Loading
Loading