1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/servicecatalog/model/ShareDetails.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 ServiceCatalog
17 {
18 namespace Model
19 {
20 
ShareDetails()21 ShareDetails::ShareDetails() :
22     m_successfulSharesHasBeenSet(false),
23     m_shareErrorsHasBeenSet(false)
24 {
25 }
26 
ShareDetails(JsonView jsonValue)27 ShareDetails::ShareDetails(JsonView jsonValue) :
28     m_successfulSharesHasBeenSet(false),
29     m_shareErrorsHasBeenSet(false)
30 {
31   *this = jsonValue;
32 }
33 
operator =(JsonView jsonValue)34 ShareDetails& ShareDetails::operator =(JsonView jsonValue)
35 {
36   if(jsonValue.ValueExists("SuccessfulShares"))
37   {
38     Array<JsonView> successfulSharesJsonList = jsonValue.GetArray("SuccessfulShares");
39     for(unsigned successfulSharesIndex = 0; successfulSharesIndex < successfulSharesJsonList.GetLength(); ++successfulSharesIndex)
40     {
41       m_successfulShares.push_back(successfulSharesJsonList[successfulSharesIndex].AsString());
42     }
43     m_successfulSharesHasBeenSet = true;
44   }
45 
46   if(jsonValue.ValueExists("ShareErrors"))
47   {
48     Array<JsonView> shareErrorsJsonList = jsonValue.GetArray("ShareErrors");
49     for(unsigned shareErrorsIndex = 0; shareErrorsIndex < shareErrorsJsonList.GetLength(); ++shareErrorsIndex)
50     {
51       m_shareErrors.push_back(shareErrorsJsonList[shareErrorsIndex].AsObject());
52     }
53     m_shareErrorsHasBeenSet = true;
54   }
55 
56   return *this;
57 }
58 
Jsonize() const59 JsonValue ShareDetails::Jsonize() const
60 {
61   JsonValue payload;
62 
63   if(m_successfulSharesHasBeenSet)
64   {
65    Array<JsonValue> successfulSharesJsonList(m_successfulShares.size());
66    for(unsigned successfulSharesIndex = 0; successfulSharesIndex < successfulSharesJsonList.GetLength(); ++successfulSharesIndex)
67    {
68      successfulSharesJsonList[successfulSharesIndex].AsString(m_successfulShares[successfulSharesIndex]);
69    }
70    payload.WithArray("SuccessfulShares", std::move(successfulSharesJsonList));
71 
72   }
73 
74   if(m_shareErrorsHasBeenSet)
75   {
76    Array<JsonValue> shareErrorsJsonList(m_shareErrors.size());
77    for(unsigned shareErrorsIndex = 0; shareErrorsIndex < shareErrorsJsonList.GetLength(); ++shareErrorsIndex)
78    {
79      shareErrorsJsonList[shareErrorsIndex].AsObject(m_shareErrors[shareErrorsIndex].Jsonize());
80    }
81    payload.WithArray("ShareErrors", std::move(shareErrorsJsonList));
82 
83   }
84 
85   return payload;
86 }
87 
88 } // namespace Model
89 } // namespace ServiceCatalog
90 } // namespace Aws
91