aws_sdk_codeartifact/protocol_serde/
shape_list_package_groups.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_package_groups_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::list_package_groups::ListPackageGroupsOutput, crate::operation::list_package_groups::ListPackageGroupsError>
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::list_package_groups::ListPackageGroupsError::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::list_package_groups::ListPackageGroupsError::unhandled(generic)),
17 };
18
19 let _error_message = generic.message().map(|msg| msg.to_owned());
20 Err(match error_code {
21 "AccessDeniedException" => crate::operation::list_package_groups::ListPackageGroupsError::AccessDeniedException({
22 #[allow(unused_mut)]
23 let mut tmp = {
24 #[allow(unused_mut)]
25 let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
26 output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
27 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?;
28 let output = output.meta(generic);
29 crate::serde_util::access_denied_exception_correct_errors(output)
30 .build()
31 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?
32 };
33 tmp
34 }),
35 "InternalServerException" => crate::operation::list_package_groups::ListPackageGroupsError::InternalServerException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
40 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
41 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?;
42 let output = output.meta(generic);
43 crate::serde_util::internal_server_exception_correct_errors(output)
44 .build()
45 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?
46 };
47 tmp
48 }),
49 "ResourceNotFoundException" => crate::operation::list_package_groups::ListPackageGroupsError::ResourceNotFoundException({
50 #[allow(unused_mut)]
51 let mut tmp = {
52 #[allow(unused_mut)]
53 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
54 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
55 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?;
56 let output = output.meta(generic);
57 crate::serde_util::resource_not_found_exception_correct_errors(output)
58 .build()
59 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?
60 };
61 tmp
62 }),
63 "ThrottlingException" => crate::operation::list_package_groups::ListPackageGroupsError::ThrottlingException({
64 #[allow(unused_mut)]
65 let mut tmp = {
66 #[allow(unused_mut)]
67 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
68 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
69 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?;
70 output = output.set_retry_after_seconds(
71 crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
72 crate::operation::list_package_groups::ListPackageGroupsError::unhandled(
73 "Failed to parse retryAfterSeconds from header `Retry-After",
74 )
75 })?,
76 );
77 let output = output.meta(generic);
78 crate::serde_util::throttling_exception_correct_errors(output)
79 .build()
80 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?
81 };
82 tmp
83 }),
84 "ValidationException" => crate::operation::list_package_groups::ListPackageGroupsError::ValidationException({
85 #[allow(unused_mut)]
86 let mut tmp = {
87 #[allow(unused_mut)]
88 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
89 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
90 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?;
91 let output = output.meta(generic);
92 crate::serde_util::validation_exception_correct_errors(output)
93 .build()
94 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?
95 };
96 tmp
97 }),
98 _ => crate::operation::list_package_groups::ListPackageGroupsError::generic(generic),
99 })
100}
101
102#[allow(clippy::unnecessary_wraps)]
103pub fn de_list_package_groups_http_response(
104 _response_status: u16,
105 _response_headers: &::aws_smithy_runtime_api::http::Headers,
106 _response_body: &[u8],
107) -> std::result::Result<crate::operation::list_package_groups::ListPackageGroupsOutput, crate::operation::list_package_groups::ListPackageGroupsError>
108{
109 Ok({
110 #[allow(unused_mut)]
111 let mut output = crate::operation::list_package_groups::builders::ListPackageGroupsOutputBuilder::default();
112 output = crate::protocol_serde::shape_list_package_groups::de_list_package_groups(_response_body, output)
113 .map_err(crate::operation::list_package_groups::ListPackageGroupsError::unhandled)?;
114 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
115 output.build()
116 })
117}
118
119pub(crate) fn de_list_package_groups(
120 value: &[u8],
121 mut builder: crate::operation::list_package_groups::builders::ListPackageGroupsOutputBuilder,
122) -> ::std::result::Result<
123 crate::operation::list_package_groups::builders::ListPackageGroupsOutputBuilder,
124 ::aws_smithy_json::deserialize::error::DeserializeError,
125> {
126 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
127 let tokens = &mut tokens_owned;
128 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
129 loop {
130 match tokens.next().transpose()? {
131 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
132 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
133 "nextToken" => {
134 builder = builder.set_next_token(
135 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
136 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
137 .transpose()?,
138 );
139 }
140 "packageGroups" => {
141 builder = builder.set_package_groups(crate::protocol_serde::shape_package_group_summary_list::de_package_group_summary_list(
142 tokens,
143 )?);
144 }
145 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
146 },
147 other => {
148 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
149 "expected object key or end object, found: {:?}",
150 other
151 )))
152 }
153 }
154 }
155 if tokens.next().is_some() {
156 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
157 "found more JSON tokens after completing parsing",
158 ));
159 }
160 Ok(builder)
161}