aws_sdk_xray/protocol_serde/
shape_get_insight_impact_graph.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_insight_impact_graph_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::get_insight_impact_graph::GetInsightImpactGraphOutput,
9    crate::operation::get_insight_impact_graph::GetInsightImpactGraphError,
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::get_insight_impact_graph::GetInsightImpactGraphError::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::get_insight_impact_graph::GetInsightImpactGraphError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "InvalidRequestException" => crate::operation::get_insight_impact_graph::GetInsightImpactGraphError::InvalidRequestException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
28                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::get_insight_impact_graph::GetInsightImpactGraphError::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        "ThrottledException" => crate::operation::get_insight_impact_graph::GetInsightImpactGraphError::ThrottledException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::ThrottledExceptionBuilder::default();
43                output = crate::protocol_serde::shape_throttled_exception::de_throttled_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::get_insight_impact_graph::GetInsightImpactGraphError::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        _ => crate::operation::get_insight_impact_graph::GetInsightImpactGraphError::generic(generic),
54    })
55}
56
57#[allow(clippy::unnecessary_wraps)]
58pub fn de_get_insight_impact_graph_http_response(
59    _response_status: u16,
60    _response_headers: &::aws_smithy_runtime_api::http::Headers,
61    _response_body: &[u8],
62) -> std::result::Result<
63    crate::operation::get_insight_impact_graph::GetInsightImpactGraphOutput,
64    crate::operation::get_insight_impact_graph::GetInsightImpactGraphError,
65> {
66    Ok({
67        #[allow(unused_mut)]
68        let mut output = crate::operation::get_insight_impact_graph::builders::GetInsightImpactGraphOutputBuilder::default();
69        output = crate::protocol_serde::shape_get_insight_impact_graph::de_get_insight_impact_graph(_response_body, output)
70            .map_err(crate::operation::get_insight_impact_graph::GetInsightImpactGraphError::unhandled)?;
71        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
72        output.build()
73    })
74}
75
76pub fn ser_get_insight_impact_graph_input(
77    input: &crate::operation::get_insight_impact_graph::GetInsightImpactGraphInput,
78) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
79    let mut out = String::new();
80    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
81    crate::protocol_serde::shape_get_insight_impact_graph_input::ser_get_insight_impact_graph_input_input(&mut object, input)?;
82    object.finish();
83    Ok(::aws_smithy_types::body::SdkBody::from(out))
84}
85
86pub(crate) fn de_get_insight_impact_graph(
87    value: &[u8],
88    mut builder: crate::operation::get_insight_impact_graph::builders::GetInsightImpactGraphOutputBuilder,
89) -> ::std::result::Result<
90    crate::operation::get_insight_impact_graph::builders::GetInsightImpactGraphOutputBuilder,
91    ::aws_smithy_json::deserialize::error::DeserializeError,
92> {
93    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
94    let tokens = &mut tokens_owned;
95    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
96    loop {
97        match tokens.next().transpose()? {
98            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
99            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
100                "EndTime" => {
101                    builder = builder.set_end_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
102                        tokens.next(),
103                        ::aws_smithy_types::date_time::Format::EpochSeconds,
104                    )?);
105                }
106                "InsightId" => {
107                    builder = builder.set_insight_id(
108                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
109                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
110                            .transpose()?,
111                    );
112                }
113                "NextToken" => {
114                    builder = builder.set_next_token(
115                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
116                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
117                            .transpose()?,
118                    );
119                }
120                "ServiceGraphEndTime" => {
121                    builder = builder.set_service_graph_end_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
122                        tokens.next(),
123                        ::aws_smithy_types::date_time::Format::EpochSeconds,
124                    )?);
125                }
126                "ServiceGraphStartTime" => {
127                    builder = builder.set_service_graph_start_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
128                        tokens.next(),
129                        ::aws_smithy_types::date_time::Format::EpochSeconds,
130                    )?);
131                }
132                "Services" => {
133                    builder = builder
134                        .set_services(crate::protocol_serde::shape_insight_impact_graph_service_list::de_insight_impact_graph_service_list(tokens)?);
135                }
136                "StartTime" => {
137                    builder = builder.set_start_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
138                        tokens.next(),
139                        ::aws_smithy_types::date_time::Format::EpochSeconds,
140                    )?);
141                }
142                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
143            },
144            other => {
145                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
146                    "expected object key or end object, found: {other:?}"
147                )))
148            }
149        }
150    }
151    if tokens.next().is_some() {
152        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
153            "found more JSON tokens after completing parsing",
154        ));
155    }
156    Ok(builder)
157}