datadog_api_client/datadogV2/model/
model_entity_v3_datadog_integration_pagerduty.rs1use serde::de::{Error, MapAccess, Visitor};
5use serde::{Deserialize, Deserializer, Serialize};
6use serde_with::skip_serializing_none;
7use std::fmt::{self, Formatter};
8
9#[non_exhaustive]
11#[skip_serializing_none]
12#[derive(Clone, Debug, PartialEq, Serialize)]
13pub struct EntityV3DatadogIntegrationPagerduty {
14 #[serde(rename = "serviceURL")]
16 pub service_url: String,
17 #[serde(skip)]
18 #[serde(default)]
19 pub(crate) _unparsed: bool,
20}
21
22impl EntityV3DatadogIntegrationPagerduty {
23 pub fn new(service_url: String) -> EntityV3DatadogIntegrationPagerduty {
24 EntityV3DatadogIntegrationPagerduty {
25 service_url,
26 _unparsed: false,
27 }
28 }
29}
30
31impl<'de> Deserialize<'de> for EntityV3DatadogIntegrationPagerduty {
32 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
33 where
34 D: Deserializer<'de>,
35 {
36 struct EntityV3DatadogIntegrationPagerdutyVisitor;
37 impl<'a> Visitor<'a> for EntityV3DatadogIntegrationPagerdutyVisitor {
38 type Value = EntityV3DatadogIntegrationPagerduty;
39
40 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
41 f.write_str("a mapping")
42 }
43
44 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
45 where
46 M: MapAccess<'a>,
47 {
48 let mut service_url: Option<String> = None;
49 let mut _unparsed = false;
50
51 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
52 match k.as_str() {
53 "serviceURL" => {
54 service_url =
55 Some(serde_json::from_value(v).map_err(M::Error::custom)?);
56 }
57 &_ => {
58 return Err(serde::de::Error::custom(
59 "Additional properties not allowed",
60 ));
61 }
62 }
63 }
64 let service_url =
65 service_url.ok_or_else(|| M::Error::missing_field("service_url"))?;
66
67 let content = EntityV3DatadogIntegrationPagerduty {
68 service_url,
69 _unparsed,
70 };
71
72 Ok(content)
73 }
74 }
75
76 deserializer.deserialize_any(EntityV3DatadogIntegrationPagerdutyVisitor)
77 }
78}