datadog_api_client/datadogV2/model/
model_case_priority.rs

1// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2// This product includes software developed at Datadog (https://www.datadoghq.com/).
3// Copyright 2019-Present Datadog, Inc.
4
5use serde::{Deserialize, Deserializer, Serialize, Serializer};
6
7#[non_exhaustive]
8#[derive(Clone, Debug, Eq, PartialEq)]
9pub enum CasePriority {
10    NOT_DEFINED,
11    P1,
12    P2,
13    P3,
14    P4,
15    P5,
16    UnparsedObject(crate::datadog::UnparsedObject),
17}
18
19impl ToString for CasePriority {
20    fn to_string(&self) -> String {
21        match self {
22            Self::NOT_DEFINED => String::from("NOT_DEFINED"),
23            Self::P1 => String::from("P1"),
24            Self::P2 => String::from("P2"),
25            Self::P3 => String::from("P3"),
26            Self::P4 => String::from("P4"),
27            Self::P5 => String::from("P5"),
28            Self::UnparsedObject(v) => v.value.to_string(),
29        }
30    }
31}
32
33impl Serialize for CasePriority {
34    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
35    where
36        S: Serializer,
37    {
38        match self {
39            Self::UnparsedObject(v) => v.serialize(serializer),
40            _ => serializer.serialize_str(self.to_string().as_str()),
41        }
42    }
43}
44
45impl<'de> Deserialize<'de> for CasePriority {
46    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
47    where
48        D: Deserializer<'de>,
49    {
50        let s: String = String::deserialize(deserializer)?;
51        Ok(match s.as_str() {
52            "NOT_DEFINED" => Self::NOT_DEFINED,
53            "P1" => Self::P1,
54            "P2" => Self::P2,
55            "P3" => Self::P3,
56            "P4" => Self::P4,
57            "P5" => Self::P5,
58            _ => Self::UnparsedObject(crate::datadog::UnparsedObject {
59                value: serde_json::Value::String(s.into()),
60            }),
61        })
62    }
63}