aws_sdk_ec2/protocol_serde/
shape_create_key_pair.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_key_pair_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::create_key_pair::CreateKeyPairOutput, crate::operation::create_key_pair::CreateKeyPairError> {
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::create_key_pair::CreateKeyPairError::unhandled)?;
11    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12    let generic = generic_builder.build();
13    Err(crate::operation::create_key_pair::CreateKeyPairError::generic(generic))
14}
15
16#[allow(clippy::unnecessary_wraps)]
17pub fn de_create_key_pair_http_response(
18    _response_status: u16,
19    _response_headers: &::aws_smithy_runtime_api::http::Headers,
20    _response_body: &[u8],
21) -> std::result::Result<crate::operation::create_key_pair::CreateKeyPairOutput, crate::operation::create_key_pair::CreateKeyPairError> {
22    Ok({
23        #[allow(unused_mut)]
24        let mut output = crate::operation::create_key_pair::builders::CreateKeyPairOutputBuilder::default();
25        output = crate::protocol_serde::shape_create_key_pair::de_create_key_pair(_response_body, output)
26            .map_err(crate::operation::create_key_pair::CreateKeyPairError::unhandled)?;
27        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
28        output.build()
29    })
30}
31
32#[allow(unused_mut)]
33pub fn de_create_key_pair(
34    inp: &[u8],
35    mut builder: crate::operation::create_key_pair::builders::CreateKeyPairOutputBuilder,
36) -> std::result::Result<crate::operation::create_key_pair::builders::CreateKeyPairOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
37    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
38
39    #[allow(unused_mut)]
40    let mut decoder = doc.root_element()?;
41    #[allow(unused_variables)]
42    let start_el = decoder.start_el();
43    if !(start_el.matches("CreateKeyPairResponse")) {
44        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
45            "invalid root, expected CreateKeyPairResponse got {:?}",
46            start_el
47        )));
48    }
49    while let Some(mut tag) = decoder.next_tag() {
50        match tag.start_el() {
51            s if s.matches("keyPairId") /* KeyPairId com.amazonaws.ec2.synthetic#CreateKeyPairOutput$KeyPairId */ =>  {
52                let var_1 =
53                    Some(
54                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
55                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
56                            .into()
57                        )
58                        ?
59                    )
60                ;
61                builder = builder.set_key_pair_id(var_1);
62            }
63            ,
64            s if s.matches("tagSet") /* Tags com.amazonaws.ec2.synthetic#CreateKeyPairOutput$Tags */ =>  {
65                let var_2 =
66                    Some(
67                        crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
68                        ?
69                    )
70                ;
71                builder = builder.set_tags(var_2);
72            }
73            ,
74            s if s.matches("keyName") /* KeyName com.amazonaws.ec2.synthetic#CreateKeyPairOutput$KeyName */ =>  {
75                let var_3 =
76                    Some(
77                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
78                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
79                            .into()
80                        )
81                        ?
82                    )
83                ;
84                builder = builder.set_key_name(var_3);
85            }
86            ,
87            s if s.matches("keyFingerprint") /* KeyFingerprint com.amazonaws.ec2.synthetic#CreateKeyPairOutput$KeyFingerprint */ =>  {
88                let var_4 =
89                    Some(
90                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
91                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
92                            .into()
93                        )
94                        ?
95                    )
96                ;
97                builder = builder.set_key_fingerprint(var_4);
98            }
99            ,
100            s if s.matches("keyMaterial") /* KeyMaterial com.amazonaws.ec2.synthetic#CreateKeyPairOutput$KeyMaterial */ =>  {
101                let var_5 =
102                    Some(
103                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
104                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
105                            .into()
106                        )
107                        ?
108                    )
109                ;
110                builder = builder.set_key_material(var_5);
111            }
112            ,
113            _ => {}
114        }
115    }
116    Ok(builder)
117}