1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_get_snapshot_block_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::GetSnapshotBlockInput,
|
7 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
|
8 + | >
|
9 + | where
|
10 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11 + | B::Data: Send,
|
12 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
13 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
14 + | {
|
15 + | Ok({
|
16 + | #[allow(unused_mut)]
|
17 + | let mut input = crate::input::get_snapshot_block_input::Builder::default();
|
18 + | #[allow(unused_variables)]
|
19 + | let ::aws_smithy_runtime_api::http::RequestParts {
|
20 + | uri, headers, body, ..
|
21 + | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
22 + | let input_string = uri.path();
|
23 + | let (input_string, (_, m1, _, m3)) =
|
24 + | ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
|
25 + | ::nom::sequence::preceded(
|
26 + | ::nom::bytes::complete::tag("/"),
|
27 + | ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("snapshots"),
|
28 + | ),
|
29 + | ::nom::sequence::preceded(
|
30 + | ::nom::bytes::complete::tag("/"),
|
31 + | ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
|
32 + | ::nom::bytes::complete::take_until("/"),
|
33 + | ::nom::combinator::rest,
|
34 + | )),
|
35 + | ),
|
36 + | ::nom::sequence::preceded(
|
37 + | ::nom::bytes::complete::tag("/"),
|
38 + | ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("blocks"),
|
39 + | ),
|
40 + | ::nom::sequence::preceded(
|
41 + | ::nom::bytes::complete::tag("/"),
|
42 + | ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
|
43 + | ::nom::bytes::complete::take_until("/"),
|
44 + | ::nom::combinator::rest,
|
45 + | )),
|
46 + | ),
|
47 + | ))(input_string)?;
|
48 + | debug_assert_eq!("", input_string);
|
49 + | input = input.set_snapshot_id(
|
50 + | crate::protocol_serde::shape_get_snapshot_block_input::de_snapshot_id(m1)?,
|
51 + | );
|
52 + | input = input.set_block_index(
|
53 + | crate::protocol_serde::shape_get_snapshot_block_input::de_block_index(m3)?,
|
54 + | );
|
55 + | let query_string = uri.query().unwrap_or("");
|
56 + | let pairs = ::form_urlencoded::parse(query_string.as_bytes());
|
57 + | let mut block_token_seen = false;
|
58 + | for (k, v) in pairs {
|
59 + | if !block_token_seen && k == "blockToken" {
|
60 + | input = input.set_block_token(
|
61 + | crate::protocol_serde::shape_get_snapshot_block_input::de_block_token(&v)?,
|
62 + | );
|
63 + | block_token_seen = true;
|
64 + | }
|
65 + | }
|
66 + | input.build()?
|
67 + | })
|
68 + | }
|
69 + |
|
70 + | #[allow(clippy::unnecessary_wraps)]
|
71 + | pub fn ser_get_snapshot_block_http_response(
|
72 + | #[allow(unused_variables)] output: crate::output::GetSnapshotBlockOutput,
|
73 + | ) -> std::result::Result<
|
74 + | ::aws_smithy_legacy_http_server::response::Response,
|
75 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
76 + | > {
|
77 + | Ok({
|
78 + | #[allow(unused_mut)]
|
79 + | let mut builder = ::http::Response::builder();
|
80 + | builder = crate::protocol_serde::shape_get_snapshot_block::ser_get_snapshot_block_headers(
|
81 + | &output, builder,
|
82 + | )?;
|
83 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
84 + | builder,
|
85 + | ::http::header::CONTENT_TYPE,
|
86 + | "application/octet-stream",
|
87 + | );
|
88 + | let http_status: u16 = 200;
|
89 + | builder = builder.status(http_status);
|
90 + | let body = ::aws_smithy_legacy_http_server::body::boxed(::aws_smithy_legacy_http_server::body::Body::wrap_stream(
|
91 + | ::aws_smithy_legacy_http::futures_stream_adapter::FuturesStreamCompatByteStream::new(
|
92 + | crate::protocol_serde::shape_get_snapshot_block_output::ser_block_data_http_payload( output.block_data)?
|
93 + | )
|
94 + | ));
|
95 + | builder.body(body)?
|
96 + | })
|
97 + | }
|
98 + |
|
99 + | #[allow(clippy::unnecessary_wraps)]
|
100 + | pub fn ser_get_snapshot_block_http_error(
|
101 + | error: &crate::error::GetSnapshotBlockError,
|
102 + | ) -> std::result::Result<
|
103 + | ::aws_smithy_legacy_http_server::response::Response,
|
104 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
105 + | > {
|
106 + | Ok({
|
107 + | match error {
|
108 + | crate::error::GetSnapshotBlockError::InternalServerException(output) => {
|
109 + | let payload = crate::protocol_serde::shape_internal_server_exception::ser_internal_server_exception_error(output)?;
|
110 + | #[allow(unused_mut)]
|
111 + | let mut builder = ::http::Response::builder();
|
112 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
113 + | builder,
|
114 + | ::http::header::CONTENT_TYPE,
|
115 + | "application/octet-stream",
|
116 + | );
|
117 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
118 + | builder,
|
119 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
120 + | "InternalServerException",
|
121 + | );
|
122 + | let content_length = payload.len();
|
123 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
124 + | builder,
|
125 + | ::http::header::CONTENT_LENGTH,
|
126 + | content_length,
|
127 + | );
|
128 + | builder
|
129 + | .status(500)
|
130 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
131 + | }
|
132 + | crate::error::GetSnapshotBlockError::ResourceNotFoundException(output) => {
|
133 + | let payload = crate::protocol_serde::shape_resource_not_found_exception::ser_resource_not_found_exception_error(output)?;
|
134 + | #[allow(unused_mut)]
|
135 + | let mut builder = ::http::Response::builder();
|
136 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
137 + | builder,
|
138 + | ::http::header::CONTENT_TYPE,
|
139 + | "application/octet-stream",
|
140 + | );
|
141 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
142 + | builder,
|
143 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
144 + | "ResourceNotFoundException",
|
145 + | );
|
146 + | let content_length = payload.len();
|
147 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
148 + | builder,
|
149 + | ::http::header::CONTENT_LENGTH,
|
150 + | content_length,
|
151 + | );
|
152 + | builder
|
153 + | .status(404)
|
154 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
155 + | }
|
156 + | crate::error::GetSnapshotBlockError::AccessDeniedException(output) => {
|
157 + | let payload = crate::protocol_serde::shape_access_denied_exception::ser_access_denied_exception_error(output)?;
|
158 + | #[allow(unused_mut)]
|
159 + | let mut builder = ::http::Response::builder();
|
160 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
161 + | builder,
|
162 + | ::http::header::CONTENT_TYPE,
|
163 + | "application/octet-stream",
|
164 + | );
|
165 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
166 + | builder,
|
167 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
168 + | "AccessDeniedException",
|
169 + | );
|
170 + | let content_length = payload.len();
|
171 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
172 + | builder,
|
173 + | ::http::header::CONTENT_LENGTH,
|
174 + | content_length,
|
175 + | );
|
176 + | builder
|
177 + | .status(403)
|
178 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
179 + | }
|
180 + | crate::error::GetSnapshotBlockError::RequestThrottledException(output) => {
|
181 + | let payload = crate::protocol_serde::shape_request_throttled_exception::ser_request_throttled_exception_error(output)?;
|
182 + | #[allow(unused_mut)]
|
183 + | let mut builder = ::http::Response::builder();
|
184 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
185 + | builder,
|
186 + | ::http::header::CONTENT_TYPE,
|
187 + | "application/octet-stream",
|
188 + | );
|
189 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
190 + | builder,
|
191 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
192 + | "RequestThrottledException",
|
193 + | );
|
194 + | let content_length = payload.len();
|
195 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
196 + | builder,
|
197 + | ::http::header::CONTENT_LENGTH,
|
198 + | content_length,
|
199 + | );
|
200 + | builder
|
201 + | .status(400)
|
202 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
203 + | }
|
204 + | crate::error::GetSnapshotBlockError::ServiceQuotaExceededException(output) => {
|
205 + | let payload = crate::protocol_serde::shape_service_quota_exceeded_exception::ser_service_quota_exceeded_exception_error(output)?;
|
206 + | #[allow(unused_mut)]
|
207 + | let mut builder = ::http::Response::builder();
|
208 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
209 + | builder,
|
210 + | ::http::header::CONTENT_TYPE,
|
211 + | "application/octet-stream",
|
212 + | );
|
213 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
214 + | builder,
|
215 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
216 + | "ServiceQuotaExceededException",
|
217 + | );
|
218 + | let content_length = payload.len();
|
219 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
220 + | builder,
|
221 + | ::http::header::CONTENT_LENGTH,
|
222 + | content_length,
|
223 + | );
|
224 + | builder
|
225 + | .status(402)
|
226 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
227 + | }
|
228 + | crate::error::GetSnapshotBlockError::ValidationException(output) => {
|
229 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
230 + | #[allow(unused_mut)]
|
231 + | let mut builder = ::http::Response::builder();
|
232 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
233 + | builder,
|
234 + | ::http::header::CONTENT_TYPE,
|
235 + | "application/octet-stream",
|
236 + | );
|
237 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
238 + | builder,
|
239 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
240 + | "ValidationException",
|
241 + | );
|
242 + | let content_length = payload.len();
|
243 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
244 + | builder,
|
245 + | ::http::header::CONTENT_LENGTH,
|
246 + | content_length,
|
247 + | );
|
248 + | builder
|
249 + | .status(400)
|
250 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
251 + | }
|
252 + | }
|
253 + | })
|
254 + | }
|
255 + |
|
256 + | pub fn ser_get_snapshot_block_headers(
|
257 + | input: &crate::output::GetSnapshotBlockOutput,
|
258 + | mut builder: ::http::response::Builder,
|
259 + | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
260 + | {
|
261 + | if let ::std::option::Option::Some(inner_1) = &input.data_length {
|
262 + | let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_1);
|
263 + | let formatted_2 = encoder.encode();
|
264 + | if !formatted_2.is_empty() {
|
265 + | let header_value = formatted_2;
|
266 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
267 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
268 + | "data_length",
|
269 + | format!(
|
270 + | "`{}` cannot be used as a header value: {}",
|
271 + | &header_value, err
|
272 + | ),
|
273 + | )
|
274 + | })?;
|
275 + | builder = builder.header("x-amz-Data-Length", header_value);
|
276 + | }
|
277 + | }
|
278 + | if let ::std::option::Option::Some(inner_3) = &input.checksum_algorithm {
|
279 + | let formatted_4 = inner_3.as_str();
|
280 + | if !formatted_4.is_empty() {
|
281 + | let header_value = formatted_4;
|
282 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
283 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
284 + | "checksum_algorithm",
|
285 + | format!(
|
286 + | "`{}` cannot be used as a header value: {}",
|
287 + | &header_value, err
|
288 + | ),
|
289 + | )
|
290 + | })?;
|
291 + | builder = builder.header("x-amz-Checksum-Algorithm", header_value);
|
292 + | }
|
293 + | }
|
294 + | if let ::std::option::Option::Some(inner_5) = &input.checksum {
|
295 + | let formatted_6 = inner_5.as_str();
|
296 + | if !formatted_6.is_empty() {
|
297 + | let header_value = formatted_6;
|
298 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
299 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
300 + | "checksum",
|
301 + | format!(
|
302 + | "`{}` cannot be used as a header value: {}",
|
303 + | &header_value, err
|
304 + | ),
|
305 + | )
|
306 + | })?;
|
307 + | builder = builder.header("x-amz-Checksum", header_value);
|
308 + | }
|
309 + | }
|
310 + | Ok(builder)
|
311 + | }
|