1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/imagebuilder/model/ContainerRecipeSummary.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 imagebuilder
17 {
18 namespace Model
19 {
20 
ContainerRecipeSummary()21 ContainerRecipeSummary::ContainerRecipeSummary() :
22     m_arnHasBeenSet(false),
23     m_containerType(ContainerType::NOT_SET),
24     m_containerTypeHasBeenSet(false),
25     m_nameHasBeenSet(false),
26     m_platform(Platform::NOT_SET),
27     m_platformHasBeenSet(false),
28     m_ownerHasBeenSet(false),
29     m_parentImageHasBeenSet(false),
30     m_dateCreatedHasBeenSet(false),
31     m_tagsHasBeenSet(false)
32 {
33 }
34 
ContainerRecipeSummary(JsonView jsonValue)35 ContainerRecipeSummary::ContainerRecipeSummary(JsonView jsonValue) :
36     m_arnHasBeenSet(false),
37     m_containerType(ContainerType::NOT_SET),
38     m_containerTypeHasBeenSet(false),
39     m_nameHasBeenSet(false),
40     m_platform(Platform::NOT_SET),
41     m_platformHasBeenSet(false),
42     m_ownerHasBeenSet(false),
43     m_parentImageHasBeenSet(false),
44     m_dateCreatedHasBeenSet(false),
45     m_tagsHasBeenSet(false)
46 {
47   *this = jsonValue;
48 }
49 
operator =(JsonView jsonValue)50 ContainerRecipeSummary& ContainerRecipeSummary::operator =(JsonView jsonValue)
51 {
52   if(jsonValue.ValueExists("arn"))
53   {
54     m_arn = jsonValue.GetString("arn");
55 
56     m_arnHasBeenSet = true;
57   }
58 
59   if(jsonValue.ValueExists("containerType"))
60   {
61     m_containerType = ContainerTypeMapper::GetContainerTypeForName(jsonValue.GetString("containerType"));
62 
63     m_containerTypeHasBeenSet = true;
64   }
65 
66   if(jsonValue.ValueExists("name"))
67   {
68     m_name = jsonValue.GetString("name");
69 
70     m_nameHasBeenSet = true;
71   }
72 
73   if(jsonValue.ValueExists("platform"))
74   {
75     m_platform = PlatformMapper::GetPlatformForName(jsonValue.GetString("platform"));
76 
77     m_platformHasBeenSet = true;
78   }
79 
80   if(jsonValue.ValueExists("owner"))
81   {
82     m_owner = jsonValue.GetString("owner");
83 
84     m_ownerHasBeenSet = true;
85   }
86 
87   if(jsonValue.ValueExists("parentImage"))
88   {
89     m_parentImage = jsonValue.GetString("parentImage");
90 
91     m_parentImageHasBeenSet = true;
92   }
93 
94   if(jsonValue.ValueExists("dateCreated"))
95   {
96     m_dateCreated = jsonValue.GetString("dateCreated");
97 
98     m_dateCreatedHasBeenSet = true;
99   }
100 
101   if(jsonValue.ValueExists("tags"))
102   {
103     Aws::Map<Aws::String, JsonView> tagsJsonMap = jsonValue.GetObject("tags").GetAllObjects();
104     for(auto& tagsItem : tagsJsonMap)
105     {
106       m_tags[tagsItem.first] = tagsItem.second.AsString();
107     }
108     m_tagsHasBeenSet = true;
109   }
110 
111   return *this;
112 }
113 
Jsonize() const114 JsonValue ContainerRecipeSummary::Jsonize() const
115 {
116   JsonValue payload;
117 
118   if(m_arnHasBeenSet)
119   {
120    payload.WithString("arn", m_arn);
121 
122   }
123 
124   if(m_containerTypeHasBeenSet)
125   {
126    payload.WithString("containerType", ContainerTypeMapper::GetNameForContainerType(m_containerType));
127   }
128 
129   if(m_nameHasBeenSet)
130   {
131    payload.WithString("name", m_name);
132 
133   }
134 
135   if(m_platformHasBeenSet)
136   {
137    payload.WithString("platform", PlatformMapper::GetNameForPlatform(m_platform));
138   }
139 
140   if(m_ownerHasBeenSet)
141   {
142    payload.WithString("owner", m_owner);
143 
144   }
145 
146   if(m_parentImageHasBeenSet)
147   {
148    payload.WithString("parentImage", m_parentImage);
149 
150   }
151 
152   if(m_dateCreatedHasBeenSet)
153   {
154    payload.WithString("dateCreated", m_dateCreated);
155 
156   }
157 
158   if(m_tagsHasBeenSet)
159   {
160    JsonValue tagsJsonMap;
161    for(auto& tagsItem : m_tags)
162    {
163      tagsJsonMap.WithString(tagsItem.first, tagsItem.second);
164    }
165    payload.WithObject("tags", std::move(tagsJsonMap));
166 
167   }
168 
169   return payload;
170 }
171 
172 } // namespace Model
173 } // namespace imagebuilder
174 } // namespace Aws
175