aws_sdk_workdocs/protocol_serde/
shape_create_labels.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_labels_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::create_labels::CreateLabelsOutput, crate::operation::create_labels::CreateLabelsError> {
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::create_labels::CreateLabelsError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::create_labels::CreateLabelsError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "EntityNotExistsException" => crate::operation::create_labels::CreateLabelsError::EntityNotExistsException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::EntityNotExistsExceptionBuilder::default();
25 output = crate::protocol_serde::shape_entity_not_exists_exception::de_entity_not_exists_exception_json_err(_response_body, output)
26 .map_err(crate::operation::create_labels::CreateLabelsError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "FailedDependencyException" => crate::operation::create_labels::CreateLabelsError::FailedDependencyException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::FailedDependencyExceptionBuilder::default();
40 output = crate::protocol_serde::shape_failed_dependency_exception::de_failed_dependency_exception_json_err(_response_body, output)
41 .map_err(crate::operation::create_labels::CreateLabelsError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 "ServiceUnavailableException" => crate::operation::create_labels::CreateLabelsError::ServiceUnavailableException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
55 output =
56 crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
57 .map_err(crate::operation::create_labels::CreateLabelsError::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 "TooManyLabelsException" => crate::operation::create_labels::CreateLabelsError::TooManyLabelsException({
67 #[allow(unused_mut)]
68 let mut tmp = {
69 #[allow(unused_mut)]
70 let mut output = crate::types::error::builders::TooManyLabelsExceptionBuilder::default();
71 output = crate::protocol_serde::shape_too_many_labels_exception::de_too_many_labels_exception_json_err(_response_body, output)
72 .map_err(crate::operation::create_labels::CreateLabelsError::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 "UnauthorizedOperationException" => crate::operation::create_labels::CreateLabelsError::UnauthorizedOperationException({
82 #[allow(unused_mut)]
83 let mut tmp = {
84 #[allow(unused_mut)]
85 let mut output = crate::types::error::builders::UnauthorizedOperationExceptionBuilder::default();
86 output = crate::protocol_serde::shape_unauthorized_operation_exception::de_unauthorized_operation_exception_json_err(
87 _response_body,
88 output,
89 )
90 .map_err(crate::operation::create_labels::CreateLabelsError::unhandled)?;
91 let output = output.meta(generic);
92 output.build()
93 };
94 if tmp.message.is_none() {
95 tmp.message = _error_message;
96 }
97 tmp
98 }),
99 "UnauthorizedResourceAccessException" => crate::operation::create_labels::CreateLabelsError::UnauthorizedResourceAccessException({
100 #[allow(unused_mut)]
101 let mut tmp = {
102 #[allow(unused_mut)]
103 let mut output = crate::types::error::builders::UnauthorizedResourceAccessExceptionBuilder::default();
104 output = crate::protocol_serde::shape_unauthorized_resource_access_exception::de_unauthorized_resource_access_exception_json_err(
105 _response_body,
106 output,
107 )
108 .map_err(crate::operation::create_labels::CreateLabelsError::unhandled)?;
109 let output = output.meta(generic);
110 output.build()
111 };
112 if tmp.message.is_none() {
113 tmp.message = _error_message;
114 }
115 tmp
116 }),
117 _ => crate::operation::create_labels::CreateLabelsError::generic(generic),
118 })
119}
120
121#[allow(clippy::unnecessary_wraps)]
122pub fn de_create_labels_http_response(
123 _response_status: u16,
124 _response_headers: &::aws_smithy_runtime_api::http::Headers,
125 _response_body: &[u8],
126) -> std::result::Result<crate::operation::create_labels::CreateLabelsOutput, crate::operation::create_labels::CreateLabelsError> {
127 Ok({
128 #[allow(unused_mut)]
129 let mut output = crate::operation::create_labels::builders::CreateLabelsOutputBuilder::default();
130 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
131 output.build()
132 })
133}
134
135pub fn ser_create_labels_headers(
136 input: &crate::operation::create_labels::CreateLabelsInput,
137 mut builder: ::http::request::Builder,
138) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
139 if let ::std::option::Option::Some(inner_1) = &input.authentication_token {
140 let formatted_2 = inner_1.as_str();
141 let header_value = formatted_2;
142 let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
143 ::aws_smithy_types::error::operation::BuildError::invalid_field(
144 "authentication_token",
145 format!("`{}` cannot be used as a header value: {}", &"*** Sensitive Data Redacted ***", err),
146 )
147 })?;
148 builder = builder.header("Authentication", header_value);
149 }
150 Ok(builder)
151}
152
153pub fn ser_create_labels_input(
154 input: &crate::operation::create_labels::CreateLabelsInput,
155) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
156 let mut out = String::new();
157 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
158 crate::protocol_serde::shape_create_labels_input::ser_create_labels_input_input(&mut object, input)?;
159 object.finish();
160 Ok(::aws_smithy_types::body::SdkBody::from(out))
161}