forked from aws/aws-lambda-rust-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
114 lines (106 loc) · 4.63 KB
/
Copy pathmod.rs
File metadata and controls
114 lines (106 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[cfg(feature = "catch-all-fields")]
use serde_json::Value;
use crate::custom_serde::deserialize_nullish_boolean;
/// `CodeCommitEvent` represents a CodeCommit event
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeCommitEvent {
#[serde(rename = "Records")]
pub records: Vec<CodeCommitRecord>,
/// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
/// Enabled with Cargo feature `catch-all-fields`.
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
#[cfg(feature = "catch-all-fields")]
#[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
#[serde(flatten)]
pub other: serde_json::Map<String, Value>,
}
pub type CodeCommitEventTime = DateTime<Utc>;
/// `CodeCommitRecord` represents a CodeCommit record
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeCommitRecord {
#[serde(default)]
pub event_id: Option<String>,
#[serde(default)]
pub event_version: Option<String>,
pub event_time: CodeCommitEventTime,
#[serde(default)]
pub event_trigger_name: Option<String>,
pub event_part_number: u64,
#[serde(rename = "codecommit")]
pub code_commit: CodeCommitCodeCommit,
#[serde(default)]
pub event_name: Option<String>,
/// nolint: stylecheck
#[serde(default)]
pub event_trigger_config_id: Option<String>,
#[serde(default)]
#[serde(rename = "eventSourceARN")]
pub event_source_arn: Option<String>,
#[serde(default)]
#[serde(rename = "userIdentityARN")]
pub user_identity_arn: Option<String>,
#[serde(default)]
pub event_source: Option<String>,
#[serde(default)]
pub aws_region: Option<String>,
pub event_total_parts: u64,
pub custom_data: Option<String>,
/// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
/// Enabled with Cargo feature `catch-all-fields`.
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
#[cfg(feature = "catch-all-fields")]
#[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
#[serde(flatten)]
pub other: serde_json::Map<String, Value>,
}
/// `CodeCommitCodeCommit` represents a CodeCommit object in a record
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeCommitCodeCommit {
pub references: Vec<CodeCommitReference>,
/// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
/// Enabled with Cargo feature `catch-all-fields`.
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
/// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
/// Enabled with Cargo feature `catch-all-fields`.
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
#[cfg(feature = "catch-all-fields")]
#[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
#[serde(flatten)]
pub other: serde_json::Map<String, Value>,
}
/// `CodeCommitReference` represents a Reference object in a CodeCommit object
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeCommitReference {
#[serde(default)]
pub commit: Option<String>,
#[serde(default)]
pub ref_: Option<String>,
#[serde(default, deserialize_with = "deserialize_nullish_boolean")]
pub created: bool,
/// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
/// Enabled with Cargo feature `catch-all-fields`.
/// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
#[cfg(feature = "catch-all-fields")]
#[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
#[serde(flatten)]
pub other: serde_json::Map<String, Value>,
}
#[cfg(test)]
mod test {
use super::*;
#[test]
#[cfg(feature = "code_commit")]
fn example_code_commit_event() {
let data = include_bytes!("../../fixtures/example-code_commit-event.json");
let parsed: CodeCommitEvent = serde_json::from_slice(data).unwrap();
let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CodeCommitEvent = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}
}