aws_sdk_appstream/protocol_serde/
shape_associate_application_to_entitlement.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_associate_application_to_entitlement_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::associate_application_to_entitlement::AssociateApplicationToEntitlementOutput,
9    crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError,
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::associate_application_to_entitlement::AssociateApplicationToEntitlementError::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::associate_application_to_entitlement::AssociateApplicationToEntitlementError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "EntitlementNotFoundException" => {
24            crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::EntitlementNotFoundException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::EntitlementNotFoundExceptionBuilder::default();
29                    output = crate::protocol_serde::shape_entitlement_not_found_exception::de_entitlement_not_found_exception_json_err(
30                        _response_body,
31                        output,
32                    )
33                    .map_err(crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::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        }
43        "LimitExceededException" => {
44            crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::LimitExceededException({
45                #[allow(unused_mut)]
46                let mut tmp = {
47                    #[allow(unused_mut)]
48                    let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
49                    output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
50                        .map_err(crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::unhandled)?;
51                    let output = output.meta(generic);
52                    output.build()
53                };
54                if tmp.message.is_none() {
55                    tmp.message = _error_message;
56                }
57                tmp
58            })
59        }
60        "OperationNotPermittedException" => {
61            crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::OperationNotPermittedException({
62                #[allow(unused_mut)]
63                let mut tmp = {
64                    #[allow(unused_mut)]
65                    let mut output = crate::types::error::builders::OperationNotPermittedExceptionBuilder::default();
66                    output = crate::protocol_serde::shape_operation_not_permitted_exception::de_operation_not_permitted_exception_json_err(
67                        _response_body,
68                        output,
69                    )
70                    .map_err(crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::unhandled)?;
71                    let output = output.meta(generic);
72                    output.build()
73                };
74                if tmp.message.is_none() {
75                    tmp.message = _error_message;
76                }
77                tmp
78            })
79        }
80        "ResourceNotFoundException" => {
81            crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::ResourceNotFoundException({
82                #[allow(unused_mut)]
83                let mut tmp = {
84                    #[allow(unused_mut)]
85                    let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
86                    output =
87                        crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
88                            .map_err(crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::unhandled)?;
89                    let output = output.meta(generic);
90                    output.build()
91                };
92                if tmp.message.is_none() {
93                    tmp.message = _error_message;
94                }
95                tmp
96            })
97        }
98        _ => crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError::generic(generic),
99    })
100}
101
102#[allow(clippy::unnecessary_wraps)]
103pub fn de_associate_application_to_entitlement_http_response(
104    _response_status: u16,
105    _response_headers: &::aws_smithy_runtime_api::http::Headers,
106    _response_body: &[u8],
107) -> std::result::Result<
108    crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementOutput,
109    crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementError,
110> {
111    Ok({
112        #[allow(unused_mut)]
113        let mut output = crate::operation::associate_application_to_entitlement::builders::AssociateApplicationToEntitlementOutputBuilder::default();
114        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
115        output.build()
116    })
117}
118
119pub fn ser_associate_application_to_entitlement_input(
120    input: &crate::operation::associate_application_to_entitlement::AssociateApplicationToEntitlementInput,
121) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
122    let mut out = String::new();
123    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
124    crate::protocol_serde::shape_associate_application_to_entitlement_input::ser_associate_application_to_entitlement_input_input(
125        &mut object,
126        input,
127    )?;
128    object.finish();
129    Ok(::aws_smithy_types::body::SdkBody::from(out))
130}