datadog_api_client/datadogV2/model/
model_ci_app_pipeline_event_pipeline.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/// Details of the top level pipeline, build, or workflow of your CI.
7#[non_exhaustive]
8#[derive(Clone, Debug, PartialEq, Serialize)]
9#[serde(untagged)]
10pub enum CIAppPipelineEventPipeline {
11    CIAppPipelineEventFinishedPipeline(
12        Box<crate::datadogV2::model::CIAppPipelineEventFinishedPipeline>,
13    ),
14    CIAppPipelineEventInProgressPipeline(
15        Box<crate::datadogV2::model::CIAppPipelineEventInProgressPipeline>,
16    ),
17    UnparsedObject(crate::datadog::UnparsedObject),
18}
19
20impl<'de> Deserialize<'de> for CIAppPipelineEventPipeline {
21    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
22    where
23        D: Deserializer<'de>,
24    {
25        let value: serde_json::Value = Deserialize::deserialize(deserializer)?;
26        if let Ok(_v) = serde_json::from_value::<
27            Box<crate::datadogV2::model::CIAppPipelineEventFinishedPipeline>,
28        >(value.clone())
29        {
30            if !_v._unparsed {
31                return Ok(CIAppPipelineEventPipeline::CIAppPipelineEventFinishedPipeline(_v));
32            }
33        }
34        if let Ok(_v) = serde_json::from_value::<
35            Box<crate::datadogV2::model::CIAppPipelineEventInProgressPipeline>,
36        >(value.clone())
37        {
38            if !_v._unparsed {
39                return Ok(CIAppPipelineEventPipeline::CIAppPipelineEventInProgressPipeline(_v));
40            }
41        }
42
43        return Ok(CIAppPipelineEventPipeline::UnparsedObject(
44            crate::datadog::UnparsedObject { value },
45        ));
46    }
47}