ARI: Add the ability to intercept hold and raise an event
[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_language = 0;
790         int has_name = 0;
791         int has_state = 0;
792
793         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
794                 if (strcmp("accountcode", ast_json_object_iter_key(iter)) == 0) {
795                         int prop_is_valid;
796                         has_accountcode = 1;
797                         prop_is_valid = ast_ari_validate_string(
798                                 ast_json_object_iter_value(iter));
799                         if (!prop_is_valid) {
800                                 ast_log(LOG_ERROR, "ARI Channel field accountcode failed validation\n");
801                                 res = 0;
802                         }
803                 } else
804                 if (strcmp("caller", ast_json_object_iter_key(iter)) == 0) {
805                         int prop_is_valid;
806                         has_caller = 1;
807                         prop_is_valid = ast_ari_validate_caller_id(
808                                 ast_json_object_iter_value(iter));
809                         if (!prop_is_valid) {
810                                 ast_log(LOG_ERROR, "ARI Channel field caller failed validation\n");
811                                 res = 0;
812                         }
813                 } else
814                 if (strcmp("connected", ast_json_object_iter_key(iter)) == 0) {
815                         int prop_is_valid;
816                         has_connected = 1;
817                         prop_is_valid = ast_ari_validate_caller_id(
818                                 ast_json_object_iter_value(iter));
819                         if (!prop_is_valid) {
820                                 ast_log(LOG_ERROR, "ARI Channel field connected failed validation\n");
821                                 res = 0;
822                         }
823                 } else
824                 if (strcmp("creationtime", ast_json_object_iter_key(iter)) == 0) {
825                         int prop_is_valid;
826                         has_creationtime = 1;
827                         prop_is_valid = ast_ari_validate_date(
828                                 ast_json_object_iter_value(iter));
829                         if (!prop_is_valid) {
830                                 ast_log(LOG_ERROR, "ARI Channel field creationtime failed validation\n");
831                                 res = 0;
832                         }
833                 } else
834                 if (strcmp("dialplan", ast_json_object_iter_key(iter)) == 0) {
835                         int prop_is_valid;
836                         has_dialplan = 1;
837                         prop_is_valid = ast_ari_validate_dialplan_cep(
838                                 ast_json_object_iter_value(iter));
839                         if (!prop_is_valid) {
840                                 ast_log(LOG_ERROR, "ARI Channel field dialplan failed validation\n");
841                                 res = 0;
842                         }
843                 } else
844                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
845                         int prop_is_valid;
846                         has_id = 1;
847                         prop_is_valid = ast_ari_validate_string(
848                                 ast_json_object_iter_value(iter));
849                         if (!prop_is_valid) {
850                                 ast_log(LOG_ERROR, "ARI Channel field id failed validation\n");
851                                 res = 0;
852                         }
853                 } else
854                 if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
855                         int prop_is_valid;
856                         has_language = 1;
857                         prop_is_valid = ast_ari_validate_string(
858                                 ast_json_object_iter_value(iter));
859                         if (!prop_is_valid) {
860                                 ast_log(LOG_ERROR, "ARI Channel field language failed validation\n");
861                                 res = 0;
862                         }
863                 } else
864                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
865                         int prop_is_valid;
866                         has_name = 1;
867                         prop_is_valid = ast_ari_validate_string(
868                                 ast_json_object_iter_value(iter));
869                         if (!prop_is_valid) {
870                                 ast_log(LOG_ERROR, "ARI Channel field name failed validation\n");
871                                 res = 0;
872                         }
873                 } else
874                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
875                         int prop_is_valid;
876                         has_state = 1;
877                         prop_is_valid = ast_ari_validate_string(
878                                 ast_json_object_iter_value(iter));
879                         if (!prop_is_valid) {
880                                 ast_log(LOG_ERROR, "ARI Channel field state failed validation\n");
881                                 res = 0;
882                         }
883                 } else
884                 {
885                         ast_log(LOG_ERROR,
886                                 "ARI Channel has undocumented field %s\n",
887                                 ast_json_object_iter_key(iter));
888                         res = 0;
889                 }
890         }
891
892         if (!has_accountcode) {
893                 ast_log(LOG_ERROR, "ARI Channel missing required field accountcode\n");
894                 res = 0;
895         }
896
897         if (!has_caller) {
898                 ast_log(LOG_ERROR, "ARI Channel missing required field caller\n");
899                 res = 0;
900         }
901
902         if (!has_connected) {
903                 ast_log(LOG_ERROR, "ARI Channel missing required field connected\n");
904                 res = 0;
905         }
906
907         if (!has_creationtime) {
908                 ast_log(LOG_ERROR, "ARI Channel missing required field creationtime\n");
909                 res = 0;
910         }
911
912         if (!has_dialplan) {
913                 ast_log(LOG_ERROR, "ARI Channel missing required field dialplan\n");
914                 res = 0;
915         }
916
917         if (!has_id) {
918                 ast_log(LOG_ERROR, "ARI Channel missing required field id\n");
919                 res = 0;
920         }
921
922         if (!has_language) {
923                 ast_log(LOG_ERROR, "ARI Channel missing required field language\n");
924                 res = 0;
925         }
926
927         if (!has_name) {
928                 ast_log(LOG_ERROR, "ARI Channel missing required field name\n");
929                 res = 0;
930         }
931
932         if (!has_state) {
933                 ast_log(LOG_ERROR, "ARI Channel missing required field state\n");
934                 res = 0;
935         }
936
937         return res;
938 }
939
940 ari_validator ast_ari_validate_channel_fn(void)
941 {
942         return ast_ari_validate_channel;
943 }
944
945 int ast_ari_validate_dialed(struct ast_json *json)
946 {
947         int res = 1;
948         struct ast_json_iter *iter;
949
950         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
951                 {
952                         ast_log(LOG_ERROR,
953                                 "ARI Dialed has undocumented field %s\n",
954                                 ast_json_object_iter_key(iter));
955                         res = 0;
956                 }
957         }
958
959         return res;
960 }
961
962 ari_validator ast_ari_validate_dialed_fn(void)
963 {
964         return ast_ari_validate_dialed;
965 }
966
967 int ast_ari_validate_dialplan_cep(struct ast_json *json)
968 {
969         int res = 1;
970         struct ast_json_iter *iter;
971         int has_context = 0;
972         int has_exten = 0;
973         int has_priority = 0;
974
975         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
976                 if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
977                         int prop_is_valid;
978                         has_context = 1;
979                         prop_is_valid = ast_ari_validate_string(
980                                 ast_json_object_iter_value(iter));
981                         if (!prop_is_valid) {
982                                 ast_log(LOG_ERROR, "ARI DialplanCEP field context failed validation\n");
983                                 res = 0;
984                         }
985                 } else
986                 if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
987                         int prop_is_valid;
988                         has_exten = 1;
989                         prop_is_valid = ast_ari_validate_string(
990                                 ast_json_object_iter_value(iter));
991                         if (!prop_is_valid) {
992                                 ast_log(LOG_ERROR, "ARI DialplanCEP field exten failed validation\n");
993                                 res = 0;
994                         }
995                 } else
996                 if (strcmp("priority", ast_json_object_iter_key(iter)) == 0) {
997                         int prop_is_valid;
998                         has_priority = 1;
999                         prop_is_valid = ast_ari_validate_long(
1000                                 ast_json_object_iter_value(iter));
1001                         if (!prop_is_valid) {
1002                                 ast_log(LOG_ERROR, "ARI DialplanCEP field priority failed validation\n");
1003                                 res = 0;
1004                         }
1005                 } else
1006                 {
1007                         ast_log(LOG_ERROR,
1008                                 "ARI DialplanCEP has undocumented field %s\n",
1009                                 ast_json_object_iter_key(iter));
1010                         res = 0;
1011                 }
1012         }
1013
1014         if (!has_context) {
1015                 ast_log(LOG_ERROR, "ARI DialplanCEP missing required field context\n");
1016                 res = 0;
1017         }
1018
1019         if (!has_exten) {
1020                 ast_log(LOG_ERROR, "ARI DialplanCEP missing required field exten\n");
1021                 res = 0;
1022         }
1023
1024         if (!has_priority) {
1025                 ast_log(LOG_ERROR, "ARI DialplanCEP missing required field priority\n");
1026                 res = 0;
1027         }
1028
1029         return res;
1030 }
1031
1032 ari_validator ast_ari_validate_dialplan_cep_fn(void)
1033 {
1034         return ast_ari_validate_dialplan_cep;
1035 }
1036
1037 int ast_ari_validate_bridge(struct ast_json *json)
1038 {
1039         int res = 1;
1040         struct ast_json_iter *iter;
1041         int has_bridge_class = 0;
1042         int has_bridge_type = 0;
1043         int has_channels = 0;
1044         int has_creator = 0;
1045         int has_id = 0;
1046         int has_name = 0;
1047         int has_technology = 0;
1048
1049         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1050                 if (strcmp("bridge_class", ast_json_object_iter_key(iter)) == 0) {
1051                         int prop_is_valid;
1052                         has_bridge_class = 1;
1053                         prop_is_valid = ast_ari_validate_string(
1054                                 ast_json_object_iter_value(iter));
1055                         if (!prop_is_valid) {
1056                                 ast_log(LOG_ERROR, "ARI Bridge field bridge_class failed validation\n");
1057                                 res = 0;
1058                         }
1059                 } else
1060                 if (strcmp("bridge_type", ast_json_object_iter_key(iter)) == 0) {
1061                         int prop_is_valid;
1062                         has_bridge_type = 1;
1063                         prop_is_valid = ast_ari_validate_string(
1064                                 ast_json_object_iter_value(iter));
1065                         if (!prop_is_valid) {
1066                                 ast_log(LOG_ERROR, "ARI Bridge field bridge_type failed validation\n");
1067                                 res = 0;
1068                         }
1069                 } else
1070                 if (strcmp("channels", ast_json_object_iter_key(iter)) == 0) {
1071                         int prop_is_valid;
1072                         has_channels = 1;
1073                         prop_is_valid = ast_ari_validate_list(
1074                                 ast_json_object_iter_value(iter),
1075                                 ast_ari_validate_string);
1076                         if (!prop_is_valid) {
1077                                 ast_log(LOG_ERROR, "ARI Bridge field channels failed validation\n");
1078                                 res = 0;
1079                         }
1080                 } else
1081                 if (strcmp("creator", ast_json_object_iter_key(iter)) == 0) {
1082                         int prop_is_valid;
1083                         has_creator = 1;
1084                         prop_is_valid = ast_ari_validate_string(
1085                                 ast_json_object_iter_value(iter));
1086                         if (!prop_is_valid) {
1087                                 ast_log(LOG_ERROR, "ARI Bridge field creator failed validation\n");
1088                                 res = 0;
1089                         }
1090                 } else
1091                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
1092                         int prop_is_valid;
1093                         has_id = 1;
1094                         prop_is_valid = ast_ari_validate_string(
1095                                 ast_json_object_iter_value(iter));
1096                         if (!prop_is_valid) {
1097                                 ast_log(LOG_ERROR, "ARI Bridge field id failed validation\n");
1098                                 res = 0;
1099                         }
1100                 } else
1101                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1102                         int prop_is_valid;
1103                         has_name = 1;
1104                         prop_is_valid = ast_ari_validate_string(
1105                                 ast_json_object_iter_value(iter));
1106                         if (!prop_is_valid) {
1107                                 ast_log(LOG_ERROR, "ARI Bridge field name failed validation\n");
1108                                 res = 0;
1109                         }
1110                 } else
1111                 if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
1112                         int prop_is_valid;
1113                         has_technology = 1;
1114                         prop_is_valid = ast_ari_validate_string(
1115                                 ast_json_object_iter_value(iter));
1116                         if (!prop_is_valid) {
1117                                 ast_log(LOG_ERROR, "ARI Bridge field technology failed validation\n");
1118                                 res = 0;
1119                         }
1120                 } else
1121                 {
1122                         ast_log(LOG_ERROR,
1123                                 "ARI Bridge has undocumented field %s\n",
1124                                 ast_json_object_iter_key(iter));
1125                         res = 0;
1126                 }
1127         }
1128
1129         if (!has_bridge_class) {
1130                 ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_class\n");
1131                 res = 0;
1132         }
1133
1134         if (!has_bridge_type) {
1135                 ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_type\n");
1136                 res = 0;
1137         }
1138
1139         if (!has_channels) {
1140                 ast_log(LOG_ERROR, "ARI Bridge missing required field channels\n");
1141                 res = 0;
1142         }
1143
1144         if (!has_creator) {
1145                 ast_log(LOG_ERROR, "ARI Bridge missing required field creator\n");
1146                 res = 0;
1147         }
1148
1149         if (!has_id) {
1150                 ast_log(LOG_ERROR, "ARI Bridge missing required field id\n");
1151                 res = 0;
1152         }
1153
1154         if (!has_name) {
1155                 ast_log(LOG_ERROR, "ARI Bridge missing required field name\n");
1156                 res = 0;
1157         }
1158
1159         if (!has_technology) {
1160                 ast_log(LOG_ERROR, "ARI Bridge missing required field technology\n");
1161                 res = 0;
1162         }
1163
1164         return res;
1165 }
1166
1167 ari_validator ast_ari_validate_bridge_fn(void)
1168 {
1169         return ast_ari_validate_bridge;
1170 }
1171
1172 int ast_ari_validate_live_recording(struct ast_json *json)
1173 {
1174         int res = 1;
1175         struct ast_json_iter *iter;
1176         int has_format = 0;
1177         int has_name = 0;
1178         int has_state = 0;
1179         int has_target_uri = 0;
1180
1181         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1182                 if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
1183                         int prop_is_valid;
1184                         prop_is_valid = ast_ari_validate_string(
1185                                 ast_json_object_iter_value(iter));
1186                         if (!prop_is_valid) {
1187                                 ast_log(LOG_ERROR, "ARI LiveRecording field cause failed validation\n");
1188                                 res = 0;
1189                         }
1190                 } else
1191                 if (strcmp("duration", ast_json_object_iter_key(iter)) == 0) {
1192                         int prop_is_valid;
1193                         prop_is_valid = ast_ari_validate_int(
1194                                 ast_json_object_iter_value(iter));
1195                         if (!prop_is_valid) {
1196                                 ast_log(LOG_ERROR, "ARI LiveRecording field duration failed validation\n");
1197                                 res = 0;
1198                         }
1199                 } else
1200                 if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
1201                         int prop_is_valid;
1202                         has_format = 1;
1203                         prop_is_valid = ast_ari_validate_string(
1204                                 ast_json_object_iter_value(iter));
1205                         if (!prop_is_valid) {
1206                                 ast_log(LOG_ERROR, "ARI LiveRecording field format failed validation\n");
1207                                 res = 0;
1208                         }
1209                 } else
1210                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1211                         int prop_is_valid;
1212                         has_name = 1;
1213                         prop_is_valid = ast_ari_validate_string(
1214                                 ast_json_object_iter_value(iter));
1215                         if (!prop_is_valid) {
1216                                 ast_log(LOG_ERROR, "ARI LiveRecording field name failed validation\n");
1217                                 res = 0;
1218                         }
1219                 } else
1220                 if (strcmp("silence_duration", ast_json_object_iter_key(iter)) == 0) {
1221                         int prop_is_valid;
1222                         prop_is_valid = ast_ari_validate_int(
1223                                 ast_json_object_iter_value(iter));
1224                         if (!prop_is_valid) {
1225                                 ast_log(LOG_ERROR, "ARI LiveRecording field silence_duration failed validation\n");
1226                                 res = 0;
1227                         }
1228                 } else
1229                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
1230                         int prop_is_valid;
1231                         has_state = 1;
1232                         prop_is_valid = ast_ari_validate_string(
1233                                 ast_json_object_iter_value(iter));
1234                         if (!prop_is_valid) {
1235                                 ast_log(LOG_ERROR, "ARI LiveRecording field state failed validation\n");
1236                                 res = 0;
1237                         }
1238                 } else
1239                 if (strcmp("talking_duration", ast_json_object_iter_key(iter)) == 0) {
1240                         int prop_is_valid;
1241                         prop_is_valid = ast_ari_validate_int(
1242                                 ast_json_object_iter_value(iter));
1243                         if (!prop_is_valid) {
1244                                 ast_log(LOG_ERROR, "ARI LiveRecording field talking_duration failed validation\n");
1245                                 res = 0;
1246                         }
1247                 } else
1248                 if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
1249                         int prop_is_valid;
1250                         has_target_uri = 1;
1251                         prop_is_valid = ast_ari_validate_string(
1252                                 ast_json_object_iter_value(iter));
1253                         if (!prop_is_valid) {
1254                                 ast_log(LOG_ERROR, "ARI LiveRecording field target_uri failed validation\n");
1255                                 res = 0;
1256                         }
1257                 } else
1258                 {
1259                         ast_log(LOG_ERROR,
1260                                 "ARI LiveRecording has undocumented field %s\n",
1261                                 ast_json_object_iter_key(iter));
1262                         res = 0;
1263                 }
1264         }
1265
1266         if (!has_format) {
1267                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field format\n");
1268                 res = 0;
1269         }
1270
1271         if (!has_name) {
1272                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field name\n");
1273                 res = 0;
1274         }
1275
1276         if (!has_state) {
1277                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field state\n");
1278                 res = 0;
1279         }
1280
1281         if (!has_target_uri) {
1282                 ast_log(LOG_ERROR, "ARI LiveRecording missing required field target_uri\n");
1283                 res = 0;
1284         }
1285
1286         return res;
1287 }
1288
1289 ari_validator ast_ari_validate_live_recording_fn(void)
1290 {
1291         return ast_ari_validate_live_recording;
1292 }
1293
1294 int ast_ari_validate_stored_recording(struct ast_json *json)
1295 {
1296         int res = 1;
1297         struct ast_json_iter *iter;
1298         int has_format = 0;
1299         int has_name = 0;
1300
1301         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1302                 if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
1303                         int prop_is_valid;
1304                         has_format = 1;
1305                         prop_is_valid = ast_ari_validate_string(
1306                                 ast_json_object_iter_value(iter));
1307                         if (!prop_is_valid) {
1308                                 ast_log(LOG_ERROR, "ARI StoredRecording field format failed validation\n");
1309                                 res = 0;
1310                         }
1311                 } else
1312                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1313                         int prop_is_valid;
1314                         has_name = 1;
1315                         prop_is_valid = ast_ari_validate_string(
1316                                 ast_json_object_iter_value(iter));
1317                         if (!prop_is_valid) {
1318                                 ast_log(LOG_ERROR, "ARI StoredRecording field name failed validation\n");
1319                                 res = 0;
1320                         }
1321                 } else
1322                 {
1323                         ast_log(LOG_ERROR,
1324                                 "ARI StoredRecording has undocumented field %s\n",
1325                                 ast_json_object_iter_key(iter));
1326                         res = 0;
1327                 }
1328         }
1329
1330         if (!has_format) {
1331                 ast_log(LOG_ERROR, "ARI StoredRecording missing required field format\n");
1332                 res = 0;
1333         }
1334
1335         if (!has_name) {
1336                 ast_log(LOG_ERROR, "ARI StoredRecording missing required field name\n");
1337                 res = 0;
1338         }
1339
1340         return res;
1341 }
1342
1343 ari_validator ast_ari_validate_stored_recording_fn(void)
1344 {
1345         return ast_ari_validate_stored_recording;
1346 }
1347
1348 int ast_ari_validate_format_lang_pair(struct ast_json *json)
1349 {
1350         int res = 1;
1351         struct ast_json_iter *iter;
1352         int has_format = 0;
1353         int has_language = 0;
1354
1355         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1356                 if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
1357                         int prop_is_valid;
1358                         has_format = 1;
1359                         prop_is_valid = ast_ari_validate_string(
1360                                 ast_json_object_iter_value(iter));
1361                         if (!prop_is_valid) {
1362                                 ast_log(LOG_ERROR, "ARI FormatLangPair field format failed validation\n");
1363                                 res = 0;
1364                         }
1365                 } else
1366                 if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
1367                         int prop_is_valid;
1368                         has_language = 1;
1369                         prop_is_valid = ast_ari_validate_string(
1370                                 ast_json_object_iter_value(iter));
1371                         if (!prop_is_valid) {
1372                                 ast_log(LOG_ERROR, "ARI FormatLangPair field language failed validation\n");
1373                                 res = 0;
1374                         }
1375                 } else
1376                 {
1377                         ast_log(LOG_ERROR,
1378                                 "ARI FormatLangPair has undocumented field %s\n",
1379                                 ast_json_object_iter_key(iter));
1380                         res = 0;
1381                 }
1382         }
1383
1384         if (!has_format) {
1385                 ast_log(LOG_ERROR, "ARI FormatLangPair missing required field format\n");
1386                 res = 0;
1387         }
1388
1389         if (!has_language) {
1390                 ast_log(LOG_ERROR, "ARI FormatLangPair missing required field language\n");
1391                 res = 0;
1392         }
1393
1394         return res;
1395 }
1396
1397 ari_validator ast_ari_validate_format_lang_pair_fn(void)
1398 {
1399         return ast_ari_validate_format_lang_pair;
1400 }
1401
1402 int ast_ari_validate_sound(struct ast_json *json)
1403 {
1404         int res = 1;
1405         struct ast_json_iter *iter;
1406         int has_formats = 0;
1407         int has_id = 0;
1408
1409         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1410                 if (strcmp("formats", ast_json_object_iter_key(iter)) == 0) {
1411                         int prop_is_valid;
1412                         has_formats = 1;
1413                         prop_is_valid = ast_ari_validate_list(
1414                                 ast_json_object_iter_value(iter),
1415                                 ast_ari_validate_format_lang_pair);
1416                         if (!prop_is_valid) {
1417                                 ast_log(LOG_ERROR, "ARI Sound field formats failed validation\n");
1418                                 res = 0;
1419                         }
1420                 } else
1421                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
1422                         int prop_is_valid;
1423                         has_id = 1;
1424                         prop_is_valid = ast_ari_validate_string(
1425                                 ast_json_object_iter_value(iter));
1426                         if (!prop_is_valid) {
1427                                 ast_log(LOG_ERROR, "ARI Sound field id failed validation\n");
1428                                 res = 0;
1429                         }
1430                 } else
1431                 if (strcmp("text", ast_json_object_iter_key(iter)) == 0) {
1432                         int prop_is_valid;
1433                         prop_is_valid = ast_ari_validate_string(
1434                                 ast_json_object_iter_value(iter));
1435                         if (!prop_is_valid) {
1436                                 ast_log(LOG_ERROR, "ARI Sound field text failed validation\n");
1437                                 res = 0;
1438                         }
1439                 } else
1440                 {
1441                         ast_log(LOG_ERROR,
1442                                 "ARI Sound has undocumented field %s\n",
1443                                 ast_json_object_iter_key(iter));
1444                         res = 0;
1445                 }
1446         }
1447
1448         if (!has_formats) {
1449                 ast_log(LOG_ERROR, "ARI Sound missing required field formats\n");
1450                 res = 0;
1451         }
1452
1453         if (!has_id) {
1454                 ast_log(LOG_ERROR, "ARI Sound missing required field id\n");
1455                 res = 0;
1456         }
1457
1458         return res;
1459 }
1460
1461 ari_validator ast_ari_validate_sound_fn(void)
1462 {
1463         return ast_ari_validate_sound;
1464 }
1465
1466 int ast_ari_validate_playback(struct ast_json *json)
1467 {
1468         int res = 1;
1469         struct ast_json_iter *iter;
1470         int has_id = 0;
1471         int has_media_uri = 0;
1472         int has_state = 0;
1473         int has_target_uri = 0;
1474
1475         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1476                 if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
1477                         int prop_is_valid;
1478                         has_id = 1;
1479                         prop_is_valid = ast_ari_validate_string(
1480                                 ast_json_object_iter_value(iter));
1481                         if (!prop_is_valid) {
1482                                 ast_log(LOG_ERROR, "ARI Playback field id failed validation\n");
1483                                 res = 0;
1484                         }
1485                 } else
1486                 if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
1487                         int prop_is_valid;
1488                         prop_is_valid = ast_ari_validate_string(
1489                                 ast_json_object_iter_value(iter));
1490                         if (!prop_is_valid) {
1491                                 ast_log(LOG_ERROR, "ARI Playback field language failed validation\n");
1492                                 res = 0;
1493                         }
1494                 } else
1495                 if (strcmp("media_uri", ast_json_object_iter_key(iter)) == 0) {
1496                         int prop_is_valid;
1497                         has_media_uri = 1;
1498                         prop_is_valid = ast_ari_validate_string(
1499                                 ast_json_object_iter_value(iter));
1500                         if (!prop_is_valid) {
1501                                 ast_log(LOG_ERROR, "ARI Playback field media_uri failed validation\n");
1502                                 res = 0;
1503                         }
1504                 } else
1505                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
1506                         int prop_is_valid;
1507                         has_state = 1;
1508                         prop_is_valid = ast_ari_validate_string(
1509                                 ast_json_object_iter_value(iter));
1510                         if (!prop_is_valid) {
1511                                 ast_log(LOG_ERROR, "ARI Playback field state failed validation\n");
1512                                 res = 0;
1513                         }
1514                 } else
1515                 if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
1516                         int prop_is_valid;
1517                         has_target_uri = 1;
1518                         prop_is_valid = ast_ari_validate_string(
1519                                 ast_json_object_iter_value(iter));
1520                         if (!prop_is_valid) {
1521                                 ast_log(LOG_ERROR, "ARI Playback field target_uri failed validation\n");
1522                                 res = 0;
1523                         }
1524                 } else
1525                 {
1526                         ast_log(LOG_ERROR,
1527                                 "ARI Playback has undocumented field %s\n",
1528                                 ast_json_object_iter_key(iter));
1529                         res = 0;
1530                 }
1531         }
1532
1533         if (!has_id) {
1534                 ast_log(LOG_ERROR, "ARI Playback missing required field id\n");
1535                 res = 0;
1536         }
1537
1538         if (!has_media_uri) {
1539                 ast_log(LOG_ERROR, "ARI Playback missing required field media_uri\n");
1540                 res = 0;
1541         }
1542
1543         if (!has_state) {
1544                 ast_log(LOG_ERROR, "ARI Playback missing required field state\n");
1545                 res = 0;
1546         }
1547
1548         if (!has_target_uri) {
1549                 ast_log(LOG_ERROR, "ARI Playback missing required field target_uri\n");
1550                 res = 0;
1551         }
1552
1553         return res;
1554 }
1555
1556 ari_validator ast_ari_validate_playback_fn(void)
1557 {
1558         return ast_ari_validate_playback;
1559 }
1560
1561 int ast_ari_validate_device_state(struct ast_json *json)
1562 {
1563         int res = 1;
1564         struct ast_json_iter *iter;
1565         int has_name = 0;
1566         int has_state = 0;
1567
1568         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1569                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1570                         int prop_is_valid;
1571                         has_name = 1;
1572                         prop_is_valid = ast_ari_validate_string(
1573                                 ast_json_object_iter_value(iter));
1574                         if (!prop_is_valid) {
1575                                 ast_log(LOG_ERROR, "ARI DeviceState field name failed validation\n");
1576                                 res = 0;
1577                         }
1578                 } else
1579                 if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
1580                         int prop_is_valid;
1581                         has_state = 1;
1582                         prop_is_valid = ast_ari_validate_string(
1583                                 ast_json_object_iter_value(iter));
1584                         if (!prop_is_valid) {
1585                                 ast_log(LOG_ERROR, "ARI DeviceState field state failed validation\n");
1586                                 res = 0;
1587                         }
1588                 } else
1589                 {
1590                         ast_log(LOG_ERROR,
1591                                 "ARI DeviceState has undocumented field %s\n",
1592                                 ast_json_object_iter_key(iter));
1593                         res = 0;
1594                 }
1595         }
1596
1597         if (!has_name) {
1598                 ast_log(LOG_ERROR, "ARI DeviceState missing required field name\n");
1599                 res = 0;
1600         }
1601
1602         if (!has_state) {
1603                 ast_log(LOG_ERROR, "ARI DeviceState missing required field state\n");
1604                 res = 0;
1605         }
1606
1607         return res;
1608 }
1609
1610 ari_validator ast_ari_validate_device_state_fn(void)
1611 {
1612         return ast_ari_validate_device_state;
1613 }
1614
1615 int ast_ari_validate_mailbox(struct ast_json *json)
1616 {
1617         int res = 1;
1618         struct ast_json_iter *iter;
1619         int has_name = 0;
1620         int has_new_messages = 0;
1621         int has_old_messages = 0;
1622
1623         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1624                 if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
1625                         int prop_is_valid;
1626                         has_name = 1;
1627                         prop_is_valid = ast_ari_validate_string(
1628                                 ast_json_object_iter_value(iter));
1629                         if (!prop_is_valid) {
1630                                 ast_log(LOG_ERROR, "ARI Mailbox field name failed validation\n");
1631                                 res = 0;
1632                         }
1633                 } else
1634                 if (strcmp("new_messages", ast_json_object_iter_key(iter)) == 0) {
1635                         int prop_is_valid;
1636                         has_new_messages = 1;
1637                         prop_is_valid = ast_ari_validate_int(
1638                                 ast_json_object_iter_value(iter));
1639                         if (!prop_is_valid) {
1640                                 ast_log(LOG_ERROR, "ARI Mailbox field new_messages failed validation\n");
1641                                 res = 0;
1642                         }
1643                 } else
1644                 if (strcmp("old_messages", ast_json_object_iter_key(iter)) == 0) {
1645                         int prop_is_valid;
1646                         has_old_messages = 1;
1647                         prop_is_valid = ast_ari_validate_int(
1648                                 ast_json_object_iter_value(iter));
1649                         if (!prop_is_valid) {
1650                                 ast_log(LOG_ERROR, "ARI Mailbox field old_messages failed validation\n");
1651                                 res = 0;
1652                         }
1653                 } else
1654                 {
1655                         ast_log(LOG_ERROR,
1656                                 "ARI Mailbox has undocumented field %s\n",
1657                                 ast_json_object_iter_key(iter));
1658                         res = 0;
1659                 }
1660         }
1661
1662         if (!has_name) {
1663                 ast_log(LOG_ERROR, "ARI Mailbox missing required field name\n");
1664                 res = 0;
1665         }
1666
1667         if (!has_new_messages) {
1668                 ast_log(LOG_ERROR, "ARI Mailbox missing required field new_messages\n");
1669                 res = 0;
1670         }
1671
1672         if (!has_old_messages) {
1673                 ast_log(LOG_ERROR, "ARI Mailbox missing required field old_messages\n");
1674                 res = 0;
1675         }
1676
1677         return res;
1678 }
1679
1680 ari_validator ast_ari_validate_mailbox_fn(void)
1681 {
1682         return ast_ari_validate_mailbox;
1683 }
1684
1685 int ast_ari_validate_application_replaced(struct ast_json *json)
1686 {
1687         int res = 1;
1688         struct ast_json_iter *iter;
1689         int has_type = 0;
1690         int has_application = 0;
1691
1692         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1693                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
1694                         int prop_is_valid;
1695                         has_type = 1;
1696                         prop_is_valid = ast_ari_validate_string(
1697                                 ast_json_object_iter_value(iter));
1698                         if (!prop_is_valid) {
1699                                 ast_log(LOG_ERROR, "ARI ApplicationReplaced field type failed validation\n");
1700                                 res = 0;
1701                         }
1702                 } else
1703                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
1704                         int prop_is_valid;
1705                         has_application = 1;
1706                         prop_is_valid = ast_ari_validate_string(
1707                                 ast_json_object_iter_value(iter));
1708                         if (!prop_is_valid) {
1709                                 ast_log(LOG_ERROR, "ARI ApplicationReplaced field application failed validation\n");
1710                                 res = 0;
1711                         }
1712                 } else
1713                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
1714                         int prop_is_valid;
1715                         prop_is_valid = ast_ari_validate_date(
1716                                 ast_json_object_iter_value(iter));
1717                         if (!prop_is_valid) {
1718                                 ast_log(LOG_ERROR, "ARI ApplicationReplaced field timestamp failed validation\n");
1719                                 res = 0;
1720                         }
1721                 } else
1722                 {
1723                         ast_log(LOG_ERROR,
1724                                 "ARI ApplicationReplaced has undocumented field %s\n",
1725                                 ast_json_object_iter_key(iter));
1726                         res = 0;
1727                 }
1728         }
1729
1730         if (!has_type) {
1731                 ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field type\n");
1732                 res = 0;
1733         }
1734
1735         if (!has_application) {
1736                 ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field application\n");
1737                 res = 0;
1738         }
1739
1740         return res;
1741 }
1742
1743 ari_validator ast_ari_validate_application_replaced_fn(void)
1744 {
1745         return ast_ari_validate_application_replaced;
1746 }
1747
1748 int ast_ari_validate_bridge_attended_transfer(struct ast_json *json)
1749 {
1750         int res = 1;
1751         struct ast_json_iter *iter;
1752         int has_type = 0;
1753         int has_application = 0;
1754         int has_destination_type = 0;
1755         int has_is_external = 0;
1756         int has_result = 0;
1757         int has_transferer_first_leg = 0;
1758         int has_transferer_second_leg = 0;
1759
1760         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
1761                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
1762                         int prop_is_valid;
1763                         has_type = 1;
1764                         prop_is_valid = ast_ari_validate_string(
1765                                 ast_json_object_iter_value(iter));
1766                         if (!prop_is_valid) {
1767                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field type failed validation\n");
1768                                 res = 0;
1769                         }
1770                 } else
1771                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
1772                         int prop_is_valid;
1773                         has_application = 1;
1774                         prop_is_valid = ast_ari_validate_string(
1775                                 ast_json_object_iter_value(iter));
1776                         if (!prop_is_valid) {
1777                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field application failed validation\n");
1778                                 res = 0;
1779                         }
1780                 } else
1781                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
1782                         int prop_is_valid;
1783                         prop_is_valid = ast_ari_validate_date(
1784                                 ast_json_object_iter_value(iter));
1785                         if (!prop_is_valid) {
1786                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field timestamp failed validation\n");
1787                                 res = 0;
1788                         }
1789                 } else
1790                 if (strcmp("destination_application", ast_json_object_iter_key(iter)) == 0) {
1791                         int prop_is_valid;
1792                         prop_is_valid = ast_ari_validate_string(
1793                                 ast_json_object_iter_value(iter));
1794                         if (!prop_is_valid) {
1795                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_application failed validation\n");
1796                                 res = 0;
1797                         }
1798                 } else
1799                 if (strcmp("destination_bridge", ast_json_object_iter_key(iter)) == 0) {
1800                         int prop_is_valid;
1801                         prop_is_valid = ast_ari_validate_string(
1802                                 ast_json_object_iter_value(iter));
1803                         if (!prop_is_valid) {
1804                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_bridge failed validation\n");
1805                                 res = 0;
1806                         }
1807                 } else
1808                 if (strcmp("destination_link_first_leg", ast_json_object_iter_key(iter)) == 0) {
1809                         int prop_is_valid;
1810                         prop_is_valid = ast_ari_validate_channel(
1811                                 ast_json_object_iter_value(iter));
1812                         if (!prop_is_valid) {
1813                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_first_leg failed validation\n");
1814                                 res = 0;
1815                         }
1816                 } else
1817                 if (strcmp("destination_link_second_leg", ast_json_object_iter_key(iter)) == 0) {
1818                         int prop_is_valid;
1819                         prop_is_valid = ast_ari_validate_channel(
1820                                 ast_json_object_iter_value(iter));
1821                         if (!prop_is_valid) {
1822                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_second_leg failed validation\n");
1823                                 res = 0;
1824                         }
1825                 } else
1826                 if (strcmp("destination_threeway_bridge", ast_json_object_iter_key(iter)) == 0) {
1827                         int prop_is_valid;
1828                         prop_is_valid = ast_ari_validate_bridge(
1829                                 ast_json_object_iter_value(iter));
1830                         if (!prop_is_valid) {
1831                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_bridge failed validation\n");
1832                                 res = 0;
1833                         }
1834                 } else
1835                 if (strcmp("destination_threeway_channel", ast_json_object_iter_key(iter)) == 0) {
1836                         int prop_is_valid;
1837                         prop_is_valid = ast_ari_validate_channel(
1838                                 ast_json_object_iter_value(iter));
1839                         if (!prop_is_valid) {
1840                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_channel failed validation\n");
1841                                 res = 0;
1842                         }
1843                 } else
1844                 if (strcmp("destination_type", ast_json_object_iter_key(iter)) == 0) {
1845                         int prop_is_valid;
1846                         has_destination_type = 1;
1847                         prop_is_valid = ast_ari_validate_string(
1848                                 ast_json_object_iter_value(iter));
1849                         if (!prop_is_valid) {
1850                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_type failed validation\n");
1851                                 res = 0;
1852                         }
1853                 } else
1854                 if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
1855                         int prop_is_valid;
1856                         has_is_external = 1;
1857                         prop_is_valid = ast_ari_validate_boolean(
1858                                 ast_json_object_iter_value(iter));
1859                         if (!prop_is_valid) {
1860                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field is_external failed validation\n");
1861                                 res = 0;
1862                         }
1863                 } else
1864                 if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
1865                         int prop_is_valid;
1866                         prop_is_valid = ast_ari_validate_channel(
1867                                 ast_json_object_iter_value(iter));
1868                         if (!prop_is_valid) {
1869                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field replace_channel failed validation\n");
1870                                 res = 0;
1871                         }
1872                 } else
1873                 if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
1874                         int prop_is_valid;
1875                         has_result = 1;
1876                         prop_is_valid = ast_ari_validate_string(
1877                                 ast_json_object_iter_value(iter));
1878                         if (!prop_is_valid) {
1879                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field result failed validation\n");
1880                                 res = 0;
1881                         }
1882                 } else
1883                 if (strcmp("transfer_target", ast_json_object_iter_key(iter)) == 0) {
1884                         int prop_is_valid;
1885                         prop_is_valid = ast_ari_validate_channel(
1886                                 ast_json_object_iter_value(iter));
1887                         if (!prop_is_valid) {
1888                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transfer_target failed validation\n");
1889                                 res = 0;
1890                         }
1891                 } else
1892                 if (strcmp("transferee", ast_json_object_iter_key(iter)) == 0) {
1893                         int prop_is_valid;
1894                         prop_is_valid = ast_ari_validate_channel(
1895                                 ast_json_object_iter_value(iter));
1896                         if (!prop_is_valid) {
1897                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferee failed validation\n");
1898                                 res = 0;
1899                         }
1900                 } else
1901                 if (strcmp("transferer_first_leg", ast_json_object_iter_key(iter)) == 0) {
1902                         int prop_is_valid;
1903                         has_transferer_first_leg = 1;
1904                         prop_is_valid = ast_ari_validate_channel(
1905                                 ast_json_object_iter_value(iter));
1906                         if (!prop_is_valid) {
1907                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg failed validation\n");
1908                                 res = 0;
1909                         }
1910                 } else
1911                 if (strcmp("transferer_first_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
1912                         int prop_is_valid;
1913                         prop_is_valid = ast_ari_validate_bridge(
1914                                 ast_json_object_iter_value(iter));
1915                         if (!prop_is_valid) {
1916                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg_bridge failed validation\n");
1917                                 res = 0;
1918                         }
1919                 } else
1920                 if (strcmp("transferer_second_leg", ast_json_object_iter_key(iter)) == 0) {
1921                         int prop_is_valid;
1922                         has_transferer_second_leg = 1;
1923                         prop_is_valid = ast_ari_validate_channel(
1924                                 ast_json_object_iter_value(iter));
1925                         if (!prop_is_valid) {
1926                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg failed validation\n");
1927                                 res = 0;
1928                         }
1929                 } else
1930                 if (strcmp("transferer_second_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
1931                         int prop_is_valid;
1932                         prop_is_valid = ast_ari_validate_bridge(
1933                                 ast_json_object_iter_value(iter));
1934                         if (!prop_is_valid) {
1935                                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg_bridge failed validation\n");
1936                                 res = 0;
1937                         }
1938                 } else
1939                 {
1940                         ast_log(LOG_ERROR,
1941                                 "ARI BridgeAttendedTransfer has undocumented field %s\n",
1942                                 ast_json_object_iter_key(iter));
1943                         res = 0;
1944                 }
1945         }
1946
1947         if (!has_type) {
1948                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field type\n");
1949                 res = 0;
1950         }
1951
1952         if (!has_application) {
1953                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field application\n");
1954                 res = 0;
1955         }
1956
1957         if (!has_destination_type) {
1958                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field destination_type\n");
1959                 res = 0;
1960         }
1961
1962         if (!has_is_external) {
1963                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field is_external\n");
1964                 res = 0;
1965         }
1966
1967         if (!has_result) {
1968                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field result\n");
1969                 res = 0;
1970         }
1971
1972         if (!has_transferer_first_leg) {
1973                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_first_leg\n");
1974                 res = 0;
1975         }
1976
1977         if (!has_transferer_second_leg) {
1978                 ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_second_leg\n");
1979                 res = 0;
1980         }
1981
1982         return res;
1983 }
1984
1985 ari_validator ast_ari_validate_bridge_attended_transfer_fn(void)
1986 {
1987         return ast_ari_validate_bridge_attended_transfer;
1988 }
1989
1990 int ast_ari_validate_bridge_blind_transfer(struct ast_json *json)
1991 {
1992         int res = 1;
1993         struct ast_json_iter *iter;
1994         int has_type = 0;
1995         int has_application = 0;
1996         int has_channel = 0;
1997         int has_context = 0;
1998         int has_exten = 0;
1999         int has_is_external = 0;
2000         int has_result = 0;
2001
2002         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2003                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2004                         int prop_is_valid;
2005                         has_type = 1;
2006                         prop_is_valid = ast_ari_validate_string(
2007                                 ast_json_object_iter_value(iter));
2008                         if (!prop_is_valid) {
2009                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field type failed validation\n");
2010                                 res = 0;
2011                         }
2012                 } else
2013                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2014                         int prop_is_valid;
2015                         has_application = 1;
2016                         prop_is_valid = ast_ari_validate_string(
2017                                 ast_json_object_iter_value(iter));
2018                         if (!prop_is_valid) {
2019                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field application failed validation\n");
2020                                 res = 0;
2021                         }
2022                 } else
2023                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2024                         int prop_is_valid;
2025                         prop_is_valid = ast_ari_validate_date(
2026                                 ast_json_object_iter_value(iter));
2027                         if (!prop_is_valid) {
2028                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field timestamp failed validation\n");
2029                                 res = 0;
2030                         }
2031                 } else
2032                 if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
2033                         int prop_is_valid;
2034                         prop_is_valid = ast_ari_validate_bridge(
2035                                 ast_json_object_iter_value(iter));
2036                         if (!prop_is_valid) {
2037                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field bridge failed validation\n");
2038                                 res = 0;
2039                         }
2040                 } else
2041                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2042                         int prop_is_valid;
2043                         has_channel = 1;
2044                         prop_is_valid = ast_ari_validate_channel(
2045                                 ast_json_object_iter_value(iter));
2046                         if (!prop_is_valid) {
2047                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field channel failed validation\n");
2048                                 res = 0;
2049                         }
2050                 } else
2051                 if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
2052                         int prop_is_valid;
2053                         has_context = 1;
2054                         prop_is_valid = ast_ari_validate_string(
2055                                 ast_json_object_iter_value(iter));
2056                         if (!prop_is_valid) {
2057                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field context failed validation\n");
2058                                 res = 0;
2059                         }
2060                 } else
2061                 if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
2062                         int prop_is_valid;
2063                         has_exten = 1;
2064                         prop_is_valid = ast_ari_validate_string(
2065                                 ast_json_object_iter_value(iter));
2066                         if (!prop_is_valid) {
2067                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field exten failed validation\n");
2068                                 res = 0;
2069                         }
2070                 } else
2071                 if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
2072                         int prop_is_valid;
2073                         has_is_external = 1;
2074                         prop_is_valid = ast_ari_validate_boolean(
2075                                 ast_json_object_iter_value(iter));
2076                         if (!prop_is_valid) {
2077                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field is_external failed validation\n");
2078                                 res = 0;
2079                         }
2080                 } else
2081                 if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
2082                         int prop_is_valid;
2083                         prop_is_valid = ast_ari_validate_channel(
2084                                 ast_json_object_iter_value(iter));
2085                         if (!prop_is_valid) {
2086                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field replace_channel failed validation\n");
2087                                 res = 0;
2088                         }
2089                 } else
2090                 if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
2091                         int prop_is_valid;
2092                         has_result = 1;
2093                         prop_is_valid = ast_ari_validate_string(
2094                                 ast_json_object_iter_value(iter));
2095                         if (!prop_is_valid) {
2096                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field result failed validation\n");
2097                                 res = 0;
2098                         }
2099                 } else
2100                 if (strcmp("transferee", ast_json_object_iter_key(iter)) == 0) {
2101                         int prop_is_valid;
2102                         prop_is_valid = ast_ari_validate_channel(
2103                                 ast_json_object_iter_value(iter));
2104                         if (!prop_is_valid) {
2105                                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field transferee failed validation\n");
2106                                 res = 0;
2107                         }
2108                 } else
2109                 {
2110                         ast_log(LOG_ERROR,
2111                                 "ARI BridgeBlindTransfer has undocumented field %s\n",
2112                                 ast_json_object_iter_key(iter));
2113                         res = 0;
2114                 }
2115         }
2116
2117         if (!has_type) {
2118                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field type\n");
2119                 res = 0;
2120         }
2121
2122         if (!has_application) {
2123                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field application\n");
2124                 res = 0;
2125         }
2126
2127         if (!has_channel) {
2128                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field channel\n");
2129                 res = 0;
2130         }
2131
2132         if (!has_context) {
2133                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field context\n");
2134                 res = 0;
2135         }
2136
2137         if (!has_exten) {
2138                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field exten\n");
2139                 res = 0;
2140         }
2141
2142         if (!has_is_external) {
2143                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field is_external\n");
2144                 res = 0;
2145         }
2146
2147         if (!has_result) {
2148                 ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field result\n");
2149                 res = 0;
2150         }
2151
2152         return res;
2153 }
2154
2155 ari_validator ast_ari_validate_bridge_blind_transfer_fn(void)
2156 {
2157         return ast_ari_validate_bridge_blind_transfer;
2158 }
2159
2160 int ast_ari_validate_bridge_created(struct ast_json *json)
2161 {
2162         int res = 1;
2163         struct ast_json_iter *iter;
2164         int has_type = 0;
2165         int has_application = 0;
2166         int has_bridge = 0;
2167
2168         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2169                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2170                         int prop_is_valid;
2171                         has_type = 1;
2172                         prop_is_valid = ast_ari_validate_string(
2173                                 ast_json_object_iter_value(iter));
2174                         if (!prop_is_valid) {
2175                                 ast_log(LOG_ERROR, "ARI BridgeCreated field type failed validation\n");
2176                                 res = 0;
2177                         }
2178                 } else
2179                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2180                         int prop_is_valid;
2181                         has_application = 1;
2182                         prop_is_valid = ast_ari_validate_string(
2183                                 ast_json_object_iter_value(iter));
2184                         if (!prop_is_valid) {
2185                                 ast_log(LOG_ERROR, "ARI BridgeCreated field application failed validation\n");
2186                                 res = 0;
2187                         }
2188                 } else
2189                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2190                         int prop_is_valid;
2191                         prop_is_valid = ast_ari_validate_date(
2192                                 ast_json_object_iter_value(iter));
2193                         if (!prop_is_valid) {
2194                                 ast_log(LOG_ERROR, "ARI BridgeCreated field timestamp failed validation\n");
2195                                 res = 0;
2196                         }
2197                 } else
2198                 if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
2199                         int prop_is_valid;
2200                         has_bridge = 1;
2201                         prop_is_valid = ast_ari_validate_bridge(
2202                                 ast_json_object_iter_value(iter));
2203                         if (!prop_is_valid) {
2204                                 ast_log(LOG_ERROR, "ARI BridgeCreated field bridge failed validation\n");
2205                                 res = 0;
2206                         }
2207                 } else
2208                 {
2209                         ast_log(LOG_ERROR,
2210                                 "ARI BridgeCreated has undocumented field %s\n",
2211                                 ast_json_object_iter_key(iter));
2212                         res = 0;
2213                 }
2214         }
2215
2216         if (!has_type) {
2217                 ast_log(LOG_ERROR, "ARI BridgeCreated missing required field type\n");
2218                 res = 0;
2219         }
2220
2221         if (!has_application) {
2222                 ast_log(LOG_ERROR, "ARI BridgeCreated missing required field application\n");
2223                 res = 0;
2224         }
2225
2226         if (!has_bridge) {
2227                 ast_log(LOG_ERROR, "ARI BridgeCreated missing required field bridge\n");
2228                 res = 0;
2229         }
2230
2231         return res;
2232 }
2233
2234 ari_validator ast_ari_validate_bridge_created_fn(void)
2235 {
2236         return ast_ari_validate_bridge_created;
2237 }
2238
2239 int ast_ari_validate_bridge_destroyed(struct ast_json *json)
2240 {
2241         int res = 1;
2242         struct ast_json_iter *iter;
2243         int has_type = 0;
2244         int has_application = 0;
2245         int has_bridge = 0;
2246
2247         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2248                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2249                         int prop_is_valid;
2250                         has_type = 1;
2251                         prop_is_valid = ast_ari_validate_string(
2252                                 ast_json_object_iter_value(iter));
2253                         if (!prop_is_valid) {
2254                                 ast_log(LOG_ERROR, "ARI BridgeDestroyed field type failed validation\n");
2255                                 res = 0;
2256                         }
2257                 } else
2258                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2259                         int prop_is_valid;
2260                         has_application = 1;
2261                         prop_is_valid = ast_ari_validate_string(
2262                                 ast_json_object_iter_value(iter));
2263                         if (!prop_is_valid) {
2264                                 ast_log(LOG_ERROR, "ARI BridgeDestroyed field application failed validation\n");
2265                                 res = 0;
2266                         }
2267                 } else
2268                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2269                         int prop_is_valid;
2270                         prop_is_valid = ast_ari_validate_date(
2271                                 ast_json_object_iter_value(iter));
2272                         if (!prop_is_valid) {
2273                                 ast_log(LOG_ERROR, "ARI BridgeDestroyed field timestamp failed validation\n");
2274                                 res = 0;
2275                         }
2276                 } else
2277                 if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
2278                         int prop_is_valid;
2279                         has_bridge = 1;
2280                         prop_is_valid = ast_ari_validate_bridge(
2281                                 ast_json_object_iter_value(iter));
2282                         if (!prop_is_valid) {
2283                                 ast_log(LOG_ERROR, "ARI BridgeDestroyed field bridge failed validation\n");
2284                                 res = 0;
2285                         }
2286                 } else
2287                 {
2288                         ast_log(LOG_ERROR,
2289                                 "ARI BridgeDestroyed has undocumented field %s\n",
2290                                 ast_json_object_iter_key(iter));
2291                         res = 0;
2292                 }
2293         }
2294
2295         if (!has_type) {
2296                 ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field type\n");
2297                 res = 0;
2298         }
2299
2300         if (!has_application) {
2301                 ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field application\n");
2302                 res = 0;
2303         }
2304
2305         if (!has_bridge) {
2306                 ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field bridge\n");
2307                 res = 0;
2308         }
2309
2310         return res;
2311 }
2312
2313 ari_validator ast_ari_validate_bridge_destroyed_fn(void)
2314 {
2315         return ast_ari_validate_bridge_destroyed;
2316 }
2317
2318 int ast_ari_validate_bridge_merged(struct ast_json *json)
2319 {
2320         int res = 1;
2321         struct ast_json_iter *iter;
2322         int has_type = 0;
2323         int has_application = 0;
2324         int has_bridge = 0;
2325         int has_bridge_from = 0;
2326
2327         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2328                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2329                         int prop_is_valid;
2330                         has_type = 1;
2331                         prop_is_valid = ast_ari_validate_string(
2332                                 ast_json_object_iter_value(iter));
2333                         if (!prop_is_valid) {
2334                                 ast_log(LOG_ERROR, "ARI BridgeMerged field type failed validation\n");
2335                                 res = 0;
2336                         }
2337                 } else
2338                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2339                         int prop_is_valid;
2340                         has_application = 1;
2341                         prop_is_valid = ast_ari_validate_string(
2342                                 ast_json_object_iter_value(iter));
2343                         if (!prop_is_valid) {
2344                                 ast_log(LOG_ERROR, "ARI BridgeMerged field application failed validation\n");
2345                                 res = 0;
2346                         }
2347                 } else
2348                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2349                         int prop_is_valid;
2350                         prop_is_valid = ast_ari_validate_date(
2351                                 ast_json_object_iter_value(iter));
2352                         if (!prop_is_valid) {
2353                                 ast_log(LOG_ERROR, "ARI BridgeMerged field timestamp failed validation\n");
2354                                 res = 0;
2355                         }
2356                 } else
2357                 if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
2358                         int prop_is_valid;
2359                         has_bridge = 1;
2360                         prop_is_valid = ast_ari_validate_bridge(
2361                                 ast_json_object_iter_value(iter));
2362                         if (!prop_is_valid) {
2363                                 ast_log(LOG_ERROR, "ARI BridgeMerged field bridge failed validation\n");
2364                                 res = 0;
2365                         }
2366                 } else
2367                 if (strcmp("bridge_from", ast_json_object_iter_key(iter)) == 0) {
2368                         int prop_is_valid;
2369                         has_bridge_from = 1;
2370                         prop_is_valid = ast_ari_validate_bridge(
2371                                 ast_json_object_iter_value(iter));
2372                         if (!prop_is_valid) {
2373                                 ast_log(LOG_ERROR, "ARI BridgeMerged field bridge_from failed validation\n");
2374                                 res = 0;
2375                         }
2376                 } else
2377                 {
2378                         ast_log(LOG_ERROR,
2379                                 "ARI BridgeMerged has undocumented field %s\n",
2380                                 ast_json_object_iter_key(iter));
2381                         res = 0;
2382                 }
2383         }
2384
2385         if (!has_type) {
2386                 ast_log(LOG_ERROR, "ARI BridgeMerged missing required field type\n");
2387                 res = 0;
2388         }
2389
2390         if (!has_application) {
2391                 ast_log(LOG_ERROR, "ARI BridgeMerged missing required field application\n");
2392                 res = 0;
2393         }
2394
2395         if (!has_bridge) {
2396                 ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge\n");
2397                 res = 0;
2398         }
2399
2400         if (!has_bridge_from) {
2401                 ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge_from\n");
2402                 res = 0;
2403         }
2404
2405         return res;
2406 }
2407
2408 ari_validator ast_ari_validate_bridge_merged_fn(void)
2409 {
2410         return ast_ari_validate_bridge_merged;
2411 }
2412
2413 int ast_ari_validate_channel_caller_id(struct ast_json *json)
2414 {
2415         int res = 1;
2416         struct ast_json_iter *iter;
2417         int has_type = 0;
2418         int has_application = 0;
2419         int has_caller_presentation = 0;
2420         int has_caller_presentation_txt = 0;
2421         int has_channel = 0;
2422
2423         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2424                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2425                         int prop_is_valid;
2426                         has_type = 1;
2427                         prop_is_valid = ast_ari_validate_string(
2428                                 ast_json_object_iter_value(iter));
2429                         if (!prop_is_valid) {
2430                                 ast_log(LOG_ERROR, "ARI ChannelCallerId field type failed validation\n");
2431                                 res = 0;
2432                         }
2433                 } else
2434                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2435                         int prop_is_valid;
2436                         has_application = 1;
2437                         prop_is_valid = ast_ari_validate_string(
2438                                 ast_json_object_iter_value(iter));
2439                         if (!prop_is_valid) {
2440                                 ast_log(LOG_ERROR, "ARI ChannelCallerId field application failed validation\n");
2441                                 res = 0;
2442                         }
2443                 } else
2444                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2445                         int prop_is_valid;
2446                         prop_is_valid = ast_ari_validate_date(
2447                                 ast_json_object_iter_value(iter));
2448                         if (!prop_is_valid) {
2449                                 ast_log(LOG_ERROR, "ARI ChannelCallerId field timestamp failed validation\n");
2450                                 res = 0;
2451                         }
2452                 } else
2453                 if (strcmp("caller_presentation", ast_json_object_iter_key(iter)) == 0) {
2454                         int prop_is_valid;
2455                         has_caller_presentation = 1;
2456                         prop_is_valid = ast_ari_validate_int(
2457                                 ast_json_object_iter_value(iter));
2458                         if (!prop_is_valid) {
2459                                 ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation failed validation\n");
2460                                 res = 0;
2461                         }
2462                 } else
2463                 if (strcmp("caller_presentation_txt", ast_json_object_iter_key(iter)) == 0) {
2464                         int prop_is_valid;
2465                         has_caller_presentation_txt = 1;
2466                         prop_is_valid = ast_ari_validate_string(
2467                                 ast_json_object_iter_value(iter));
2468                         if (!prop_is_valid) {
2469                                 ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation_txt failed validation\n");
2470                                 res = 0;
2471                         }
2472                 } else
2473                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2474                         int prop_is_valid;
2475                         has_channel = 1;
2476                         prop_is_valid = ast_ari_validate_channel(
2477                                 ast_json_object_iter_value(iter));
2478                         if (!prop_is_valid) {
2479                                 ast_log(LOG_ERROR, "ARI ChannelCallerId field channel failed validation\n");
2480                                 res = 0;
2481                         }
2482                 } else
2483                 {
2484                         ast_log(LOG_ERROR,
2485                                 "ARI ChannelCallerId has undocumented field %s\n",
2486                                 ast_json_object_iter_key(iter));
2487                         res = 0;
2488                 }
2489         }
2490
2491         if (!has_type) {
2492                 ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field type\n");
2493                 res = 0;
2494         }
2495
2496         if (!has_application) {
2497                 ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field application\n");
2498                 res = 0;
2499         }
2500
2501         if (!has_caller_presentation) {
2502                 ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation\n");
2503                 res = 0;
2504         }
2505
2506         if (!has_caller_presentation_txt) {
2507                 ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation_txt\n");
2508                 res = 0;
2509         }
2510
2511         if (!has_channel) {
2512                 ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field channel\n");
2513                 res = 0;
2514         }
2515
2516         return res;
2517 }
2518
2519 ari_validator ast_ari_validate_channel_caller_id_fn(void)
2520 {
2521         return ast_ari_validate_channel_caller_id;
2522 }
2523
2524 int ast_ari_validate_channel_connected_line(struct ast_json *json)
2525 {
2526         int res = 1;
2527         struct ast_json_iter *iter;
2528         int has_type = 0;
2529         int has_application = 0;
2530         int has_channel = 0;
2531
2532         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2533                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2534                         int prop_is_valid;
2535                         has_type = 1;
2536                         prop_is_valid = ast_ari_validate_string(
2537                                 ast_json_object_iter_value(iter));
2538                         if (!prop_is_valid) {
2539                                 ast_log(LOG_ERROR, "ARI ChannelConnectedLine field type failed validation\n");
2540                                 res = 0;
2541                         }
2542                 } else
2543                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2544                         int prop_is_valid;
2545                         has_application = 1;
2546                         prop_is_valid = ast_ari_validate_string(
2547                                 ast_json_object_iter_value(iter));
2548                         if (!prop_is_valid) {
2549                                 ast_log(LOG_ERROR, "ARI ChannelConnectedLine field application failed validation\n");
2550                                 res = 0;
2551                         }
2552                 } else
2553                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2554                         int prop_is_valid;
2555                         prop_is_valid = ast_ari_validate_date(
2556                                 ast_json_object_iter_value(iter));
2557                         if (!prop_is_valid) {
2558                                 ast_log(LOG_ERROR, "ARI ChannelConnectedLine field timestamp failed validation\n");
2559                                 res = 0;
2560                         }
2561                 } else
2562                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2563                         int prop_is_valid;
2564                         has_channel = 1;
2565                         prop_is_valid = ast_ari_validate_channel(
2566                                 ast_json_object_iter_value(iter));
2567                         if (!prop_is_valid) {
2568                                 ast_log(LOG_ERROR, "ARI ChannelConnectedLine field channel failed validation\n");
2569                                 res = 0;
2570                         }
2571                 } else
2572                 {
2573                         ast_log(LOG_ERROR,
2574                                 "ARI ChannelConnectedLine has undocumented field %s\n",
2575                                 ast_json_object_iter_key(iter));
2576                         res = 0;
2577                 }
2578         }
2579
2580         if (!has_type) {
2581                 ast_log(LOG_ERROR, "ARI ChannelConnectedLine missing required field type\n");
2582                 res = 0;
2583         }
2584
2585         if (!has_application) {
2586                 ast_log(LOG_ERROR, "ARI ChannelConnectedLine missing required field application\n");
2587                 res = 0;
2588         }
2589
2590         if (!has_channel) {
2591                 ast_log(LOG_ERROR, "ARI ChannelConnectedLine missing required field channel\n");
2592                 res = 0;
2593         }
2594
2595         return res;
2596 }
2597
2598 ari_validator ast_ari_validate_channel_connected_line_fn(void)
2599 {
2600         return ast_ari_validate_channel_connected_line;
2601 }
2602
2603 int ast_ari_validate_channel_created(struct ast_json *json)
2604 {
2605         int res = 1;
2606         struct ast_json_iter *iter;
2607         int has_type = 0;
2608         int has_application = 0;
2609         int has_channel = 0;
2610
2611         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2612                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2613                         int prop_is_valid;
2614                         has_type = 1;
2615                         prop_is_valid = ast_ari_validate_string(
2616                                 ast_json_object_iter_value(iter));
2617                         if (!prop_is_valid) {
2618                                 ast_log(LOG_ERROR, "ARI ChannelCreated field type failed validation\n");
2619                                 res = 0;
2620                         }
2621                 } else
2622                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2623                         int prop_is_valid;
2624                         has_application = 1;
2625                         prop_is_valid = ast_ari_validate_string(
2626                                 ast_json_object_iter_value(iter));
2627                         if (!prop_is_valid) {
2628                                 ast_log(LOG_ERROR, "ARI ChannelCreated field application failed validation\n");
2629                                 res = 0;
2630                         }
2631                 } else
2632                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2633                         int prop_is_valid;
2634                         prop_is_valid = ast_ari_validate_date(
2635                                 ast_json_object_iter_value(iter));
2636                         if (!prop_is_valid) {
2637                                 ast_log(LOG_ERROR, "ARI ChannelCreated field timestamp failed validation\n");
2638                                 res = 0;
2639                         }
2640                 } else
2641                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2642                         int prop_is_valid;
2643                         has_channel = 1;
2644                         prop_is_valid = ast_ari_validate_channel(
2645                                 ast_json_object_iter_value(iter));
2646                         if (!prop_is_valid) {
2647                                 ast_log(LOG_ERROR, "ARI ChannelCreated field channel failed validation\n");
2648                                 res = 0;
2649                         }
2650                 } else
2651                 {
2652                         ast_log(LOG_ERROR,
2653                                 "ARI ChannelCreated has undocumented field %s\n",
2654                                 ast_json_object_iter_key(iter));
2655                         res = 0;
2656                 }
2657         }
2658
2659         if (!has_type) {
2660                 ast_log(LOG_ERROR, "ARI ChannelCreated missing required field type\n");
2661                 res = 0;
2662         }
2663
2664         if (!has_application) {
2665                 ast_log(LOG_ERROR, "ARI ChannelCreated missing required field application\n");
2666                 res = 0;
2667         }
2668
2669         if (!has_channel) {
2670                 ast_log(LOG_ERROR, "ARI ChannelCreated missing required field channel\n");
2671                 res = 0;
2672         }
2673
2674         return res;
2675 }
2676
2677 ari_validator ast_ari_validate_channel_created_fn(void)
2678 {
2679         return ast_ari_validate_channel_created;
2680 }
2681
2682 int ast_ari_validate_channel_destroyed(struct ast_json *json)
2683 {
2684         int res = 1;
2685         struct ast_json_iter *iter;
2686         int has_type = 0;
2687         int has_application = 0;
2688         int has_cause = 0;
2689         int has_cause_txt = 0;
2690         int has_channel = 0;
2691
2692         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2693                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2694                         int prop_is_valid;
2695                         has_type = 1;
2696                         prop_is_valid = ast_ari_validate_string(
2697                                 ast_json_object_iter_value(iter));
2698                         if (!prop_is_valid) {
2699                                 ast_log(LOG_ERROR, "ARI ChannelDestroyed field type failed validation\n");
2700                                 res = 0;
2701                         }
2702                 } else
2703                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2704                         int prop_is_valid;
2705                         has_application = 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 ChannelDestroyed field application failed validation\n");
2710                                 res = 0;
2711                         }
2712                 } else
2713                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2714                         int prop_is_valid;
2715                         prop_is_valid = ast_ari_validate_date(
2716                                 ast_json_object_iter_value(iter));
2717                         if (!prop_is_valid) {
2718                                 ast_log(LOG_ERROR, "ARI ChannelDestroyed field timestamp failed validation\n");
2719                                 res = 0;
2720                         }
2721                 } else
2722                 if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
2723                         int prop_is_valid;
2724                         has_cause = 1;
2725                         prop_is_valid = ast_ari_validate_int(
2726                                 ast_json_object_iter_value(iter));
2727                         if (!prop_is_valid) {
2728                                 ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause failed validation\n");
2729                                 res = 0;
2730                         }
2731                 } else
2732                 if (strcmp("cause_txt", ast_json_object_iter_key(iter)) == 0) {
2733                         int prop_is_valid;
2734                         has_cause_txt = 1;
2735                         prop_is_valid = ast_ari_validate_string(
2736                                 ast_json_object_iter_value(iter));
2737                         if (!prop_is_valid) {
2738                                 ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause_txt failed validation\n");
2739                                 res = 0;
2740                         }
2741                 } else
2742                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2743                         int prop_is_valid;
2744                         has_channel = 1;
2745                         prop_is_valid = ast_ari_validate_channel(
2746                                 ast_json_object_iter_value(iter));
2747                         if (!prop_is_valid) {
2748                                 ast_log(LOG_ERROR, "ARI ChannelDestroyed field channel failed validation\n");
2749                                 res = 0;
2750                         }
2751                 } else
2752                 {
2753                         ast_log(LOG_ERROR,
2754                                 "ARI ChannelDestroyed has undocumented field %s\n",
2755                                 ast_json_object_iter_key(iter));
2756                         res = 0;
2757                 }
2758         }
2759
2760         if (!has_type) {
2761                 ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field type\n");
2762                 res = 0;
2763         }
2764
2765         if (!has_application) {
2766                 ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field application\n");
2767                 res = 0;
2768         }
2769
2770         if (!has_cause) {
2771                 ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause\n");
2772                 res = 0;
2773         }
2774
2775         if (!has_cause_txt) {
2776                 ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause_txt\n");
2777                 res = 0;
2778         }
2779
2780         if (!has_channel) {
2781                 ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field channel\n");
2782                 res = 0;
2783         }
2784
2785         return res;
2786 }
2787
2788 ari_validator ast_ari_validate_channel_destroyed_fn(void)
2789 {
2790         return ast_ari_validate_channel_destroyed;
2791 }
2792
2793 int ast_ari_validate_channel_dialplan(struct ast_json *json)
2794 {
2795         int res = 1;
2796         struct ast_json_iter *iter;
2797         int has_type = 0;
2798         int has_application = 0;
2799         int has_channel = 0;
2800         int has_dialplan_app = 0;
2801         int has_dialplan_app_data = 0;
2802
2803         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2804                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2805                         int prop_is_valid;
2806                         has_type = 1;
2807                         prop_is_valid = ast_ari_validate_string(
2808                                 ast_json_object_iter_value(iter));
2809                         if (!prop_is_valid) {
2810                                 ast_log(LOG_ERROR, "ARI ChannelDialplan field type failed validation\n");
2811                                 res = 0;
2812                         }
2813                 } else
2814                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2815                         int prop_is_valid;
2816                         has_application = 1;
2817                         prop_is_valid = ast_ari_validate_string(
2818                                 ast_json_object_iter_value(iter));
2819                         if (!prop_is_valid) {
2820                                 ast_log(LOG_ERROR, "ARI ChannelDialplan field application failed validation\n");
2821                                 res = 0;
2822                         }
2823                 } else
2824                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2825                         int prop_is_valid;
2826                         prop_is_valid = ast_ari_validate_date(
2827                                 ast_json_object_iter_value(iter));
2828                         if (!prop_is_valid) {
2829                                 ast_log(LOG_ERROR, "ARI ChannelDialplan field timestamp failed validation\n");
2830                                 res = 0;
2831                         }
2832                 } else
2833                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2834                         int prop_is_valid;
2835                         has_channel = 1;
2836                         prop_is_valid = ast_ari_validate_channel(
2837                                 ast_json_object_iter_value(iter));
2838                         if (!prop_is_valid) {
2839                                 ast_log(LOG_ERROR, "ARI ChannelDialplan field channel failed validation\n");
2840                                 res = 0;
2841                         }
2842                 } else
2843                 if (strcmp("dialplan_app", ast_json_object_iter_key(iter)) == 0) {
2844                         int prop_is_valid;
2845                         has_dialplan_app = 1;
2846                         prop_is_valid = ast_ari_validate_string(
2847                                 ast_json_object_iter_value(iter));
2848                         if (!prop_is_valid) {
2849                                 ast_log(LOG_ERROR, "ARI ChannelDialplan field dialplan_app failed validation\n");
2850                                 res = 0;
2851                         }
2852                 } else
2853                 if (strcmp("dialplan_app_data", ast_json_object_iter_key(iter)) == 0) {
2854                         int prop_is_valid;
2855                         has_dialplan_app_data = 1;
2856                         prop_is_valid = ast_ari_validate_string(
2857                                 ast_json_object_iter_value(iter));
2858                         if (!prop_is_valid) {
2859                                 ast_log(LOG_ERROR, "ARI ChannelDialplan field dialplan_app_data failed validation\n");
2860                                 res = 0;
2861                         }
2862                 } else
2863                 {
2864                         ast_log(LOG_ERROR,
2865                                 "ARI ChannelDialplan has undocumented field %s\n",
2866                                 ast_json_object_iter_key(iter));
2867                         res = 0;
2868                 }
2869         }
2870
2871         if (!has_type) {
2872                 ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field type\n");
2873                 res = 0;
2874         }
2875
2876         if (!has_application) {
2877                 ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field application\n");
2878                 res = 0;
2879         }
2880
2881         if (!has_channel) {
2882                 ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field channel\n");
2883                 res = 0;
2884         }
2885
2886         if (!has_dialplan_app) {
2887                 ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field dialplan_app\n");
2888                 res = 0;
2889         }
2890
2891         if (!has_dialplan_app_data) {
2892                 ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field dialplan_app_data\n");
2893                 res = 0;
2894         }
2895
2896         return res;
2897 }
2898
2899 ari_validator ast_ari_validate_channel_dialplan_fn(void)
2900 {
2901         return ast_ari_validate_channel_dialplan;
2902 }
2903
2904 int ast_ari_validate_channel_dtmf_received(struct ast_json *json)
2905 {
2906         int res = 1;
2907         struct ast_json_iter *iter;
2908         int has_type = 0;
2909         int has_application = 0;
2910         int has_channel = 0;
2911         int has_digit = 0;
2912         int has_duration_ms = 0;
2913
2914         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
2915                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
2916                         int prop_is_valid;
2917                         has_type = 1;
2918                         prop_is_valid = ast_ari_validate_string(
2919                                 ast_json_object_iter_value(iter));
2920                         if (!prop_is_valid) {
2921                                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field type failed validation\n");
2922                                 res = 0;
2923                         }
2924                 } else
2925                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
2926                         int prop_is_valid;
2927                         has_application = 1;
2928                         prop_is_valid = ast_ari_validate_string(
2929                                 ast_json_object_iter_value(iter));
2930                         if (!prop_is_valid) {
2931                                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field application failed validation\n");
2932                                 res = 0;
2933                         }
2934                 } else
2935                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
2936                         int prop_is_valid;
2937                         prop_is_valid = ast_ari_validate_date(
2938                                 ast_json_object_iter_value(iter));
2939                         if (!prop_is_valid) {
2940                                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field timestamp failed validation\n");
2941                                 res = 0;
2942                         }
2943                 } else
2944                 if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
2945                         int prop_is_valid;
2946                         has_channel = 1;
2947                         prop_is_valid = ast_ari_validate_channel(
2948                                 ast_json_object_iter_value(iter));
2949                         if (!prop_is_valid) {
2950                                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field channel failed validation\n");
2951                                 res = 0;
2952                         }
2953                 } else
2954                 if (strcmp("digit", ast_json_object_iter_key(iter)) == 0) {
2955                         int prop_is_valid;
2956                         has_digit = 1;
2957                         prop_is_valid = ast_ari_validate_string(
2958                                 ast_json_object_iter_value(iter));
2959                         if (!prop_is_valid) {
2960                                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field digit failed validation\n");
2961                                 res = 0;
2962                         }
2963                 } else
2964                 if (strcmp("duration_ms", ast_json_object_iter_key(iter)) == 0) {
2965                         int prop_is_valid;
2966                         has_duration_ms = 1;
2967                         prop_is_valid = ast_ari_validate_int(
2968                                 ast_json_object_iter_value(iter));
2969                         if (!prop_is_valid) {
2970                                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field duration_ms failed validation\n");
2971                                 res = 0;
2972                         }
2973                 } else
2974                 {
2975                         ast_log(LOG_ERROR,
2976                                 "ARI ChannelDtmfReceived has undocumented field %s\n",
2977                                 ast_json_object_iter_key(iter));
2978                         res = 0;
2979                 }
2980         }
2981
2982         if (!has_type) {
2983                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field type\n");
2984                 res = 0;
2985         }
2986
2987         if (!has_application) {
2988                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field application\n");
2989                 res = 0;
2990         }
2991
2992         if (!has_channel) {
2993                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field channel\n");
2994                 res = 0;
2995         }
2996
2997         if (!has_digit) {
2998                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field digit\n");
2999                 res = 0;
3000         }
3001
3002         if (!has_duration_ms) {
3003                 ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field duration_ms\n");
3004                 res = 0;
3005         }
3006
3007         return res;
3008 }
3009
3010 ari_validator ast_ari_validate_channel_dtmf_received_fn(void)
3011 {
3012         return ast_ari_validate_channel_dtmf_received;
3013 }
3014
3015 int ast_ari_validate_channel_entered_bridge(struct ast_json *json)
3016 {
3017         int res = 1;
3018         struct ast_json_iter *iter;
3019         int has_type = 0;
3020         int has_application = 0;
3021         int has_bridge = 0;
3022
3023         for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
3024                 if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
3025                         int prop_is_valid;
3026                         has_type = 1;
3027                         prop_is_valid = ast_ari_validate_string(
3028                                 ast_json_object_iter_value(iter));
3029                         if (!prop_is_valid) {
3030                                 ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field type failed validation\n");
3031                                 res = 0;
3032                         }
3033                 } else
3034                 if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
3035                         int prop_is_valid;
3036                         has_application = 1;
3037                         prop_is_valid = ast_ari_validate_string(
3038                                 ast_json_object_iter_value(iter));
3039                         if (!prop_is_valid) {
3040                                 ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field application failed validation\n");
3041                                 res = 0;
3042                         }
3043                 } else
3044                 if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
3045                         int prop_is_valid;
3046                         prop_is_valid = ast_ari_validate_date(
3047                                 ast_json_object_iter_value(iter));
3048                         if (!prop_is_valid) {
3049                                 ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field timestamp failed validation\n");
3050                                 res = 0;
3051                         }
3052                 } else
3053                 if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
3054                         int prop_is_valid;