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