1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/servicediscovery/model/HttpInstanceSummary.h>
7 #include <aws/core/utils/json/JsonSerializer.h>
8
9 #include <utility>
10
11 using namespace Aws::Utils::Json;
12 using namespace Aws::Utils;
13
14 namespace Aws
15 {
16 namespace ServiceDiscovery
17 {
18 namespace Model
19 {
20
HttpInstanceSummary()21 HttpInstanceSummary::HttpInstanceSummary() :
22 m_instanceIdHasBeenSet(false),
23 m_namespaceNameHasBeenSet(false),
24 m_serviceNameHasBeenSet(false),
25 m_healthStatus(HealthStatus::NOT_SET),
26 m_healthStatusHasBeenSet(false),
27 m_attributesHasBeenSet(false)
28 {
29 }
30
HttpInstanceSummary(JsonView jsonValue)31 HttpInstanceSummary::HttpInstanceSummary(JsonView jsonValue) :
32 m_instanceIdHasBeenSet(false),
33 m_namespaceNameHasBeenSet(false),
34 m_serviceNameHasBeenSet(false),
35 m_healthStatus(HealthStatus::NOT_SET),
36 m_healthStatusHasBeenSet(false),
37 m_attributesHasBeenSet(false)
38 {
39 *this = jsonValue;
40 }
41
operator =(JsonView jsonValue)42 HttpInstanceSummary& HttpInstanceSummary::operator =(JsonView jsonValue)
43 {
44 if(jsonValue.ValueExists("InstanceId"))
45 {
46 m_instanceId = jsonValue.GetString("InstanceId");
47
48 m_instanceIdHasBeenSet = true;
49 }
50
51 if(jsonValue.ValueExists("NamespaceName"))
52 {
53 m_namespaceName = jsonValue.GetString("NamespaceName");
54
55 m_namespaceNameHasBeenSet = true;
56 }
57
58 if(jsonValue.ValueExists("ServiceName"))
59 {
60 m_serviceName = jsonValue.GetString("ServiceName");
61
62 m_serviceNameHasBeenSet = true;
63 }
64
65 if(jsonValue.ValueExists("HealthStatus"))
66 {
67 m_healthStatus = HealthStatusMapper::GetHealthStatusForName(jsonValue.GetString("HealthStatus"));
68
69 m_healthStatusHasBeenSet = true;
70 }
71
72 if(jsonValue.ValueExists("Attributes"))
73 {
74 Aws::Map<Aws::String, JsonView> attributesJsonMap = jsonValue.GetObject("Attributes").GetAllObjects();
75 for(auto& attributesItem : attributesJsonMap)
76 {
77 m_attributes[attributesItem.first] = attributesItem.second.AsString();
78 }
79 m_attributesHasBeenSet = true;
80 }
81
82 return *this;
83 }
84
Jsonize() const85 JsonValue HttpInstanceSummary::Jsonize() const
86 {
87 JsonValue payload;
88
89 if(m_instanceIdHasBeenSet)
90 {
91 payload.WithString("InstanceId", m_instanceId);
92
93 }
94
95 if(m_namespaceNameHasBeenSet)
96 {
97 payload.WithString("NamespaceName", m_namespaceName);
98
99 }
100
101 if(m_serviceNameHasBeenSet)
102 {
103 payload.WithString("ServiceName", m_serviceName);
104
105 }
106
107 if(m_healthStatusHasBeenSet)
108 {
109 payload.WithString("HealthStatus", HealthStatusMapper::GetNameForHealthStatus(m_healthStatus));
110 }
111
112 if(m_attributesHasBeenSet)
113 {
114 JsonValue attributesJsonMap;
115 for(auto& attributesItem : m_attributes)
116 {
117 attributesJsonMap.WithString(attributesItem.first, attributesItem.second);
118 }
119 payload.WithObject("Attributes", std::move(attributesJsonMap));
120
121 }
122
123 return payload;
124 }
125
126 } // namespace Model
127 } // namespace ServiceDiscovery
128 } // namespace Aws
129