aws_sdk_datasync/protocol_serde/
shape_describe_location_fsx_ontap.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_location_fsx_ontap_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::describe_location_fsx_ontap::DescribeLocationFsxOntapOutput,
9    crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError,
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::describe_location_fsx_ontap::DescribeLocationFsxOntapError::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 => {
19            return Err(crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "InternalException" => crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError::InternalException({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::InternalExceptionBuilder::default();
32                output = crate::protocol_serde::shape_internal_exception::de_internal_exception_json_err(_response_body, output)
33                    .map_err(crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError::unhandled)?;
34                let output = output.meta(generic);
35                output.build()
36            };
37            if tmp.message.is_none() {
38                tmp.message = _error_message;
39            }
40            tmp
41        }),
42        "InvalidRequestException" => crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError::InvalidRequestException({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
47                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
48                    .map_err(crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError::unhandled)?;
49                let output = output.meta(generic);
50                output.build()
51            };
52            if tmp.message.is_none() {
53                tmp.message = _error_message;
54            }
55            tmp
56        }),
57        _ => crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError::generic(generic),
58    })
59}
60
61#[allow(clippy::unnecessary_wraps)]
62pub fn de_describe_location_fsx_ontap_http_response(
63    _response_status: u16,
64    _response_headers: &::aws_smithy_runtime_api::http::Headers,
65    _response_body: &[u8],
66) -> std::result::Result<
67    crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapOutput,
68    crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError,
69> {
70    Ok({
71        #[allow(unused_mut)]
72        let mut output = crate::operation::describe_location_fsx_ontap::builders::DescribeLocationFsxOntapOutputBuilder::default();
73        output = crate::protocol_serde::shape_describe_location_fsx_ontap::de_describe_location_fsx_ontap(_response_body, output)
74            .map_err(crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapError::unhandled)?;
75        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
76        output.build()
77    })
78}
79
80pub fn ser_describe_location_fsx_ontap_input(
81    input: &crate::operation::describe_location_fsx_ontap::DescribeLocationFsxOntapInput,
82) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
83    let mut out = String::new();
84    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
85    crate::protocol_serde::shape_describe_location_fsx_ontap_input::ser_describe_location_fsx_ontap_input_input(&mut object, input)?;
86    object.finish();
87    Ok(::aws_smithy_types::body::SdkBody::from(out))
88}
89
90pub(crate) fn de_describe_location_fsx_ontap(
91    value: &[u8],
92    mut builder: crate::operation::describe_location_fsx_ontap::builders::DescribeLocationFsxOntapOutputBuilder,
93) -> ::std::result::Result<
94    crate::operation::describe_location_fsx_ontap::builders::DescribeLocationFsxOntapOutputBuilder,
95    ::aws_smithy_json::deserialize::error::DeserializeError,
96> {
97    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
98    let tokens = &mut tokens_owned;
99    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
100    loop {
101        match tokens.next().transpose()? {
102            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
103            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
104                "CreationTime" => {
105                    builder = builder.set_creation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
106                        tokens.next(),
107                        ::aws_smithy_types::date_time::Format::EpochSeconds,
108                    )?);
109                }
110                "LocationArn" => {
111                    builder = builder.set_location_arn(
112                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
113                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
114                            .transpose()?,
115                    );
116                }
117                "LocationUri" => {
118                    builder = builder.set_location_uri(
119                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
120                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
121                            .transpose()?,
122                    );
123                }
124                "Protocol" => {
125                    builder = builder.set_protocol(crate::protocol_serde::shape_fsx_protocol::de_fsx_protocol(tokens)?);
126                }
127                "SecurityGroupArns" => {
128                    builder = builder.set_security_group_arns(
129                        crate::protocol_serde::shape_ec2_security_group_arn_list::de_ec2_security_group_arn_list(tokens)?,
130                    );
131                }
132                "StorageVirtualMachineArn" => {
133                    builder = builder.set_storage_virtual_machine_arn(
134                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
135                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
136                            .transpose()?,
137                    );
138                }
139                "FsxFilesystemArn" => {
140                    builder = builder.set_fsx_filesystem_arn(
141                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
142                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
143                            .transpose()?,
144                    );
145                }
146                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
147            },
148            other => {
149                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
150                    "expected object key or end object, found: {:?}",
151                    other
152                )))
153            }
154        }
155    }
156    if tokens.next().is_some() {
157        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
158            "found more JSON tokens after completing parsing",
159        ));
160    }
161    Ok(builder)
162}