Skip to main content

aws_sdk_connect/protocol_serde/
shape_list_flow_associations.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_flow_associations_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::list_flow_associations::ListFlowAssociationsOutput,
9    crate::operation::list_flow_associations::ListFlowAssociationsError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    let error_code = match generic.code() {
17        Some(code) => code,
18        None => return Err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "AccessDeniedException" => crate::operation::list_flow_associations::ListFlowAssociationsError::AccessDeniedException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
28                output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
30                let output = output.meta(generic);
31                output.build()
32            };
33            if tmp.message.is_none() {
34                tmp.message = _error_message;
35            }
36            tmp
37        }),
38        "InternalServiceException" => crate::operation::list_flow_associations::ListFlowAssociationsError::InternalServiceException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::InternalServiceExceptionBuilder::default();
43                output = crate::protocol_serde::shape_internal_service_exception::de_internal_service_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
45                let output = output.meta(generic);
46                output.build()
47            };
48            if tmp.message.is_none() {
49                tmp.message = _error_message;
50            }
51            tmp
52        }),
53        "InvalidParameterException" => crate::operation::list_flow_associations::ListFlowAssociationsError::InvalidParameterException({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::InvalidParameterExceptionBuilder::default();
58                output = crate::protocol_serde::shape_invalid_parameter_exception::de_invalid_parameter_exception_json_err(_response_body, output)
59                    .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
60                let output = output.meta(generic);
61                output.build()
62            };
63            if tmp.message.is_none() {
64                tmp.message = _error_message;
65            }
66            tmp
67        }),
68        "InvalidRequestException" => crate::operation::list_flow_associations::ListFlowAssociationsError::InvalidRequestException({
69            #[allow(unused_mut)]
70            let mut tmp = {
71                #[allow(unused_mut)]
72                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
73                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
74                    .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
75                let output = output.meta(generic);
76                output.build()
77            };
78            if tmp.message.is_none() {
79                tmp.message = _error_message;
80            }
81            tmp
82        }),
83        "ResourceNotFoundException" => crate::operation::list_flow_associations::ListFlowAssociationsError::ResourceNotFoundException({
84            #[allow(unused_mut)]
85            let mut tmp = {
86                #[allow(unused_mut)]
87                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
88                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
89                    .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
90                let output = output.meta(generic);
91                output.build()
92            };
93            if tmp.message.is_none() {
94                tmp.message = _error_message;
95            }
96            tmp
97        }),
98        "ThrottlingException" => crate::operation::list_flow_associations::ListFlowAssociationsError::ThrottlingException({
99            #[allow(unused_mut)]
100            let mut tmp = {
101                #[allow(unused_mut)]
102                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
103                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
104                    .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
105                let output = output.meta(generic);
106                output.build()
107            };
108            if tmp.message.is_none() {
109                tmp.message = _error_message;
110            }
111            tmp
112        }),
113        _ => crate::operation::list_flow_associations::ListFlowAssociationsError::generic(generic),
114    })
115}
116
117#[allow(clippy::unnecessary_wraps)]
118pub fn de_list_flow_associations_http_response(
119    _response_status: u16,
120    _response_headers: &::aws_smithy_runtime_api::http::Headers,
121    _response_body: &[u8],
122) -> std::result::Result<
123    crate::operation::list_flow_associations::ListFlowAssociationsOutput,
124    crate::operation::list_flow_associations::ListFlowAssociationsError,
125> {
126    Ok({
127        #[allow(unused_mut)]
128        let mut output = crate::operation::list_flow_associations::builders::ListFlowAssociationsOutputBuilder::default();
129        output = crate::protocol_serde::shape_list_flow_associations::de_list_flow_associations(_response_body, output)
130            .map_err(crate::operation::list_flow_associations::ListFlowAssociationsError::unhandled)?;
131        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
132        output.build()
133    })
134}
135
136pub(crate) fn de_list_flow_associations(
137    _value: &[u8],
138    mut builder: crate::operation::list_flow_associations::builders::ListFlowAssociationsOutputBuilder,
139) -> ::std::result::Result<
140    crate::operation::list_flow_associations::builders::ListFlowAssociationsOutputBuilder,
141    ::aws_smithy_json::deserialize::error::DeserializeError,
142> {
143    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
144    let tokens = &mut tokens_owned;
145    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
146    loop {
147        match tokens.next().transpose()? {
148            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
149            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
150                "FlowAssociationSummaryList" => {
151                    builder = builder.set_flow_association_summary_list(
152                        crate::protocol_serde::shape_flow_association_summary_list::de_flow_association_summary_list(tokens, _value)?,
153                    );
154                }
155                "NextToken" => {
156                    builder = builder.set_next_token(
157                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
158                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
159                            .transpose()?,
160                    );
161                }
162                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
163            },
164            other => {
165                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
166                    "expected object key or end object, found: {other:?}"
167                )))
168            }
169        }
170    }
171    if tokens.next().is_some() {
172        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
173            "found more JSON tokens after completing parsing",
174        ));
175    }
176    Ok(builder)
177}