aws_sdk_fsx/protocol_serde/
shape_disassociate_file_system_aliases.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_disassociate_file_system_aliases_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::disassociate_file_system_aliases::DisassociateFileSystemAliasesOutput,
9    crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError,
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::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::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::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "BadRequest" => crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::BadRequest({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::BadRequestBuilder::default();
28                output = crate::protocol_serde::shape_bad_request::de_bad_request_json_err(_response_body, output)
29                    .map_err(crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::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        "FileSystemNotFound" => crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::FileSystemNotFound({
39            #[allow(unused_mut)]
40            let mut tmp = {
41                #[allow(unused_mut)]
42                let mut output = crate::types::error::builders::FileSystemNotFoundBuilder::default();
43                output = crate::protocol_serde::shape_file_system_not_found::de_file_system_not_found_json_err(_response_body, output)
44                    .map_err(crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::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        "InternalServerError" => crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::InternalServerError({
54            #[allow(unused_mut)]
55            let mut tmp = {
56                #[allow(unused_mut)]
57                let mut output = crate::types::error::builders::InternalServerErrorBuilder::default();
58                output = crate::protocol_serde::shape_internal_server_error::de_internal_server_error_json_err(_response_body, output)
59                    .map_err(crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::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        _ => crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::generic(generic),
69    })
70}
71
72#[allow(clippy::unnecessary_wraps)]
73pub fn de_disassociate_file_system_aliases_http_response(
74    _response_status: u16,
75    _response_headers: &::aws_smithy_runtime_api::http::Headers,
76    _response_body: &[u8],
77) -> std::result::Result<
78    crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesOutput,
79    crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError,
80> {
81    Ok({
82        #[allow(unused_mut)]
83        let mut output = crate::operation::disassociate_file_system_aliases::builders::DisassociateFileSystemAliasesOutputBuilder::default();
84        output = crate::protocol_serde::shape_disassociate_file_system_aliases::de_disassociate_file_system_aliases(_response_body, output)
85            .map_err(crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesError::unhandled)?;
86        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
87        output.build()
88    })
89}
90
91pub fn ser_disassociate_file_system_aliases_input(
92    input: &crate::operation::disassociate_file_system_aliases::DisassociateFileSystemAliasesInput,
93) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
94    let mut out = String::new();
95    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
96    crate::protocol_serde::shape_disassociate_file_system_aliases_input::ser_disassociate_file_system_aliases_input_input(&mut object, input)?;
97    object.finish();
98    Ok(::aws_smithy_types::body::SdkBody::from(out))
99}
100
101pub(crate) fn de_disassociate_file_system_aliases(
102    value: &[u8],
103    mut builder: crate::operation::disassociate_file_system_aliases::builders::DisassociateFileSystemAliasesOutputBuilder,
104) -> ::std::result::Result<
105    crate::operation::disassociate_file_system_aliases::builders::DisassociateFileSystemAliasesOutputBuilder,
106    ::aws_smithy_json::deserialize::error::DeserializeError,
107> {
108    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
109    let tokens = &mut tokens_owned;
110    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
111    loop {
112        match tokens.next().transpose()? {
113            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
114            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
115                "Aliases" => {
116                    builder = builder.set_aliases(crate::protocol_serde::shape_aliases::de_aliases(tokens)?);
117                }
118                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
119            },
120            other => {
121                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
122                    "expected object key or end object, found: {:?}",
123                    other
124                )))
125            }
126        }
127    }
128    if tokens.next().is_some() {
129        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
130            "found more JSON tokens after completing parsing",
131        ));
132    }
133    Ok(builder)
134}