aws_sdk_s3/protocol_serde/
shape_get_bucket_notification_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_bucket_notification_configuration_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_bucket_notification_configuration::GetBucketNotificationConfigurationOutput,
9    crate::operation::get_bucket_notification_configuration::GetBucketNotificationConfigurationError,
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_bucket_notification_configuration::GetBucketNotificationConfigurationError::unhandled)?;
14    generic_builder = crate::s3_request_id::apply_extended_request_id(generic_builder, _response_headers);
15    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
16    let generic = generic_builder.build();
17    Err(crate::operation::get_bucket_notification_configuration::GetBucketNotificationConfigurationError::generic(generic))
18}
19
20#[allow(clippy::unnecessary_wraps)]
21pub fn de_get_bucket_notification_configuration_http_response(
22    _response_status: u16,
23    _response_headers: &::aws_smithy_runtime_api::http::Headers,
24    _response_body: &[u8],
25) -> std::result::Result<
26    crate::operation::get_bucket_notification_configuration::GetBucketNotificationConfigurationOutput,
27    crate::operation::get_bucket_notification_configuration::GetBucketNotificationConfigurationError,
28> {
29    Ok({
30        #[allow(unused_mut)]
31        let mut output =
32            crate::operation::get_bucket_notification_configuration::builders::GetBucketNotificationConfigurationOutputBuilder::default();
33        output = crate::protocol_serde::shape_get_bucket_notification_configuration::de_get_bucket_notification_configuration(_response_body, output)
34            .map_err(crate::operation::get_bucket_notification_configuration::GetBucketNotificationConfigurationError::unhandled)?;
35        output._set_extended_request_id(crate::s3_request_id::RequestIdExt::extended_request_id(_response_headers).map(str::to_string));
36        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
37        output.build()
38    })
39}
40
41pub fn ser_get_bucket_notification_configuration_headers(
42    input: &crate::operation::get_bucket_notification_configuration::GetBucketNotificationConfigurationInput,
43    mut builder: ::http::request::Builder,
44) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
45    if let ::std::option::Option::Some(inner_1) = &input.expected_bucket_owner {
46        let formatted_2 = inner_1.as_str();
47        let header_value = formatted_2;
48        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
49            ::aws_smithy_types::error::operation::BuildError::invalid_field(
50                "expected_bucket_owner",
51                format!("`{}` cannot be used as a header value: {}", &header_value, err),
52            )
53        })?;
54        builder = builder.header("x-amz-expected-bucket-owner", header_value);
55    }
56    Ok(builder)
57}
58
59#[allow(unused_mut)]
60pub fn de_get_bucket_notification_configuration(
61    inp: &[u8],
62    mut builder: crate::operation::get_bucket_notification_configuration::builders::GetBucketNotificationConfigurationOutputBuilder,
63) -> std::result::Result<
64    crate::operation::get_bucket_notification_configuration::builders::GetBucketNotificationConfigurationOutputBuilder,
65    ::aws_smithy_xml::decode::XmlDecodeError,
66> {
67    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
68
69    #[allow(unused_mut)]
70    let mut decoder = doc.root_element()?;
71    #[allow(unused_variables)]
72    let start_el = decoder.start_el();
73    if !start_el.matches("NotificationConfiguration") {
74        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
75            "encountered invalid XML root: expected NotificationConfiguration but got {:?}. This is likely a bug in the SDK.",
76            start_el
77        )));
78    }
79    while let Some(mut tag) = decoder.next_tag() {
80        match tag.start_el() {
81            s if s.matches("CloudFunctionConfiguration") /* LambdaFunctionConfigurations com.amazonaws.s3.synthetic#GetBucketNotificationConfigurationOutput$LambdaFunctionConfigurations */ =>  {
82                let var_3 =
83                    Some(
84                        Result::<::std::vec::Vec::<crate::types::LambdaFunctionConfiguration>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
85                            let mut list_4 = builder.lambda_function_configurations.take().unwrap_or_default();
86                            list_4.push(
87                                crate::protocol_serde::shape_lambda_function_configuration::de_lambda_function_configuration(&mut tag)
88                                ?
89                            );
90                            list_4
91                        })
92                        ?
93                    )
94                ;
95                builder = builder.set_lambda_function_configurations(var_3);
96            }
97            ,
98            s if s.matches("TopicConfiguration") /* TopicConfigurations com.amazonaws.s3.synthetic#GetBucketNotificationConfigurationOutput$TopicConfigurations */ =>  {
99                let var_5 =
100                    Some(
101                        Result::<::std::vec::Vec::<crate::types::TopicConfiguration>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
102                            let mut list_6 = builder.topic_configurations.take().unwrap_or_default();
103                            list_6.push(
104                                crate::protocol_serde::shape_topic_configuration::de_topic_configuration(&mut tag)
105                                ?
106                            );
107                            list_6
108                        })
109                        ?
110                    )
111                ;
112                builder = builder.set_topic_configurations(var_5);
113            }
114            ,
115            s if s.matches("QueueConfiguration") /* QueueConfigurations com.amazonaws.s3.synthetic#GetBucketNotificationConfigurationOutput$QueueConfigurations */ =>  {
116                let var_7 =
117                    Some(
118                        Result::<::std::vec::Vec::<crate::types::QueueConfiguration>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
119                            let mut list_8 = builder.queue_configurations.take().unwrap_or_default();
120                            list_8.push(
121                                crate::protocol_serde::shape_queue_configuration::de_queue_configuration(&mut tag)
122                                ?
123                            );
124                            list_8
125                        })
126                        ?
127                    )
128                ;
129                builder = builder.set_queue_configurations(var_7);
130            }
131            ,
132            s if s.matches("EventBridgeConfiguration") /* EventBridgeConfiguration com.amazonaws.s3.synthetic#GetBucketNotificationConfigurationOutput$EventBridgeConfiguration */ =>  {
133                let var_9 =
134                    Some(
135                        crate::protocol_serde::shape_event_bridge_configuration::de_event_bridge_configuration(&mut tag)
136                        ?
137                    )
138                ;
139                builder = builder.set_event_bridge_configuration(var_9);
140            }
141            ,
142            _ => {}
143        }
144    }
145    Ok(builder)
146}