aws_sdk_codepipeline/protocol_serde/
shape_put_webhook.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_put_webhook_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::put_webhook::PutWebhookOutput, crate::operation::put_webhook::PutWebhookError> {
8    #[allow(unused_mut)]
9    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10        .map_err(crate::operation::put_webhook::PutWebhookError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    let error_code = match generic.code() {
14        Some(code) => code,
15        None => return Err(crate::operation::put_webhook::PutWebhookError::unhandled(generic)),
16    };
17
18    let _error_message = generic.message().map(|msg| msg.to_owned());
19    Err(match error_code {
20        "ConcurrentModificationException" => crate::operation::put_webhook::PutWebhookError::ConcurrentModificationException({
21            #[allow(unused_mut)]
22            let mut tmp = {
23                #[allow(unused_mut)]
24                let mut output = crate::types::error::builders::ConcurrentModificationExceptionBuilder::default();
25                output = crate::protocol_serde::shape_concurrent_modification_exception::de_concurrent_modification_exception_json_err(
26                    _response_body,
27                    output,
28                )
29                .map_err(crate::operation::put_webhook::PutWebhookError::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        "InvalidTagsException" => crate::operation::put_webhook::PutWebhookError::InvalidTagsException({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::InvalidTagsExceptionBuilder::default();
43                output = crate::protocol_serde::shape_invalid_tags_exception::de_invalid_tags_exception_json_err(_response_body, output)
44                    .map_err(crate::operation::put_webhook::PutWebhookError::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        "InvalidWebhookAuthenticationParametersException" => {
54            crate::operation::put_webhook::PutWebhookError::InvalidWebhookAuthenticationParametersException({
55                #[allow(unused_mut)]
56                let mut tmp = {
57                    #[allow(unused_mut)]
58                    let mut output = crate::types::error::builders::InvalidWebhookAuthenticationParametersExceptionBuilder::default();
59                    output = crate::protocol_serde::shape_invalid_webhook_authentication_parameters_exception::de_invalid_webhook_authentication_parameters_exception_json_err(_response_body, output).map_err(crate::operation::put_webhook::PutWebhookError::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        }
69        "InvalidWebhookFilterPatternException" => crate::operation::put_webhook::PutWebhookError::InvalidWebhookFilterPatternException({
70            #[allow(unused_mut)]
71            let mut tmp = {
72                #[allow(unused_mut)]
73                let mut output = crate::types::error::builders::InvalidWebhookFilterPatternExceptionBuilder::default();
74                output = crate::protocol_serde::shape_invalid_webhook_filter_pattern_exception::de_invalid_webhook_filter_pattern_exception_json_err(
75                    _response_body,
76                    output,
77                )
78                .map_err(crate::operation::put_webhook::PutWebhookError::unhandled)?;
79                let output = output.meta(generic);
80                output.build()
81            };
82            if tmp.message.is_none() {
83                tmp.message = _error_message;
84            }
85            tmp
86        }),
87        "LimitExceededException" => crate::operation::put_webhook::PutWebhookError::LimitExceededException({
88            #[allow(unused_mut)]
89            let mut tmp = {
90                #[allow(unused_mut)]
91                let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
92                output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
93                    .map_err(crate::operation::put_webhook::PutWebhookError::unhandled)?;
94                let output = output.meta(generic);
95                output.build()
96            };
97            if tmp.message.is_none() {
98                tmp.message = _error_message;
99            }
100            tmp
101        }),
102        "PipelineNotFoundException" => crate::operation::put_webhook::PutWebhookError::PipelineNotFoundException({
103            #[allow(unused_mut)]
104            let mut tmp = {
105                #[allow(unused_mut)]
106                let mut output = crate::types::error::builders::PipelineNotFoundExceptionBuilder::default();
107                output = crate::protocol_serde::shape_pipeline_not_found_exception::de_pipeline_not_found_exception_json_err(_response_body, output)
108                    .map_err(crate::operation::put_webhook::PutWebhookError::unhandled)?;
109                let output = output.meta(generic);
110                output.build()
111            };
112            if tmp.message.is_none() {
113                tmp.message = _error_message;
114            }
115            tmp
116        }),
117        "TooManyTagsException" => crate::operation::put_webhook::PutWebhookError::TooManyTagsException({
118            #[allow(unused_mut)]
119            let mut tmp = {
120                #[allow(unused_mut)]
121                let mut output = crate::types::error::builders::TooManyTagsExceptionBuilder::default();
122                output = crate::protocol_serde::shape_too_many_tags_exception::de_too_many_tags_exception_json_err(_response_body, output)
123                    .map_err(crate::operation::put_webhook::PutWebhookError::unhandled)?;
124                let output = output.meta(generic);
125                output.build()
126            };
127            if tmp.message.is_none() {
128                tmp.message = _error_message;
129            }
130            tmp
131        }),
132        "ValidationException" => crate::operation::put_webhook::PutWebhookError::ValidationException({
133            #[allow(unused_mut)]
134            let mut tmp = {
135                #[allow(unused_mut)]
136                let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
137                output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
138                    .map_err(crate::operation::put_webhook::PutWebhookError::unhandled)?;
139                let output = output.meta(generic);
140                output.build()
141            };
142            if tmp.message.is_none() {
143                tmp.message = _error_message;
144            }
145            tmp
146        }),
147        _ => crate::operation::put_webhook::PutWebhookError::generic(generic),
148    })
149}
150
151#[allow(clippy::unnecessary_wraps)]
152pub fn de_put_webhook_http_response(
153    _response_status: u16,
154    _response_headers: &::aws_smithy_runtime_api::http::Headers,
155    _response_body: &[u8],
156) -> std::result::Result<crate::operation::put_webhook::PutWebhookOutput, crate::operation::put_webhook::PutWebhookError> {
157    Ok({
158        #[allow(unused_mut)]
159        let mut output = crate::operation::put_webhook::builders::PutWebhookOutputBuilder::default();
160        output = crate::protocol_serde::shape_put_webhook::de_put_webhook(_response_body, output)
161            .map_err(crate::operation::put_webhook::PutWebhookError::unhandled)?;
162        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
163        output.build()
164    })
165}
166
167pub fn ser_put_webhook_input(
168    input: &crate::operation::put_webhook::PutWebhookInput,
169) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
170    let mut out = String::new();
171    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
172    crate::protocol_serde::shape_put_webhook_input::ser_put_webhook_input_input(&mut object, input)?;
173    object.finish();
174    Ok(::aws_smithy_types::body::SdkBody::from(out))
175}
176
177pub(crate) fn de_put_webhook(
178    value: &[u8],
179    mut builder: crate::operation::put_webhook::builders::PutWebhookOutputBuilder,
180) -> ::std::result::Result<crate::operation::put_webhook::builders::PutWebhookOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError>
181{
182    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
183    let tokens = &mut tokens_owned;
184    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
185    loop {
186        match tokens.next().transpose()? {
187            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
188            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
189                "webhook" => {
190                    builder = builder.set_webhook(crate::protocol_serde::shape_list_webhook_item::de_list_webhook_item(tokens)?);
191                }
192                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
193            },
194            other => {
195                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
196                    "expected object key or end object, found: {:?}",
197                    other
198                )))
199            }
200        }
201    }
202    if tokens.next().is_some() {
203        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
204            "found more JSON tokens after completing parsing",
205        ));
206    }
207    Ok(builder)
208}