datadog_api_client/datadogV2/model/
model_action_query_condition.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.
4use serde::{Deserialize, Deserializer, Serialize};
5
6/// Whether to run this query. If specified, the query will only run if this condition evaluates to `true` in JavaScript and all other conditions are also met.
7#[non_exhaustive]
8#[derive(Clone, Debug, PartialEq, Serialize)]
9#[serde(untagged)]
10pub enum ActionQueryCondition {
11    Bool(bool),
12    String(String),
13    UnparsedObject(crate::datadog::UnparsedObject),
14}
15
16impl<'de> Deserialize<'de> for ActionQueryCondition {
17    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
18    where
19        D: Deserializer<'de>,
20    {
21        let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
22        if let Ok(_v) = serde_json::from_value::<bool>(value.clone()) {
23            return Ok(ActionQueryCondition::Bool(_v));
24        }
25        if let Ok(_v) = serde_json::from_value::<String>(value.clone()) {
26            return Ok(ActionQueryCondition::String(_v));
27        }
28
29        return Ok(ActionQueryCondition::UnparsedObject(
30            crate::datadog::UnparsedObject { value },
31        ));
32    }
33}