aws_sdk_sagemaker/protocol_serde/
shape_create_notebook_instance_lifecycle_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_notebook_instance_lifecycle_config_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_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigOutput,
9    crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError,
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_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError::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::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError::unhandled(generic))
20        }
21    };
22
23    let _error_message = generic.message().map(|msg| msg.to_owned());
24    Err(match error_code {
25        "ResourceLimitExceeded" => {
26            crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError::ResourceLimitExceeded({
27                #[allow(unused_mut)]
28                let mut tmp = {
29                    #[allow(unused_mut)]
30                    let mut output = crate::types::error::builders::ResourceLimitExceededBuilder::default();
31                    output = crate::protocol_serde::shape_resource_limit_exceeded::de_resource_limit_exceeded_json_err(_response_body, output)
32                        .map_err(
33                            crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError::unhandled,
34                        )?;
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        _ => crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError::generic(generic),
45    })
46}
47
48#[allow(clippy::unnecessary_wraps)]
49pub fn de_create_notebook_instance_lifecycle_config_http_response(
50    _response_status: u16,
51    _response_headers: &::aws_smithy_runtime_api::http::Headers,
52    _response_body: &[u8],
53) -> std::result::Result<
54    crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigOutput,
55    crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError,
56> {
57    Ok({
58        #[allow(unused_mut)]
59        let mut output =
60            crate::operation::create_notebook_instance_lifecycle_config::builders::CreateNotebookInstanceLifecycleConfigOutputBuilder::default();
61        output = crate::protocol_serde::shape_create_notebook_instance_lifecycle_config::de_create_notebook_instance_lifecycle_config(
62            _response_body,
63            output,
64        )
65        .map_err(crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigError::unhandled)?;
66        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
67        output.build()
68    })
69}
70
71pub fn ser_create_notebook_instance_lifecycle_config_input(
72    input: &crate::operation::create_notebook_instance_lifecycle_config::CreateNotebookInstanceLifecycleConfigInput,
73) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
74    let mut out = String::new();
75    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
76    crate::protocol_serde::shape_create_notebook_instance_lifecycle_config_input::ser_create_notebook_instance_lifecycle_config_input_input(
77        &mut object,
78        input,
79    )?;
80    object.finish();
81    Ok(::aws_smithy_types::body::SdkBody::from(out))
82}
83
84pub(crate) fn de_create_notebook_instance_lifecycle_config(
85    value: &[u8],
86    mut builder: crate::operation::create_notebook_instance_lifecycle_config::builders::CreateNotebookInstanceLifecycleConfigOutputBuilder,
87) -> ::std::result::Result<
88    crate::operation::create_notebook_instance_lifecycle_config::builders::CreateNotebookInstanceLifecycleConfigOutputBuilder,
89    ::aws_smithy_json::deserialize::error::DeserializeError,
90> {
91    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
92    let tokens = &mut tokens_owned;
93    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
94    loop {
95        match tokens.next().transpose()? {
96            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
97            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
98                "NotebookInstanceLifecycleConfigArn" => {
99                    builder = builder.set_notebook_instance_lifecycle_config_arn(
100                        ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
101                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
102                            .transpose()?,
103                    );
104                }
105                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
106            },
107            other => {
108                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
109                    "expected object key or end object, found: {:?}",
110                    other
111                )))
112            }
113        }
114    }
115    if tokens.next().is_some() {
116        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
117            "found more JSON tokens after completing parsing",
118        ));
119    }
120    Ok(builder)
121}