/src/open5gs/lib/sbi/openapi/model/dccf_event.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "dccf_event.h" |
6 | | |
7 | | OpenAPI_dccf_event_t *OpenAPI_dccf_event_create( |
8 | | OpenAPI_nwdaf_event_e nwdaf_event, |
9 | | OpenAPI_smf_event_e smf_event, |
10 | | OpenAPI_amf_event_type_e amf_event, |
11 | | OpenAPI_nef_event_e nef_event, |
12 | | OpenAPI_event_type_e udm_event, |
13 | | OpenAPI_af_event_e af_event, |
14 | | OpenAPI_sac_event_t *sac_event, |
15 | | OpenAPI_notification_event_type_e nrf_event, |
16 | | OpenAPI_event_notify_data_type_e gmlc_event, |
17 | | OpenAPI_event_type_1_e upf_event, |
18 | | OpenAPI_pc_event_e pcf_event |
19 | | ) |
20 | 0 | { |
21 | 0 | OpenAPI_dccf_event_t *dccf_event_local_var = ogs_malloc(sizeof(OpenAPI_dccf_event_t)); |
22 | 0 | ogs_assert(dccf_event_local_var); |
23 | | |
24 | 0 | dccf_event_local_var->nwdaf_event = nwdaf_event; |
25 | 0 | dccf_event_local_var->smf_event = smf_event; |
26 | 0 | dccf_event_local_var->amf_event = amf_event; |
27 | 0 | dccf_event_local_var->nef_event = nef_event; |
28 | 0 | dccf_event_local_var->udm_event = udm_event; |
29 | 0 | dccf_event_local_var->af_event = af_event; |
30 | 0 | dccf_event_local_var->sac_event = sac_event; |
31 | 0 | dccf_event_local_var->nrf_event = nrf_event; |
32 | 0 | dccf_event_local_var->gmlc_event = gmlc_event; |
33 | 0 | dccf_event_local_var->upf_event = upf_event; |
34 | 0 | dccf_event_local_var->pcf_event = pcf_event; |
35 | |
|
36 | 0 | return dccf_event_local_var; |
37 | 0 | } |
38 | | |
39 | | void OpenAPI_dccf_event_free(OpenAPI_dccf_event_t *dccf_event) |
40 | 0 | { |
41 | 0 | OpenAPI_lnode_t *node = NULL; |
42 | |
|
43 | 0 | if (NULL == dccf_event) { |
44 | 0 | return; |
45 | 0 | } |
46 | 0 | if (dccf_event->sac_event) { |
47 | 0 | OpenAPI_sac_event_free(dccf_event->sac_event); |
48 | 0 | dccf_event->sac_event = NULL; |
49 | 0 | } |
50 | 0 | ogs_free(dccf_event); |
51 | 0 | } |
52 | | |
53 | | cJSON *OpenAPI_dccf_event_convertToJSON(OpenAPI_dccf_event_t *dccf_event) |
54 | 0 | { |
55 | 0 | cJSON *item = NULL; |
56 | 0 | OpenAPI_lnode_t *node = NULL; |
57 | |
|
58 | 0 | if (dccf_event == NULL) { |
59 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [DccfEvent]"); |
60 | 0 | return NULL; |
61 | 0 | } |
62 | | |
63 | 0 | item = cJSON_CreateObject(); |
64 | 0 | if (dccf_event->nwdaf_event != OpenAPI_nwdaf_event_NULL) { |
65 | 0 | if (cJSON_AddStringToObject(item, "nwdafEvent", OpenAPI_nwdaf_event_ToString(dccf_event->nwdaf_event)) == NULL) { |
66 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [nwdaf_event]"); |
67 | 0 | goto end; |
68 | 0 | } |
69 | 0 | } |
70 | | |
71 | 0 | if (dccf_event->smf_event != OpenAPI_smf_event_NULL) { |
72 | 0 | if (cJSON_AddStringToObject(item, "smfEvent", OpenAPI_smf_event_ToString(dccf_event->smf_event)) == NULL) { |
73 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [smf_event]"); |
74 | 0 | goto end; |
75 | 0 | } |
76 | 0 | } |
77 | | |
78 | 0 | if (dccf_event->amf_event != OpenAPI_amf_event_type_NULL) { |
79 | 0 | if (cJSON_AddStringToObject(item, "amfEvent", OpenAPI_amf_event_type_ToString(dccf_event->amf_event)) == NULL) { |
80 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [amf_event]"); |
81 | 0 | goto end; |
82 | 0 | } |
83 | 0 | } |
84 | | |
85 | 0 | if (dccf_event->nef_event != OpenAPI_nef_event_NULL) { |
86 | 0 | if (cJSON_AddStringToObject(item, "nefEvent", OpenAPI_nef_event_ToString(dccf_event->nef_event)) == NULL) { |
87 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [nef_event]"); |
88 | 0 | goto end; |
89 | 0 | } |
90 | 0 | } |
91 | | |
92 | 0 | if (dccf_event->udm_event != OpenAPI_event_type_NULL) { |
93 | 0 | if (cJSON_AddStringToObject(item, "udmEvent", OpenAPI_event_type_ToString(dccf_event->udm_event)) == NULL) { |
94 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [udm_event]"); |
95 | 0 | goto end; |
96 | 0 | } |
97 | 0 | } |
98 | | |
99 | 0 | if (dccf_event->af_event != OpenAPI_af_event_NULL) { |
100 | 0 | if (cJSON_AddStringToObject(item, "afEvent", OpenAPI_af_event_ToString(dccf_event->af_event)) == NULL) { |
101 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [af_event]"); |
102 | 0 | goto end; |
103 | 0 | } |
104 | 0 | } |
105 | | |
106 | 0 | if (dccf_event->sac_event) { |
107 | 0 | cJSON *sac_event_local_JSON = OpenAPI_sac_event_convertToJSON(dccf_event->sac_event); |
108 | 0 | if (sac_event_local_JSON == NULL) { |
109 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [sac_event]"); |
110 | 0 | goto end; |
111 | 0 | } |
112 | 0 | cJSON_AddItemToObject(item, "sacEvent", sac_event_local_JSON); |
113 | 0 | if (item->child == NULL) { |
114 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [sac_event]"); |
115 | 0 | goto end; |
116 | 0 | } |
117 | 0 | } |
118 | | |
119 | 0 | if (dccf_event->nrf_event != OpenAPI_notification_event_type_NULL) { |
120 | 0 | if (cJSON_AddStringToObject(item, "nrfEvent", OpenAPI_notification_event_type_ToString(dccf_event->nrf_event)) == NULL) { |
121 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [nrf_event]"); |
122 | 0 | goto end; |
123 | 0 | } |
124 | 0 | } |
125 | | |
126 | 0 | if (dccf_event->gmlc_event != OpenAPI_event_notify_data_type_NULL) { |
127 | 0 | if (cJSON_AddStringToObject(item, "gmlcEvent", OpenAPI_event_notify_data_type_ToString(dccf_event->gmlc_event)) == NULL) { |
128 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [gmlc_event]"); |
129 | 0 | goto end; |
130 | 0 | } |
131 | 0 | } |
132 | | |
133 | 0 | if (dccf_event->upf_event != OpenAPI_event_type_1_NULL) { |
134 | 0 | if (cJSON_AddStringToObject(item, "upfEvent", OpenAPI_event_type_1_ToString(dccf_event->upf_event)) == NULL) { |
135 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [upf_event]"); |
136 | 0 | goto end; |
137 | 0 | } |
138 | 0 | } |
139 | | |
140 | 0 | if (dccf_event->pcf_event != OpenAPI_pc_event_NULL) { |
141 | 0 | if (cJSON_AddStringToObject(item, "pcfEvent", OpenAPI_pc_event_ToString(dccf_event->pcf_event)) == NULL) { |
142 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed [pcf_event]"); |
143 | 0 | goto end; |
144 | 0 | } |
145 | 0 | } |
146 | | |
147 | 0 | end: |
148 | 0 | return item; |
149 | 0 | } |
150 | | |
151 | | OpenAPI_dccf_event_t *OpenAPI_dccf_event_parseFromJSON(cJSON *dccf_eventJSON) |
152 | 0 | { |
153 | 0 | OpenAPI_dccf_event_t *dccf_event_local_var = NULL; |
154 | 0 | OpenAPI_lnode_t *node = NULL; |
155 | 0 | cJSON *nwdaf_event = NULL; |
156 | 0 | OpenAPI_nwdaf_event_e nwdaf_eventVariable = 0; |
157 | 0 | cJSON *smf_event = NULL; |
158 | 0 | OpenAPI_smf_event_e smf_eventVariable = 0; |
159 | 0 | cJSON *amf_event = NULL; |
160 | 0 | OpenAPI_amf_event_type_e amf_eventVariable = 0; |
161 | 0 | cJSON *nef_event = NULL; |
162 | 0 | OpenAPI_nef_event_e nef_eventVariable = 0; |
163 | 0 | cJSON *udm_event = NULL; |
164 | 0 | OpenAPI_event_type_e udm_eventVariable = 0; |
165 | 0 | cJSON *af_event = NULL; |
166 | 0 | OpenAPI_af_event_e af_eventVariable = 0; |
167 | 0 | cJSON *sac_event = NULL; |
168 | 0 | OpenAPI_sac_event_t *sac_event_local_nonprim = NULL; |
169 | 0 | cJSON *nrf_event = NULL; |
170 | 0 | OpenAPI_notification_event_type_e nrf_eventVariable = 0; |
171 | 0 | cJSON *gmlc_event = NULL; |
172 | 0 | OpenAPI_event_notify_data_type_e gmlc_eventVariable = 0; |
173 | 0 | cJSON *upf_event = NULL; |
174 | 0 | OpenAPI_event_type_1_e upf_eventVariable = 0; |
175 | 0 | cJSON *pcf_event = NULL; |
176 | 0 | OpenAPI_pc_event_e pcf_eventVariable = 0; |
177 | 0 | nwdaf_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "nwdafEvent"); |
178 | 0 | if (nwdaf_event) { |
179 | 0 | if (!cJSON_IsString(nwdaf_event)) { |
180 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [nwdaf_event]"); |
181 | 0 | goto end; |
182 | 0 | } |
183 | 0 | nwdaf_eventVariable = OpenAPI_nwdaf_event_FromString(nwdaf_event->valuestring); |
184 | 0 | } |
185 | | |
186 | 0 | smf_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "smfEvent"); |
187 | 0 | if (smf_event) { |
188 | 0 | if (!cJSON_IsString(smf_event)) { |
189 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [smf_event]"); |
190 | 0 | goto end; |
191 | 0 | } |
192 | 0 | smf_eventVariable = OpenAPI_smf_event_FromString(smf_event->valuestring); |
193 | 0 | } |
194 | | |
195 | 0 | amf_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "amfEvent"); |
196 | 0 | if (amf_event) { |
197 | 0 | if (!cJSON_IsString(amf_event)) { |
198 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [amf_event]"); |
199 | 0 | goto end; |
200 | 0 | } |
201 | 0 | amf_eventVariable = OpenAPI_amf_event_type_FromString(amf_event->valuestring); |
202 | 0 | } |
203 | | |
204 | 0 | nef_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "nefEvent"); |
205 | 0 | if (nef_event) { |
206 | 0 | if (!cJSON_IsString(nef_event)) { |
207 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [nef_event]"); |
208 | 0 | goto end; |
209 | 0 | } |
210 | 0 | nef_eventVariable = OpenAPI_nef_event_FromString(nef_event->valuestring); |
211 | 0 | } |
212 | | |
213 | 0 | udm_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "udmEvent"); |
214 | 0 | if (udm_event) { |
215 | 0 | if (!cJSON_IsString(udm_event)) { |
216 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [udm_event]"); |
217 | 0 | goto end; |
218 | 0 | } |
219 | 0 | udm_eventVariable = OpenAPI_event_type_FromString(udm_event->valuestring); |
220 | 0 | } |
221 | | |
222 | 0 | af_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "afEvent"); |
223 | 0 | if (af_event) { |
224 | 0 | if (!cJSON_IsString(af_event)) { |
225 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [af_event]"); |
226 | 0 | goto end; |
227 | 0 | } |
228 | 0 | af_eventVariable = OpenAPI_af_event_FromString(af_event->valuestring); |
229 | 0 | } |
230 | | |
231 | 0 | sac_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "sacEvent"); |
232 | 0 | if (sac_event) { |
233 | 0 | sac_event_local_nonprim = OpenAPI_sac_event_parseFromJSON(sac_event); |
234 | 0 | if (!sac_event_local_nonprim) { |
235 | 0 | ogs_error("OpenAPI_sac_event_parseFromJSON failed [sac_event]"); |
236 | 0 | goto end; |
237 | 0 | } |
238 | 0 | } |
239 | | |
240 | 0 | nrf_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "nrfEvent"); |
241 | 0 | if (nrf_event) { |
242 | 0 | if (!cJSON_IsString(nrf_event)) { |
243 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [nrf_event]"); |
244 | 0 | goto end; |
245 | 0 | } |
246 | 0 | nrf_eventVariable = OpenAPI_notification_event_type_FromString(nrf_event->valuestring); |
247 | 0 | } |
248 | | |
249 | 0 | gmlc_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "gmlcEvent"); |
250 | 0 | if (gmlc_event) { |
251 | 0 | if (!cJSON_IsString(gmlc_event)) { |
252 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [gmlc_event]"); |
253 | 0 | goto end; |
254 | 0 | } |
255 | 0 | gmlc_eventVariable = OpenAPI_event_notify_data_type_FromString(gmlc_event->valuestring); |
256 | 0 | } |
257 | | |
258 | 0 | upf_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "upfEvent"); |
259 | 0 | if (upf_event) { |
260 | 0 | if (!cJSON_IsString(upf_event)) { |
261 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [upf_event]"); |
262 | 0 | goto end; |
263 | 0 | } |
264 | 0 | upf_eventVariable = OpenAPI_event_type_1_FromString(upf_event->valuestring); |
265 | 0 | } |
266 | | |
267 | 0 | pcf_event = cJSON_GetObjectItemCaseSensitive(dccf_eventJSON, "pcfEvent"); |
268 | 0 | if (pcf_event) { |
269 | 0 | if (!cJSON_IsString(pcf_event)) { |
270 | 0 | ogs_error("OpenAPI_dccf_event_parseFromJSON() failed [pcf_event]"); |
271 | 0 | goto end; |
272 | 0 | } |
273 | 0 | pcf_eventVariable = OpenAPI_pc_event_FromString(pcf_event->valuestring); |
274 | 0 | } |
275 | | |
276 | 0 | dccf_event_local_var = OpenAPI_dccf_event_create ( |
277 | 0 | nwdaf_event ? nwdaf_eventVariable : 0, |
278 | 0 | smf_event ? smf_eventVariable : 0, |
279 | 0 | amf_event ? amf_eventVariable : 0, |
280 | 0 | nef_event ? nef_eventVariable : 0, |
281 | 0 | udm_event ? udm_eventVariable : 0, |
282 | 0 | af_event ? af_eventVariable : 0, |
283 | 0 | sac_event ? sac_event_local_nonprim : NULL, |
284 | 0 | nrf_event ? nrf_eventVariable : 0, |
285 | 0 | gmlc_event ? gmlc_eventVariable : 0, |
286 | 0 | upf_event ? upf_eventVariable : 0, |
287 | 0 | pcf_event ? pcf_eventVariable : 0 |
288 | 0 | ); |
289 | |
|
290 | 0 | return dccf_event_local_var; |
291 | 0 | end: |
292 | 0 | if (sac_event_local_nonprim) { |
293 | 0 | OpenAPI_sac_event_free(sac_event_local_nonprim); |
294 | 0 | sac_event_local_nonprim = NULL; |
295 | 0 | } |
296 | 0 | return NULL; |
297 | 0 | } |
298 | | |
299 | | OpenAPI_dccf_event_t *OpenAPI_dccf_event_copy(OpenAPI_dccf_event_t *dst, OpenAPI_dccf_event_t *src) |
300 | 0 | { |
301 | 0 | cJSON *item = NULL; |
302 | 0 | char *content = NULL; |
303 | |
|
304 | 0 | ogs_assert(src); |
305 | 0 | item = OpenAPI_dccf_event_convertToJSON(src); |
306 | 0 | if (!item) { |
307 | 0 | ogs_error("OpenAPI_dccf_event_convertToJSON() failed"); |
308 | 0 | return NULL; |
309 | 0 | } |
310 | | |
311 | 0 | content = cJSON_Print(item); |
312 | 0 | cJSON_Delete(item); |
313 | |
|
314 | 0 | if (!content) { |
315 | 0 | ogs_error("cJSON_Print() failed"); |
316 | 0 | return NULL; |
317 | 0 | } |
318 | | |
319 | 0 | item = cJSON_Parse(content); |
320 | 0 | ogs_free(content); |
321 | 0 | if (!item) { |
322 | 0 | ogs_error("cJSON_Parse() failed"); |
323 | 0 | return NULL; |
324 | 0 | } |
325 | | |
326 | 0 | OpenAPI_dccf_event_free(dst); |
327 | 0 | dst = OpenAPI_dccf_event_parseFromJSON(item); |
328 | 0 | cJSON_Delete(item); |
329 | |
|
330 | 0 | return dst; |
331 | 0 | } |
332 | | |