1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/sso-admin/model/AccountAssignment.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 SSOAdmin
17 {
18 namespace Model
19 {
20 
AccountAssignment()21 AccountAssignment::AccountAssignment() :
22     m_accountIdHasBeenSet(false),
23     m_permissionSetArnHasBeenSet(false),
24     m_principalType(PrincipalType::NOT_SET),
25     m_principalTypeHasBeenSet(false),
26     m_principalIdHasBeenSet(false)
27 {
28 }
29 
AccountAssignment(JsonView jsonValue)30 AccountAssignment::AccountAssignment(JsonView jsonValue) :
31     m_accountIdHasBeenSet(false),
32     m_permissionSetArnHasBeenSet(false),
33     m_principalType(PrincipalType::NOT_SET),
34     m_principalTypeHasBeenSet(false),
35     m_principalIdHasBeenSet(false)
36 {
37   *this = jsonValue;
38 }
39 
operator =(JsonView jsonValue)40 AccountAssignment& AccountAssignment::operator =(JsonView jsonValue)
41 {
42   if(jsonValue.ValueExists("AccountId"))
43   {
44     m_accountId = jsonValue.GetString("AccountId");
45 
46     m_accountIdHasBeenSet = true;
47   }
48 
49   if(jsonValue.ValueExists("PermissionSetArn"))
50   {
51     m_permissionSetArn = jsonValue.GetString("PermissionSetArn");
52 
53     m_permissionSetArnHasBeenSet = true;
54   }
55 
56   if(jsonValue.ValueExists("PrincipalType"))
57   {
58     m_principalType = PrincipalTypeMapper::GetPrincipalTypeForName(jsonValue.GetString("PrincipalType"));
59 
60     m_principalTypeHasBeenSet = true;
61   }
62 
63   if(jsonValue.ValueExists("PrincipalId"))
64   {
65     m_principalId = jsonValue.GetString("PrincipalId");
66 
67     m_principalIdHasBeenSet = true;
68   }
69 
70   return *this;
71 }
72 
Jsonize() const73 JsonValue AccountAssignment::Jsonize() const
74 {
75   JsonValue payload;
76 
77   if(m_accountIdHasBeenSet)
78   {
79    payload.WithString("AccountId", m_accountId);
80 
81   }
82 
83   if(m_permissionSetArnHasBeenSet)
84   {
85    payload.WithString("PermissionSetArn", m_permissionSetArn);
86 
87   }
88 
89   if(m_principalTypeHasBeenSet)
90   {
91    payload.WithString("PrincipalType", PrincipalTypeMapper::GetNameForPrincipalType(m_principalType));
92   }
93 
94   if(m_principalIdHasBeenSet)
95   {
96    payload.WithString("PrincipalId", m_principalId);
97 
98   }
99 
100   return payload;
101 }
102 
103 } // namespace Model
104 } // namespace SSOAdmin
105 } // namespace Aws
106