aws_sdk_sagemaker/protocol_serde/
shape_workforce.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_workforce<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::Workforce>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::WorkforceBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "WorkforceName" => {
18                            builder = builder.set_workforce_name(
19                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
20                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
21                                    .transpose()?,
22                            );
23                        }
24                        "WorkforceArn" => {
25                            builder = builder.set_workforce_arn(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
28                                    .transpose()?,
29                            );
30                        }
31                        "LastUpdatedDate" => {
32                            builder = builder.set_last_updated_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
33                                tokens.next(),
34                                ::aws_smithy_types::date_time::Format::EpochSeconds,
35                            )?);
36                        }
37                        "SourceIpConfig" => {
38                            builder = builder.set_source_ip_config(crate::protocol_serde::shape_source_ip_config::de_source_ip_config(tokens)?);
39                        }
40                        "SubDomain" => {
41                            builder = builder.set_sub_domain(
42                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
43                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
44                                    .transpose()?,
45                            );
46                        }
47                        "CognitoConfig" => {
48                            builder = builder.set_cognito_config(crate::protocol_serde::shape_cognito_config::de_cognito_config(tokens)?);
49                        }
50                        "OidcConfig" => {
51                            builder = builder.set_oidc_config(crate::protocol_serde::shape_oidc_config_for_response::de_oidc_config_for_response(
52                                tokens,
53                            )?);
54                        }
55                        "CreateDate" => {
56                            builder = builder.set_create_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
57                                tokens.next(),
58                                ::aws_smithy_types::date_time::Format::EpochSeconds,
59                            )?);
60                        }
61                        "WorkforceVpcConfig" => {
62                            builder = builder.set_workforce_vpc_config(
63                                crate::protocol_serde::shape_workforce_vpc_config_response::de_workforce_vpc_config_response(tokens)?,
64                            );
65                        }
66                        "Status" => {
67                            builder = builder.set_status(
68                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
69                                    .map(|s| s.to_unescaped().map(|u| crate::types::WorkforceStatus::from(u.as_ref())))
70                                    .transpose()?,
71                            );
72                        }
73                        "FailureReason" => {
74                            builder = builder.set_failure_reason(
75                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
76                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
77                                    .transpose()?,
78                            );
79                        }
80                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
81                    },
82                    other => {
83                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
84                            "expected object key or end object, found: {:?}",
85                            other
86                        )))
87                    }
88                }
89            }
90            Ok(Some(crate::serde_util::workforce_correct_errors(builder).build()))
91        }
92        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
93            "expected start object or null",
94        )),
95    }
96}