aws_sdk_ecs/protocol_serde/
shape_cluster.rs1pub(crate) fn de_cluster<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::Cluster>, ::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::ClusterBuilder::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 "clusterArn" => {
18 builder = builder.set_cluster_arn(
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 "clusterName" => {
25 builder = builder.set_cluster_name(
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 "configuration" => {
32 builder =
33 builder.set_configuration(crate::protocol_serde::shape_cluster_configuration::de_cluster_configuration(tokens)?);
34 }
35 "status" => {
36 builder = builder.set_status(
37 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
38 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
39 .transpose()?,
40 );
41 }
42 "registeredContainerInstancesCount" => {
43 builder = builder.set_registered_container_instances_count(
44 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
45 .map(i32::try_from)
46 .transpose()?,
47 );
48 }
49 "runningTasksCount" => {
50 builder = builder.set_running_tasks_count(
51 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
52 .map(i32::try_from)
53 .transpose()?,
54 );
55 }
56 "pendingTasksCount" => {
57 builder = builder.set_pending_tasks_count(
58 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
59 .map(i32::try_from)
60 .transpose()?,
61 );
62 }
63 "activeServicesCount" => {
64 builder = builder.set_active_services_count(
65 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
66 .map(i32::try_from)
67 .transpose()?,
68 );
69 }
70 "statistics" => {
71 builder = builder.set_statistics(crate::protocol_serde::shape_statistics::de_statistics(tokens)?);
72 }
73 "tags" => {
74 builder = builder.set_tags(crate::protocol_serde::shape_tags::de_tags(tokens)?);
75 }
76 "settings" => {
77 builder = builder.set_settings(crate::protocol_serde::shape_cluster_settings::de_cluster_settings(tokens)?);
78 }
79 "capacityProviders" => {
80 builder = builder.set_capacity_providers(crate::protocol_serde::shape_string_list::de_string_list(tokens)?);
81 }
82 "defaultCapacityProviderStrategy" => {
83 builder = builder.set_default_capacity_provider_strategy(
84 crate::protocol_serde::shape_capacity_provider_strategy::de_capacity_provider_strategy(tokens)?,
85 );
86 }
87 "attachments" => {
88 builder = builder.set_attachments(crate::protocol_serde::shape_attachments::de_attachments(tokens)?);
89 }
90 "attachmentsStatus" => {
91 builder = builder.set_attachments_status(
92 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
93 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
94 .transpose()?,
95 );
96 }
97 "serviceConnectDefaults" => {
98 builder = builder.set_service_connect_defaults(
99 crate::protocol_serde::shape_cluster_service_connect_defaults::de_cluster_service_connect_defaults(tokens)?,
100 );
101 }
102 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
103 },
104 other => {
105 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
106 "expected object key or end object, found: {:?}",
107 other
108 )))
109 }
110 }
111 }
112 Ok(Some(builder.build()))
113 }
114 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
115 "expected start object or null",
116 )),
117 }
118}