1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | #[allow(clippy::unnecessary_wraps)]
|
3 - | pub fn de_put_resource_policy_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::put_resource_policy::PutResourcePolicyOutput, crate::operation::put_resource_policy::PutResourcePolicyError>
|
8 - | {
|
9 - | #[allow(unused_mut)]
|
10 - | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
|
11 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
12 - | generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
|
13 - | let generic = generic_builder.build();
|
14 - | let error_code = match generic.code() {
|
15 - | Some(code) => code,
|
16 - | None => return Err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled(generic)),
|
17 - | };
|
18 - |
|
19 - | let _error_message = generic.message().map(|msg| msg.to_owned());
|
20 - | Err(match error_code {
|
21 - | "InternalServerError" => crate::operation::put_resource_policy::PutResourcePolicyError::InternalServerError({
|
22 - | #[allow(unused_mut)]
|
23 - | let mut tmp = {
|
24 - | #[allow(unused_mut)]
|
25 - | let mut output = crate::types::error::builders::InternalServerErrorBuilder::default();
|
26 - | output = crate::protocol_serde::shape_internal_server_error::de_internal_server_error_json_err(_response_body, output)
|
27 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
28 - | let output = output.meta(generic);
|
29 - | output.build()
|
30 - | };
|
31 - | if tmp.message.is_none() {
|
32 - | tmp.message = _error_message;
|
33 - | }
|
34 - | tmp
|
35 - | }),
|
36 - | "InvalidEndpointException" => crate::operation::put_resource_policy::PutResourcePolicyError::InvalidEndpointException({
|
37 - | #[allow(unused_mut)]
|
38 - | let mut tmp = {
|
39 - | #[allow(unused_mut)]
|
40 - | let mut output = crate::types::error::builders::InvalidEndpointExceptionBuilder::default();
|
41 - | output = crate::protocol_serde::shape_invalid_endpoint_exception::de_invalid_endpoint_exception_json_err(_response_body, output)
|
42 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
43 - | let output = output.meta(generic);
|
44 - | output.build()
|
45 - | };
|
46 - | if tmp.message.is_none() {
|
47 - | tmp.message = _error_message;
|
48 - | }
|
49 - | tmp
|
50 - | }),
|
51 - | "LimitExceededException" => crate::operation::put_resource_policy::PutResourcePolicyError::LimitExceededException({
|
52 - | #[allow(unused_mut)]
|
53 - | let mut tmp = {
|
54 - | #[allow(unused_mut)]
|
55 - | let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
|
56 - | output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
|
57 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
58 - | let output = output.meta(generic);
|
59 - | output.build()
|
60 - | };
|
61 - | if tmp.message.is_none() {
|
62 - | tmp.message = _error_message;
|
63 - | }
|
64 - | tmp
|
65 - | }),
|
66 - | "PolicyNotFoundException" => crate::operation::put_resource_policy::PutResourcePolicyError::PolicyNotFoundException({
|
67 - | #[allow(unused_mut)]
|
68 - | let mut tmp = {
|
69 - | #[allow(unused_mut)]
|
70 - | let mut output = crate::types::error::builders::PolicyNotFoundExceptionBuilder::default();
|
71 - | output = crate::protocol_serde::shape_policy_not_found_exception::de_policy_not_found_exception_json_err(_response_body, output)
|
72 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
73 - | let output = output.meta(generic);
|
74 - | output.build()
|
75 - | };
|
76 - | if tmp.message.is_none() {
|
77 - | tmp.message = _error_message;
|
78 - | }
|
79 - | tmp
|
80 - | }),
|
81 - | "ResourceInUseException" => crate::operation::put_resource_policy::PutResourcePolicyError::ResourceInUseException({
|
82 - | #[allow(unused_mut)]
|
83 - | let mut tmp = {
|
84 - | #[allow(unused_mut)]
|
85 - | let mut output = crate::types::error::builders::ResourceInUseExceptionBuilder::default();
|
86 - | output = crate::protocol_serde::shape_resource_in_use_exception::de_resource_in_use_exception_json_err(_response_body, output)
|
87 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
88 - | let output = output.meta(generic);
|
89 - | output.build()
|
90 - | };
|
91 - | if tmp.message.is_none() {
|
92 - | tmp.message = _error_message;
|
93 - | }
|
94 - | tmp
|
95 - | }),
|
96 - | "ResourceNotFoundException" => crate::operation::put_resource_policy::PutResourcePolicyError::ResourceNotFoundException({
|
97 - | #[allow(unused_mut)]
|
98 - | let mut tmp = {
|
99 - | #[allow(unused_mut)]
|
100 - | let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
|
101 - | output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
|
102 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
103 - | let output = output.meta(generic);
|
104 - | output.build()
|
105 - | };
|
106 - | if tmp.message.is_none() {
|
107 - | tmp.message = _error_message;
|
108 - | }
|
109 - | tmp
|
110 - | }),
|
111 - | _ => crate::operation::put_resource_policy::PutResourcePolicyError::generic(generic),
|
112 - | })
|
113 - | }
|
114 - |
|
115 - | #[allow(clippy::unnecessary_wraps)]
|
116 - | pub fn de_put_resource_policy_http_response(
|
117 - | _response_status: u16,
|
118 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
119 - | _response_body: &[u8],
|
120 - | ) -> std::result::Result<crate::operation::put_resource_policy::PutResourcePolicyOutput, crate::operation::put_resource_policy::PutResourcePolicyError>
|
121 - | {
|
122 - | Ok({
|
123 - | #[allow(unused_mut)]
|
124 - | let mut output = crate::operation::put_resource_policy::builders::PutResourcePolicyOutputBuilder::default();
|
125 - | output = crate::protocol_serde::shape_put_resource_policy::de_put_resource_policy(_response_body, output)
|
126 - | .map_err(crate::operation::put_resource_policy::PutResourcePolicyError::unhandled)?;
|
127 - | output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
|
128 - | output.build()
|
129 - | })
|
130 - | }
|
131 - |
|
132 - | pub fn ser_put_resource_policy_input(
|
133 - | input: &crate::operation::put_resource_policy::PutResourcePolicyInput,
|
134 - | ) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
|
135 - | let mut out = String::new();
|
136 - | let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
|
137 - | crate::protocol_serde::shape_put_resource_policy_input::ser_put_resource_policy_input_input(&mut object, input)?;
|
138 - | object.finish();
|
139 - | Ok(::aws_smithy_types::body::SdkBody::from(out))
|
140 - | }
|
141 - |
|
142 - | pub(crate) fn de_put_resource_policy(
|
143 - | _value: &[u8],
|
144 - | mut builder: crate::operation::put_resource_policy::builders::PutResourcePolicyOutputBuilder,
|
145 - | ) -> ::std::result::Result<
|
146 - | crate::operation::put_resource_policy::builders::PutResourcePolicyOutputBuilder,
|
147 - | ::aws_smithy_json::deserialize::error::DeserializeError,
|
148 - | > {
|
149 - | let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
|
150 - | let tokens = &mut tokens_owned;
|
151 - | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
152 - | loop {
|
153 - | match tokens.next().transpose()? {
|
154 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
155 - | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
|
156 - | "RevisionId" => {
|
157 - | builder = builder.set_revision_id(
|
158 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
159 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
160 - | .transpose()?,
|
161 - | );
|
162 - | }
|
163 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
164 - | },
|
165 - | other => {
|
166 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
167 - | "expected object key or end object, found: {other:?}"
|
168 - | )))
|
169 - | }
|
170 - | }
|
171 - | }
|
172 - | if tokens.next().is_some() {
|
173 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
174 - | "found more JSON tokens after completing parsing",
|
175 - | ));
|
176 - | }
|
177 - | Ok(builder)
|
178 - | }
|