1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/securityhub/model/AwsWafWebAclDetails.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 SecurityHub
17 {
18 namespace Model
19 {
20
AwsWafWebAclDetails()21 AwsWafWebAclDetails::AwsWafWebAclDetails() :
22 m_nameHasBeenSet(false),
23 m_defaultActionHasBeenSet(false),
24 m_rulesHasBeenSet(false),
25 m_webAclIdHasBeenSet(false)
26 {
27 }
28
AwsWafWebAclDetails(JsonView jsonValue)29 AwsWafWebAclDetails::AwsWafWebAclDetails(JsonView jsonValue) :
30 m_nameHasBeenSet(false),
31 m_defaultActionHasBeenSet(false),
32 m_rulesHasBeenSet(false),
33 m_webAclIdHasBeenSet(false)
34 {
35 *this = jsonValue;
36 }
37
operator =(JsonView jsonValue)38 AwsWafWebAclDetails& AwsWafWebAclDetails::operator =(JsonView jsonValue)
39 {
40 if(jsonValue.ValueExists("Name"))
41 {
42 m_name = jsonValue.GetString("Name");
43
44 m_nameHasBeenSet = true;
45 }
46
47 if(jsonValue.ValueExists("DefaultAction"))
48 {
49 m_defaultAction = jsonValue.GetString("DefaultAction");
50
51 m_defaultActionHasBeenSet = true;
52 }
53
54 if(jsonValue.ValueExists("Rules"))
55 {
56 Array<JsonView> rulesJsonList = jsonValue.GetArray("Rules");
57 for(unsigned rulesIndex = 0; rulesIndex < rulesJsonList.GetLength(); ++rulesIndex)
58 {
59 m_rules.push_back(rulesJsonList[rulesIndex].AsObject());
60 }
61 m_rulesHasBeenSet = true;
62 }
63
64 if(jsonValue.ValueExists("WebAclId"))
65 {
66 m_webAclId = jsonValue.GetString("WebAclId");
67
68 m_webAclIdHasBeenSet = true;
69 }
70
71 return *this;
72 }
73
Jsonize() const74 JsonValue AwsWafWebAclDetails::Jsonize() const
75 {
76 JsonValue payload;
77
78 if(m_nameHasBeenSet)
79 {
80 payload.WithString("Name", m_name);
81
82 }
83
84 if(m_defaultActionHasBeenSet)
85 {
86 payload.WithString("DefaultAction", m_defaultAction);
87
88 }
89
90 if(m_rulesHasBeenSet)
91 {
92 Array<JsonValue> rulesJsonList(m_rules.size());
93 for(unsigned rulesIndex = 0; rulesIndex < rulesJsonList.GetLength(); ++rulesIndex)
94 {
95 rulesJsonList[rulesIndex].AsObject(m_rules[rulesIndex].Jsonize());
96 }
97 payload.WithArray("Rules", std::move(rulesJsonList));
98
99 }
100
101 if(m_webAclIdHasBeenSet)
102 {
103 payload.WithString("WebAclId", m_webAclId);
104
105 }
106
107 return payload;
108 }
109
110 } // namespace Model
111 } // namespace SecurityHub
112 } // namespace Aws
113