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