Skip to main content

aws_sdk_ioteventsdata/protocol_serde/
shape_batch_delete_detector.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_batch_delete_detector_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::batch_delete_detector::BatchDeleteDetectorOutput,
9    crate::operation::batch_delete_detector::BatchDeleteDetectorError,
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::batch_delete_detector::BatchDeleteDetectorError::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::batch_delete_detector::BatchDeleteDetectorError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "InternalFailureException" => crate::operation::batch_delete_detector::BatchDeleteDetectorError::InternalFailureException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::InternalFailureExceptionBuilder::default();
28                output = crate::protocol_serde::shape_internal_failure_exception::de_internal_failure_exception_json_err(_response_body, output)
29                    .map_err(crate::operation::batch_delete_detector::BatchDeleteDetectorError::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        "InvalidRequestException" => crate::operation::batch_delete_detector::BatchDeleteDetectorError::InvalidRequestException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
43                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::batch_delete_detector::BatchDeleteDetectorError::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        "ServiceUnavailableException" => crate::operation::batch_delete_detector::BatchDeleteDetectorError::ServiceUnavailableException({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
58                output =
59                    crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
60                        .map_err(crate::operation::batch_delete_detector::BatchDeleteDetectorError::unhandled)?;
61                let output = output.meta(generic);
62                output.build()
63            };
64            if tmp.message.is_none() {
65                tmp.message = _error_message;
66            }
67            tmp
68        }),
69        "ThrottlingException" => crate::operation::batch_delete_detector::BatchDeleteDetectorError::ThrottlingException({
70            #[allow(unused_mut)]
71            let mut tmp = {
72                #[allow(unused_mut)]
73                let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
74                output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
75                    .map_err(crate::operation::batch_delete_detector::BatchDeleteDetectorError::unhandled)?;
76                let output = output.meta(generic);
77                output.build()
78            };
79            if tmp.message.is_none() {
80                tmp.message = _error_message;
81            }
82            tmp
83        }),
84        _ => crate::operation::batch_delete_detector::BatchDeleteDetectorError::generic(generic),
85    })
86}
87
88#[allow(clippy::unnecessary_wraps)]
89pub fn de_batch_delete_detector_http_response(
90    _response_status: u16,
91    _response_headers: &::aws_smithy_runtime_api::http::Headers,
92    _response_body: &[u8],
93) -> std::result::Result<
94    crate::operation::batch_delete_detector::BatchDeleteDetectorOutput,
95    crate::operation::batch_delete_detector::BatchDeleteDetectorError,
96> {
97    Ok({
98        #[allow(unused_mut)]
99        let mut output = crate::operation::batch_delete_detector::builders::BatchDeleteDetectorOutputBuilder::default();
100        output = crate::protocol_serde::shape_batch_delete_detector::de_batch_delete_detector(_response_body, output)
101            .map_err(crate::operation::batch_delete_detector::BatchDeleteDetectorError::unhandled)?;
102        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
103        output.build()
104    })
105}
106
107pub fn ser_batch_delete_detector_input(
108    input: &crate::operation::batch_delete_detector::BatchDeleteDetectorInput,
109) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
110    let mut out = String::new();
111    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
112    crate::protocol_serde::shape_batch_delete_detector_input::ser_batch_delete_detector_input_input(&mut object, input)?;
113    object.finish();
114    Ok(::aws_smithy_types::body::SdkBody::from(out))
115}
116
117pub(crate) fn de_batch_delete_detector(
118    _value: &[u8],
119    mut builder: crate::operation::batch_delete_detector::builders::BatchDeleteDetectorOutputBuilder,
120) -> ::std::result::Result<
121    crate::operation::batch_delete_detector::builders::BatchDeleteDetectorOutputBuilder,
122    ::aws_smithy_json::deserialize::error::DeserializeError,
123> {
124    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
125    let tokens = &mut tokens_owned;
126    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
127    loop {
128        match tokens.next().transpose()? {
129            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
130            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
131                "batchDeleteDetectorErrorEntries" => {
132                    builder = builder.set_batch_delete_detector_error_entries(
133                        crate::protocol_serde::shape_batch_delete_detector_error_entries::de_batch_delete_detector_error_entries(tokens, _value)?,
134                    );
135                }
136                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
137            },
138            other => {
139                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
140                    "expected object key or end object, found: {other:?}"
141                )))
142            }
143        }
144    }
145    if tokens.next().is_some() {
146        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
147            "found more JSON tokens after completing parsing",
148        ));
149    }
150    Ok(builder)
151}