1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/ecs/model/Attribute.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 ECS
17 {
18 namespace Model
19 {
20 
Attribute()21 Attribute::Attribute() :
22     m_nameHasBeenSet(false),
23     m_valueHasBeenSet(false),
24     m_targetType(TargetType::NOT_SET),
25     m_targetTypeHasBeenSet(false),
26     m_targetIdHasBeenSet(false)
27 {
28 }
29 
Attribute(JsonView jsonValue)30 Attribute::Attribute(JsonView jsonValue) :
31     m_nameHasBeenSet(false),
32     m_valueHasBeenSet(false),
33     m_targetType(TargetType::NOT_SET),
34     m_targetTypeHasBeenSet(false),
35     m_targetIdHasBeenSet(false)
36 {
37   *this = jsonValue;
38 }
39 
operator =(JsonView jsonValue)40 Attribute& Attribute::operator =(JsonView jsonValue)
41 {
42   if(jsonValue.ValueExists("name"))
43   {
44     m_name = jsonValue.GetString("name");
45 
46     m_nameHasBeenSet = true;
47   }
48 
49   if(jsonValue.ValueExists("value"))
50   {
51     m_value = jsonValue.GetString("value");
52 
53     m_valueHasBeenSet = true;
54   }
55 
56   if(jsonValue.ValueExists("targetType"))
57   {
58     m_targetType = TargetTypeMapper::GetTargetTypeForName(jsonValue.GetString("targetType"));
59 
60     m_targetTypeHasBeenSet = true;
61   }
62 
63   if(jsonValue.ValueExists("targetId"))
64   {
65     m_targetId = jsonValue.GetString("targetId");
66 
67     m_targetIdHasBeenSet = true;
68   }
69 
70   return *this;
71 }
72 
Jsonize() const73 JsonValue Attribute::Jsonize() const
74 {
75   JsonValue payload;
76 
77   if(m_nameHasBeenSet)
78   {
79    payload.WithString("name", m_name);
80 
81   }
82 
83   if(m_valueHasBeenSet)
84   {
85    payload.WithString("value", m_value);
86 
87   }
88 
89   if(m_targetTypeHasBeenSet)
90   {
91    payload.WithString("targetType", TargetTypeMapper::GetNameForTargetType(m_targetType));
92   }
93 
94   if(m_targetIdHasBeenSet)
95   {
96    payload.WithString("targetId", m_targetId);
97 
98   }
99 
100   return payload;
101 }
102 
103 } // namespace Model
104 } // namespace ECS
105 } // namespace Aws
106