|
1 | 1 | use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
2 | 2 | use serde_json::Value;
|
| 3 | +use std::collections::HashMap; |
3 | 4 |
|
4 | 5 | #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
5 | 6 | #[serde(tag = "RequestType")]
|
|
75 | 76 | pub resource_properties: P2,
|
76 | 77 | }
|
77 | 78 |
|
| 79 | +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] |
| 80 | +#[serde(rename_all = "PascalCase")] |
| 81 | +pub struct CloudFormationCustomResourceResponse { |
| 82 | + pub status: CloudFormationCustomResourceResponseStatus, |
| 83 | + pub reason: Option<String>, |
| 84 | + pub physical_resource_id: String, |
| 85 | + pub stack_id: String, |
| 86 | + pub request_id: String, |
| 87 | + pub logical_resource_id: String, |
| 88 | + pub no_echo: bool, |
| 89 | + pub data: HashMap<String, String>, |
| 90 | +} |
| 91 | + |
| 92 | +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] |
| 93 | +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] |
| 94 | +pub enum CloudFormationCustomResourceResponseStatus { |
| 95 | + Success, |
| 96 | + Failed, |
| 97 | +} |
| 98 | + |
78 | 99 | #[cfg(test)]
|
79 | 100 | mod test {
|
80 | 101 | use std::collections::HashMap;
|
@@ -136,4 +157,13 @@ mod test {
|
136 | 157 | let reparsed: TestRequest = serde_json::from_slice(output.as_bytes()).unwrap();
|
137 | 158 | assert_eq!(parsed, reparsed);
|
138 | 159 | }
|
| 160 | + |
| 161 | + #[test] |
| 162 | + fn example_cloudformation_custom_resource_response() { |
| 163 | + let data = include_bytes!("../../fixtures/example-cloudformation-custom-resource-response.json"); |
| 164 | + let parsed: CloudFormationCustomResourceResponse = serde_json::from_slice(data).unwrap(); |
| 165 | + let output: String = serde_json::to_string(&parsed).unwrap(); |
| 166 | + let reparsed: CloudFormationCustomResourceResponse = serde_json::from_slice(output.as_bytes()).unwrap(); |
| 167 | + assert_eq!(parsed, reparsed); |
| 168 | + } |
139 | 169 | }
|
0 commit comments