1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/ssm/model/Target.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 SSM
17 {
18 namespace Model
19 {
20 
Target()21 Target::Target() :
22     m_keyHasBeenSet(false),
23     m_valuesHasBeenSet(false)
24 {
25 }
26 
Target(JsonView jsonValue)27 Target::Target(JsonView jsonValue) :
28     m_keyHasBeenSet(false),
29     m_valuesHasBeenSet(false)
30 {
31   *this = jsonValue;
32 }
33 
operator =(JsonView jsonValue)34 Target& Target::operator =(JsonView jsonValue)
35 {
36   if(jsonValue.ValueExists("Key"))
37   {
38     m_key = jsonValue.GetString("Key");
39 
40     m_keyHasBeenSet = true;
41   }
42 
43   if(jsonValue.ValueExists("Values"))
44   {
45     Array<JsonView> valuesJsonList = jsonValue.GetArray("Values");
46     for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex)
47     {
48       m_values.push_back(valuesJsonList[valuesIndex].AsString());
49     }
50     m_valuesHasBeenSet = true;
51   }
52 
53   return *this;
54 }
55 
Jsonize() const56 JsonValue Target::Jsonize() const
57 {
58   JsonValue payload;
59 
60   if(m_keyHasBeenSet)
61   {
62    payload.WithString("Key", m_key);
63 
64   }
65 
66   if(m_valuesHasBeenSet)
67   {
68    Array<JsonValue> valuesJsonList(m_values.size());
69    for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex)
70    {
71      valuesJsonList[valuesIndex].AsString(m_values[valuesIndex]);
72    }
73    payload.WithArray("Values", std::move(valuesJsonList));
74 
75   }
76 
77   return payload;
78 }
79 
80 } // namespace Model
81 } // namespace SSM
82 } // namespace Aws
83