aws_sdk_ec2/protocol_serde/
shape_lock_snapshot.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_lock_snapshot_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::lock_snapshot::LockSnapshotOutput, crate::operation::lock_snapshot::LockSnapshotError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::lock_snapshot::LockSnapshotError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 Err(crate::operation::lock_snapshot::LockSnapshotError::generic(generic))
14}
15
16#[allow(clippy::unnecessary_wraps)]
17pub fn de_lock_snapshot_http_response(
18 _response_status: u16,
19 _response_headers: &::aws_smithy_runtime_api::http::Headers,
20 _response_body: &[u8],
21) -> std::result::Result<crate::operation::lock_snapshot::LockSnapshotOutput, crate::operation::lock_snapshot::LockSnapshotError> {
22 Ok({
23 #[allow(unused_mut)]
24 let mut output = crate::operation::lock_snapshot::builders::LockSnapshotOutputBuilder::default();
25 output = crate::protocol_serde::shape_lock_snapshot::de_lock_snapshot(_response_body, output)
26 .map_err(crate::operation::lock_snapshot::LockSnapshotError::unhandled)?;
27 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
28 output.build()
29 })
30}
31
32#[allow(unused_mut)]
33pub fn de_lock_snapshot(
34 inp: &[u8],
35 mut builder: crate::operation::lock_snapshot::builders::LockSnapshotOutputBuilder,
36) -> std::result::Result<crate::operation::lock_snapshot::builders::LockSnapshotOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
37 let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
38
39 #[allow(unused_mut)]
40 let mut decoder = doc.root_element()?;
41 #[allow(unused_variables)]
42 let start_el = decoder.start_el();
43 if !(start_el.matches("LockSnapshotResponse")) {
44 return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
45 "invalid root, expected LockSnapshotResponse got {:?}",
46 start_el
47 )));
48 }
49 while let Some(mut tag) = decoder.next_tag() {
50 match tag.start_el() {
51 s if s.matches("snapshotId") => {
52 let var_1 =
53 Some(
54 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
55 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
56 .into()
57 )
58 ?
59 )
60 ;
61 builder = builder.set_snapshot_id(var_1);
62 }
63 ,
64 s if s.matches("lockState") => {
65 let var_2 =
66 Some(
67 Result::<crate::types::LockState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
68 crate::types::LockState::from(
69 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
70 )
71 )
72 ?
73 )
74 ;
75 builder = builder.set_lock_state(var_2);
76 }
77 ,
78 s if s.matches("lockDuration") => {
79 let var_3 =
80 Some(
81 {
82 <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
83 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
84 )
85 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#RetentionPeriodResponseDays`)"))
86 }
87 ?
88 )
89 ;
90 builder = builder.set_lock_duration(var_3);
91 }
92 ,
93 s if s.matches("coolOffPeriod") => {
94 let var_4 =
95 Some(
96 {
97 <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
98 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
99 )
100 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#CoolOffPeriodResponseHours`)"))
101 }
102 ?
103 )
104 ;
105 builder = builder.set_cool_off_period(var_4);
106 }
107 ,
108 s if s.matches("coolOffPeriodExpiresOn") => {
109 let var_5 =
110 Some(
111 ::aws_smithy_types::DateTime::from_str(
112 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
113 , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
114 )
115 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
116 ?
117 )
118 ;
119 builder = builder.set_cool_off_period_expires_on(var_5);
120 }
121 ,
122 s if s.matches("lockCreatedOn") => {
123 let var_6 =
124 Some(
125 ::aws_smithy_types::DateTime::from_str(
126 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
127 , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
128 )
129 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
130 ?
131 )
132 ;
133 builder = builder.set_lock_created_on(var_6);
134 }
135 ,
136 s if s.matches("lockExpiresOn") => {
137 let var_7 =
138 Some(
139 ::aws_smithy_types::DateTime::from_str(
140 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
141 , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
142 )
143 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
144 ?
145 )
146 ;
147 builder = builder.set_lock_expires_on(var_7);
148 }
149 ,
150 s if s.matches("lockDurationStartTime") => {
151 let var_8 =
152 Some(
153 ::aws_smithy_types::DateTime::from_str(
154 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
155 , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
156 )
157 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
158 ?
159 )
160 ;
161 builder = builder.set_lock_duration_start_time(var_8);
162 }
163 ,
164 _ => {}
165 }
166 }
167 Ok(builder)
168}