use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
pub type CodePipelineStageState = String;
pub type CodePipelineState = String;
pub type CodePipelineActionState = String;
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodePipelineCloudWatchEvent {
#[serde(default)]
pub version: Option<String>,
#[serde(default)]
pub id: Option<String>,
#[serde(default)]
#[serde(rename = "detail-type")]
pub detail_type: Option<String>,
#[serde(default)]
pub source: Option<String>,
#[serde(default)]
#[serde(rename = "account")]
pub account_id: Option<String>,
pub time: DateTime<Utc>,
#[serde(default)]
pub region: Option<String>,
pub resources: Vec<String>,
pub detail: CodePipelineEventDetail,
}
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodePipelineEventDetail {
#[serde(default)]
pub pipeline: Option<String>,
pub version: i64,
#[serde(default)]
#[serde(rename = "execution-id")]
pub execution_id: Option<String>,
#[serde(default)]
pub stage: Option<String>,
#[serde(default)]
pub action: Option<String>,
pub state: CodePipelineState,
#[serde(default)]
pub region: Option<String>,
pub type_: Option<CodePipelineEventDetailType>,
}
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodePipelineEventDetailType {
#[serde(default)]
pub owner: Option<String>,
#[serde(default)]
pub category: Option<String>,
#[serde(default)]
pub provider: Option<String>,
pub version: i64,
}
#[cfg(test)]
mod test {
use super::*;
#[test]
#[cfg(feature = "codepipeline_cloudwatch")]
fn example_codepipeline_action_execution_stage_change_event() {
let data = include_bytes!("../../fixtures/example-codepipeline-action-execution-stage-change-event.json");
let parsed: CodePipelineCloudWatchEvent = serde_json::from_slice(data).unwrap();
let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CodePipelineCloudWatchEvent = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}
#[test]
#[cfg(feature = "codepipeline_cloudwatch")]
fn example_codepipeline_execution_stage_change_event() {
let data = include_bytes!("../../fixtures/example-codepipeline-execution-stage-change-event.json");
let parsed: CodePipelineCloudWatchEvent = serde_json::from_slice(data).unwrap();
let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CodePipelineCloudWatchEvent = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}
#[test]
#[cfg(feature = "codepipeline_cloudwatch")]
fn example_codepipeline_execution_state_change_event() {
let data = include_bytes!("../../fixtures/example-codepipeline-execution-state-change-event.json");
let parsed: CodePipelineCloudWatchEvent = serde_json::from_slice(data).unwrap();
let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CodePipelineCloudWatchEvent = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}
}