1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/glue/model/UserDefinedFunction.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 Glue
17 {
18 namespace Model
19 {
20
UserDefinedFunction()21 UserDefinedFunction::UserDefinedFunction() :
22 m_functionNameHasBeenSet(false),
23 m_databaseNameHasBeenSet(false),
24 m_classNameHasBeenSet(false),
25 m_ownerNameHasBeenSet(false),
26 m_ownerType(PrincipalType::NOT_SET),
27 m_ownerTypeHasBeenSet(false),
28 m_createTimeHasBeenSet(false),
29 m_resourceUrisHasBeenSet(false),
30 m_catalogIdHasBeenSet(false)
31 {
32 }
33
UserDefinedFunction(JsonView jsonValue)34 UserDefinedFunction::UserDefinedFunction(JsonView jsonValue) :
35 m_functionNameHasBeenSet(false),
36 m_databaseNameHasBeenSet(false),
37 m_classNameHasBeenSet(false),
38 m_ownerNameHasBeenSet(false),
39 m_ownerType(PrincipalType::NOT_SET),
40 m_ownerTypeHasBeenSet(false),
41 m_createTimeHasBeenSet(false),
42 m_resourceUrisHasBeenSet(false),
43 m_catalogIdHasBeenSet(false)
44 {
45 *this = jsonValue;
46 }
47
operator =(JsonView jsonValue)48 UserDefinedFunction& UserDefinedFunction::operator =(JsonView jsonValue)
49 {
50 if(jsonValue.ValueExists("FunctionName"))
51 {
52 m_functionName = jsonValue.GetString("FunctionName");
53
54 m_functionNameHasBeenSet = true;
55 }
56
57 if(jsonValue.ValueExists("DatabaseName"))
58 {
59 m_databaseName = jsonValue.GetString("DatabaseName");
60
61 m_databaseNameHasBeenSet = true;
62 }
63
64 if(jsonValue.ValueExists("ClassName"))
65 {
66 m_className = jsonValue.GetString("ClassName");
67
68 m_classNameHasBeenSet = true;
69 }
70
71 if(jsonValue.ValueExists("OwnerName"))
72 {
73 m_ownerName = jsonValue.GetString("OwnerName");
74
75 m_ownerNameHasBeenSet = true;
76 }
77
78 if(jsonValue.ValueExists("OwnerType"))
79 {
80 m_ownerType = PrincipalTypeMapper::GetPrincipalTypeForName(jsonValue.GetString("OwnerType"));
81
82 m_ownerTypeHasBeenSet = true;
83 }
84
85 if(jsonValue.ValueExists("CreateTime"))
86 {
87 m_createTime = jsonValue.GetDouble("CreateTime");
88
89 m_createTimeHasBeenSet = true;
90 }
91
92 if(jsonValue.ValueExists("ResourceUris"))
93 {
94 Array<JsonView> resourceUrisJsonList = jsonValue.GetArray("ResourceUris");
95 for(unsigned resourceUrisIndex = 0; resourceUrisIndex < resourceUrisJsonList.GetLength(); ++resourceUrisIndex)
96 {
97 m_resourceUris.push_back(resourceUrisJsonList[resourceUrisIndex].AsObject());
98 }
99 m_resourceUrisHasBeenSet = true;
100 }
101
102 if(jsonValue.ValueExists("CatalogId"))
103 {
104 m_catalogId = jsonValue.GetString("CatalogId");
105
106 m_catalogIdHasBeenSet = true;
107 }
108
109 return *this;
110 }
111
Jsonize() const112 JsonValue UserDefinedFunction::Jsonize() const
113 {
114 JsonValue payload;
115
116 if(m_functionNameHasBeenSet)
117 {
118 payload.WithString("FunctionName", m_functionName);
119
120 }
121
122 if(m_databaseNameHasBeenSet)
123 {
124 payload.WithString("DatabaseName", m_databaseName);
125
126 }
127
128 if(m_classNameHasBeenSet)
129 {
130 payload.WithString("ClassName", m_className);
131
132 }
133
134 if(m_ownerNameHasBeenSet)
135 {
136 payload.WithString("OwnerName", m_ownerName);
137
138 }
139
140 if(m_ownerTypeHasBeenSet)
141 {
142 payload.WithString("OwnerType", PrincipalTypeMapper::GetNameForPrincipalType(m_ownerType));
143 }
144
145 if(m_createTimeHasBeenSet)
146 {
147 payload.WithDouble("CreateTime", m_createTime.SecondsWithMSPrecision());
148 }
149
150 if(m_resourceUrisHasBeenSet)
151 {
152 Array<JsonValue> resourceUrisJsonList(m_resourceUris.size());
153 for(unsigned resourceUrisIndex = 0; resourceUrisIndex < resourceUrisJsonList.GetLength(); ++resourceUrisIndex)
154 {
155 resourceUrisJsonList[resourceUrisIndex].AsObject(m_resourceUris[resourceUrisIndex].Jsonize());
156 }
157 payload.WithArray("ResourceUris", std::move(resourceUrisJsonList));
158
159 }
160
161 if(m_catalogIdHasBeenSet)
162 {
163 payload.WithString("CatalogId", m_catalogId);
164
165 }
166
167 return payload;
168 }
169
170 } // namespace Model
171 } // namespace Glue
172 } // namespace Aws
173