1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_sensitive_validation_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::SensitiveValidationInput,
|
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::sensitive_validation_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 bytes = ::hyper::body::to_bytes(body).await?;
|
23 + | if !bytes.is_empty() {
|
24 + | ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
|
25 + | &headers,
|
26 + | Some("application/json"),
|
27 + | )?;
|
28 + | input = crate::protocol_serde::shape_sensitive_validation::de_sensitive_validation(
|
29 + | bytes.as_ref(),
|
30 + | input,
|
31 + | )?;
|
32 + | }
|
33 + | input.build()?
|
34 + | })
|
35 + | }
|
36 + |
|
37 + | #[allow(clippy::unnecessary_wraps)]
|
38 + | pub fn ser_sensitive_validation_http_response(
|
39 + | #[allow(unused_variables)] output: crate::output::SensitiveValidationOutput,
|
40 + | ) -> std::result::Result<
|
41 + | ::aws_smithy_legacy_http_server::response::Response,
|
42 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
43 + | > {
|
44 + | Ok({
|
45 + | #[allow(unused_mut)]
|
46 + | let mut builder = ::http::Response::builder();
|
47 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
48 + | builder,
|
49 + | ::http::header::CONTENT_TYPE,
|
50 + | "application/json",
|
51 + | );
|
52 + | let http_status: u16 = 200;
|
53 + | builder = builder.status(http_status);
|
54 + | let payload = "";
|
55 + | let content_length = payload.len();
|
56 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
57 + | builder,
|
58 + | ::http::header::CONTENT_LENGTH,
|
59 + | content_length,
|
60 + | );
|
61 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
62 + | builder.body(body)?
|
63 + | })
|
64 + | }
|
65 + |
|
66 + | #[allow(clippy::unnecessary_wraps)]
|
67 + | pub fn ser_sensitive_validation_http_error(
|
68 + | error: &crate::error::SensitiveValidationError,
|
69 + | ) -> std::result::Result<
|
70 + | ::aws_smithy_legacy_http_server::response::Response,
|
71 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
72 + | > {
|
73 + | Ok({
|
74 + | match error {
|
75 + | crate::error::SensitiveValidationError::ValidationException(output) => {
|
76 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
77 + | #[allow(unused_mut)]
|
78 + | let mut builder = ::http::Response::builder();
|
79 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
80 + | builder,
|
81 + | ::http::header::CONTENT_TYPE,
|
82 + | "application/json",
|
83 + | );
|
84 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
85 + | builder,
|
86 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
87 + | "ValidationException",
|
88 + | );
|
89 + | let content_length = payload.len();
|
90 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
91 + | builder,
|
92 + | ::http::header::CONTENT_LENGTH,
|
93 + | content_length,
|
94 + | );
|
95 + | builder
|
96 + | .status(400)
|
97 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
98 + | }
|
99 + | }
|
100 + | })
|
101 + | }
|
102 + |
|
103 + | pub(crate) fn de_sensitive_validation(
|
104 + | value: &[u8],
|
105 + | mut builder: crate::input::sensitive_validation_input::Builder,
|
106 + | ) -> ::std::result::Result<
|
107 + | crate::input::sensitive_validation_input::Builder,
|
108 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
109 + | > {
|
110 + | let mut tokens_owned =
|
111 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
112 + | .peekable();
|
113 + | let tokens = &mut tokens_owned;
|
114 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
115 + | loop {
|
116 + | match tokens.next().transpose()? {
|
117 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
118 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
119 + | match key.to_unescaped()?.as_ref() {
|
120 + | "string" => {
|
121 + | builder = builder.set_string(
|
122 + | ::aws_smithy_json::deserialize::token::expect_string_or_null(
|
123 + | tokens.next(),
|
124 + | )?
|
125 + | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
126 + | .transpose()?,
|
127 + | );
|
128 + | }
|
129 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
130 + | }
|
131 + | }
|
132 + | other => {
|
133 + | return Err(
|
134 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
135 + | "expected object key or end object, found: {other:?}"
|
136 + | )),
|
137 + | )
|
138 + | }
|
139 + | }
|
140 + | }
|
141 + | if tokens.next().is_some() {
|
142 + | return Err(
|
143 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
144 + | "found more JSON tokens after completing parsing",
|
145 + | ),
|
146 + | );
|
147 + | }
|
148 + | Ok(builder)
|
149 + | }
|