res/res_ari: Added ARI resource /ari/channels/{channelId}/rtp_statistics
[asterisk/asterisk.git] / res / ari / ari_model_validators.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2013, Digium, Inc.
5  *
6  * See http://www.asterisk.org for more information about
7  * the Asterisk project. Please do not directly contact
8  * any of the maintainers of this project for assistance;
9  * the project provides a web site, mailing lists and IRC
10  * channels for your use.
11  *
12  * This program is free software, distributed under the terms of
13  * the GNU General Public License Version 2. See the LICENSE file
14  * at the top of the source tree.
15  */
16
17 /*! \file
18  *
19  * \brief Generated file - Build validators for ARI model objects.
20  */
21
22  /*
23  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24  * !!!!!                               DO NOT EDIT                        !!!!!
25  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26  * This file is generated by a mustache template. Please see the original
27  * template in rest-api-templates/ari_model_validators.c.mustache
28  */
29
30 #include "asterisk.h"
31
32 #include "asterisk/logger.h"
33 #include "asterisk/module.h"
34 #include "ari_model_validators.h"
35
36 int ast_ari_validate_asterisk_info(struct ast_json *json)
37 {
38         int res = 1;
39         struct ast_json_iter *iter;
40
41         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
42                 if (strcmp("build", ast_json_object_iter_key(iter)) == 0) {
43                         int prop_is_valid;
44                         prop_is_valid = ast_ari_validate_build_info(
45                                 ast_json_object_iter_value(iter));
46                         if (!prop_is_valid) {
47                                 ast_log(LOG_ERROR, "ARI AsteriskInfo field build failed validation\n");
48                                 res = 0;
49                         }
50                 } else
51                 if (strcmp("config", ast_json_object_iter_key(iter)) == 0) {
52                         int prop_is_valid;
53                         prop_is_valid = ast_ari_validate_config_info(
54                                 ast_json_object_iter_value(iter));
55                         if (!prop_is_valid) {
56                                 ast_log(LOG_ERROR, "ARI AsteriskInfo field config failed validation\n");
57                                 res = 0;
58                         }
59                 } else
60                 if (strcmp("status", ast_json_object_iter_key(iter)) == 0) {
61                         int prop_is_valid;
62                         prop_is_valid = ast_ari_validate_status_info(
63                                 ast_json_object_iter_value(iter));
64                         if (!prop_is_valid) {
65                                 ast_log(LOG_ERROR, "ARI AsteriskInfo field status failed validation\n");
66                                 res = 0;
67                         }
68                 } else
69                 if (strcmp("system", ast_json_object_iter_key(iter)) == 0) {
70                         int prop_is_valid;
71                         prop_is_valid = ast_ari_validate_system_info(
72                                 ast_json_object_iter_value(iter));
73                         if (!prop_is_valid) {
74                                 ast_log(LOG_ERROR, "ARI AsteriskInfo field system failed validation\n");
75                                 res = 0;
76                         }
77                 } else
78                 {
79                         ast_log(LOG_ERROR,
80                                 "ARI AsteriskInfo has undocumented field %s\n",
81                                 ast_json_object_iter_key(iter));
82                         res = 0;
83                 }
84         }
85
86         return res;
87 }
88
89 ari_validator ast_ari_validate_asterisk_info_fn(void)
90 {
91         return ast_ari_validate_asterisk_info;
92 }
93
94 int ast_ari_validate_asterisk_ping(struct ast_json *json)
95 {
96         int res = 1;
97         struct ast_json_iter *iter;
98         int has_asterisk_id = 0;
99         int has_ping = 0;
100         int has_timestamp = 0;
101
102         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
103                 if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
104                         int prop_is_valid;
105                         has_asterisk_id = 1;
106                         prop_is_valid = ast_ari_validate_string(
107                                 ast_json_object_iter_value(iter));
108                         if (!prop_is_valid) {
109                                 ast_log(LOG_ERROR, "ARI AsteriskPing field asterisk_id failed validation\n");
110                                 res = 0;
111                         }
112                 } else
113                 if (strcmp("ping", ast_json_object_iter_key(iter)) == 0) {
114                         int prop_is_valid;
115                         has_ping = 1;
116                         prop_is_valid = ast_ari_validate_string(
117                                 ast_json_object_iter_value(iter));
118                         if (!prop_is_valid) {
119                                 ast_log(LOG_ERROR, "ARI AsteriskPing field ping failed validation\n");
120                                 res = 0;
121                         }
122                 } else
123                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
124                         int prop_is_valid;
125                         has_timestamp = 1;
126                         prop_is_valid = ast_ari_validate_string(
127                                 ast_json_object_iter_value(iter));
128                         if (!prop_is_valid) {
129                                 ast_log(LOG_ERROR, "ARI AsteriskPing field timestamp failed validation\n");
130                                 res = 0;
131                         }
132                 } else
133                 {
134                         ast_log(LOG_ERROR,
135                                 "ARI AsteriskPing has undocumented field %s\n",
136                                 ast_json_object_iter_key(iter));
137                         res = 0;
138                 }
139         }
140
141         if (!has_asterisk_id) {
142                 ast_log(LOG_ERROR, "ARI AsteriskPing missing required field asterisk_id\n");
143                 res = 0;
144         }
145
146         if (!has_ping) {
147                 ast_log(LOG_ERROR, "ARI AsteriskPing missing required field ping\n");
148                 res = 0;
149         }
150
151         if (!has_timestamp) {
152                 ast_log(LOG_ERROR, "ARI AsteriskPing missing required field timestamp\n");
153                 res = 0;
154         }
155
156         return res;
157 }
158
159 ari_validator ast_ari_validate_asterisk_ping_fn(void)
160 {
161         return ast_ari_validate_asterisk_ping;
162 }
163
164 int ast_ari_validate_build_info(struct ast_json *json)
165 {
166         int res = 1;
167         struct ast_json_iter *iter;
168         int has_date = 0;
169         int has_kernel = 0;
170         int has_machine = 0;
171         int has_options = 0;
172         int has_os = 0;
173         int has_user = 0;
174
175         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
176                 if (strcmp("date", ast_json_object_iter_key(iter)) == 0) {
177                         int prop_is_valid;
178                         has_date = 1;
179                         prop_is_valid = ast_ari_validate_string(
180                                 ast_json_object_iter_value(iter));
181                         if (!prop_is_valid) {
182                                 ast_log(LOG_ERROR, "ARI BuildInfo field date failed validation\n");
183                                 res = 0;
184                         }
185                 } else
186                 if (strcmp("kernel", ast_json_object_iter_key(iter)) == 0) {
187                         int prop_is_valid;
188                         has_kernel = 1;
189                         prop_is_valid = ast_ari_validate_string(
190                                 ast_json_object_iter_value(iter));
191                         if (!prop_is_valid) {
192                                 ast_log(LOG_ERROR, "ARI BuildInfo field kernel failed validation\n");
193                                 res = 0;
194                         }
195                 } else
196                 if (strcmp("machine", ast_json_object_iter_key(iter)) == 0) {
197                         int prop_is_valid;
198                         has_machine = 1;
199                         prop_is_valid = ast_ari_validate_string(
200                                 ast_json_object_iter_value(iter));
201                         if (!prop_is_valid) {
202                                 ast_log(LOG_ERROR, "ARI BuildInfo field machine failed validation\n");
203                                 res = 0;
204                         }
205                 } else
206                 if (strcmp("options", ast_json_object_iter_key(iter)) == 0) {
207                         int prop_is_valid;
208                         has_options = 1;
209                         prop_is_valid = ast_ari_validate_string(
210                                 ast_json_object_iter_value(iter));
211                         if (!prop_is_valid) {
212                                 ast_log(LOG_ERROR, "ARI BuildInfo field options failed validation\n");
213                                 res = 0;
214                         }
215                 } else
216                 if (strcmp("os", ast_json_object_iter_key(iter)) == 0) {
217                         int prop_is_valid;
218                         has_os = 1;
219                         prop_is_valid = ast_ari_validate_string(
220                                 ast_json_object_iter_value(iter));
221                         if (!prop_is_valid) {
222                                 ast_log(LOG_ERROR, "ARI BuildInfo field os failed validation\n");
223                                 res = 0;
224                         }
225                 } else
226                 if (strcmp("user", ast_json_object_iter_key(iter)) == 0) {
227                         int prop_is_valid;
228                         has_user = 1;
229                         prop_is_valid = ast_ari_validate_string(
230                                 ast_json_object_iter_value(iter));
231                         if (!prop_is_valid) {
232                                 ast_log(LOG_ERROR, "ARI BuildInfo field user failed validation\n");
233                                 res = 0;
234                         }
235                 } else
236                 {
237                         ast_log(LOG_ERROR,
238                                 "ARI BuildInfo has undocumented field %s\n",
239                                 ast_json_object_iter_key(iter));
240                         res = 0;
241                 }
242         }
243
244         if (!has_date) {
245                 ast_log(LOG_ERROR, "ARI BuildInfo missing required field date\n");
246                 res = 0;
247         }
248
249         if (!has_kernel) {
250                 ast_log(LOG_ERROR, "ARI BuildInfo missing required field kernel\n");
251                 res = 0;
252         }
253
254         if (!has_machine) {
255                 ast_log(LOG_ERROR, "ARI BuildInfo missing required field machine\n");
256                 res = 0;
257         }
258
259         if (!has_options) {
260                 ast_log(LOG_ERROR, "ARI BuildInfo missing required field options\n");
261                 res = 0;
262         }
263
264         if (!has_os) {
265                 ast_log(LOG_ERROR, "ARI BuildInfo missing required field os\n");
266                 res = 0;
267         }
268
269         if (!has_user) {
270                 ast_log(LOG_ERROR, "ARI BuildInfo missing required field user\n");
271                 res = 0;
272         }
273
274         return res;
275 }
276
277 ari_validator ast_ari_validate_build_info_fn(void)
278 {
279         return ast_ari_validate_build_info;
280 }
281
282 int ast_ari_validate_config_info(struct ast_json *json)
283 {
284         int res = 1;
285         struct ast_json_iter *iter;
286         int has_default_language = 0;
287         int has_name = 0;
288         int has_setid = 0;
289
290         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
291                 if (strcmp("default_language", ast_json_object_iter_key(iter)) == 0) {
292                         int prop_is_valid;
293                         has_default_language = 1;
294                         prop_is_valid = ast_ari_validate_string(
295                                 ast_json_object_iter_value(iter));
296                         if (!prop_is_valid) {
297                                 ast_log(LOG_ERROR, "ARI ConfigInfo field default_language failed validation\n");
298                                 res = 0;
299                         }
300                 } else
301                 if (strcmp("max_channels", ast_json_object_iter_key(iter)) == 0) {
302                         int prop_is_valid;
303                         prop_is_valid = ast_ari_validate_int(
304                                 ast_json_object_iter_value(iter));
305                         if (!prop_is_valid) {
306                                 ast_log(LOG_ERROR, "ARI ConfigInfo field max_channels failed validation\n");
307                                 res = 0;
308                         }
309                 } else
310                 if (strcmp("max_load", ast_json_object_iter_key(iter)) == 0) {
311                         int prop_is_valid;
312                         prop_is_valid = ast_ari_validate_double(
313                                 ast_json_object_iter_value(iter));
314                         if (!prop_is_valid) {
315                                 ast_log(LOG_ERROR, "ARI ConfigInfo field max_load failed validation\n");
316                                 res = 0;
317                         }
318                 } else
319                 if (strcmp("max_open_files", ast_json_object_iter_key(iter)) == 0) {
320                         int prop_is_valid;
321                         prop_is_valid = ast_ari_validate_int(
322                                 ast_json_object_iter_value(iter));
323                         if (!prop_is_valid) {
324                                 ast_log(LOG_ERROR, "ARI ConfigInfo field max_open_files failed validation\n");
325                                 res = 0;
326                         }
327                 } else
328                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
329                         int prop_is_valid;
330                         has_name = 1;
331                         prop_is_valid = ast_ari_validate_string(
332                                 ast_json_object_iter_value(iter));
333                         if (!prop_is_valid) {
334                                 ast_log(LOG_ERROR, "ARI ConfigInfo field name failed validation\n");
335                                 res = 0;
336                         }
337                 } else
338                 if (strcmp("setid", ast_json_object_iter_key(iter)) == 0) {
339                         int prop_is_valid;
340                         has_setid = 1;
341                         prop_is_valid = ast_ari_validate_set_id(
342                                 ast_json_object_iter_value(iter));
343                         if (!prop_is_valid) {
344                                 ast_log(LOG_ERROR, "ARI ConfigInfo field setid failed validation\n");
345                                 res = 0;
346                         }
347                 } else
348                 {
349                         ast_log(LOG_ERROR,
350                                 "ARI ConfigInfo has undocumented field %s\n",
351                                 ast_json_object_iter_key(iter));
352                         res = 0;
353                 }
354         }
355
356         if (!has_default_language) {
357                 ast_log(LOG_ERROR, "ARI ConfigInfo missing required field default_language\n");
358                 res = 0;
359         }
360
361         if (!has_name) {
362                 ast_log(LOG_ERROR, "ARI ConfigInfo missing required field name\n");
363                 res = 0;
364         }
365
366         if (!has_setid) {
367                 ast_log(LOG_ERROR, "ARI ConfigInfo missing required field setid\n");
368                 res = 0;
369         }
370
371         return res;
372 }
373
374 ari_validator ast_ari_validate_config_info_fn(void)
375 {
376         return ast_ari_validate_config_info;
377 }
378
379 int ast_ari_validate_config_tuple(struct ast_json *json)
380 {
381         int res = 1;
382         struct ast_json_iter *iter;
383         int has_attribute = 0;
384         int has_value = 0;
385
386         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
387                 if (strcmp("attribute", ast_json_object_iter_key(iter)) == 0) {
388                         int prop_is_valid;
389                         has_attribute = 1;
390                         prop_is_valid = ast_ari_validate_string(
391                                 ast_json_object_iter_value(iter));
392                         if (!prop_is_valid) {
393                                 ast_log(LOG_ERROR, "ARI ConfigTuple field attribute failed validation\n");
394                                 res = 0;
395                         }
396                 } else
397                 if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
398                         int prop_is_valid;
399                         has_value = 1;
400                         prop_is_valid = ast_ari_validate_string(
401                                 ast_json_object_iter_value(iter));
402                         if (!prop_is_valid) {
403                                 ast_log(LOG_ERROR, "ARI ConfigTuple field value failed validation\n");
404                                 res = 0;
405                         }
406                 } else
407                 {
408                         ast_log(LOG_ERROR,
409                                 "ARI ConfigTuple has undocumented field %s\n",
410                                 ast_json_object_iter_key(iter));
411                         res = 0;
412                 }
413         }
414
415         if (!has_attribute) {
416                 ast_log(LOG_ERROR, "ARI ConfigTuple missing required field attribute\n");
417                 res = 0;
418         }
419
420         if (!has_value) {
421                 ast_log(LOG_ERROR, "ARI ConfigTuple missing required field value\n");
422                 res = 0;
423         }
424
425         return res;
426 }
427
428 ari_validator ast_ari_validate_config_tuple_fn(void)
429 {
430         return ast_ari_validate_config_tuple;
431 }
432
433 int ast_ari_validate_log_channel(struct ast_json *json)
434 {
435         int res = 1;
436         struct ast_json_iter *iter;
437         int has_channel = 0;
438         int has_configuration = 0;
439         int has_status = 0;
440         int has_type = 0;
441
442         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
443                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
444                         int prop_is_valid;
445                         has_channel = 1;
446                         prop_is_valid = ast_ari_validate_string(
447                                 ast_json_object_iter_value(iter));
448                         if (!prop_is_valid) {
449                                 ast_log(LOG_ERROR, "ARI LogChannel field channel failed validation\n");
450                                 res = 0;
451                         }
452                 } else
453                 if (strcmp("configuration", ast_json_object_iter_key(iter)) == 0) {
454                         int prop_is_valid;
455                         has_configuration = 1;
456                         prop_is_valid = ast_ari_validate_string(
457                                 ast_json_object_iter_value(iter));
458                         if (!prop_is_valid) {
459                                 ast_log(LOG_ERROR, "ARI LogChannel field configuration failed validation\n");
460                                 res = 0;
461                         }
462                 } else
463                 if (strcmp("status", ast_json_object_iter_key(iter)) == 0) {
464                         int prop_is_valid;
465                         has_status = 1;
466                         prop_is_valid = ast_ari_validate_string(
467                                 ast_json_object_iter_value(iter));
468                         if (!prop_is_valid) {
469                                 ast_log(LOG_ERROR, "ARI LogChannel field status failed validation\n");
470                                 res = 0;
471                         }
472                 } else
473                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
474                         int prop_is_valid;
475                         has_type = 1;
476                         prop_is_valid = ast_ari_validate_string(
477                                 ast_json_object_iter_value(iter));
478                         if (!prop_is_valid) {
479                                 ast_log(LOG_ERROR, "ARI LogChannel field type failed validation\n");
480                                 res = 0;
481                         }
482                 } else
483                 {
484                         ast_log(LOG_ERROR,
485                                 "ARI LogChannel has undocumented field %s\n",
486                                 ast_json_object_iter_key(iter));
487                         res = 0;
488                 }
489         }
490
491         if (!has_channel) {
492                 ast_log(LOG_ERROR, "ARI LogChannel missing required field channel\n");
493                 res = 0;
494         }
495
496         if (!has_configuration) {
497                 ast_log(LOG_ERROR, "ARI LogChannel missing required field configuration\n");
498                 res = 0;
499         }
500
501         if (!has_status) {
502                 ast_log(LOG_ERROR, "ARI LogChannel missing required field status\n");
503                 res = 0;
504         }
505
506         if (!has_type) {
507                 ast_log(LOG_ERROR, "ARI LogChannel missing required field type\n");
508                 res = 0;
509         }
510
511         return res;
512 }
513
514 ari_validator ast_ari_validate_log_channel_fn(void)
515 {
516         return ast_ari_validate_log_channel;
517 }
518
519 int ast_ari_validate_module(struct ast_json *json)
520 {
521         int res = 1;
522         struct ast_json_iter *iter;
523         int has_description = 0;
524         int has_name = 0;
525         int has_status = 0;
526         int has_support_level = 0;
527         int has_use_count = 0;
528
529         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
530                 if (strcmp("description", ast_json_object_iter_key(iter)) == 0) {
531                         int prop_is_valid;
532                         has_description = 1;
533                         prop_is_valid = ast_ari_validate_string(
534                                 ast_json_object_iter_value(iter));
535                         if (!prop_is_valid) {
536                                 ast_log(LOG_ERROR, "ARI Module field description failed validation\n");
537                                 res = 0;
538                         }
539                 } else
540                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
541                         int prop_is_valid;
542                         has_name = 1;
543                         prop_is_valid = ast_ari_validate_string(
544                                 ast_json_object_iter_value(iter));
545                         if (!prop_is_valid) {
546                                 ast_log(LOG_ERROR, "ARI Module field name failed validation\n");
547                                 res = 0;
548                         }
549                 } else
550                 if (strcmp("status", ast_json_object_iter_key(iter)) == 0) {
551                         int prop_is_valid;
552                         has_status = 1;
553                         prop_is_valid = ast_ari_validate_string(
554                                 ast_json_object_iter_value(iter));
555                         if (!prop_is_valid) {
556                                 ast_log(LOG_ERROR, "ARI Module field status failed validation\n");
557                                 res = 0;
558                         }
559                 } else
560                 if (strcmp("support_level", ast_json_object_iter_key(iter)) == 0) {
561                         int prop_is_valid;
562                         has_support_level = 1;
563                         prop_is_valid = ast_ari_validate_string(
564                                 ast_json_object_iter_value(iter));
565                         if (!prop_is_valid) {
566                                 ast_log(LOG_ERROR, "ARI Module field support_level failed validation\n");
567                                 res = 0;
568                         }
569                 } else
570                 if (strcmp("use_count", ast_json_object_iter_key(iter)) == 0) {
571                         int prop_is_valid;
572                         has_use_count = 1;
573                         prop_is_valid = ast_ari_validate_int(
574                                 ast_json_object_iter_value(iter));
575                         if (!prop_is_valid) {
576                                 ast_log(LOG_ERROR, "ARI Module field use_count failed validation\n");
577                                 res = 0;
578                         }
579                 } else
580                 {
581                         ast_log(LOG_ERROR,
582                                 "ARI Module has undocumented field %s\n",
583                                 ast_json_object_iter_key(iter));
584                         res = 0;
585                 }
586         }
587
588         if (!has_description) {
589                 ast_log(LOG_ERROR, "ARI Module missing required field description\n");
590                 res = 0;
591         }
592
593         if (!has_name) {
594                 ast_log(LOG_ERROR, "ARI Module missing required field name\n");
595                 res = 0;
596         }
597
598         if (!has_status) {
599                 ast_log(LOG_ERROR, "ARI Module missing required field status\n");
600                 res = 0;
601         }
602
603         if (!has_support_level) {
604                 ast_log(LOG_ERROR, "ARI Module missing required field support_level\n");
605                 res = 0;
606         }
607
608         if (!has_use_count) {
609                 ast_log(LOG_ERROR, "ARI Module missing required field use_count\n");
610                 res = 0;
611         }
612
613         return res;
614 }
615
616 ari_validator ast_ari_validate_module_fn(void)
617 {
618         return ast_ari_validate_module;
619 }
620
621 int ast_ari_validate_set_id(struct ast_json *json)
622 {
623         int res = 1;
624         struct ast_json_iter *iter;
625         int has_group = 0;
626         int has_user = 0;
627
628         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
629                 if (strcmp("group", ast_json_object_iter_key(iter)) == 0) {
630                         int prop_is_valid;
631                         has_group = 1;
632                         prop_is_valid = ast_ari_validate_string(
633                                 ast_json_object_iter_value(iter));
634                         if (!prop_is_valid) {
635                                 ast_log(LOG_ERROR, "ARI SetId field group failed validation\n");
636                                 res = 0;
637                         }
638                 } else
639                 if (strcmp("user", ast_json_object_iter_key(iter)) == 0) {
640                         int prop_is_valid;
641                         has_user = 1;
642                         prop_is_valid = ast_ari_validate_string(
643                                 ast_json_object_iter_value(iter));
644                         if (!prop_is_valid) {
645                                 ast_log(LOG_ERROR, "ARI SetId field user failed validation\n");
646                                 res = 0;
647                         }
648                 } else
649                 {
650                         ast_log(LOG_ERROR,
651                                 "ARI SetId has undocumented field %s\n",
652                                 ast_json_object_iter_key(iter));
653                         res = 0;
654                 }
655         }
656
657         if (!has_group) {
658                 ast_log(LOG_ERROR, "ARI SetId missing required field group\n");
659                 res = 0;
660         }
661
662         if (!has_user) {
663                 ast_log(LOG_ERROR, "ARI SetId missing required field user\n");
664                 res = 0;
665         }
666
667         return res;
668 }
669
670 ari_validator ast_ari_validate_set_id_fn(void)
671 {
672         return ast_ari_validate_set_id;
673 }
674
675 int ast_ari_validate_status_info(struct ast_json *json)
676 {
677         int res = 1;
678         struct ast_json_iter *iter;
679         int has_last_reload_time = 0;
680         int has_startup_time = 0;
681
682         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
683                 if (strcmp("last_reload_time", ast_json_object_iter_key(iter)) == 0) {
684                         int prop_is_valid;
685                         has_last_reload_time = 1;
686                         prop_is_valid = ast_ari_validate_date(
687                                 ast_json_object_iter_value(iter));
688                         if (!prop_is_valid) {
689                                 ast_log(LOG_ERROR, "ARI StatusInfo field last_reload_time failed validation\n");
690                                 res = 0;
691                         }
692                 } else
693                 if (strcmp("startup_time", ast_json_object_iter_key(iter)) == 0) {
694                         int prop_is_valid;
695                         has_startup_time = 1;
696                         prop_is_valid = ast_ari_validate_date(
697                                 ast_json_object_iter_value(iter));
698                         if (!prop_is_valid) {
699                                 ast_log(LOG_ERROR, "ARI StatusInfo field startup_time failed validation\n");
700                                 res = 0;
701                         }
702                 } else
703                 {
704                         ast_log(LOG_ERROR,
705                                 "ARI StatusInfo has undocumented field %s\n",
706                                 ast_json_object_iter_key(iter));
707                         res = 0;
708                 }
709         }
710
711         if (!has_last_reload_time) {
712                 ast_log(LOG_ERROR, "ARI StatusInfo missing required field last_reload_time\n");
713                 res = 0;
714         }
715
716         if (!has_startup_time) {
717                 ast_log(LOG_ERROR, "ARI StatusInfo missing required field startup_time\n");
718                 res = 0;
719         }
720
721         return res;
722 }
723
724 ari_validator ast_ari_validate_status_info_fn(void)
725 {
726         return ast_ari_validate_status_info;
727 }
728
729 int ast_ari_validate_system_info(struct ast_json *json)
730 {
731         int res = 1;
732         struct ast_json_iter *iter;
733         int has_entity_id = 0;
734         int has_version = 0;
735
736         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
737                 if (strcmp("entity_id", ast_json_object_iter_key(iter)) == 0) {
738                         int prop_is_valid;
739                         has_entity_id = 1;
740                         prop_is_valid = ast_ari_validate_string(
741                                 ast_json_object_iter_value(iter));
742                         if (!prop_is_valid) {
743                                 ast_log(LOG_ERROR, "ARI SystemInfo field entity_id failed validation\n");
744                                 res = 0;
745                         }
746                 } else
747                 if (strcmp("version", ast_json_object_iter_key(iter)) == 0) {
748                         int prop_is_valid;
749                         has_version = 1;
750                         prop_is_valid = ast_ari_validate_string(
751                                 ast_json_object_iter_value(iter));
752                         if (!prop_is_valid) {
753                                 ast_log(LOG_ERROR, "ARI SystemInfo field version failed validation\n");
754                                 res = 0;
755                         }
756                 } else
757                 {
758                         ast_log(LOG_ERROR,
759                                 "ARI SystemInfo has undocumented field %s\n",
760                                 ast_json_object_iter_key(iter));
761                         res = 0;
762                 }
763         }
764
765         if (!has_entity_id) {
766                 ast_log(LOG_ERROR, "ARI SystemInfo missing required field entity_id\n");
767                 res = 0;
768         }
769
770         if (!has_version) {
771                 ast_log(LOG_ERROR, "ARI SystemInfo missing required field version\n");
772                 res = 0;
773         }
774
775         return res;
776 }
777
778 ari_validator ast_ari_validate_system_info_fn(void)
779 {
780         return ast_ari_validate_system_info;
781 }
782
783 int ast_ari_validate_variable(struct ast_json *json)
784 {
785         int res = 1;
786         struct ast_json_iter *iter;
787         int has_value = 0;
788
789         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
790                 if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
791                         int prop_is_valid;
792                         has_value = 1;
793                         prop_is_valid = ast_ari_validate_string(
794                                 ast_json_object_iter_value(iter));
795                         if (!prop_is_valid) {
796                                 ast_log(LOG_ERROR, "ARI Variable field value failed validation\n");
797                                 res = 0;
798                         }
799                 } else
800                 {
801                         ast_log(LOG_ERROR,
802                                 "ARI Variable has undocumented field %s\n",
803                                 ast_json_object_iter_key(iter));
804                         res = 0;
805                 }
806         }
807
808         if (!has_value) {
809                 ast_log(LOG_ERROR, "ARI Variable missing required field value\n");
810                 res = 0;
811         }
812
813         return res;
814 }
815
816 ari_validator ast_ari_validate_variable_fn(void)
817 {
818         return ast_ari_validate_variable;
819 }
820
821 int ast_ari_validate_endpoint(struct ast_json *json)
822 {
823         int res = 1;
824         struct ast_json_iter *iter;
825         int has_channel_ids = 0;
826         int has_resource = 0;
827         int has_technology = 0;
828
829         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
830                 if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
831                         int prop_is_valid;
832                         has_channel_ids = 1;
833                         prop_is_valid = ast_ari_validate_list(
834                                 ast_json_object_iter_value(iter),
835                                 ast_ari_validate_string);
836                         if (!prop_is_valid) {
837                                 ast_log(LOG_ERROR, "ARI Endpoint field channel_ids failed validation\n");
838                                 res = 0;
839                         }
840                 } else
841                 if (strcmp("resource", ast_json_object_iter_key(iter)) == 0) {
842                         int prop_is_valid;
843                         has_resource = 1;
844                         prop_is_valid = ast_ari_validate_string(
845                                 ast_json_object_iter_value(iter));
846                         if (!prop_is_valid) {
847                                 ast_log(LOG_ERROR, "ARI Endpoint field resource failed validation\n");
848                                 res = 0;
849                         }
850                 } else
851                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
852                         int prop_is_valid;
853                         prop_is_valid = ast_ari_validate_string(
854                                 ast_json_object_iter_value(iter));
855                         if (!prop_is_valid) {
856                                 ast_log(LOG_ERROR, "ARI Endpoint field state failed validation\n");
857                                 res = 0;
858                         }
859                 } else
860                 if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
861                         int prop_is_valid;
862                         has_technology = 1;
863                         prop_is_valid = ast_ari_validate_string(
864                                 ast_json_object_iter_value(iter));
865                         if (!prop_is_valid) {
866                                 ast_log(LOG_ERROR, "ARI Endpoint field technology failed validation\n");
867                                 res = 0;
868                         }
869                 } else
870                 {
871                         ast_log(LOG_ERROR,
872                                 "ARI Endpoint has undocumented field %s\n",
873                                 ast_json_object_iter_key(iter));
874                         res = 0;
875                 }
876         }
877
878         if (!has_channel_ids) {
879                 ast_log(LOG_ERROR, "ARI Endpoint missing required field channel_ids\n");
880                 res = 0;
881         }
882
883         if (!has_resource) {
884                 ast_log(LOG_ERROR, "ARI Endpoint missing required field resource\n");
885                 res = 0;
886         }
887
888         if (!has_technology) {
889                 ast_log(LOG_ERROR, "ARI Endpoint missing required field technology\n");
890                 res = 0;
891         }
892
893         return res;
894 }
895
896 ari_validator ast_ari_validate_endpoint_fn(void)
897 {
898         return ast_ari_validate_endpoint;
899 }
900
901 int ast_ari_validate_text_message(struct ast_json *json)
902 {
903         int res = 1;
904         struct ast_json_iter *iter;
905         int has_body = 0;
906         int has_from = 0;
907         int has_to = 0;
908
909         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
910                 if (strcmp("body", ast_json_object_iter_key(iter)) == 0) {
911                         int prop_is_valid;
912                         has_body = 1;
913                         prop_is_valid = ast_ari_validate_string(
914                                 ast_json_object_iter_value(iter));
915                         if (!prop_is_valid) {
916                                 ast_log(LOG_ERROR, "ARI TextMessage field body failed validation\n");
917                                 res = 0;
918                         }
919                 } else
920                 if (strcmp("from", ast_json_object_iter_key(iter)) == 0) {
921                         int prop_is_valid;
922                         has_from = 1;
923                         prop_is_valid = ast_ari_validate_string(
924                                 ast_json_object_iter_value(iter));
925                         if (!prop_is_valid) {
926                                 ast_log(LOG_ERROR, "ARI TextMessage field from failed validation\n");
927                                 res = 0;
928                         }
929                 } else
930                 if (strcmp("to", ast_json_object_iter_key(iter)) == 0) {
931                         int prop_is_valid;
932                         has_to = 1;
933                         prop_is_valid = ast_ari_validate_string(
934                                 ast_json_object_iter_value(iter));
935                         if (!prop_is_valid) {
936                                 ast_log(LOG_ERROR, "ARI TextMessage field to failed validation\n");
937                                 res = 0;
938                         }
939                 } else
940                 if (strcmp("variables", ast_json_object_iter_key(iter)) == 0) {
941                         int prop_is_valid;
942                         prop_is_valid = ast_ari_validate_list(
943                                 ast_json_object_iter_value(iter),
944                                 ast_ari_validate_text_message_variable);
945                         if (!prop_is_valid) {
946                                 ast_log(LOG_ERROR, "ARI TextMessage field variables failed validation\n");
947                                 res = 0;
948                         }
949                 } else
950                 {
951                         ast_log(LOG_ERROR,
952                                 "ARI TextMessage has undocumented field %s\n",
953                                 ast_json_object_iter_key(iter));
954                         res = 0;
955                 }
956         }
957
958         if (!has_body) {
959                 ast_log(LOG_ERROR, "ARI TextMessage missing required field body\n");
960                 res = 0;
961         }
962
963         if (!has_from) {
964                 ast_log(LOG_ERROR, "ARI TextMessage missing required field from\n");
965                 res = 0;
966         }
967
968         if (!has_to) {
969                 ast_log(LOG_ERROR, "ARI TextMessage missing required field to\n");
970                 res = 0;
971         }
972
973         return res;
974 }
975
976 ari_validator ast_ari_validate_text_message_fn(void)
977 {
978         return ast_ari_validate_text_message;
979 }
980
981 int ast_ari_validate_text_message_variable(struct ast_json *json)
982 {
983         int res = 1;
984         struct ast_json_iter *iter;
985         int has_key = 0;
986         int has_value = 0;
987
988         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
989                 if (strcmp("key", ast_json_object_iter_key(iter)) == 0) {
990                         int prop_is_valid;
991                         has_key = 1;
992                         prop_is_valid = ast_ari_validate_string(
993                                 ast_json_object_iter_value(iter));
994                         if (!prop_is_valid) {
995                                 ast_log(LOG_ERROR, "ARI TextMessageVariable field key failed validation\n");
996                                 res = 0;
997                         }
998                 } else
999                 if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
1000                         int prop_is_valid;
1001                         has_value = 1;
1002                         prop_is_valid = ast_ari_validate_string(
1003                                 ast_json_object_iter_value(iter));
1004                         if (!prop_is_valid) {
1005                                 ast_log(LOG_ERROR, "ARI TextMessageVariable field value failed validation\n");
1006                                 res = 0;
1007                         }
1008                 } else
1009                 {
1010                         ast_log(LOG_ERROR,
1011                                 "ARI TextMessageVariable has undocumented field %s\n",
1012                                 ast_json_object_iter_key(iter));
1013                         res = 0;
1014                 }
1015         }
1016
1017         if (!has_key) {
1018                 ast_log(LOG_ERROR, "ARI TextMessageVariable missing required field key\n");
1019                 res = 0;
1020         }
1021
1022         if (!has_value) {
1023                 ast_log(LOG_ERROR, "ARI TextMessageVariable missing required field value\n");
1024                 res = 0;
1025         }
1026
1027         return res;
1028 }
1029
1030 ari_validator ast_ari_validate_text_message_variable_fn(void)
1031 {
1032         return ast_ari_validate_text_message_variable;
1033 }
1034
1035 int ast_ari_validate_caller_id(struct ast_json *json)
1036 {
1037         int res = 1;
1038         struct ast_json_iter *iter;
1039         int has_name = 0;
1040         int has_number = 0;
1041
1042         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1043                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1044                         int prop_is_valid;
1045                         has_name = 1;
1046                         prop_is_valid = ast_ari_validate_string(
1047                                 ast_json_object_iter_value(iter));
1048                         if (!prop_is_valid) {
1049                                 ast_log(LOG_ERROR, "ARI CallerID field name failed validation\n");
1050                                 res = 0;
1051                         }
1052                 } else
1053                 if (strcmp("number", ast_json_object_iter_key(iter)) == 0) {
1054                         int prop_is_valid;
1055                         has_number = 1;
1056                         prop_is_valid = ast_ari_validate_string(
1057                                 ast_json_object_iter_value(iter));
1058                         if (!prop_is_valid) {
1059                                 ast_log(LOG_ERROR, "ARI CallerID field number failed validation\n");
1060                                 res = 0;
1061                         }
1062                 } else
1063                 {
1064                         ast_log(LOG_ERROR,
1065                                 "ARI CallerID has undocumented field %s\n",
1066                                 ast_json_object_iter_key(iter));
1067                         res = 0;
1068                 }
1069         }
1070
1071         if (!has_name) {
1072                 ast_log(LOG_ERROR, "ARI CallerID missing required field name\n");
1073                 res = 0;
1074         }
1075
1076         if (!has_number) {
1077                 ast_log(LOG_ERROR, "ARI CallerID missing required field number\n");
1078                 res = 0;
1079         }
1080
1081         return res;
1082 }
1083
1084 ari_validator ast_ari_validate_caller_id_fn(void)
1085 {
1086         return ast_ari_validate_caller_id;
1087 }
1088
1089 int ast_ari_validate_channel(struct ast_json *json)
1090 {
1091         int res = 1;
1092         struct ast_json_iter *iter;
1093         int has_accountcode = 0;
1094         int has_caller = 0;
1095         int has_connected = 0;
1096         int has_creationtime = 0;
1097         int has_dialplan = 0;
1098         int has_id = 0;
1099         int has_language = 0;
1100         int has_name = 0;
1101         int has_state = 0;
1102
1103         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1104                 if (strcmp("accountcode", ast_json_object_iter_key(iter)) == 0) {
1105                         int prop_is_valid;
1106                         has_accountcode = 1;
1107                         prop_is_valid = ast_ari_validate_string(
1108                                 ast_json_object_iter_value(iter));
1109                         if (!prop_is_valid) {
1110                                 ast_log(LOG_ERROR, "ARI Channel field accountcode failed validation\n");
1111                                 res = 0;
1112                         }
1113                 } else
1114                 if (strcmp("caller", ast_json_object_iter_key(iter)) == 0) {
1115                         int prop_is_valid;
1116                         has_caller = 1;
1117                         prop_is_valid = ast_ari_validate_caller_id(
1118                                 ast_json_object_iter_value(iter));
1119                         if (!prop_is_valid) {
1120                                 ast_log(LOG_ERROR, "ARI Channel field caller failed validation\n");
1121                                 res = 0;
1122                         }
1123                 } else
1124                 if (strcmp("channelvars", ast_json_object_iter_key(iter)) == 0) {
1125                         int prop_is_valid;
1126                         prop_is_valid = ast_ari_validate_object(
1127                                 ast_json_object_iter_value(iter));
1128                         if (!prop_is_valid) {
1129                                 ast_log(LOG_ERROR, "ARI Channel field channelvars failed validation\n");
1130                                 res = 0;
1131                         }
1132                 } else
1133                 if (strcmp("connected", ast_json_object_iter_key(iter)) == 0) {
1134                         int prop_is_valid;
1135                         has_connected = 1;
1136                         prop_is_valid = ast_ari_validate_caller_id(
1137                                 ast_json_object_iter_value(iter));
1138                         if (!prop_is_valid) {
1139                                 ast_log(LOG_ERROR, "ARI Channel field connected failed validation\n");
1140                                 res = 0;
1141                         }
1142                 } else
1143                 if (strcmp("creationtime", ast_json_object_iter_key(iter)) == 0) {
1144                         int prop_is_valid;
1145                         has_creationtime = 1;
1146                         prop_is_valid = ast_ari_validate_date(
1147                                 ast_json_object_iter_value(iter));
1148                         if (!prop_is_valid) {
1149                                 ast_log(LOG_ERROR, "ARI Channel field creationtime failed validation\n");
1150                                 res = 0;
1151                         }
1152                 } else
1153                 if (strcmp("dialplan", ast_json_object_iter_key(iter)) == 0) {
1154                         int prop_is_valid;
1155                         has_dialplan = 1;
1156                         prop_is_valid = ast_ari_validate_dialplan_cep(
1157                                 ast_json_object_iter_value(iter));
1158                         if (!prop_is_valid) {
1159                                 ast_log(LOG_ERROR, "ARI Channel field dialplan failed validation\n");
1160                                 res = 0;
1161                         }
1162                 } else
1163                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
1164                         int prop_is_valid;
1165                         has_id = 1;
1166                         prop_is_valid = ast_ari_validate_string(
1167                                 ast_json_object_iter_value(iter));
1168                         if (!prop_is_valid) {
1169                                 ast_log(LOG_ERROR, "ARI Channel field id failed validation\n");
1170                                 res = 0;
1171                         }
1172                 } else
1173                 if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
1174                         int prop_is_valid;
1175                         has_language = 1;
1176                         prop_is_valid = ast_ari_validate_string(
1177                                 ast_json_object_iter_value(iter));
1178                         if (!prop_is_valid) {
1179                                 ast_log(LOG_ERROR, "ARI Channel field language failed validation\n");
1180                                 res = 0;
1181                         }
1182                 } else
1183                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1184                         int prop_is_valid;
1185                         has_name = 1;
1186                         prop_is_valid = ast_ari_validate_string(
1187                                 ast_json_object_iter_value(iter));
1188                         if (!prop_is_valid) {
1189                                 ast_log(LOG_ERROR, "ARI Channel field name failed validation\n");
1190                                 res = 0;
1191                         }
1192                 } else
1193                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
1194                         int prop_is_valid;
1195                         has_state = 1;
1196                         prop_is_valid = ast_ari_validate_string(
1197                                 ast_json_object_iter_value(iter));
1198                         if (!prop_is_valid) {
1199                                 ast_log(LOG_ERROR, "ARI Channel field state failed validation\n");
1200                                 res = 0;
1201                         }
1202                 } else
1203                 {
1204                         ast_log(LOG_ERROR,
1205                                 "ARI Channel has undocumented field %s\n",
1206                                 ast_json_object_iter_key(iter));
1207                         res = 0;
1208                 }
1209         }
1210
1211         if (!has_accountcode) {
1212                 ast_log(LOG_ERROR, "ARI Channel missing required field accountcode\n");
1213                 res = 0;
1214         }
1215
1216         if (!has_caller) {
1217                 ast_log(LOG_ERROR, "ARI Channel missing required field caller\n");
1218                 res = 0;
1219         }
1220
1221         if (!has_connected) {
1222                 ast_log(LOG_ERROR, "ARI Channel missing required field connected\n");
1223                 res = 0;
1224         }
1225
1226         if (!has_creationtime) {
1227                 ast_log(LOG_ERROR, "ARI Channel missing required field creationtime\n");
1228                 res = 0;
1229         }
1230
1231         if (!has_dialplan) {
1232                 ast_log(LOG_ERROR, "ARI Channel missing required field dialplan\n");
1233                 res = 0;
1234         }
1235
1236         if (!has_id) {
1237                 ast_log(LOG_ERROR, "ARI Channel missing required field id\n");
1238                 res = 0;
1239         }
1240
1241         if (!has_language) {
1242                 ast_log(LOG_ERROR, "ARI Channel missing required field language\n");
1243                 res = 0;
1244         }
1245
1246         if (!has_name) {
1247                 ast_log(LOG_ERROR, "ARI Channel missing required field name\n");
1248                 res = 0;
1249         }
1250
1251         if (!has_state) {
1252                 ast_log(LOG_ERROR, "ARI Channel missing required field state\n");
1253                 res = 0;
1254         }
1255
1256         return res;
1257 }
1258
1259 ari_validator ast_ari_validate_channel_fn(void)
1260 {
1261         return ast_ari_validate_channel;
1262 }
1263
1264 int ast_ari_validate_dialed(struct ast_json *json)
1265 {
1266         int res = 1;
1267         struct ast_json_iter *iter;
1268
1269         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1270                 {
1271                         ast_log(LOG_ERROR,
1272                                 "ARI Dialed has undocumented field %s\n",
1273                                 ast_json_object_iter_key(iter));
1274                         res = 0;
1275                 }
1276         }
1277
1278         return res;
1279 }
1280
1281 ari_validator ast_ari_validate_dialed_fn(void)
1282 {
1283         return ast_ari_validate_dialed;
1284 }
1285
1286 int ast_ari_validate_dialplan_cep(struct ast_json *json)
1287 {
1288         int res = 1;
1289         struct ast_json_iter *iter;
1290         int has_context = 0;
1291         int has_exten = 0;
1292         int has_priority = 0;
1293
1294         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1295                 if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
1296                         int prop_is_valid;
1297                         has_context = 1;
1298                         prop_is_valid = ast_ari_validate_string(
1299                                 ast_json_object_iter_value(iter));
1300                         if (!prop_is_valid) {
1301                                 ast_log(LOG_ERROR, "ARI DialplanCEP field context failed validation\n");
1302                                 res = 0;
1303                         }
1304                 } else
1305                 if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
1306                         int prop_is_valid;
1307                         has_exten = 1;
1308                         prop_is_valid = ast_ari_validate_string(
1309                                 ast_json_object_iter_value(iter));
1310                         if (!prop_is_valid) {
1311                                 ast_log(LOG_ERROR, "ARI DialplanCEP field exten failed validation\n");
1312                                 res = 0;
1313                         }
1314                 } else
1315                 if (strcmp("priority", ast_json_object_iter_key(iter)) == 0) {
1316                         int prop_is_valid;
1317                         has_priority = 1;
1318                         prop_is_valid = ast_ari_validate_long(
1319                                 ast_json_object_iter_value(iter));
1320                         if (!prop_is_valid) {
1321                                 ast_log(LOG_ERROR, "ARI DialplanCEP field priority failed validation\n");
1322                                 res = 0;
1323                         }
1324                 } else
1325                 {
1326                         ast_log(LOG_ERROR,
1327                                 "ARI DialplanCEP has undocumented field %s\n",
1328                                 ast_json_object_iter_key(iter));
1329                         res = 0;
1330                 }
1331         }
1332
1333         if (!has_context) {
1334                 ast_log(LOG_ERROR, "ARI DialplanCEP missing required field context\n");
1335                 res = 0;
1336         }
1337
1338         if (!has_exten) {
1339                 ast_log(LOG_ERROR, "ARI DialplanCEP missing required field exten\n");
1340                 res = 0;
1341         }
1342
1343         if (!has_priority) {
1344                 ast_log(LOG_ERROR, "ARI DialplanCEP missing required field priority\n");
1345                 res = 0;
1346         }
1347
1348         return res;
1349 }
1350
1351 ari_validator ast_ari_validate_dialplan_cep_fn(void)
1352 {
1353         return ast_ari_validate_dialplan_cep;
1354 }
1355
1356 int ast_ari_validate_rtpstat(struct ast_json *json)
1357 {
1358         int res = 1;
1359         struct ast_json_iter *iter;
1360         int has_channel_uniqueid = 0;
1361         int has_local_ssrc = 0;
1362         int has_remote_ssrc = 0;
1363         int has_rxcount = 0;
1364         int has_rxoctetcount = 0;
1365         int has_rxploss = 0;
1366         int has_txcount = 0;
1367         int has_txoctetcount = 0;
1368         int has_txploss = 0;
1369
1370         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1371                 if (strcmp("channel_uniqueid", ast_json_object_iter_key(iter)) == 0) {
1372                         int prop_is_valid;
1373                         has_channel_uniqueid = 1;
1374                         prop_is_valid = ast_ari_validate_string(
1375                                 ast_json_object_iter_value(iter));
1376                         if (!prop_is_valid) {
1377                                 ast_log(LOG_ERROR, "ARI RTPstat field channel_uniqueid failed validation\n");
1378                                 res = 0;
1379                         }
1380                 } else
1381                 if (strcmp("local_maxjitter", ast_json_object_iter_key(iter)) == 0) {
1382                         int prop_is_valid;
1383                         prop_is_valid = ast_ari_validate_double(
1384                                 ast_json_object_iter_value(iter));
1385                         if (!prop_is_valid) {
1386                                 ast_log(LOG_ERROR, "ARI RTPstat field local_maxjitter failed validation\n");
1387                                 res = 0;
1388                         }
1389                 } else
1390                 if (strcmp("local_maxrxploss", ast_json_object_iter_key(iter)) == 0) {
1391                         int prop_is_valid;
1392                         prop_is_valid = ast_ari_validate_double(
1393                                 ast_json_object_iter_value(iter));
1394                         if (!prop_is_valid) {
1395                                 ast_log(LOG_ERROR, "ARI RTPstat field local_maxrxploss failed validation\n");
1396                                 res = 0;
1397                         }
1398                 } else
1399                 if (strcmp("local_minjitter", ast_json_object_iter_key(iter)) == 0) {
1400                         int prop_is_valid;
1401                         prop_is_valid = ast_ari_validate_double(
1402                                 ast_json_object_iter_value(iter));
1403                         if (!prop_is_valid) {
1404                                 ast_log(LOG_ERROR, "ARI RTPstat field local_minjitter failed validation\n");
1405                                 res = 0;
1406                         }
1407                 } else
1408                 if (strcmp("local_minrxploss", ast_json_object_iter_key(iter)) == 0) {
1409                         int prop_is_valid;
1410                         prop_is_valid = ast_ari_validate_double(
1411                                 ast_json_object_iter_value(iter));
1412                         if (!prop_is_valid) {
1413                                 ast_log(LOG_ERROR, "ARI RTPstat field local_minrxploss failed validation\n");
1414                                 res = 0;
1415                         }
1416                 } else
1417                 if (strcmp("local_normdevjitter", ast_json_object_iter_key(iter)) == 0) {
1418                         int prop_is_valid;
1419                         prop_is_valid = ast_ari_validate_double(
1420                                 ast_json_object_iter_value(iter));
1421                         if (!prop_is_valid) {
1422                                 ast_log(LOG_ERROR, "ARI RTPstat field local_normdevjitter failed validation\n");
1423                                 res = 0;
1424                         }
1425                 } else
1426                 if (strcmp("local_normdevrxploss", ast_json_object_iter_key(iter)) == 0) {
1427                         int prop_is_valid;
1428                         prop_is_valid = ast_ari_validate_double(
1429                                 ast_json_object_iter_value(iter));
1430                         if (!prop_is_valid) {
1431                                 ast_log(LOG_ERROR, "ARI RTPstat field local_normdevrxploss failed validation\n");
1432                                 res = 0;
1433                         }
1434                 } else
1435                 if (strcmp("local_ssrc", ast_json_object_iter_key(iter)) == 0) {
1436                         int prop_is_valid;
1437                         has_local_ssrc = 1;
1438                         prop_is_valid = ast_ari_validate_int(
1439                                 ast_json_object_iter_value(iter));
1440                         if (!prop_is_valid) {
1441                                 ast_log(LOG_ERROR, "ARI RTPstat field local_ssrc failed validation\n");
1442                                 res = 0;
1443                         }
1444                 } else
1445                 if (strcmp("local_stdevjitter", ast_json_object_iter_key(iter)) == 0) {
1446                         int prop_is_valid;
1447                         prop_is_valid = ast_ari_validate_double(
1448                                 ast_json_object_iter_value(iter));
1449                         if (!prop_is_valid) {
1450                                 ast_log(LOG_ERROR, "ARI RTPstat field local_stdevjitter failed validation\n");
1451                                 res = 0;
1452                         }
1453                 } else
1454                 if (strcmp("local_stdevrxploss", ast_json_object_iter_key(iter)) == 0) {
1455                         int prop_is_valid;
1456                         prop_is_valid = ast_ari_validate_double(
1457                                 ast_json_object_iter_value(iter));
1458                         if (!prop_is_valid) {
1459                                 ast_log(LOG_ERROR, "ARI RTPstat field local_stdevrxploss failed validation\n");
1460                                 res = 0;
1461                         }
1462                 } else
1463                 if (strcmp("maxrtt", ast_json_object_iter_key(iter)) == 0) {
1464                         int prop_is_valid;
1465                         prop_is_valid = ast_ari_validate_double(
1466                                 ast_json_object_iter_value(iter));
1467                         if (!prop_is_valid) {
1468                                 ast_log(LOG_ERROR, "ARI RTPstat field maxrtt failed validation\n");
1469                                 res = 0;
1470                         }
1471                 } else
1472                 if (strcmp("minrtt", ast_json_object_iter_key(iter)) == 0) {
1473                         int prop_is_valid;
1474                         prop_is_valid = ast_ari_validate_double(
1475                                 ast_json_object_iter_value(iter));
1476                         if (!prop_is_valid) {
1477                                 ast_log(LOG_ERROR, "ARI RTPstat field minrtt failed validation\n");
1478                                 res = 0;
1479                         }
1480                 } else
1481                 if (strcmp("normdevrtt", ast_json_object_iter_key(iter)) == 0) {
1482                         int prop_is_valid;
1483                         prop_is_valid = ast_ari_validate_double(
1484                                 ast_json_object_iter_value(iter));
1485                         if (!prop_is_valid) {
1486                                 ast_log(LOG_ERROR, "ARI RTPstat field normdevrtt failed validation\n");
1487                                 res = 0;
1488                         }
1489                 } else
1490                 if (strcmp("remote_maxjitter", ast_json_object_iter_key(iter)) == 0) {
1491                         int prop_is_valid;
1492                         prop_is_valid = ast_ari_validate_double(
1493                                 ast_json_object_iter_value(iter));
1494                         if (!prop_is_valid) {
1495                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_maxjitter failed validation\n");
1496                                 res = 0;
1497                         }
1498                 } else
1499                 if (strcmp("remote_maxrxploss", ast_json_object_iter_key(iter)) == 0) {
1500                         int prop_is_valid;
1501                         prop_is_valid = ast_ari_validate_double(
1502                                 ast_json_object_iter_value(iter));
1503                         if (!prop_is_valid) {
1504                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_maxrxploss failed validation\n");
1505                                 res = 0;
1506                         }
1507                 } else
1508                 if (strcmp("remote_minjitter", ast_json_object_iter_key(iter)) == 0) {
1509                         int prop_is_valid;
1510                         prop_is_valid = ast_ari_validate_double(
1511                                 ast_json_object_iter_value(iter));
1512                         if (!prop_is_valid) {
1513                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_minjitter failed validation\n");
1514                                 res = 0;
1515                         }
1516                 } else
1517                 if (strcmp("remote_minrxploss", ast_json_object_iter_key(iter)) == 0) {
1518                         int prop_is_valid;
1519                         prop_is_valid = ast_ari_validate_double(
1520                                 ast_json_object_iter_value(iter));
1521                         if (!prop_is_valid) {
1522                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_minrxploss failed validation\n");
1523                                 res = 0;
1524                         }
1525                 } else
1526                 if (strcmp("remote_normdevjitter", ast_json_object_iter_key(iter)) == 0) {
1527                         int prop_is_valid;
1528                         prop_is_valid = ast_ari_validate_double(
1529                                 ast_json_object_iter_value(iter));
1530                         if (!prop_is_valid) {
1531                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_normdevjitter failed validation\n");
1532                                 res = 0;
1533                         }
1534                 } else
1535                 if (strcmp("remote_normdevrxploss", ast_json_object_iter_key(iter)) == 0) {
1536                         int prop_is_valid;
1537                         prop_is_valid = ast_ari_validate_double(
1538                                 ast_json_object_iter_value(iter));
1539                         if (!prop_is_valid) {
1540                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_normdevrxploss failed validation\n");
1541                                 res = 0;
1542                         }
1543                 } else
1544                 if (strcmp("remote_ssrc", ast_json_object_iter_key(iter)) == 0) {
1545                         int prop_is_valid;
1546                         has_remote_ssrc = 1;
1547                         prop_is_valid = ast_ari_validate_int(
1548                                 ast_json_object_iter_value(iter));
1549                         if (!prop_is_valid) {
1550                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_ssrc failed validation\n");
1551                                 res = 0;
1552                         }
1553                 } else
1554                 if (strcmp("remote_stdevjitter", ast_json_object_iter_key(iter)) == 0) {
1555                         int prop_is_valid;
1556                         prop_is_valid = ast_ari_validate_double(
1557                                 ast_json_object_iter_value(iter));
1558                         if (!prop_is_valid) {
1559                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_stdevjitter failed validation\n");
1560                                 res = 0;
1561                         }
1562                 } else
1563                 if (strcmp("remote_stdevrxploss", ast_json_object_iter_key(iter)) == 0) {
1564                         int prop_is_valid;
1565                         prop_is_valid = ast_ari_validate_double(
1566                                 ast_json_object_iter_value(iter));
1567                         if (!prop_is_valid) {
1568                                 ast_log(LOG_ERROR, "ARI RTPstat field remote_stdevrxploss failed validation\n");
1569                                 res = 0;
1570                         }
1571                 } else
1572                 if (strcmp("rtt", ast_json_object_iter_key(iter)) == 0) {
1573                         int prop_is_valid;
1574                         prop_is_valid = ast_ari_validate_double(
1575                                 ast_json_object_iter_value(iter));
1576                         if (!prop_is_valid) {
1577                                 ast_log(LOG_ERROR, "ARI RTPstat field rtt failed validation\n");
1578                                 res = 0;
1579                         }
1580                 } else
1581                 if (strcmp("rxcount", ast_json_object_iter_key(iter)) == 0) {
1582                         int prop_is_valid;
1583                         has_rxcount = 1;
1584                         prop_is_valid = ast_ari_validate_int(
1585                                 ast_json_object_iter_value(iter));
1586                         if (!prop_is_valid) {
1587                                 ast_log(LOG_ERROR, "ARI RTPstat field rxcount failed validation\n");
1588                                 res = 0;
1589                         }
1590                 } else
1591                 if (strcmp("rxjitter", ast_json_object_iter_key(iter)) == 0) {
1592                         int prop_is_valid;
1593                         prop_is_valid = ast_ari_validate_double(
1594                                 ast_json_object_iter_value(iter));
1595                         if (!prop_is_valid) {
1596                                 ast_log(LOG_ERROR, "ARI RTPstat field rxjitter failed validation\n");
1597                                 res = 0;
1598                         }
1599                 } else
1600                 if (strcmp("rxoctetcount", ast_json_object_iter_key(iter)) == 0) {
1601                         int prop_is_valid;
1602                         has_rxoctetcount = 1;
1603                         prop_is_valid = ast_ari_validate_int(
1604                                 ast_json_object_iter_value(iter));
1605                         if (!prop_is_valid) {
1606                                 ast_log(LOG_ERROR, "ARI RTPstat field rxoctetcount failed validation\n");
1607                                 res = 0;
1608                         }
1609                 } else
1610                 if (strcmp("rxploss", ast_json_object_iter_key(iter)) == 0) {
1611                         int prop_is_valid;
1612                         has_rxploss = 1;
1613                         prop_is_valid = ast_ari_validate_int(
1614                                 ast_json_object_iter_value(iter));
1615                         if (!prop_is_valid) {
1616                                 ast_log(LOG_ERROR, "ARI RTPstat field rxploss failed validation\n");
1617                                 res = 0;
1618                         }
1619                 } else
1620                 if (strcmp("stdevrtt", ast_json_object_iter_key(iter)) == 0) {
1621                         int prop_is_valid;
1622                         prop_is_valid = ast_ari_validate_double(
1623                                 ast_json_object_iter_value(iter));
1624                         if (!prop_is_valid) {
1625                                 ast_log(LOG_ERROR, "ARI RTPstat field stdevrtt failed validation\n");
1626                                 res = 0;
1627                         }
1628                 } else
1629                 if (strcmp("txcount", ast_json_object_iter_key(iter)) == 0) {
1630                         int prop_is_valid;
1631                         has_txcount = 1;
1632                         prop_is_valid = ast_ari_validate_int(
1633                                 ast_json_object_iter_value(iter));
1634                         if (!prop_is_valid) {
1635                                 ast_log(LOG_ERROR, "ARI RTPstat field txcount failed validation\n");
1636                                 res = 0;
1637                         }
1638                 } else
1639                 if (strcmp("txjitter", ast_json_object_iter_key(iter)) == 0) {
1640                         int prop_is_valid;
1641                         prop_is_valid = ast_ari_validate_double(
1642                                 ast_json_object_iter_value(iter));
1643                         if (!prop_is_valid) {
1644                                 ast_log(LOG_ERROR, "ARI RTPstat field txjitter failed validation\n");
1645                                 res = 0;
1646                         }
1647                 } else
1648                 if (strcmp("txoctetcount", ast_json_object_iter_key(iter)) == 0) {
1649                         int prop_is_valid;
1650                         has_txoctetcount = 1;
1651                         prop_is_valid = ast_ari_validate_int(
1652                                 ast_json_object_iter_value(iter));
1653                         if (!prop_is_valid) {
1654                                 ast_log(LOG_ERROR, "ARI RTPstat field txoctetcount failed validation\n");
1655                                 res = 0;
1656                         }
1657                 } else
1658                 if (strcmp("txploss", ast_json_object_iter_key(iter)) == 0) {
1659                         int prop_is_valid;
1660                         has_txploss = 1;
1661                         prop_is_valid = ast_ari_validate_int(
1662                                 ast_json_object_iter_value(iter));
1663                         if (!prop_is_valid) {
1664                                 ast_log(LOG_ERROR, "ARI RTPstat field txploss failed validation\n");
1665                                 res = 0;
1666                         }
1667                 } else
1668                 {
1669                         ast_log(LOG_ERROR,
1670                                 "ARI RTPstat has undocumented field %s\n",
1671                                 ast_json_object_iter_key(iter));
1672                         res = 0;
1673                 }
1674         }
1675
1676         if (!has_channel_uniqueid) {
1677                 ast_log(LOG_ERROR, "ARI RTPstat missing required field channel_uniqueid\n");
1678                 res = 0;
1679         }
1680
1681         if (!has_local_ssrc) {
1682                 ast_log(LOG_ERROR, "ARI RTPstat missing required field local_ssrc\n");
1683                 res = 0;
1684         }
1685
1686         if (!has_remote_ssrc) {
1687                 ast_log(LOG_ERROR, "ARI RTPstat missing required field remote_ssrc\n");
1688                 res = 0;
1689         }
1690
1691         if (!has_rxcount) {
1692                 ast_log(LOG_ERROR, "ARI RTPstat missing required field rxcount\n");
1693                 res = 0;
1694         }
1695
1696         if (!has_rxoctetcount) {
1697                 ast_log(LOG_ERROR, "ARI RTPstat missing required field rxoctetcount\n");
1698                 res = 0;
1699         }
1700
1701         if (!has_rxploss) {
1702                 ast_log(LOG_ERROR, "ARI RTPstat missing required field rxploss\n");
1703                 res = 0;
1704         }
1705
1706         if (!has_txcount) {
1707                 ast_log(LOG_ERROR, "ARI RTPstat missing required field txcount\n");
1708                 res = 0;
1709         }
1710
1711         if (!has_txoctetcount) {
1712                 ast_log(LOG_ERROR, "ARI RTPstat missing required field txoctetcount\n");
1713                 res = 0;
1714         }
1715
1716         if (!has_txploss) {
1717                 ast_log(LOG_ERROR, "ARI RTPstat missing required field txploss\n");
1718                 res = 0;
1719         }
1720
1721         return res;
1722 }
1723
1724 ari_validator ast_ari_validate_rtpstat_fn(void)
1725 {
1726         return ast_ari_validate_rtpstat;
1727 }
1728
1729 int ast_ari_validate_bridge(struct ast_json *json)
1730 {
1731         int res = 1;
1732         struct ast_json_iter *iter;
1733         int has_bridge_class = 0;
1734         int has_bridge_type = 0;
1735         int has_channels = 0;
1736         int has_creationtime = 0;
1737         int has_creator = 0;
1738         int has_id = 0;
1739         int has_name = 0;
1740         int has_technology = 0;
1741
1742         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1743                 if (strcmp("bridge_class", ast_json_object_iter_key(iter)) == 0) {
1744                         int prop_is_valid;
1745                         has_bridge_class = 1;
1746                         prop_is_valid = ast_ari_validate_string(
1747                                 ast_json_object_iter_value(iter));
1748                         if (!prop_is_valid) {
1749                                 ast_log(LOG_ERROR, "ARI Bridge field bridge_class failed validation\n");
1750                                 res = 0;
1751                         }
1752                 } else
1753                 if (strcmp("bridge_type", ast_json_object_iter_key(iter)) == 0) {
1754                         int prop_is_valid;
1755                         has_bridge_type = 1;
1756                         prop_is_valid = ast_ari_validate_string(
1757                                 ast_json_object_iter_value(iter));
1758                         if (!prop_is_valid) {
1759                                 ast_log(LOG_ERROR, "ARI Bridge field bridge_type failed validation\n");
1760                                 res = 0;
1761                         }
1762                 } else
1763                 if (strcmp("channels", ast_json_object_iter_key(iter)) == 0) {
1764                         int prop_is_valid;
1765                         has_channels = 1;
1766                         prop_is_valid = ast_ari_validate_list(
1767                                 ast_json_object_iter_value(iter),
1768                                 ast_ari_validate_string);
1769                         if (!prop_is_valid) {
1770                                 ast_log(LOG_ERROR, "ARI Bridge field channels failed validation\n");
1771                                 res = 0;
1772                         }
1773                 } else
1774                 if (strcmp("creationtime", ast_json_object_iter_key(iter)) == 0) {
1775                         int prop_is_valid;
1776                         has_creationtime = 1;
1777                         prop_is_valid = ast_ari_validate_date(
1778                                 ast_json_object_iter_value(iter));
1779                         if (!prop_is_valid) {
1780                                 ast_log(LOG_ERROR, "ARI Bridge field creationtime failed validation\n");
1781                                 res = 0;
1782                         }
1783                 } else
1784                 if (strcmp("creator", ast_json_object_iter_key(iter)) == 0) {
1785                         int prop_is_valid;
1786                         has_creator = 1;
1787                         prop_is_valid = ast_ari_validate_string(
1788                                 ast_json_object_iter_value(iter));
1789                         if (!prop_is_valid) {
1790                                 ast_log(LOG_ERROR, "ARI Bridge field creator failed validation\n");
1791                                 res = 0;
1792                         }
1793                 } else
1794                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
1795                         int prop_is_valid;
1796                         has_id = 1;
1797                         prop_is_valid = ast_ari_validate_string(
1798                                 ast_json_object_iter_value(iter));
1799                         if (!prop_is_valid) {
1800                                 ast_log(LOG_ERROR, "ARI Bridge field id failed validation\n");
1801                                 res = 0;
1802                         }
1803                 } else
1804                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1805                         int prop_is_valid;
1806                         has_name = 1;
1807                         prop_is_valid = ast_ari_validate_string(
1808                                 ast_json_object_iter_value(iter));
1809                         if (!prop_is_valid) {
1810                                 ast_log(LOG_ERROR, "ARI Bridge field name failed validation\n");
1811                                 res = 0;
1812                         }
1813                 } else
1814                 if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
1815                         int prop_is_valid;
1816                         has_technology = 1;
1817                         prop_is_valid = ast_ari_validate_string(
1818                                 ast_json_object_iter_value(iter));
1819                         if (!prop_is_valid) {
1820                                 ast_log(LOG_ERROR, "ARI Bridge field technology failed validation\n");
1821                                 res = 0;
1822                         }
1823                 } else
1824                 if (strcmp("video_mode", ast_json_object_iter_key(iter)) == 0) {
1825                         int prop_is_valid;
1826                         prop_is_valid = ast_ari_validate_string(
1827                                 ast_json_object_iter_value(iter));
1828                         if (!prop_is_valid) {
1829                                 ast_log(LOG_ERROR, "ARI Bridge field video_mode failed validation\n");
1830                                 res = 0;
1831                         }
1832                 } else
1833                 if (strcmp("video_source_id", ast_json_object_iter_key(iter)) == 0) {
1834                         int prop_is_valid;
1835                         prop_is_valid = ast_ari_validate_string(
1836                                 ast_json_object_iter_value(iter));
1837                         if (!prop_is_valid) {
1838                                 ast_log(LOG_ERROR, "ARI Bridge field video_source_id failed validation\n");
1839                                 res = 0;
1840                         }
1841                 } else
1842                 {
1843                         ast_log(LOG_ERROR,
1844                                 "ARI Bridge has undocumented field %s\n",
1845                                 ast_json_object_iter_key(iter));
1846                         res = 0;
1847                 }
1848         }
1849
1850         if (!has_bridge_class) {
1851                 ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_class\n");
1852                 res = 0;
1853         }
1854
1855         if (!has_bridge_type) {
1856                 ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_type\n");
1857                 res = 0;
1858         }
1859
1860         if (!has_channels) {
1861                 ast_log(LOG_ERROR, "ARI Bridge missing required field channels\n");
1862                 res = 0;
1863         }
1864
1865         if (!has_creationtime) {
1866                 ast_log(LOG_ERROR, "ARI Bridge missing required field creationtime\n");
1867                 res = 0;
1868         }
1869
1870         if (!has_creator) {
1871                 ast_log(LOG_ERROR, "ARI Bridge missing required field creator\n");
1872                 res = 0;
1873         }
1874
1875         if (!has_id) {
1876                 ast_log(LOG_ERROR, "ARI Bridge missing required field id\n");
1877                 res = 0;
1878         }
1879
1880         if (!has_name) {
1881                 ast_log(LOG_ERROR, "ARI Bridge missing required field name\n");
1882                 res = 0;
1883         }
1884
1885         if (!has_technology) {
1886                 ast_log(LOG_ERROR, "ARI Bridge missing required field technology\n");
1887                 res = 0;
1888         }
1889
1890         return res;
1891 }
1892
1893 ari_validator ast_ari_validate_bridge_fn(void)
1894 {
1895         return ast_ari_validate_bridge;
1896 }
1897
1898 int ast_ari_validate_live_recording(struct ast_json *json)
1899 {
1900         int res = 1;
1901         struct ast_json_iter *iter;
1902         int has_format = 0;
1903         int has_name = 0;
1904         int has_state = 0;
1905         int has_target_uri = 0;
1906
1907         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1908                 if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
1909                         int prop_is_valid;
1910                         prop_is_valid = ast_ari_validate_string(
1911                                 ast_json_object_iter_value(iter));
1912                         if (!prop_is_valid) {
1913                                 ast_log(LOG_ERROR, "ARI LiveRecording field cause failed validation\n");
1914                                 res = 0;
1915                         }
1916                 } else
1917                 if (strcmp("duration", ast_json_object_iter_key(iter)) == 0) {
1918                         int prop_is_valid;
1919                         prop_is_valid = ast_ari_validate_int(
1920                                 ast_json_object_iter_value(iter));
1921                         if (!prop_is_valid) {
1922                                 ast_log(LOG_ERROR, "ARI LiveRecording field duration failed validation\n");
1923                                 res = 0;
1924                         }
1925                 } else
1926                 if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
1927                         int prop_is_valid;
1928                         has_format = 1;
1929                         prop_is_valid = ast_ari_validate_string(
1930                                 ast_json_object_iter_value(iter));
1931                         if (!prop_is_valid) {
1932                                 ast_log(LOG_ERROR, "ARI LiveRecording field format failed validation\n");
1933                                 res = 0;
1934                         }
1935                 } else
1936                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1937                         int prop_is_valid;
1938                         has_name = 1;
1939                         prop_is_valid = ast_ari_validate_string(
1940                                 ast_json_object_iter_value(iter));
1941                         if (!prop_is_valid) {
1942                                 ast_log(LOG_ERROR, "ARI LiveRecording field name failed validation\n");
1943                                 res = 0;
1944                         }
1945                 } else
1946                 if (strcmp("silence_duration", ast_json_object_iter_key(iter)) == 0) {
1947                         int prop_is_valid;
1948                         prop_is_valid = ast_ari_validate_int(
1949                                 ast_json_object_iter_value(iter));
1950                         if (!prop_is_valid) {
1951                                 ast_log(LOG_ERROR, "ARI LiveRecording field silence_duration failed validation\n");
1952                                 res = 0;
1953                         }
1954                 } else
1955                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
1956                         int prop_is_valid;
1957                         has_state = 1;
1958                         prop_is_valid = ast_ari_validate_string(
1959                                 ast_json_object_iter_value(iter));
1960                         if (!prop_is_valid) {
1961                                 ast_log(LOG_ERROR, "ARI LiveRecording field state failed validation\n");
1962                                 res = 0;
1963                         }
1964                 } else
1965                 if (strcmp("talking_duration", ast_json_object_iter_key(iter)) == 0) {
1966                         int prop_is_valid;
1967                         prop_is_valid = ast_ari_validate_int(
1968                                 ast_json_object_iter_value(iter));
1969                         if (!prop_is_valid) {
1970                                 ast_log(LOG_ERROR, "ARI LiveRecording field talking_duration failed validation\n");
1971                                 res = 0;
1972                         }
1973                 } else
1974                 if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
1975                         int prop_is_valid;
1976                         has_target_uri = 1;
1977                         prop_is_valid = ast_ari_validate_string(
1978                                 ast_json_object_iter_value(iter));
1979                         if (!prop_is_valid) {
1980                                 ast_log(LOG_ERROR, "ARI LiveRecording field target_uri failed validation\n");
1981                                 res = 0;
1982                         }
1983                 } else
1984                 {
1985                         ast_log(LOG_ERROR,
1986                                 "ARI LiveRecording has undocumented field %s\n",
1987                                 ast_json_object_iter_key(iter));
1988                         res = 0;
1989                 }
1990         }
1991
1992         if (!has_format) {
1993                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field format\n");
1994                 res = 0;
1995         }
1996
1997         if (!has_name) {
1998                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field name\n");
1999                 res = 0;
2000         }
2001
2002         if (!has_state) {
2003                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field state\n");
2004                 res = 0;
2005         }
2006
2007         if (!has_target_uri) {
2008                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field target_uri\n");
2009                 res = 0;
2010         }
2011
2012         return res;
2013 }
2014
2015 ari_validator ast_ari_validate_live_recording_fn(void)
2016 {
2017         return ast_ari_validate_live_recording;
2018 }
2019
2020 int ast_ari_validate_stored_recording(struct ast_json *json)
2021 {
2022         int res = 1;
2023         struct ast_json_iter *iter;
2024         int has_format = 0;
2025         int has_name = 0;
2026
2027         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2028                 if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
2029                         int prop_is_valid;
2030                         has_format = 1;
2031                         prop_is_valid = ast_ari_validate_string(
2032                                 ast_json_object_iter_value(iter));
2033                         if (!prop_is_valid) {
2034                                 ast_log(LOG_ERROR, "ARI StoredRecording field format failed validation\n");
2035                                 res = 0;
2036                         }
2037                 } else
2038                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
2039                         int prop_is_valid;
2040                         has_name = 1;
2041                         prop_is_valid = ast_ari_validate_string(
2042                                 ast_json_object_iter_value(iter));
2043                         if (!prop_is_valid) {
2044                                 ast_log(LOG_ERROR, "ARI StoredRecording field name failed validation\n");
2045                                 res = 0;
2046                         }
2047                 } else
2048                 {
2049                         ast_log(LOG_ERROR,
2050                                 "ARI StoredRecording has undocumented field %s\n",
2051                                 ast_json_object_iter_key(iter));
2052                         res = 0;
2053                 }
2054         }
2055
2056         if (!has_format) {
2057                 ast_log(LOG_ERROR, "ARI StoredRecording missing required field format\n");
2058                 res = 0;
2059         }
2060
2061         if (!has_name) {
2062                 ast_log(LOG_ERROR, "ARI StoredRecording missing required field name\n");
2063                 res = 0;
2064         }
2065
2066         return res;
2067 }
2068
2069 ari_validator ast_ari_validate_stored_recording_fn(void)
2070 {
2071         return ast_ari_validate_stored_recording;
2072 }
2073
2074 int ast_ari_validate_format_lang_pair(struct ast_json *json)
2075 {
2076         int res = 1;
2077         struct ast_json_iter *iter;
2078         int has_format = 0;
2079         int has_language = 0;
2080
2081         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2082                 if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
2083                         int prop_is_valid;
2084                         has_format = 1;
2085                         prop_is_valid = ast_ari_validate_string(
2086                                 ast_json_object_iter_value(iter));
2087                         if (!prop_is_valid) {
2088                                 ast_log(LOG_ERROR, "ARI FormatLangPair field format failed validation\n");
2089                                 res = 0;
2090                         }
2091                 } else
2092                 if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
2093                         int prop_is_valid;
2094                         has_language = 1;
2095                         prop_is_valid = ast_ari_validate_string(
2096                                 ast_json_object_iter_value(iter));
2097                         if (!prop_is_valid) {
2098                                 ast_log(LOG_ERROR, "ARI FormatLangPair field language failed validation\n");
2099                                 res = 0;
2100                         }
2101                 } else
2102                 {
2103                         ast_log(LOG_ERROR,
2104                                 "ARI FormatLangPair has undocumented field %s\n",
2105                                 ast_json_object_iter_key(iter));
2106                         res = 0;
2107                 }
2108         }
2109
2110         if (!has_format) {
2111                 ast_log(LOG_ERROR, "ARI FormatLangPair missing required field format\n");
2112                 res = 0;
2113         }
2114
2115         if (!has_language) {
2116                 ast_log(LOG_ERROR, "ARI FormatLangPair missing required field language\n");
2117                 res = 0;
2118         }
2119
2120         return res;
2121 }
2122
2123 ari_validator ast_ari_validate_format_lang_pair_fn(void)
2124 {
2125         return ast_ari_validate_format_lang_pair;
2126 }
2127
2128 int ast_ari_validate_sound(struct ast_json *json)
2129 {
2130         int res = 1;
2131         struct ast_json_iter *iter;
2132         int has_formats = 0;
2133         int has_id = 0;
2134
2135         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2136                 if (strcmp("formats", ast_json_object_iter_key(iter)) == 0) {
2137                         int prop_is_valid;
2138                         has_formats = 1;
2139                         prop_is_valid = ast_ari_validate_list(
2140                                 ast_json_object_iter_value(iter),
2141                                 ast_ari_validate_format_lang_pair);
2142                         if (!prop_is_valid) {
2143                                 ast_log(LOG_ERROR, "ARI Sound field formats failed validation\n");
2144                                 res = 0;
2145                         }
2146                 } else
2147                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
2148                         int prop_is_valid;
2149                         has_id = 1;
2150                         prop_is_valid = ast_ari_validate_string(
2151                                 ast_json_object_iter_value(iter));
2152                         if (!prop_is_valid) {
2153                                 ast_log(LOG_ERROR, "ARI Sound field id failed validation\n");
2154                                 res = 0;
2155                         }
2156                 } else
2157                 if (strcmp("text", ast_json_object_iter_key(iter)) == 0) {
2158                         int prop_is_valid;
2159                         prop_is_valid = ast_ari_validate_string(
2160                                 ast_json_object_iter_value(iter));
2161                         if (!prop_is_valid) {
2162                                 ast_log(LOG_ERROR, "ARI Sound field text failed validation\n");
2163                                 res = 0;
2164                         }
2165                 } else
2166                 {
2167                         ast_log(LOG_ERROR,
2168                                 "ARI Sound has undocumented field %s\n",
2169                                 ast_json_object_iter_key(iter));
2170                         res = 0;
2171                 }
2172         }
2173
2174         if (!has_formats) {
2175                 ast_log(LOG_ERROR, "ARI Sound missing required field formats\n");
2176                 res = 0;
2177         }
2178
2179         if (!has_id) {
2180                 ast_log(LOG_ERROR, "ARI Sound missing required field id\n");
2181                 res = 0;
2182         }
2183
2184         return res;
2185 }
2186
2187 ari_validator ast_ari_validate_sound_fn(void)
2188 {
2189         return ast_ari_validate_sound;
2190 }
2191
2192 int ast_ari_validate_playback(struct ast_json *json)
2193 {
2194         int res = 1;
2195         struct ast_json_iter *iter;
2196         int has_id = 0;
2197         int has_media_uri = 0;
2198         int has_state = 0;
2199         int has_target_uri = 0;
2200
2201         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2202                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
2203                         int prop_is_valid;
2204                         has_id = 1;
2205                         prop_is_valid = ast_ari_validate_string(
2206                                 ast_json_object_iter_value(iter));
2207                         if (!prop_is_valid) {
2208                                 ast_log(LOG_ERROR, "ARI Playback field id failed validation\n");
2209                                 res = 0;
2210                         }
2211                 } else
2212                 if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
2213                         int prop_is_valid;
2214                         prop_is_valid = ast_ari_validate_string(
2215                                 ast_json_object_iter_value(iter));
2216                         if (!prop_is_valid) {
2217                                 ast_log(LOG_ERROR, "ARI Playback field language failed validation\n");
2218                                 res = 0;
2219                         }
2220                 } else
2221                 if (strcmp("media_uri", ast_json_object_iter_key(iter)) == 0) {
2222                         int prop_is_valid;
2223                         has_media_uri = 1;
2224                         prop_is_valid = ast_ari_validate_string(
2225                                 ast_json_object_iter_value(iter));
2226                         if (!prop_is_valid) {
2227                                 ast_log(LOG_ERROR, "ARI Playback field media_uri failed validation\n");
2228                                 res = 0;
2229                         }
2230                 } else
2231                 if (strcmp("next_media_uri", ast_json_object_iter_key(iter)) == 0) {
2232                         int prop_is_valid;
2233                         prop_is_valid = ast_ari_validate_string(
2234                                 ast_json_object_iter_value(iter));
2235                         if (!prop_is_valid) {
2236                                 ast_log(LOG_ERROR, "ARI Playback field next_media_uri failed validation\n");
2237                                 res = 0;
2238                         }
2239                 } else
2240                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
2241                         int prop_is_valid;
2242                         has_state = 1;
2243                         prop_is_valid = ast_ari_validate_string(
2244                                 ast_json_object_iter_value(iter));
2245                         if (!prop_is_valid) {
2246                                 ast_log(LOG_ERROR, "ARI Playback field state failed validation\n");
2247                                 res = 0;
2248                         }
2249                 } else
2250                 if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
2251                         int prop_is_valid;
2252                         has_target_uri = 1;
2253                         prop_is_valid = ast_ari_validate_string(
2254                                 ast_json_object_iter_value(iter));
2255                         if (!prop_is_valid) {
2256                                 ast_log(LOG_ERROR, "ARI Playback field target_uri failed validation\n");
2257                                 res = 0;
2258                         }
2259                 } else
2260                 {
2261                         ast_log(LOG_ERROR,
2262                                 "ARI Playback has undocumented field %s\n",
2263                                 ast_json_object_iter_key(iter));
2264                         res = 0;
2265                 }
2266         }
2267
2268         if (!has_id) {
2269                 ast_log(LOG_ERROR, "ARI Playback missing required field id\n");
2270                 res = 0;
2271         }
2272
2273         if (!has_media_uri) {
2274                 ast_log(LOG_ERROR, "ARI Playback missing required field media_uri\n");
2275                 res = 0;
2276         }
2277
2278         if (!has_state) {
2279                 ast_log(LOG_ERROR, "ARI Playback missing required field state\n");
2280                 res = 0;
2281         }
2282
2283         if (!has_target_uri) {
2284                 ast_log(LOG_ERROR, "ARI Playback missing required field target_uri\n");
2285                 res = 0;
2286         }
2287
2288         return res;
2289 }
2290
2291 ari_validator ast_ari_validate_playback_fn(void)
2292 {
2293         return ast_ari_validate_playback;
2294 }
2295
2296 int ast_ari_validate_device_state(struct ast_json *json)
2297 {
2298         int res = 1;
2299         struct ast_json_iter *iter;
2300         int has_name = 0;
2301         int has_state = 0;
2302
2303         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2304                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
2305                         int prop_is_valid;
2306                         has_name = 1;
2307                         prop_is_valid = ast_ari_validate_string(
2308                                 ast_json_object_iter_value(iter));
2309                         if (!prop_is_valid) {
2310                                 ast_log(LOG_ERROR, "ARI DeviceState field name failed validation\n");
2311                                 res = 0;
2312                         }
2313                 } else
2314                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
2315                         int prop_is_valid;
2316                         has_state = 1;
2317                         prop_is_valid = ast_ari_validate_string(
2318                                 ast_json_object_iter_value(iter));
2319                         if (!prop_is_valid) {
2320                                 ast_log(LOG_ERROR, "ARI DeviceState field state failed validation\n");
2321                                 res = 0;
2322                         }
2323                 } else
2324                 {
2325                         ast_log(LOG_ERROR,
2326                                 "ARI DeviceState has undocumented field %s\n",
2327                                 ast_json_object_iter_key(iter));
2328                         res = 0;
2329                 }
2330         }
2331
2332         if (!has_name) {
2333                 ast_log(LOG_ERROR, "ARI DeviceState missing required field name\n");
2334                 res = 0;
2335         }
2336
2337         if (!has_state) {
2338                 ast_log(LOG_ERROR, "ARI DeviceState missing required field state\n");
2339                 res = 0;
2340         }
2341
2342         return res;
2343 }
2344
2345 ari_validator ast_ari_validate_device_state_fn(void)
2346 {
2347         return ast_ari_validate_device_state;
2348 }
2349
2350 int ast_ari_validate_mailbox(struct ast_json *json)
2351 {
2352         int res = 1;
2353         struct ast_json_iter *iter;
2354         int has_name = 0;
2355         int has_new_messages = 0;
2356         int has_old_messages = 0;
2357
2358         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2359                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
2360                         int prop_is_valid;
2361                         has_name = 1;
2362                         prop_is_valid = ast_ari_validate_string(
2363                                 ast_json_object_iter_value(iter));
2364                         if (!prop_is_valid) {
2365                                 ast_log(LOG_ERROR, "ARI Mailbox field name failed validation\n");
2366                                 res = 0;
2367                         }
2368                 } else
2369                 if (strcmp("new_messages", ast_json_object_iter_key(iter)) == 0) {
2370                         int prop_is_valid;
2371                         has_new_messages = 1;
2372                         prop_is_valid = ast_ari_validate_int(
2373                                 ast_json_object_iter_value(iter));
2374                         if (!prop_is_valid) {
2375                                 ast_log(LOG_ERROR, "ARI Mailbox field new_messages failed validation\n");
2376                                 res = 0;
2377                         }
2378                 } else
2379                 if (strcmp("old_messages", ast_json_object_iter_key(iter)) == 0) {
2380                         int prop_is_valid;
2381                         has_old_messages = 1;
2382                         prop_is_valid = ast_ari_validate_int(
2383                                 ast_json_object_iter_value(iter));
2384                         if (!prop_is_valid) {
2385                                 ast_log(LOG_ERROR, "ARI Mailbox field old_messages failed validation\n");
2386                                 res = 0;
2387                         }
2388                 } else
2389                 {
2390                         ast_log(LOG_ERROR,
2391                                 "ARI Mailbox has undocumented field %s\n",
2392                                 ast_json_object_iter_key(iter));
2393                         res = 0;
2394                 }
2395         }
2396
2397         if (!has_name) {
2398                 ast_log(LOG_ERROR, "ARI Mailbox missing required field name\n");
2399                 res = 0;
2400         }
2401
2402         if (!has_new_messages) {
2403                 ast_log(LOG_ERROR, "ARI Mailbox missing required field new_messages\n");
2404                 res = 0;
2405         }
2406
2407         if (!has_old_messages) {
2408                 ast_log(LOG_ERROR, "ARI Mailbox missing required field old_messages\n");
2409                 res = 0;
2410         }
2411
2412         return res;
2413 }
2414
2415 ari_validator ast_ari_validate_mailbox_fn(void)
2416 {
2417         return ast_ari_validate_mailbox;
2418 }
2419
2420 int ast_ari_validate_application_move_failed(struct ast_json *json)
2421 {
2422         int res = 1;
2423         struct ast_json_iter *iter;
2424         int has_type = 0;
2425         int has_application = 0;
2426         int has_args = 0;
2427         int has_channel = 0;
2428         int has_destination = 0;
2429
2430         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2431                 if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
2432                         int prop_is_valid;
2433                         prop_is_valid = ast_ari_validate_string(
2434                                 ast_json_object_iter_value(iter));
2435                         if (!prop_is_valid) {
2436                                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed field asterisk_id failed validation\n");
2437                                 res = 0;
2438                         }
2439                 } else
2440                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2441                         int prop_is_valid;
2442                         has_type = 1;
2443                         prop_is_valid = ast_ari_validate_string(
2444                                 ast_json_object_iter_value(iter));
2445                         if (!prop_is_valid) {
2446                                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed field type failed validation\n");
2447                                 res = 0;
2448                         }
2449                 } else
2450                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2451                         int prop_is_valid;
2452                         has_application = 1;
2453                         prop_is_valid = ast_ari_validate_string(
2454                                 ast_json_object_iter_value(iter));
2455                         if (!prop_is_valid) {
2456                                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed field application failed validation\n");
2457                                 res = 0;
2458                         }
2459                 } else
2460                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2461                         int prop_is_valid;
2462                         prop_is_valid = ast_ari_validate_date(
2463                                 ast_json_object_iter_value(iter));
2464                         if (!prop_is_valid) {
2465                                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed field timestamp failed validation\n");
2466                                 res = 0;
2467                         }
2468                 } else
2469                 if (strcmp("args", ast_json_object_iter_key(iter)) == 0) {
2470                         int prop_is_valid;
2471                         has_args = 1;
2472                         prop_is_valid = ast_ari_validate_list(
2473                                 ast_json_object_iter_value(iter),
2474                                 ast_ari_validate_string);
2475                         if (!prop_is_valid) {
2476                                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed field args failed validation\n");
2477                                 res = 0;
2478                         }
2479                 } else
2480                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2481                         int prop_is_valid;
2482                         has_channel = 1;
2483                         prop_is_valid = ast_ari_validate_channel(
2484                                 ast_json_object_iter_value(iter));
2485                         if (!prop_is_valid) {
2486                                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed field channel failed validation\n");
2487                                 res = 0;
2488                         }
2489                 } else
2490                 if (strcmp("destination", ast_json_object_iter_key(iter)) == 0) {
2491                         int prop_is_valid;
2492                         has_destination = 1;
2493                         prop_is_valid = ast_ari_validate_string(
2494                                 ast_json_object_iter_value(iter));
2495                         if (!prop_is_valid) {
2496                                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed field destination failed validation\n");
2497                                 res = 0;
2498                         }
2499                 } else
2500                 {
2501                         ast_log(LOG_ERROR,
2502                                 "ARI ApplicationMoveFailed has undocumented field %s\n",
2503                                 ast_json_object_iter_key(iter));
2504                         res = 0;
2505                 }
2506         }
2507
2508         if (!has_type) {
2509                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed missing required field type\n");
2510                 res = 0;
2511         }
2512
2513         if (!has_application) {
2514                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed missing required field application\n");
2515                 res = 0;
2516         }
2517
2518         if (!has_args) {
2519                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed missing required field args\n");
2520                 res = 0;
2521         }
2522
2523         if (!has_channel) {
2524                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed missing required field channel\n");
2525                 res = 0;
2526         }
2527
2528         if (!has_destination) {
2529                 ast_log(LOG_ERROR, "ARI ApplicationMoveFailed missing required field destination\n");
2530                 res = 0;
2531         }
2532
2533         return res;
2534 }
2535
2536 ari_validator ast_ari_validate_application_move_failed_fn(void)
2537 {
2538         return ast_ari_validate_application_move_failed;
2539 }
2540
2541 int ast_ari_validate_application_replaced(struct ast_json *json)
2542 {
2543         int res = 1;
2544         struct ast_json_iter *iter;
2545         int has_type = 0;
2546         int has_application = 0;
2547
2548         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2549                 if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
2550                         int prop_is_valid;
2551                         prop_is_valid = ast_ari_validate_string(
2552                                 ast_json_object_iter_value(iter));
2553                         if (!prop_is_valid) {
2554                                 ast_log(LOG_ERROR, "ARI ApplicationReplaced field asterisk_id failed validation\n");
2555                                 res = 0;
2556                         }
2557                 } else
2558                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2559                         int prop_is_valid;
2560                         has_type = 1;
2561                         prop_is_valid = ast_ari_validate_string(
2562                                 ast_json_object_iter_value(iter));
2563                         if (!prop_is_valid) {
2564                                 ast_log(LOG_ERROR, "ARI ApplicationReplaced field type failed validation\n");
2565                                 res = 0;
2566                         }
2567                 } else
2568                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2569                         int prop_is_valid;
2570                         has_application = 1;
2571                         prop_is_valid = ast_ari_validate_string(
2572                                 ast_json_object_iter_value(iter));
2573                         if (!prop_is_valid) {
2574                                 ast_log(LOG_ERROR, "ARI ApplicationReplaced field application failed validation\n");
2575                                 res = 0;
2576                         }
2577                 } else
2578                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2579                         int prop_is_valid;
2580                         prop_is_valid = ast_ari_validate_date(
2581                                 ast_json_object_iter_value(iter));
2582                         if (!prop_is_valid) {
2583                                 ast_log(LOG_ERROR, "ARI ApplicationReplaced field timestamp failed validation\n");
2584                                 res = 0;
2585                         }
2586                 } else
2587                 {
2588                         ast_log(LOG_ERROR,
2589                                 "ARI ApplicationReplaced has undocumented field %s\n",
2590                                 ast_json_object_iter_key(iter));
2591                         res = 0;
2592                 }
2593         }
2594
2595         if (!has_type) {
2596                 ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field type\n");
2597                 res = 0;
2598         }
2599
2600         if (!has_application) {
2601                 ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field application\n");
2602                 res = 0;
2603         }
2604
2605         return res;
2606 }
2607
2608 ari_validator ast_ari_validate_application_replaced_fn(void)
2609 {
2610         return ast_ari_validate_application_replaced;
2611 }
2612
2613 int ast_ari_validate_bridge_attended_transfer(struct ast_json *json)
2614 {
2615         int res = 1;
2616         struct ast_json_iter *iter;
2617         int has_type = 0;
2618         int has_application = 0;
2619         int has_destination_type = 0;
2620         int has_is_external = 0;
2621         int has_result = 0;
2622         int has_transferer_first_leg = 0;
2623         int has_transferer_second_leg = 0;
2624
2625         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2626                 if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
2627                         int prop_is_valid;
2628                         prop_is_valid = ast_ari_validate_string(
2629                                 ast_json_object_iter_value(iter));
2630                         if (!prop_is_valid) {
2631                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field asterisk_id failed validation\n");
2632                                 res = 0;
2633                         }
2634                 } else
2635                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2636                         int prop_is_valid;
2637                         has_type = 1;
2638                         prop_is_valid = ast_ari_validate_string(
2639                                 ast_json_object_iter_value(iter));
2640                         if (!prop_is_valid) {
2641                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field type failed validation\n");
2642                                 res = 0;
2643                         }
2644                 } else
2645                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2646                         int prop_is_valid;
2647                         has_application = 1;
2648                         prop_is_valid = ast_ari_validate_string(
2649                                 ast_json_object_iter_value(iter));
2650                         if (!prop_is_valid) {
2651                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field application failed validation\n");
2652                                 res = 0;
2653                         }
2654                 } else
2655                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2656                         int prop_is_valid;
2657                         prop_is_valid = ast_ari_validate_date(
2658                                 ast_json_object_iter_value(iter));
2659                         if (!prop_is_valid) {
2660                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field timestamp failed validation\n");
2661                                 res = 0;
2662                         }
2663                 } else
2664                 if (strcmp("destination_application", ast_json_object_iter_key(iter)) == 0) {
2665                         int prop_is_valid;
2666                         prop_is_valid = ast_ari_validate_string(
2667                                 ast_json_object_iter_value(iter));
2668                         if (!prop_is_valid) {
2669                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_application failed validation\n");
2670                                 res = 0;
2671                         }
2672                 } else
2673                 if (strcmp("destination_bridge", ast_json_object_iter_key(iter)) == 0) {
2674                         int prop_is_valid;
2675                         prop_is_valid = ast_ari_validate_string(
2676                                 ast_json_object_iter_value(iter));
2677                         if (!prop_is_valid) {
2678                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_bridge failed validation\n");
2679                                 res = 0;
2680                         }
2681                 } else
2682                 if (strcmp("destination_link_first_leg", ast_json_object_iter_key(iter)) == 0) {
2683                         int prop_is_valid;
2684                         prop_is_valid = ast_ari_validate_channel(
2685                                 ast_json_object_iter_value(iter));
2686                         if (!prop_is_valid) {
2687                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_first_leg failed validation\n");
2688                                 res = 0;
2689                         }
2690                 } else
2691                 if (strcmp("destination_link_second_leg", ast_json_object_iter_key(iter)) == 0) {
2692                         int prop_is_valid;
2693                         prop_is_valid = ast_ari_validate_channel(
2694                                 ast_json_object_iter_value(iter));
2695                         if (!prop_is_valid) {
2696                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_second_leg failed validation\n");
2697                                 res = 0;
2698                         }
2699                 } else
2700                 if (strcmp("destination_threeway_bridge", ast_json_object_iter_key(iter)) == 0) {
2701                         int prop_is_valid;
2702                         prop_is_valid = ast_ari_validate_bridge(
2703                                 ast_json_object_iter_value(iter));
2704                         if (!prop_is_valid) {
2705                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_bridge failed validation\n");
2706                                 res = 0;
2707                         }
2708                 } else
2709                 if (strcmp("destination_threeway_channel", ast_json_object_iter_key(iter)) == 0) {
2710                         int prop_is_valid;
2711                         prop_is_valid = ast_ari_validate_channel(
2712                                 ast_json_object_iter_value(iter));
2713                         if (!prop_is_valid) {
2714                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_channel failed validation\n");
2715                                 res = 0;
2716                         }
2717                 } else
2718                 if (strcmp("destination_type", ast_json_object_iter_key(iter)) == 0) {
2719                         int prop_is_valid;
2720                         has_destination_type = 1;
2721                         prop_is_valid = ast_ari_validate_string(
2722                                 ast_json_object_iter_value(iter));
2723                         if (!prop_is_valid) {
2724                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_type failed validation\n");
2725                                 res = 0;
2726                         }
2727                 } else
2728                 if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
2729                         int prop_is_valid;
2730                         has_is_external = 1;
2731                         prop_is_valid = ast_ari_validate_boolean(
2732                                 ast_json_object_iter_value(iter));
2733                         if (!prop_is_valid) {
2734                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field is_external failed validation\n");
2735                                 res = 0;
2736                         }
2737                 } else
2738                 if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
2739                         int prop_is_valid;
2740                         prop_is_valid = ast_ari_validate_channel(
2741                                 ast_json_object_iter_value(iter));
2742                         if (!prop_is_valid) {
2743                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field replace_channel failed validation\n");
2744                                 res = 0;
2745                         }
2746                 } else
2747                 if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
2748                         int prop_is_valid;
2749                         has_result = 1;
2750                         prop_is_valid = ast_ari_validate_string(
2751                                 ast_json_object_iter_value(iter));
2752                         if (!prop_is_valid) {
2753                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field result failed validation\n");
2754                                 res = 0;
2755                         }
2756                 } else
2757                 if (strcmp("transfer_target", ast_json_object_iter_key(iter)) == 0) {
2758                         int prop_is_valid;
2759                         prop_is_valid = ast_ari_validate_channel(
2760                                 ast_json_object_iter_value(iter));
2761                         if (!prop_is_valid) {
2762                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transfer_target failed validation\n");
2763                                 res = 0;
2764                         }
2765                 } else
2766                 if (strcmp("transferee", ast_json_object_iter_key(iter)) == 0) {
2767                         int prop_is_valid;
2768                         prop_is_valid = ast_ari_validate_channel(
2769                                 ast_json_object_iter_value(iter));
2770                         if (!prop_is_valid) {
2771                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferee failed validation\n");
2772                                 res = 0;
2773                         }
2774                 } else
2775                 if (strcmp("transferer_first_leg", ast_json_object_iter_key(iter)) == 0) {
2776                         int prop_is_valid;
2777                         has_transferer_first_leg = 1;
2778                         prop_is_valid = ast_ari_validate_channel(
2779                                 ast_json_object_iter_value(iter));
2780                         if (!prop_is_valid) {