aws_sdk_ecs/protocol_serde/
shape_container_instance.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_container_instance<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::ContainerInstance>, ::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::ContainerInstanceBuilder::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                        "containerInstanceArn" => {
18                            builder = builder.set_container_instance_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                        "ec2InstanceId" => {
25                            builder = builder.set_ec2_instance_id(
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                        "capacityProviderName" => {
32                            builder = builder.set_capacity_provider_name(
33                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
34                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
35                                    .transpose()?,
36                            );
37                        }
38                        "version" => {
39                            builder = builder.set_version(
40                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
41                                    .map(i64::try_from)
42                                    .transpose()?,
43                            );
44                        }
45                        "versionInfo" => {
46                            builder = builder.set_version_info(crate::protocol_serde::shape_version_info::de_version_info(tokens)?);
47                        }
48                        "remainingResources" => {
49                            builder = builder.set_remaining_resources(crate::protocol_serde::shape_resources::de_resources(tokens)?);
50                        }
51                        "registeredResources" => {
52                            builder = builder.set_registered_resources(crate::protocol_serde::shape_resources::de_resources(tokens)?);
53                        }
54                        "status" => {
55                            builder = builder.set_status(
56                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
57                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
58                                    .transpose()?,
59                            );
60                        }
61                        "statusReason" => {
62                            builder = builder.set_status_reason(
63                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
64                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
65                                    .transpose()?,
66                            );
67                        }
68                        "agentConnected" => {
69                            builder = builder.set_agent_connected(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
70                        }
71                        "runningTasksCount" => {
72                            builder = builder.set_running_tasks_count(
73                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
74                                    .map(i32::try_from)
75                                    .transpose()?,
76                            );
77                        }
78                        "pendingTasksCount" => {
79                            builder = builder.set_pending_tasks_count(
80                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
81                                    .map(i32::try_from)
82                                    .transpose()?,
83                            );
84                        }
85                        "agentUpdateStatus" => {
86                            builder = builder.set_agent_update_status(
87                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
88                                    .map(|s| s.to_unescaped().map(|u| crate::types::AgentUpdateStatus::from(u.as_ref())))
89                                    .transpose()?,
90                            );
91                        }
92                        "attributes" => {
93                            builder = builder.set_attributes(crate::protocol_serde::shape_attributes::de_attributes(tokens)?);
94                        }
95                        "registeredAt" => {
96                            builder = builder.set_registered_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
97                                tokens.next(),
98                                ::aws_smithy_types::date_time::Format::EpochSeconds,
99                            )?);
100                        }
101                        "attachments" => {
102                            builder = builder.set_attachments(crate::protocol_serde::shape_attachments::de_attachments(tokens)?);
103                        }
104                        "tags" => {
105                            builder = builder.set_tags(crate::protocol_serde::shape_tags::de_tags(tokens)?);
106                        }
107                        "healthStatus" => {
108                            builder = builder.set_health_status(
109                                crate::protocol_serde::shape_container_instance_health_status::de_container_instance_health_status(tokens)?,
110                            );
111                        }
112                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
113                    },
114                    other => {
115                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
116                            "expected object key or end object, found: {:?}",
117                            other
118                        )))
119                    }
120                }
121            }
122            Ok(Some(builder.build()))
123        }
124        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
125            "expected start object or null",
126        )),
127    }
128}