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/Compliance.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
Compliance()21 Compliance::Compliance() :
22 m_status(ComplianceStatus::NOT_SET),
23 m_statusHasBeenSet(false),
24 m_relatedRequirementsHasBeenSet(false),
25 m_statusReasonsHasBeenSet(false)
26 {
27 }
28
Compliance(JsonView jsonValue)29 Compliance::Compliance(JsonView jsonValue) :
30 m_status(ComplianceStatus::NOT_SET),
31 m_statusHasBeenSet(false),
32 m_relatedRequirementsHasBeenSet(false),
33 m_statusReasonsHasBeenSet(false)
34 {
35 *this = jsonValue;
36 }
37
operator =(JsonView jsonValue)38 Compliance& Compliance::operator =(JsonView jsonValue)
39 {
40 if(jsonValue.ValueExists("Status"))
41 {
42 m_status = ComplianceStatusMapper::GetComplianceStatusForName(jsonValue.GetString("Status"));
43
44 m_statusHasBeenSet = true;
45 }
46
47 if(jsonValue.ValueExists("RelatedRequirements"))
48 {
49 Array<JsonView> relatedRequirementsJsonList = jsonValue.GetArray("RelatedRequirements");
50 for(unsigned relatedRequirementsIndex = 0; relatedRequirementsIndex < relatedRequirementsJsonList.GetLength(); ++relatedRequirementsIndex)
51 {
52 m_relatedRequirements.push_back(relatedRequirementsJsonList[relatedRequirementsIndex].AsString());
53 }
54 m_relatedRequirementsHasBeenSet = true;
55 }
56
57 if(jsonValue.ValueExists("StatusReasons"))
58 {
59 Array<JsonView> statusReasonsJsonList = jsonValue.GetArray("StatusReasons");
60 for(unsigned statusReasonsIndex = 0; statusReasonsIndex < statusReasonsJsonList.GetLength(); ++statusReasonsIndex)
61 {
62 m_statusReasons.push_back(statusReasonsJsonList[statusReasonsIndex].AsObject());
63 }
64 m_statusReasonsHasBeenSet = true;
65 }
66
67 return *this;
68 }
69
Jsonize() const70 JsonValue Compliance::Jsonize() const
71 {
72 JsonValue payload;
73
74 if(m_statusHasBeenSet)
75 {
76 payload.WithString("Status", ComplianceStatusMapper::GetNameForComplianceStatus(m_status));
77 }
78
79 if(m_relatedRequirementsHasBeenSet)
80 {
81 Array<JsonValue> relatedRequirementsJsonList(m_relatedRequirements.size());
82 for(unsigned relatedRequirementsIndex = 0; relatedRequirementsIndex < relatedRequirementsJsonList.GetLength(); ++relatedRequirementsIndex)
83 {
84 relatedRequirementsJsonList[relatedRequirementsIndex].AsString(m_relatedRequirements[relatedRequirementsIndex]);
85 }
86 payload.WithArray("RelatedRequirements", std::move(relatedRequirementsJsonList));
87
88 }
89
90 if(m_statusReasonsHasBeenSet)
91 {
92 Array<JsonValue> statusReasonsJsonList(m_statusReasons.size());
93 for(unsigned statusReasonsIndex = 0; statusReasonsIndex < statusReasonsJsonList.GetLength(); ++statusReasonsIndex)
94 {
95 statusReasonsJsonList[statusReasonsIndex].AsObject(m_statusReasons[statusReasonsIndex].Jsonize());
96 }
97 payload.WithArray("StatusReasons", std::move(statusReasonsJsonList));
98
99 }
100
101 return payload;
102 }
103
104 } // namespace Model
105 } // namespace SecurityHub
106 } // namespace Aws
107