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