datadog_api_client/datadogV2/model/
model_security_monitoring_signal_state.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 SecurityMonitoringSignalState {
10    OPEN,
11    ARCHIVED,
12    UNDER_REVIEW,
13    UnparsedObject(crate::datadog::UnparsedObject),
14}
15
16impl ToString for SecurityMonitoringSignalState {
17    fn to_string(&self) -> String {
18        match self {
19            Self::OPEN => String::from("open"),
20            Self::ARCHIVED => String::from("archived"),
21            Self::UNDER_REVIEW => String::from("under_review"),
22            Self::UnparsedObject(v) => v.value.to_string(),
23        }
24    }
25}
26
27impl Serialize for SecurityMonitoringSignalState {
28    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
29    where
30        S: Serializer,
31    {
32        match self {
33            Self::UnparsedObject(v) => v.serialize(serializer),
34            _ => serializer.serialize_str(self.to_string().as_str()),
35        }
36    }
37}
38
39impl<'de> Deserialize<'de> for SecurityMonitoringSignalState {
40    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
41    where
42        D: Deserializer<'de>,
43    {
44        let s: String = String::deserialize(deserializer)?;
45        Ok(match s.as_str() {
46            "open" => Self::OPEN,
47            "archived" => Self::ARCHIVED,
48            "under_review" => Self::UNDER_REVIEW,
49            _ => Self::UnparsedObject(crate::datadog::UnparsedObject {
50                value: serde_json::Value::String(s.into()),
51            }),
52        })
53    }
54}