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