aws_sdk_appstream/protocol_serde/
shape_create_streaming_url.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_streaming_url_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::create_streaming_url::CreateStreamingUrlOutput,
9    crate::operation::create_streaming_url::CreateStreamingURLError,
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::create_streaming_url::CreateStreamingURLError::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::create_streaming_url::CreateStreamingURLError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "InvalidParameterCombinationException" => {
24            crate::operation::create_streaming_url::CreateStreamingURLError::InvalidParameterCombinationException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::InvalidParameterCombinationExceptionBuilder::default();
29                    output =
30                        crate::protocol_serde::shape_invalid_parameter_combination_exception::de_invalid_parameter_combination_exception_json_err(
31                            _response_body,
32                            output,
33                        )
34                        .map_err(crate::operation::create_streaming_url::CreateStreamingURLError::unhandled)?;
35                    let output = output.meta(generic);
36                    output.build()
37                };
38                if tmp.message.is_none() {
39                    tmp.message = _error_message;
40                }
41                tmp
42            })
43        }
44        "OperationNotPermittedException" => crate::operation::create_streaming_url::CreateStreamingURLError::OperationNotPermittedException({
45            #[allow(unused_mut)]
46            let mut tmp = {
47                #[allow(unused_mut)]
48                let mut output = crate::types::error::builders::OperationNotPermittedExceptionBuilder::default();
49                output = crate::protocol_serde::shape_operation_not_permitted_exception::de_operation_not_permitted_exception_json_err(
50                    _response_body,
51                    output,
52                )
53                .map_err(crate::operation::create_streaming_url::CreateStreamingURLError::unhandled)?;
54                let output = output.meta(generic);
55                output.build()
56            };
57            if tmp.message.is_none() {
58                tmp.message = _error_message;
59            }
60            tmp
61        }),
62        "ResourceNotAvailableException" => crate::operation::create_streaming_url::CreateStreamingURLError::ResourceNotAvailableException({
63            #[allow(unused_mut)]
64            let mut tmp = {
65                #[allow(unused_mut)]
66                let mut output = crate::types::error::builders::ResourceNotAvailableExceptionBuilder::default();
67                output = crate::protocol_serde::shape_resource_not_available_exception::de_resource_not_available_exception_json_err(
68                    _response_body,
69                    output,
70                )
71                .map_err(crate::operation::create_streaming_url::CreateStreamingURLError::unhandled)?;
72                let output = output.meta(generic);
73                output.build()
74            };
75            if tmp.message.is_none() {
76                tmp.message = _error_message;
77            }
78            tmp
79        }),
80        "ResourceNotFoundException" => crate::operation::create_streaming_url::CreateStreamingURLError::ResourceNotFoundException({
81            #[allow(unused_mut)]
82            let mut tmp = {
83                #[allow(unused_mut)]
84                let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
85                output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
86                    .map_err(crate::operation::create_streaming_url::CreateStreamingURLError::unhandled)?;
87                let output = output.meta(generic);
88                output.build()
89            };
90            if tmp.message.is_none() {
91                tmp.message = _error_message;
92            }
93            tmp
94        }),
95        _ => crate::operation::create_streaming_url::CreateStreamingURLError::generic(generic),
96    })
97}
98
99#[allow(clippy::unnecessary_wraps)]
100pub fn de_create_streaming_url_http_response(
101    _response_status: u16,
102    _response_headers: &::aws_smithy_runtime_api::http::Headers,
103    _response_body: &[u8],
104) -> std::result::Result<
105    crate::operation::create_streaming_url::CreateStreamingUrlOutput,
106    crate::operation::create_streaming_url::CreateStreamingURLError,
107> {
108    Ok({
109        #[allow(unused_mut)]
110        let mut output = crate::operation::create_streaming_url::builders::CreateStreamingUrlOutputBuilder::default();
111        output = crate::protocol_serde::shape_create_streaming_url::de_create_streaming_url(_response_body, output)
112            .map_err(crate::operation::create_streaming_url::CreateStreamingURLError::unhandled)?;
113        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
114        output.build()
115    })
116}
117
118pub fn ser_create_streaming_url_input(
119    input: &crate::operation::create_streaming_url::CreateStreamingUrlInput,
120) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
121    let mut out = String::new();
122    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
123    crate::protocol_serde::shape_create_streaming_url_input::ser_create_streaming_url_input_input(&mut object, input)?;
124    object.finish();
125    Ok(::aws_smithy_types::body::SdkBody::from(out))
126}
127
128pub(crate) fn de_create_streaming_url(
129    value: &[u8],
130    mut builder: crate::operation::create_streaming_url::builders::CreateStreamingUrlOutputBuilder,
131) -> ::std::result::Result<
132    crate::operation::create_streaming_url::builders::CreateStreamingUrlOutputBuilder,
133    ::aws_smithy_json::deserialize::error::DeserializeError,
134> {
135    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
136    let tokens = &mut tokens_owned;
137    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
138    loop {
139        match tokens.next().transpose()? {
140            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
141            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
142                "StreamingURL" => {
143                    builder = builder.set_streaming_url(
144                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
145                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
146                            .transpose()?,
147                    );
148                }
149                "Expires" => {
150                    builder = builder.set_expires(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
151                        tokens.next(),
152                        ::aws_smithy_types::date_time::Format::EpochSeconds,
153                    )?);
154                }
155                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
156            },
157            other => {
158                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
159                    "expected object key or end object, found: {:?}",
160                    other
161                )))
162            }
163        }
164    }
165    if tokens.next().is_some() {
166        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
167            "found more JSON tokens after completing parsing",
168        ));
169    }
170    Ok(builder)
171}