1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/amplifybackend/model/CreateBackendAuthOAuthConfig.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 AmplifyBackend
17 {
18 namespace Model
19 {
20
CreateBackendAuthOAuthConfig()21 CreateBackendAuthOAuthConfig::CreateBackendAuthOAuthConfig() :
22 m_domainPrefixHasBeenSet(false),
23 m_oAuthGrantType(OAuthGrantType::NOT_SET),
24 m_oAuthGrantTypeHasBeenSet(false),
25 m_oAuthScopesHasBeenSet(false),
26 m_redirectSignInURIsHasBeenSet(false),
27 m_redirectSignOutURIsHasBeenSet(false),
28 m_socialProviderSettingsHasBeenSet(false)
29 {
30 }
31
CreateBackendAuthOAuthConfig(JsonView jsonValue)32 CreateBackendAuthOAuthConfig::CreateBackendAuthOAuthConfig(JsonView jsonValue) :
33 m_domainPrefixHasBeenSet(false),
34 m_oAuthGrantType(OAuthGrantType::NOT_SET),
35 m_oAuthGrantTypeHasBeenSet(false),
36 m_oAuthScopesHasBeenSet(false),
37 m_redirectSignInURIsHasBeenSet(false),
38 m_redirectSignOutURIsHasBeenSet(false),
39 m_socialProviderSettingsHasBeenSet(false)
40 {
41 *this = jsonValue;
42 }
43
operator =(JsonView jsonValue)44 CreateBackendAuthOAuthConfig& CreateBackendAuthOAuthConfig::operator =(JsonView jsonValue)
45 {
46 if(jsonValue.ValueExists("domainPrefix"))
47 {
48 m_domainPrefix = jsonValue.GetString("domainPrefix");
49
50 m_domainPrefixHasBeenSet = true;
51 }
52
53 if(jsonValue.ValueExists("oAuthGrantType"))
54 {
55 m_oAuthGrantType = OAuthGrantTypeMapper::GetOAuthGrantTypeForName(jsonValue.GetString("oAuthGrantType"));
56
57 m_oAuthGrantTypeHasBeenSet = true;
58 }
59
60 if(jsonValue.ValueExists("oAuthScopes"))
61 {
62 Array<JsonView> oAuthScopesJsonList = jsonValue.GetArray("oAuthScopes");
63 for(unsigned oAuthScopesIndex = 0; oAuthScopesIndex < oAuthScopesJsonList.GetLength(); ++oAuthScopesIndex)
64 {
65 m_oAuthScopes.push_back(OAuthScopesElementMapper::GetOAuthScopesElementForName(oAuthScopesJsonList[oAuthScopesIndex].AsString()));
66 }
67 m_oAuthScopesHasBeenSet = true;
68 }
69
70 if(jsonValue.ValueExists("redirectSignInURIs"))
71 {
72 Array<JsonView> redirectSignInURIsJsonList = jsonValue.GetArray("redirectSignInURIs");
73 for(unsigned redirectSignInURIsIndex = 0; redirectSignInURIsIndex < redirectSignInURIsJsonList.GetLength(); ++redirectSignInURIsIndex)
74 {
75 m_redirectSignInURIs.push_back(redirectSignInURIsJsonList[redirectSignInURIsIndex].AsString());
76 }
77 m_redirectSignInURIsHasBeenSet = true;
78 }
79
80 if(jsonValue.ValueExists("redirectSignOutURIs"))
81 {
82 Array<JsonView> redirectSignOutURIsJsonList = jsonValue.GetArray("redirectSignOutURIs");
83 for(unsigned redirectSignOutURIsIndex = 0; redirectSignOutURIsIndex < redirectSignOutURIsJsonList.GetLength(); ++redirectSignOutURIsIndex)
84 {
85 m_redirectSignOutURIs.push_back(redirectSignOutURIsJsonList[redirectSignOutURIsIndex].AsString());
86 }
87 m_redirectSignOutURIsHasBeenSet = true;
88 }
89
90 if(jsonValue.ValueExists("socialProviderSettings"))
91 {
92 m_socialProviderSettings = jsonValue.GetObject("socialProviderSettings");
93
94 m_socialProviderSettingsHasBeenSet = true;
95 }
96
97 return *this;
98 }
99
Jsonize() const100 JsonValue CreateBackendAuthOAuthConfig::Jsonize() const
101 {
102 JsonValue payload;
103
104 if(m_domainPrefixHasBeenSet)
105 {
106 payload.WithString("domainPrefix", m_domainPrefix);
107
108 }
109
110 if(m_oAuthGrantTypeHasBeenSet)
111 {
112 payload.WithString("oAuthGrantType", OAuthGrantTypeMapper::GetNameForOAuthGrantType(m_oAuthGrantType));
113 }
114
115 if(m_oAuthScopesHasBeenSet)
116 {
117 Array<JsonValue> oAuthScopesJsonList(m_oAuthScopes.size());
118 for(unsigned oAuthScopesIndex = 0; oAuthScopesIndex < oAuthScopesJsonList.GetLength(); ++oAuthScopesIndex)
119 {
120 oAuthScopesJsonList[oAuthScopesIndex].AsString(OAuthScopesElementMapper::GetNameForOAuthScopesElement(m_oAuthScopes[oAuthScopesIndex]));
121 }
122 payload.WithArray("oAuthScopes", std::move(oAuthScopesJsonList));
123
124 }
125
126 if(m_redirectSignInURIsHasBeenSet)
127 {
128 Array<JsonValue> redirectSignInURIsJsonList(m_redirectSignInURIs.size());
129 for(unsigned redirectSignInURIsIndex = 0; redirectSignInURIsIndex < redirectSignInURIsJsonList.GetLength(); ++redirectSignInURIsIndex)
130 {
131 redirectSignInURIsJsonList[redirectSignInURIsIndex].AsString(m_redirectSignInURIs[redirectSignInURIsIndex]);
132 }
133 payload.WithArray("redirectSignInURIs", std::move(redirectSignInURIsJsonList));
134
135 }
136
137 if(m_redirectSignOutURIsHasBeenSet)
138 {
139 Array<JsonValue> redirectSignOutURIsJsonList(m_redirectSignOutURIs.size());
140 for(unsigned redirectSignOutURIsIndex = 0; redirectSignOutURIsIndex < redirectSignOutURIsJsonList.GetLength(); ++redirectSignOutURIsIndex)
141 {
142 redirectSignOutURIsJsonList[redirectSignOutURIsIndex].AsString(m_redirectSignOutURIs[redirectSignOutURIsIndex]);
143 }
144 payload.WithArray("redirectSignOutURIs", std::move(redirectSignOutURIsJsonList));
145
146 }
147
148 if(m_socialProviderSettingsHasBeenSet)
149 {
150 payload.WithObject("socialProviderSettings", m_socialProviderSettings.Jsonize());
151
152 }
153
154 return payload;
155 }
156
157 } // namespace Model
158 } // namespace AmplifyBackend
159 } // namespace Aws
160