datadog_api_client/datadogV1/model/
model_list_stream_source.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 ListStreamSource {
10    LOGS_STREAM,
11    AUDIT_STREAM,
12    CI_PIPELINE_STREAM,
13    CI_TEST_STREAM,
14    RUM_ISSUE_STREAM,
15    APM_ISSUE_STREAM,
16    TRACE_STREAM,
17    LOGS_ISSUE_STREAM,
18    LOGS_PATTERN_STREAM,
19    LOGS_TRANSACTION_STREAM,
20    EVENT_STREAM,
21    RUM_STREAM,
22    LLM_OBSERVABILITY_STREAM,
23    UnparsedObject(crate::datadog::UnparsedObject),
24}
25
26impl ToString for ListStreamSource {
27    fn to_string(&self) -> String {
28        match self {
29            Self::LOGS_STREAM => String::from("logs_stream"),
30            Self::AUDIT_STREAM => String::from("audit_stream"),
31            Self::CI_PIPELINE_STREAM => String::from("ci_pipeline_stream"),
32            Self::CI_TEST_STREAM => String::from("ci_test_stream"),
33            Self::RUM_ISSUE_STREAM => String::from("rum_issue_stream"),
34            Self::APM_ISSUE_STREAM => String::from("apm_issue_stream"),
35            Self::TRACE_STREAM => String::from("trace_stream"),
36            Self::LOGS_ISSUE_STREAM => String::from("logs_issue_stream"),
37            Self::LOGS_PATTERN_STREAM => String::from("logs_pattern_stream"),
38            Self::LOGS_TRANSACTION_STREAM => String::from("logs_transaction_stream"),
39            Self::EVENT_STREAM => String::from("event_stream"),
40            Self::RUM_STREAM => String::from("rum_stream"),
41            Self::LLM_OBSERVABILITY_STREAM => String::from("llm_observability_stream"),
42            Self::UnparsedObject(v) => v.value.to_string(),
43        }
44    }
45}
46
47impl Serialize for ListStreamSource {
48    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
49    where
50        S: Serializer,
51    {
52        match self {
53            Self::UnparsedObject(v) => v.serialize(serializer),
54            _ => serializer.serialize_str(self.to_string().as_str()),
55        }
56    }
57}
58
59impl<'de> Deserialize<'de> for ListStreamSource {
60    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
61    where
62        D: Deserializer<'de>,
63    {
64        let s: String = String::deserialize(deserializer)?;
65        Ok(match s.as_str() {
66            "logs_stream" => Self::LOGS_STREAM,
67            "audit_stream" => Self::AUDIT_STREAM,
68            "ci_pipeline_stream" => Self::CI_PIPELINE_STREAM,
69            "ci_test_stream" => Self::CI_TEST_STREAM,
70            "rum_issue_stream" => Self::RUM_ISSUE_STREAM,
71            "apm_issue_stream" => Self::APM_ISSUE_STREAM,
72            "trace_stream" => Self::TRACE_STREAM,
73            "logs_issue_stream" => Self::LOGS_ISSUE_STREAM,
74            "logs_pattern_stream" => Self::LOGS_PATTERN_STREAM,
75            "logs_transaction_stream" => Self::LOGS_TRANSACTION_STREAM,
76            "event_stream" => Self::EVENT_STREAM,
77            "rum_stream" => Self::RUM_STREAM,
78            "llm_observability_stream" => Self::LLM_OBSERVABILITY_STREAM,
79            _ => Self::UnparsedObject(crate::datadog::UnparsedObject {
80                value: serde_json::Value::String(s.into()),
81            }),
82        })
83    }
84}