Asterisk - The Open Source Telephony Project GIT-master-6144b6b
Loading...
Searching...
No Matches
res_ari_bridges.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2012 - 2013, Digium, Inc.
5 *
6 * David M. Lee, II <dlee@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*
20 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21 * !!!!! DO NOT EDIT !!!!!
22 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23 * This file is generated by a mustache template. Please see the original
24 * template in rest-api-templates/res_ari_resource.c.mustache
25 */
26
27/*! \file
28 *
29 * \brief Bridge resources
30 *
31 * \author David M. Lee, II <dlee@digium.com>
32 */
33
34/*** MODULEINFO
35 <depend type="module">res_ari</depend>
36 <depend type="module">res_ari_model</depend>
37 <depend type="module">res_stasis</depend>
38 <depend type="module">res_stasis_recording</depend>
39 <depend type="module">res_stasis_playback</depend>
40 <support_level>core</support_level>
41 ***/
42
43#include "asterisk.h"
44
45#include "asterisk/app.h"
46#include "asterisk/module.h"
47#include "asterisk/stasis_app.h"
49#if defined(AST_DEVMODE)
51#endif
52
53#define MAX_VALS 128
54
55/*!
56 * \brief Parameter parsing callback for /bridges.
57 * \param ser TCP/TLS session object
58 * \param get_params GET parameters in the HTTP request.
59 * \param path_vars Path variables extracted from the request.
60 * \param headers HTTP headers.
61 * \param body
62 * \param[out] response Response to the HTTP request.
63 */
66 struct ast_variable *get_params, struct ast_variable *path_vars,
67 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
68{
70#if defined(AST_DEVMODE)
71 int is_valid;
72 int code;
73#endif /* AST_DEVMODE */
74
75 ast_ari_bridges_list(headers, &args, response);
76#if defined(AST_DEVMODE)
77 code = response->response_code;
78
79 switch (code) {
80 case 0: /* Implementation is still a stub, or the code wasn't set */
81 is_valid = response->message == NULL;
82 break;
83 case 500: /* Internal Server Error */
84 case 501: /* Not Implemented */
85 is_valid = 1;
86 break;
87 default:
88 if (200 <= code && code <= 299) {
89 is_valid = ast_ari_validate_list(response->message,
91 } else {
92 ast_log(LOG_ERROR, "Invalid error response %d for /bridges\n", code);
93 is_valid = 0;
94 }
95 }
96
97 if (!is_valid) {
98 ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
99 ast_ari_response_error(response, 500,
100 "Internal Server Error", "Response validation failed");
101 }
102#endif /* AST_DEVMODE */
103
104fin: __attribute__((unused))
105 return;
106}
108 struct ast_json *body,
110{
111 struct ast_json *field;
112 /* Parse query parameters out of it */
113 field = ast_json_object_get(body, "type");
114 if (field) {
115 args->type = ast_json_string_get(field);
116 }
117 field = ast_json_object_get(body, "bridgeId");
118 if (field) {
119 args->bridge_id = ast_json_string_get(field);
120 }
121 field = ast_json_object_get(body, "name");
122 if (field) {
123 args->name = ast_json_string_get(field);
124 }
125 return 0;
126}
127
128/*!
129 * \brief Parameter parsing callback for /bridges.
130 * \param ser TCP/TLS session object
131 * \param get_params GET parameters in the HTTP request.
132 * \param path_vars Path variables extracted from the request.
133 * \param headers HTTP headers.
134 * \param body
135 * \param[out] response Response to the HTTP request.
136 */
138 struct ast_tcptls_session_instance *ser,
139 struct ast_variable *get_params, struct ast_variable *path_vars,
140 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
141{
143 struct ast_variable *i;
144#if defined(AST_DEVMODE)
145 int is_valid;
146 int code;
147#endif /* AST_DEVMODE */
148
149 for (i = get_params; i; i = i->next) {
150 if (strcmp(i->name, "type") == 0) {
151 args.type = (i->value);
152 } else
153 if (strcmp(i->name, "bridgeId") == 0) {
154 args.bridge_id = (i->value);
155 } else
156 if (strcmp(i->name, "name") == 0) {
157 args.name = (i->value);
158 } else
159 {}
160 }
161 args.variables = body;
162 ast_ari_bridges_create(headers, &args, response);
163#if defined(AST_DEVMODE)
164 code = response->response_code;
165
166 switch (code) {
167 case 0: /* Implementation is still a stub, or the code wasn't set */
168 is_valid = response->message == NULL;
169 break;
170 case 500: /* Internal Server Error */
171 case 501: /* Not Implemented */
172 case 409: /* Bridge with the same bridgeId already exists */
173 is_valid = 1;
174 break;
175 default:
176 if (200 <= code && code <= 299) {
177 is_valid = ast_ari_validate_bridge(
178 response->message);
179 } else {
180 ast_log(LOG_ERROR, "Invalid error response %d for /bridges\n", code);
181 is_valid = 0;
182 }
183 }
184
185 if (!is_valid) {
186 ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
187 ast_ari_response_error(response, 500,
188 "Internal Server Error", "Response validation failed");
189 }
190#endif /* AST_DEVMODE */
191
192fin: __attribute__((unused))
193 return;
194}
196 struct ast_json *body,
198{
199 struct ast_json *field;
200 /* Parse query parameters out of it */
201 field = ast_json_object_get(body, "type");
202 if (field) {
203 args->type = ast_json_string_get(field);
204 }
205 field = ast_json_object_get(body, "name");
206 if (field) {
207 args->name = ast_json_string_get(field);
208 }
209 return 0;
210}
211
212/*!
213 * \brief Parameter parsing callback for /bridges/{bridgeId}.
214 * \param ser TCP/TLS session object
215 * \param get_params GET parameters in the HTTP request.
216 * \param path_vars Path variables extracted from the request.
217 * \param headers HTTP headers.
218 * \param body
219 * \param[out] response Response to the HTTP request.
220 */
222 struct ast_tcptls_session_instance *ser,
223 struct ast_variable *get_params, struct ast_variable *path_vars,
224 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
225{
227 struct ast_variable *i;
228#if defined(AST_DEVMODE)
229 int is_valid;
230 int code;
231#endif /* AST_DEVMODE */
232
233 for (i = get_params; i; i = i->next) {
234 if (strcmp(i->name, "type") == 0) {
235 args.type = (i->value);
236 } else
237 if (strcmp(i->name, "name") == 0) {
238 args.name = (i->value);
239 } else
240 {}
241 }
242 for (i = path_vars; i; i = i->next) {
243 if (strcmp(i->name, "bridgeId") == 0) {
244 args.bridge_id = (i->value);
245 } else
246 {}
247 }
248 args.variables = body;
249 ast_ari_bridges_create_with_id(headers, &args, response);
250#if defined(AST_DEVMODE)
251 code = response->response_code;
252
253 switch (code) {
254 case 0: /* Implementation is still a stub, or the code wasn't set */
255 is_valid = response->message == NULL;
256 break;
257 case 500: /* Internal Server Error */
258 case 501: /* Not Implemented */
259 case 409: /* Bridge with the same bridgeId already exists */
260 is_valid = 1;
261 break;
262 default:
263 if (200 <= code && code <= 299) {
264 is_valid = ast_ari_validate_bridge(
265 response->message);
266 } else {
267 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
268 is_valid = 0;
269 }
270 }
271
272 if (!is_valid) {
273 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
274 ast_ari_response_error(response, 500,
275 "Internal Server Error", "Response validation failed");
276 }
277#endif /* AST_DEVMODE */
278
279fin: __attribute__((unused))
280 return;
281}
282/*!
283 * \brief Parameter parsing callback for /bridges/{bridgeId}.
284 * \param ser TCP/TLS session object
285 * \param get_params GET parameters in the HTTP request.
286 * \param path_vars Path variables extracted from the request.
287 * \param headers HTTP headers.
288 * \param body
289 * \param[out] response Response to the HTTP request.
290 */
292 struct ast_tcptls_session_instance *ser,
293 struct ast_variable *get_params, struct ast_variable *path_vars,
294 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
295{
296 struct ast_ari_bridges_get_args args = {};
297 struct ast_variable *i;
298#if defined(AST_DEVMODE)
299 int is_valid;
300 int code;
301#endif /* AST_DEVMODE */
302
303 for (i = path_vars; i; i = i->next) {
304 if (strcmp(i->name, "bridgeId") == 0) {
305 args.bridge_id = (i->value);
306 } else
307 {}
308 }
309 ast_ari_bridges_get(headers, &args, response);
310#if defined(AST_DEVMODE)
311 code = response->response_code;
312
313 switch (code) {
314 case 0: /* Implementation is still a stub, or the code wasn't set */
315 is_valid = response->message == NULL;
316 break;
317 case 500: /* Internal Server Error */
318 case 501: /* Not Implemented */
319 case 404: /* Bridge not found */
320 is_valid = 1;
321 break;
322 default:
323 if (200 <= code && code <= 299) {
324 is_valid = ast_ari_validate_bridge(
325 response->message);
326 } else {
327 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
328 is_valid = 0;
329 }
330 }
331
332 if (!is_valid) {
333 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
334 ast_ari_response_error(response, 500,
335 "Internal Server Error", "Response validation failed");
336 }
337#endif /* AST_DEVMODE */
338
339fin: __attribute__((unused))
340 return;
341}
342/*!
343 * \brief Parameter parsing callback for /bridges/{bridgeId}.
344 * \param ser TCP/TLS session object
345 * \param get_params GET parameters in the HTTP request.
346 * \param path_vars Path variables extracted from the request.
347 * \param headers HTTP headers.
348 * \param body
349 * \param[out] response Response to the HTTP request.
350 */
352 struct ast_tcptls_session_instance *ser,
353 struct ast_variable *get_params, struct ast_variable *path_vars,
354 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
355{
357 struct ast_variable *i;
358#if defined(AST_DEVMODE)
359 int is_valid;
360 int code;
361#endif /* AST_DEVMODE */
362
363 for (i = path_vars; i; i = i->next) {
364 if (strcmp(i->name, "bridgeId") == 0) {
365 args.bridge_id = (i->value);
366 } else
367 {}
368 }
369 ast_ari_bridges_destroy(headers, &args, response);
370#if defined(AST_DEVMODE)
371 code = response->response_code;
372
373 switch (code) {
374 case 0: /* Implementation is still a stub, or the code wasn't set */
375 is_valid = response->message == NULL;
376 break;
377 case 500: /* Internal Server Error */
378 case 501: /* Not Implemented */
379 case 404: /* Bridge not found */
380 is_valid = 1;
381 break;
382 default:
383 if (200 <= code && code <= 299) {
384 is_valid = ast_ari_validate_void(
385 response->message);
386 } else {
387 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
388 is_valid = 0;
389 }
390 }
391
392 if (!is_valid) {
393 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
394 ast_ari_response_error(response, 500,
395 "Internal Server Error", "Response validation failed");
396 }
397#endif /* AST_DEVMODE */
398
399fin: __attribute__((unused))
400 return;
401}
403 struct ast_json *body,
405{
406 struct ast_json *field;
407 /* Parse query parameters out of it */
408 field = ast_json_object_get(body, "variable");
409 if (field) {
410 args->variable = ast_json_string_get(field);
411 }
412 return 0;
413}
414
415/*!
416 * \brief Parameter parsing callback for /bridges/{bridgeId}/variable.
417 * \param ser TCP/TLS session object
418 * \param get_params GET parameters in the HTTP request.
419 * \param path_vars Path variables extracted from the request.
420 * \param headers HTTP headers.
421 * \param body
422 * \param[out] response Response to the HTTP request.
423 */
425 struct ast_tcptls_session_instance *ser,
426 struct ast_variable *get_params, struct ast_variable *path_vars,
427 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
428{
430 struct ast_variable *i;
431#if defined(AST_DEVMODE)
432 int is_valid;
433 int code;
434#endif /* AST_DEVMODE */
435
436 for (i = get_params; i; i = i->next) {
437 if (strcmp(i->name, "variable") == 0) {
438 args.variable = (i->value);
439 } else
440 {}
441 }
442 for (i = path_vars; i; i = i->next) {
443 if (strcmp(i->name, "bridgeId") == 0) {
444 args.bridge_id = (i->value);
445 } else
446 {}
447 }
450 goto fin;
451 }
452 ast_ari_bridges_get_bridge_var(headers, &args, response);
453#if defined(AST_DEVMODE)
454 code = response->response_code;
455
456 switch (code) {
457 case 0: /* Implementation is still a stub, or the code wasn't set */
458 is_valid = response->message == NULL;
459 break;
460 case 500: /* Internal Server Error */
461 case 501: /* Not Implemented */
462 case 400: /* Missing variable parameter. */
463 case 404: /* Bridge or variable not found */
464 case 409: /* Bridge not in a Stasis application */
465 is_valid = 1;
466 break;
467 default:
468 if (200 <= code && code <= 299) {
469 is_valid = ast_ari_validate_variable(
470 response->message);
471 } else {
472 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/variable\n", code);
473 is_valid = 0;
474 }
475 }
476
477 if (!is_valid) {
478 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/variable\n");
479 ast_ari_response_error(response, 500,
480 "Internal Server Error", "Response validation failed");
481 }
482#endif /* AST_DEVMODE */
483
484fin: __attribute__((unused))
485 return;
486}
488 struct ast_json *body,
490{
491 struct ast_json *field;
492 /* Parse query parameters out of it */
493 field = ast_json_object_get(body, "variable");
494 if (field) {
495 args->variable = ast_json_string_get(field);
496 }
497 field = ast_json_object_get(body, "value");
498 if (field) {
499 args->value = ast_json_string_get(field);
500 }
501 field = ast_json_object_get(body, "report_events");
502 if (field) {
503 args->report_events = ast_json_is_true(field);
504 }
505 return 0;
506}
507
508/*!
509 * \brief Parameter parsing callback for /bridges/{bridgeId}/variable.
510 * \param ser TCP/TLS session object
511 * \param get_params GET parameters in the HTTP request.
512 * \param path_vars Path variables extracted from the request.
513 * \param headers HTTP headers.
514 * \param body
515 * \param[out] response Response to the HTTP request.
516 */
518 struct ast_tcptls_session_instance *ser,
519 struct ast_variable *get_params, struct ast_variable *path_vars,
520 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
521{
523 struct ast_variable *i;
524#if defined(AST_DEVMODE)
525 int is_valid;
526 int code;
527#endif /* AST_DEVMODE */
528
529 for (i = get_params; i; i = i->next) {
530 if (strcmp(i->name, "variable") == 0) {
531 args.variable = (i->value);
532 } else
533 if (strcmp(i->name, "value") == 0) {
534 args.value = (i->value);
535 } else
536 if (strcmp(i->name, "report_events") == 0) {
537 args.report_events = ast_true(i->value);
538 } else
539 {}
540 }
541 for (i = path_vars; i; i = i->next) {
542 if (strcmp(i->name, "bridgeId") == 0) {
543 args.bridge_id = (i->value);
544 } else
545 {}
546 }
549 goto fin;
550 }
551 ast_ari_bridges_set_bridge_var(headers, &args, response);
552#if defined(AST_DEVMODE)
553 code = response->response_code;
554
555 switch (code) {
556 case 0: /* Implementation is still a stub, or the code wasn't set */
557 is_valid = response->message == NULL;
558 break;
559 case 500: /* Internal Server Error */
560 case 501: /* Not Implemented */
561 case 400: /* Missing variable parameter. */
562 case 404: /* Bridge not found */
563 case 409: /* Bridge not in a Stasis application */
564 is_valid = 1;
565 break;
566 default:
567 if (200 <= code && code <= 299) {
568 is_valid = ast_ari_validate_void(
569 response->message);
570 } else {
571 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/variable\n", code);
572 is_valid = 0;
573 }
574 }
575
576 if (!is_valid) {
577 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/variable\n");
578 ast_ari_response_error(response, 500,
579 "Internal Server Error", "Response validation failed");
580 }
581#endif /* AST_DEVMODE */
582
583fin: __attribute__((unused))
584 return;
585}
587 struct ast_json *body,
589{
590 struct ast_json *field;
591 /* Parse query parameters out of it */
592 field = ast_json_object_get(body, "variables");
593 if (field) {
594 /* If they were silly enough to both pass in a query param and a
595 * JSON body, free up the query value.
596 */
597 ast_free(args->variables);
598 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
599 /* Multiple param passed as array */
600 size_t i;
601 args->variables_count = ast_json_array_size(field);
602 args->variables = ast_malloc(sizeof(*args->variables) * args->variables_count);
603
604 if (!args->variables) {
605 return -1;
606 }
607
608 for (i = 0; i < args->variables_count; ++i) {
609 args->variables[i] = ast_json_string_get(ast_json_array_get(field, i));
610 }
611 } else {
612 /* Multiple param passed as single value */
613 args->variables_count = 1;
614 args->variables = ast_malloc(sizeof(*args->variables) * args->variables_count);
615 if (!args->variables) {
616 return -1;
617 }
618 args->variables[0] = ast_json_string_get(field);
619 }
620 }
621 return 0;
622}
623
624/*!
625 * \brief Parameter parsing callback for /bridges/{bridgeId}/variables.
626 * \param ser TCP/TLS session object
627 * \param get_params GET parameters in the HTTP request.
628 * \param path_vars Path variables extracted from the request.
629 * \param headers HTTP headers.
630 * \param body
631 * \param[out] response Response to the HTTP request.
632 */
634 struct ast_tcptls_session_instance *ser,
635 struct ast_variable *get_params, struct ast_variable *path_vars,
636 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
637{
639 struct ast_variable *i;
640#if defined(AST_DEVMODE)
641 int is_valid;
642 int code;
643#endif /* AST_DEVMODE */
644
645 for (i = get_params; i; i = i->next) {
646 if (strcmp(i->name, "variables") == 0) {
647 /* Parse comma separated list */
648 char *vals[MAX_VALS];
649 size_t j;
650
651 args.variables_parse = ast_strdup(i->value);
652 if (!args.variables_parse) {
654 goto fin;
655 }
656
657 if (strlen(args.variables_parse) == 0) {
658 /* ast_app_separate_args can't handle "" */
659 args.variables_count = 1;
660 vals[0] = args.variables_parse;
661 } else {
662 args.variables_count = ast_app_separate_args(
663 args.variables_parse, ',', vals,
664 ARRAY_LEN(vals));
665 }
666
667 if (args.variables_count == 0) {
669 goto fin;
670 }
671
672 if (args.variables_count >= MAX_VALS) {
673 ast_ari_response_error(response, 400,
674 "Bad Request",
675 "Too many values for variables");
676 goto fin;
677 }
678
679 args.variables = ast_malloc(sizeof(*args.variables) * args.variables_count);
680 if (!args.variables) {
682 goto fin;
683 }
684
685 for (j = 0; j < args.variables_count; ++j) {
686 args.variables[j] = (vals[j]);
687 }
688 } else
689 {}
690 }
691 for (i = path_vars; i; i = i->next) {
692 if (strcmp(i->name, "bridgeId") == 0) {
693 args.bridge_id = (i->value);
694 } else
695 {}
696 }
699 goto fin;
700 }
701 ast_ari_bridges_get_bridge_vars(headers, &args, response);
702#if defined(AST_DEVMODE)
703 code = response->response_code;
704
705 switch (code) {
706 case 0: /* Implementation is still a stub, or the code wasn't set */
707 is_valid = response->message == NULL;
708 break;
709 case 500: /* Internal Server Error */
710 case 501: /* Not Implemented */
711 case 400: /* Missing variables parameter. */
712 case 404: /* Bridge or variable not found */
713 case 409: /* Bridge not in a Stasis application */
714 is_valid = 1;
715 break;
716 default:
717 if (200 <= code && code <= 299) {
719 response->message);
720 } else {
721 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/variables\n", code);
722 is_valid = 0;
723 }
724 }
725
726 if (!is_valid) {
727 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/variables\n");
728 ast_ari_response_error(response, 500,
729 "Internal Server Error", "Response validation failed");
730 }
731#endif /* AST_DEVMODE */
732
733fin: __attribute__((unused))
734 ast_free(args.variables_parse);
735 ast_free(args.variables);
736 return;
737}
739 struct ast_json *body,
741{
742 /* Parse query parameters out of it */
743 return 0;
744}
745
746/*!
747 * \brief Parameter parsing callback for /bridges/{bridgeId}/variables.
748 * \param ser TCP/TLS session object
749 * \param get_params GET parameters in the HTTP request.
750 * \param path_vars Path variables extracted from the request.
751 * \param headers HTTP headers.
752 * \param body
753 * \param[out] response Response to the HTTP request.
754 */
756 struct ast_tcptls_session_instance *ser,
757 struct ast_variable *get_params, struct ast_variable *path_vars,
758 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
759{
761 struct ast_variable *i;
762#if defined(AST_DEVMODE)
763 int is_valid;
764 int code;
765#endif /* AST_DEVMODE */
766
767 for (i = path_vars; i; i = i->next) {
768 if (strcmp(i->name, "bridgeId") == 0) {
769 args.bridge_id = (i->value);
770 } else
771 {}
772 }
773 args.variables = body;
774 ast_ari_bridges_set_bridge_vars(headers, &args, response);
775#if defined(AST_DEVMODE)
776 code = response->response_code;
777
778 switch (code) {
779 case 0: /* Implementation is still a stub, or the code wasn't set */
780 is_valid = response->message == NULL;
781 break;
782 case 500: /* Internal Server Error */
783 case 501: /* Not Implemented */
784 case 400: /* Missing variables parameter. */
785 case 404: /* Bridge not found */
786 case 409: /* Bridge not in a Stasis application */
787 is_valid = 1;
788 break;
789 default:
790 if (200 <= code && code <= 299) {
791 is_valid = ast_ari_validate_void(
792 response->message);
793 } else {
794 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/variables\n", code);
795 is_valid = 0;
796 }
797 }
798
799 if (!is_valid) {
800 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/variables\n");
801 ast_ari_response_error(response, 500,
802 "Internal Server Error", "Response validation failed");
803 }
804#endif /* AST_DEVMODE */
805
806fin: __attribute__((unused))
807 return;
808}
810 struct ast_json *body,
812{
813 struct ast_json *field;
814 /* Parse query parameters out of it */
815 field = ast_json_object_get(body, "channel");
816 if (field) {
817 /* If they were silly enough to both pass in a query param and a
818 * JSON body, free up the query value.
819 */
820 ast_free(args->channel);
821 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
822 /* Multiple param passed as array */
823 size_t i;
824 args->channel_count = ast_json_array_size(field);
825 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
826
827 if (!args->channel) {
828 return -1;
829 }
830
831 for (i = 0; i < args->channel_count; ++i) {
832 args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
833 }
834 } else {
835 /* Multiple param passed as single value */
836 args->channel_count = 1;
837 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
838 if (!args->channel) {
839 return -1;
840 }
841 args->channel[0] = ast_json_string_get(field);
842 }
843 }
844 field = ast_json_object_get(body, "role");
845 if (field) {
846 args->role = ast_json_string_get(field);
847 }
848 field = ast_json_object_get(body, "absorbDTMF");
849 if (field) {
850 args->absorb_dtmf = ast_json_is_true(field);
851 }
852 field = ast_json_object_get(body, "mute");
853 if (field) {
854 args->mute = ast_json_is_true(field);
855 }
856 field = ast_json_object_get(body, "inhibitConnectedLineUpdates");
857 if (field) {
858 args->inhibit_connected_line_updates = ast_json_is_true(field);
859 }
860 return 0;
861}
862
863/*!
864 * \brief Parameter parsing callback for /bridges/{bridgeId}/addChannel.
865 * \param ser TCP/TLS session object
866 * \param get_params GET parameters in the HTTP request.
867 * \param path_vars Path variables extracted from the request.
868 * \param headers HTTP headers.
869 * \param body
870 * \param[out] response Response to the HTTP request.
871 */
873 struct ast_tcptls_session_instance *ser,
874 struct ast_variable *get_params, struct ast_variable *path_vars,
875 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
876{
878 struct ast_variable *i;
879#if defined(AST_DEVMODE)
880 int is_valid;
881 int code;
882#endif /* AST_DEVMODE */
883
884 for (i = get_params; i; i = i->next) {
885 if (strcmp(i->name, "channel") == 0) {
886 /* Parse comma separated list */
887 char *vals[MAX_VALS];
888 size_t j;
889
890 args.channel_parse = ast_strdup(i->value);
891 if (!args.channel_parse) {
893 goto fin;
894 }
895
896 if (strlen(args.channel_parse) == 0) {
897 /* ast_app_separate_args can't handle "" */
898 args.channel_count = 1;
899 vals[0] = args.channel_parse;
900 } else {
901 args.channel_count = ast_app_separate_args(
902 args.channel_parse, ',', vals,
903 ARRAY_LEN(vals));
904 }
905
906 if (args.channel_count == 0) {
908 goto fin;
909 }
910
911 if (args.channel_count >= MAX_VALS) {
912 ast_ari_response_error(response, 400,
913 "Bad Request",
914 "Too many values for channel");
915 goto fin;
916 }
917
918 args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
919 if (!args.channel) {
921 goto fin;
922 }
923
924 for (j = 0; j < args.channel_count; ++j) {
925 args.channel[j] = (vals[j]);
926 }
927 } else
928 if (strcmp(i->name, "role") == 0) {
929 args.role = (i->value);
930 } else
931 if (strcmp(i->name, "absorbDTMF") == 0) {
932 args.absorb_dtmf = ast_true(i->value);
933 } else
934 if (strcmp(i->name, "mute") == 0) {
935 args.mute = ast_true(i->value);
936 } else
937 if (strcmp(i->name, "inhibitConnectedLineUpdates") == 0) {
938 args.inhibit_connected_line_updates = ast_true(i->value);
939 } else
940 {}
941 }
942 for (i = path_vars; i; i = i->next) {
943 if (strcmp(i->name, "bridgeId") == 0) {
944 args.bridge_id = (i->value);
945 } else
946 {}
947 }
950 goto fin;
951 }
952 ast_ari_bridges_add_channel(headers, &args, response);
953#if defined(AST_DEVMODE)
954 code = response->response_code;
955
956 switch (code) {
957 case 0: /* Implementation is still a stub, or the code wasn't set */
958 is_valid = response->message == NULL;
959 break;
960 case 500: /* Internal Server Error */
961 case 501: /* Not Implemented */
962 case 400: /* Channel not found */
963 case 404: /* Bridge not found */
964 case 409: /* Bridge not in Stasis application; Channel currently recording */
965 case 422: /* Channel not in Stasis application */
966 is_valid = 1;
967 break;
968 default:
969 if (200 <= code && code <= 299) {
970 is_valid = ast_ari_validate_void(
971 response->message);
972 } else {
973 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/addChannel\n", code);
974 is_valid = 0;
975 }
976 }
977
978 if (!is_valid) {
979 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/addChannel\n");
980 ast_ari_response_error(response, 500,
981 "Internal Server Error", "Response validation failed");
982 }
983#endif /* AST_DEVMODE */
984
985fin: __attribute__((unused))
986 ast_free(args.channel_parse);
987 ast_free(args.channel);
988 return;
989}
991 struct ast_json *body,
993{
994 struct ast_json *field;
995 /* Parse query parameters out of it */
996 field = ast_json_object_get(body, "channel");
997 if (field) {
998 /* If they were silly enough to both pass in a query param and a
999 * JSON body, free up the query value.
1000 */
1001 ast_free(args->channel);
1002 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1003 /* Multiple param passed as array */
1004 size_t i;
1005 args->channel_count = ast_json_array_size(field);
1006 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
1007
1008 if (!args->channel) {
1009 return -1;
1010 }
1011
1012 for (i = 0; i < args->channel_count; ++i) {
1013 args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
1014 }
1015 } else {
1016 /* Multiple param passed as single value */
1017 args->channel_count = 1;
1018 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
1019 if (!args->channel) {
1020 return -1;
1021 }
1022 args->channel[0] = ast_json_string_get(field);
1023 }
1024 }
1025 return 0;
1026}
1027
1028/*!
1029 * \brief Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
1030 * \param ser TCP/TLS session object
1031 * \param get_params GET parameters in the HTTP request.
1032 * \param path_vars Path variables extracted from the request.
1033 * \param headers HTTP headers.
1034 * \param body
1035 * \param[out] response Response to the HTTP request.
1036 */
1038 struct ast_tcptls_session_instance *ser,
1039 struct ast_variable *get_params, struct ast_variable *path_vars,
1040 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1041{
1043 struct ast_variable *i;
1044#if defined(AST_DEVMODE)
1045 int is_valid;
1046 int code;
1047#endif /* AST_DEVMODE */
1048
1049 for (i = get_params; i; i = i->next) {
1050 if (strcmp(i->name, "channel") == 0) {
1051 /* Parse comma separated list */
1052 char *vals[MAX_VALS];
1053 size_t j;
1054
1055 args.channel_parse = ast_strdup(i->value);
1056 if (!args.channel_parse) {
1058 goto fin;
1059 }
1060
1061 if (strlen(args.channel_parse) == 0) {
1062 /* ast_app_separate_args can't handle "" */
1063 args.channel_count = 1;
1064 vals[0] = args.channel_parse;
1065 } else {
1066 args.channel_count = ast_app_separate_args(
1067 args.channel_parse, ',', vals,
1068 ARRAY_LEN(vals));
1069 }
1070
1071 if (args.channel_count == 0) {
1073 goto fin;
1074 }
1075
1076 if (args.channel_count >= MAX_VALS) {
1077 ast_ari_response_error(response, 400,
1078 "Bad Request",
1079 "Too many values for channel");
1080 goto fin;
1081 }
1082
1083 args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
1084 if (!args.channel) {
1086 goto fin;
1087 }
1088
1089 for (j = 0; j < args.channel_count; ++j) {
1090 args.channel[j] = (vals[j]);
1091 }
1092 } else
1093 {}
1094 }
1095 for (i = path_vars; i; i = i->next) {
1096 if (strcmp(i->name, "bridgeId") == 0) {
1097 args.bridge_id = (i->value);
1098 } else
1099 {}
1100 }
1103 goto fin;
1104 }
1105 ast_ari_bridges_remove_channel(headers, &args, response);
1106#if defined(AST_DEVMODE)
1107 code = response->response_code;
1108
1109 switch (code) {
1110 case 0: /* Implementation is still a stub, or the code wasn't set */
1111 is_valid = response->message == NULL;
1112 break;
1113 case 500: /* Internal Server Error */
1114 case 501: /* Not Implemented */
1115 case 400: /* Channel not found */
1116 case 404: /* Bridge not found */
1117 case 409: /* Bridge not in Stasis application */
1118 case 422: /* Channel not in this bridge */
1119 is_valid = 1;
1120 break;
1121 default:
1122 if (200 <= code && code <= 299) {
1123 is_valid = ast_ari_validate_void(
1124 response->message);
1125 } else {
1126 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/removeChannel\n", code);
1127 is_valid = 0;
1128 }
1129 }
1130
1131 if (!is_valid) {
1132 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/removeChannel\n");
1133 ast_ari_response_error(response, 500,
1134 "Internal Server Error", "Response validation failed");
1135 }
1136#endif /* AST_DEVMODE */
1137
1138fin: __attribute__((unused))
1139 ast_free(args.channel_parse);
1140 ast_free(args.channel);
1141 return;
1142}
1143/*!
1144 * \brief Parameter parsing callback for /bridges/{bridgeId}/videoSource/{channelId}.
1145 * \param ser TCP/TLS session object
1146 * \param get_params GET parameters in the HTTP request.
1147 * \param path_vars Path variables extracted from the request.
1148 * \param headers HTTP headers.
1149 * \param body
1150 * \param[out] response Response to the HTTP request.
1151 */
1153 struct ast_tcptls_session_instance *ser,
1154 struct ast_variable *get_params, struct ast_variable *path_vars,
1155 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1156{
1158 struct ast_variable *i;
1159#if defined(AST_DEVMODE)
1160 int is_valid;
1161 int code;
1162#endif /* AST_DEVMODE */
1163
1164 for (i = path_vars; i; i = i->next) {
1165 if (strcmp(i->name, "bridgeId") == 0) {
1166 args.bridge_id = (i->value);
1167 } else
1168 if (strcmp(i->name, "channelId") == 0) {
1169 args.channel_id = (i->value);
1170 } else
1171 {}
1172 }
1173 ast_ari_bridges_set_video_source(headers, &args, response);
1174#if defined(AST_DEVMODE)
1175 code = response->response_code;
1176
1177 switch (code) {
1178 case 0: /* Implementation is still a stub, or the code wasn't set */
1179 is_valid = response->message == NULL;
1180 break;
1181 case 500: /* Internal Server Error */
1182 case 501: /* Not Implemented */
1183 case 404: /* Bridge or Channel not found */
1184 case 409: /* Channel not in Stasis application */
1185 case 422: /* Channel not in this Bridge */
1186 is_valid = 1;
1187 break;
1188 default:
1189 if (200 <= code && code <= 299) {
1190 is_valid = ast_ari_validate_void(
1191 response->message);
1192 } else {
1193 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/videoSource/{channelId}\n", code);
1194 is_valid = 0;
1195 }
1196 }
1197
1198 if (!is_valid) {
1199 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/videoSource/{channelId}\n");
1200 ast_ari_response_error(response, 500,
1201 "Internal Server Error", "Response validation failed");
1202 }
1203#endif /* AST_DEVMODE */
1204
1205fin: __attribute__((unused))
1206 return;
1207}
1208/*!
1209 * \brief Parameter parsing callback for /bridges/{bridgeId}/videoSource.
1210 * \param ser TCP/TLS session object
1211 * \param get_params GET parameters in the HTTP request.
1212 * \param path_vars Path variables extracted from the request.
1213 * \param headers HTTP headers.
1214 * \param body
1215 * \param[out] response Response to the HTTP request.
1216 */
1218 struct ast_tcptls_session_instance *ser,
1219 struct ast_variable *get_params, struct ast_variable *path_vars,
1220 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1221{
1223 struct ast_variable *i;
1224#if defined(AST_DEVMODE)
1225 int is_valid;
1226 int code;
1227#endif /* AST_DEVMODE */
1228
1229 for (i = path_vars; i; i = i->next) {
1230 if (strcmp(i->name, "bridgeId") == 0) {
1231 args.bridge_id = (i->value);
1232 } else
1233 {}
1234 }
1235 ast_ari_bridges_clear_video_source(headers, &args, response);
1236#if defined(AST_DEVMODE)
1237 code = response->response_code;
1238
1239 switch (code) {
1240 case 0: /* Implementation is still a stub, or the code wasn't set */
1241 is_valid = response->message == NULL;
1242 break;
1243 case 500: /* Internal Server Error */
1244 case 501: /* Not Implemented */
1245 case 404: /* Bridge not found */
1246 is_valid = 1;
1247 break;
1248 default:
1249 if (200 <= code && code <= 299) {
1250 is_valid = ast_ari_validate_void(
1251 response->message);
1252 } else {
1253 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/videoSource\n", code);
1254 is_valid = 0;
1255 }
1256 }
1257
1258 if (!is_valid) {
1259 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/videoSource\n");
1260 ast_ari_response_error(response, 500,
1261 "Internal Server Error", "Response validation failed");
1262 }
1263#endif /* AST_DEVMODE */
1264
1265fin: __attribute__((unused))
1266 return;
1267}
1269 struct ast_json *body,
1271{
1272 struct ast_json *field;
1273 /* Parse query parameters out of it */
1274 field = ast_json_object_get(body, "mohClass");
1275 if (field) {
1276 args->moh_class = ast_json_string_get(field);
1277 }
1278 return 0;
1279}
1280
1281/*!
1282 * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
1283 * \param ser TCP/TLS session object
1284 * \param get_params GET parameters in the HTTP request.
1285 * \param path_vars Path variables extracted from the request.
1286 * \param headers HTTP headers.
1287 * \param body
1288 * \param[out] response Response to the HTTP request.
1289 */
1291 struct ast_tcptls_session_instance *ser,
1292 struct ast_variable *get_params, struct ast_variable *path_vars,
1293 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1294{
1296 struct ast_variable *i;
1297#if defined(AST_DEVMODE)
1298 int is_valid;
1299 int code;
1300#endif /* AST_DEVMODE */
1301
1302 for (i = get_params; i; i = i->next) {
1303 if (strcmp(i->name, "mohClass") == 0) {
1304 args.moh_class = (i->value);
1305 } else
1306 {}
1307 }
1308 for (i = path_vars; i; i = i->next) {
1309 if (strcmp(i->name, "bridgeId") == 0) {
1310 args.bridge_id = (i->value);
1311 } else
1312 {}
1313 }
1316 goto fin;
1317 }
1318 ast_ari_bridges_start_moh(headers, &args, response);
1319#if defined(AST_DEVMODE)
1320 code = response->response_code;
1321
1322 switch (code) {
1323 case 0: /* Implementation is still a stub, or the code wasn't set */
1324 is_valid = response->message == NULL;
1325 break;
1326 case 500: /* Internal Server Error */
1327 case 501: /* Not Implemented */
1328 case 404: /* Bridge not found */
1329 case 409: /* Bridge not in Stasis application */
1330 is_valid = 1;
1331 break;
1332 default:
1333 if (200 <= code && code <= 299) {
1334 is_valid = ast_ari_validate_void(
1335 response->message);
1336 } else {
1337 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
1338 is_valid = 0;
1339 }
1340 }
1341
1342 if (!is_valid) {
1343 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
1344 ast_ari_response_error(response, 500,
1345 "Internal Server Error", "Response validation failed");
1346 }
1347#endif /* AST_DEVMODE */
1348
1349fin: __attribute__((unused))
1350 return;
1351}
1352/*!
1353 * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
1354 * \param ser TCP/TLS session object
1355 * \param get_params GET parameters in the HTTP request.
1356 * \param path_vars Path variables extracted from the request.
1357 * \param headers HTTP headers.
1358 * \param body
1359 * \param[out] response Response to the HTTP request.
1360 */
1362 struct ast_tcptls_session_instance *ser,
1363 struct ast_variable *get_params, struct ast_variable *path_vars,
1364 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1365{
1367 struct ast_variable *i;
1368#if defined(AST_DEVMODE)
1369 int is_valid;
1370 int code;
1371#endif /* AST_DEVMODE */
1372
1373 for (i = path_vars; i; i = i->next) {
1374 if (strcmp(i->name, "bridgeId") == 0) {
1375 args.bridge_id = (i->value);
1376 } else
1377 {}
1378 }
1379 ast_ari_bridges_stop_moh(headers, &args, response);
1380#if defined(AST_DEVMODE)
1381 code = response->response_code;
1382
1383 switch (code) {
1384 case 0: /* Implementation is still a stub, or the code wasn't set */
1385 is_valid = response->message == NULL;
1386 break;
1387 case 500: /* Internal Server Error */
1388 case 501: /* Not Implemented */
1389 case 404: /* Bridge not found */
1390 case 409: /* Bridge not in Stasis application */
1391 is_valid = 1;
1392 break;
1393 default:
1394 if (200 <= code && code <= 299) {
1395 is_valid = ast_ari_validate_void(
1396 response->message);
1397 } else {
1398 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
1399 is_valid = 0;
1400 }
1401 }
1402
1403 if (!is_valid) {
1404 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
1405 ast_ari_response_error(response, 500,
1406 "Internal Server Error", "Response validation failed");
1407 }
1408#endif /* AST_DEVMODE */
1409
1410fin: __attribute__((unused))
1411 return;
1412}
1414 struct ast_json *body,
1416{
1417 struct ast_json *field;
1418 /* Parse query parameters out of it */
1419 field = ast_json_object_get(body, "media");
1420 if (field) {
1421 /* If they were silly enough to both pass in a query param and a
1422 * JSON body, free up the query value.
1423 */
1424 ast_free(args->media);
1425 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1426 /* Multiple param passed as array */
1427 size_t i;
1428 args->media_count = ast_json_array_size(field);
1429 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1430
1431 if (!args->media) {
1432 return -1;
1433 }
1434
1435 for (i = 0; i < args->media_count; ++i) {
1436 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1437 }
1438 } else {
1439 /* Multiple param passed as single value */
1440 args->media_count = 1;
1441 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1442 if (!args->media) {
1443 return -1;
1444 }
1445 args->media[0] = ast_json_string_get(field);
1446 }
1447 }
1448 field = ast_json_object_get(body, "announcer_format");
1449 if (field) {
1450 args->announcer_format = ast_json_string_get(field);
1451 }
1452 field = ast_json_object_get(body, "lang");
1453 if (field) {
1454 args->lang = ast_json_string_get(field);
1455 }
1456 field = ast_json_object_get(body, "offsetms");
1457 if (field) {
1458 args->offsetms = ast_json_integer_get(field);
1459 }
1460 field = ast_json_object_get(body, "skipms");
1461 if (field) {
1462 args->skipms = ast_json_integer_get(field);
1463 }
1464 field = ast_json_object_get(body, "playbackId");
1465 if (field) {
1466 args->playback_id = ast_json_string_get(field);
1467 }
1468 return 0;
1469}
1470
1471/*!
1472 * \brief Parameter parsing callback for /bridges/{bridgeId}/play.
1473 * \param ser TCP/TLS session object
1474 * \param get_params GET parameters in the HTTP request.
1475 * \param path_vars Path variables extracted from the request.
1476 * \param headers HTTP headers.
1477 * \param body
1478 * \param[out] response Response to the HTTP request.
1479 */
1481 struct ast_tcptls_session_instance *ser,
1482 struct ast_variable *get_params, struct ast_variable *path_vars,
1483 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1484{
1485 struct ast_ari_bridges_play_args args = {};
1486 struct ast_variable *i;
1487#if defined(AST_DEVMODE)
1488 int is_valid;
1489 int code;
1490#endif /* AST_DEVMODE */
1491
1492 for (i = get_params; i; i = i->next) {
1493 if (strcmp(i->name, "media") == 0) {
1494 /* Parse comma separated list */
1495 char *vals[MAX_VALS];
1496 size_t j;
1497
1498 args.media_parse = ast_strdup(i->value);
1499 if (!args.media_parse) {
1501 goto fin;
1502 }
1503
1504 if (strlen(args.media_parse) == 0) {
1505 /* ast_app_separate_args can't handle "" */
1506 args.media_count = 1;
1507 vals[0] = args.media_parse;
1508 } else {
1509 args.media_count = ast_app_separate_args(
1510 args.media_parse, ',', vals,
1511 ARRAY_LEN(vals));
1512 }
1513
1514 if (args.media_count == 0) {
1516 goto fin;
1517 }
1518
1519 if (args.media_count >= MAX_VALS) {
1520 ast_ari_response_error(response, 400,
1521 "Bad Request",
1522 "Too many values for media");
1523 goto fin;
1524 }
1525
1526 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
1527 if (!args.media) {
1529 goto fin;
1530 }
1531
1532 for (j = 0; j < args.media_count; ++j) {
1533 args.media[j] = (vals[j]);
1534 }
1535 } else
1536 if (strcmp(i->name, "announcer_format") == 0) {
1537 args.announcer_format = (i->value);
1538 } else
1539 if (strcmp(i->name, "lang") == 0) {
1540 args.lang = (i->value);
1541 } else
1542 if (strcmp(i->name, "offsetms") == 0) {
1543 args.offsetms = atoi(i->value);
1544 } else
1545 if (strcmp(i->name, "skipms") == 0) {
1546 args.skipms = atoi(i->value);
1547 } else
1548 if (strcmp(i->name, "playbackId") == 0) {
1549 args.playback_id = (i->value);
1550 } else
1551 {}
1552 }
1553 for (i = path_vars; i; i = i->next) {
1554 if (strcmp(i->name, "bridgeId") == 0) {
1555 args.bridge_id = (i->value);
1556 } else
1557 {}
1558 }
1561 goto fin;
1562 }
1563 ast_ari_bridges_play(headers, &args, response);
1564#if defined(AST_DEVMODE)
1565 code = response->response_code;
1566
1567 switch (code) {
1568 case 0: /* Implementation is still a stub, or the code wasn't set */
1569 is_valid = response->message == NULL;
1570 break;
1571 case 500: /* Internal Server Error */
1572 case 501: /* Not Implemented */
1573 case 404: /* Bridge not found */
1574 case 409: /* Bridge not in a Stasis application */
1575 case 422: /* The format specified is unknown on this system */
1576 is_valid = 1;
1577 break;
1578 default:
1579 if (200 <= code && code <= 299) {
1580 is_valid = ast_ari_validate_playback(
1581 response->message);
1582 } else {
1583 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/play\n", code);
1584 is_valid = 0;
1585 }
1586 }
1587
1588 if (!is_valid) {
1589 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/play\n");
1590 ast_ari_response_error(response, 500,
1591 "Internal Server Error", "Response validation failed");
1592 }
1593#endif /* AST_DEVMODE */
1594
1595fin: __attribute__((unused))
1596 ast_free(args.media_parse);
1597 ast_free(args.media);
1598 return;
1599}
1601 struct ast_json *body,
1603{
1604 struct ast_json *field;
1605 /* Parse query parameters out of it */
1606 field = ast_json_object_get(body, "media");
1607 if (field) {
1608 /* If they were silly enough to both pass in a query param and a
1609 * JSON body, free up the query value.
1610 */
1611 ast_free(args->media);
1612 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1613 /* Multiple param passed as array */
1614 size_t i;
1615 args->media_count = ast_json_array_size(field);
1616 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1617
1618 if (!args->media) {
1619 return -1;
1620 }
1621
1622 for (i = 0; i < args->media_count; ++i) {
1623 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1624 }
1625 } else {
1626 /* Multiple param passed as single value */
1627 args->media_count = 1;
1628 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1629 if (!args->media) {
1630 return -1;
1631 }
1632 args->media[0] = ast_json_string_get(field);
1633 }
1634 }
1635 field = ast_json_object_get(body, "announcer_format");
1636 if (field) {
1637 args->announcer_format = ast_json_string_get(field);
1638 }
1639 field = ast_json_object_get(body, "lang");
1640 if (field) {
1641 args->lang = ast_json_string_get(field);
1642 }
1643 field = ast_json_object_get(body, "offsetms");
1644 if (field) {
1645 args->offsetms = ast_json_integer_get(field);
1646 }
1647 field = ast_json_object_get(body, "skipms");
1648 if (field) {
1649 args->skipms = ast_json_integer_get(field);
1650 }
1651 return 0;
1652}
1653
1654/*!
1655 * \brief Parameter parsing callback for /bridges/{bridgeId}/play/{playbackId}.
1656 * \param ser TCP/TLS session object
1657 * \param get_params GET parameters in the HTTP request.
1658 * \param path_vars Path variables extracted from the request.
1659 * \param headers HTTP headers.
1660 * \param body
1661 * \param[out] response Response to the HTTP request.
1662 */
1664 struct ast_tcptls_session_instance *ser,
1665 struct ast_variable *get_params, struct ast_variable *path_vars,
1666 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1667{
1669 struct ast_variable *i;
1670#if defined(AST_DEVMODE)
1671 int is_valid;
1672 int code;
1673#endif /* AST_DEVMODE */
1674
1675 for (i = get_params; i; i = i->next) {
1676 if (strcmp(i->name, "media") == 0) {
1677 /* Parse comma separated list */
1678 char *vals[MAX_VALS];
1679 size_t j;
1680
1681 args.media_parse = ast_strdup(i->value);
1682 if (!args.media_parse) {
1684 goto fin;
1685 }
1686
1687 if (strlen(args.media_parse) == 0) {
1688 /* ast_app_separate_args can't handle "" */
1689 args.media_count = 1;
1690 vals[0] = args.media_parse;
1691 } else {
1692 args.media_count = ast_app_separate_args(
1693 args.media_parse, ',', vals,
1694 ARRAY_LEN(vals));
1695 }
1696
1697 if (args.media_count == 0) {
1699 goto fin;
1700 }
1701
1702 if (args.media_count >= MAX_VALS) {
1703 ast_ari_response_error(response, 400,
1704 "Bad Request",
1705 "Too many values for media");
1706 goto fin;
1707 }
1708
1709 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
1710 if (!args.media) {
1712 goto fin;
1713 }
1714
1715 for (j = 0; j < args.media_count; ++j) {
1716 args.media[j] = (vals[j]);
1717 }
1718 } else
1719 if (strcmp(i->name, "announcer_format") == 0) {
1720 args.announcer_format = (i->value);
1721 } else
1722 if (strcmp(i->name, "lang") == 0) {
1723 args.lang = (i->value);
1724 } else
1725 if (strcmp(i->name, "offsetms") == 0) {
1726 args.offsetms = atoi(i->value);
1727 } else
1728 if (strcmp(i->name, "skipms") == 0) {
1729 args.skipms = atoi(i->value);
1730 } else
1731 {}
1732 }
1733 for (i = path_vars; i; i = i->next) {
1734 if (strcmp(i->name, "bridgeId") == 0) {
1735 args.bridge_id = (i->value);
1736 } else
1737 if (strcmp(i->name, "playbackId") == 0) {
1738 args.playback_id = (i->value);
1739 } else
1740 {}
1741 }
1744 goto fin;
1745 }
1746 ast_ari_bridges_play_with_id(headers, &args, response);
1747#if defined(AST_DEVMODE)
1748 code = response->response_code;
1749
1750 switch (code) {
1751 case 0: /* Implementation is still a stub, or the code wasn't set */
1752 is_valid = response->message == NULL;
1753 break;
1754 case 500: /* Internal Server Error */
1755 case 501: /* Not Implemented */
1756 case 404: /* Bridge not found */
1757 case 409: /* Bridge not in a Stasis application */
1758 case 422: /* The format specified is unknown on this system */
1759 is_valid = 1;
1760 break;
1761 default:
1762 if (200 <= code && code <= 299) {
1763 is_valid = ast_ari_validate_playback(
1764 response->message);
1765 } else {
1766 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/play/{playbackId}\n", code);
1767 is_valid = 0;
1768 }
1769 }
1770
1771 if (!is_valid) {
1772 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/play/{playbackId}\n");
1773 ast_ari_response_error(response, 500,
1774 "Internal Server Error", "Response validation failed");
1775 }
1776#endif /* AST_DEVMODE */
1777
1778fin: __attribute__((unused))
1779 ast_free(args.media_parse);
1780 ast_free(args.media);
1781 return;
1782}
1784 struct ast_json *body,
1786{
1787 struct ast_json *field;
1788 /* Parse query parameters out of it */
1789 field = ast_json_object_get(body, "name");
1790 if (field) {
1791 args->name = ast_json_string_get(field);
1792 }
1793 field = ast_json_object_get(body, "format");
1794 if (field) {
1795 args->format = ast_json_string_get(field);
1796 }
1797 field = ast_json_object_get(body, "recorder_format");
1798 if (field) {
1799 args->recorder_format = ast_json_string_get(field);
1800 }
1801 field = ast_json_object_get(body, "maxDurationSeconds");
1802 if (field) {
1803 args->max_duration_seconds = ast_json_integer_get(field);
1804 }
1805 field = ast_json_object_get(body, "maxSilenceSeconds");
1806 if (field) {
1807 args->max_silence_seconds = ast_json_integer_get(field);
1808 }
1809 field = ast_json_object_get(body, "ifExists");
1810 if (field) {
1811 args->if_exists = ast_json_string_get(field);
1812 }
1813 field = ast_json_object_get(body, "beep");
1814 if (field) {
1815 args->beep = ast_json_is_true(field);
1816 }
1817 field = ast_json_object_get(body, "terminateOn");
1818 if (field) {
1819 args->terminate_on = ast_json_string_get(field);
1820 }
1821 return 0;
1822}
1823
1824/*!
1825 * \brief Parameter parsing callback for /bridges/{bridgeId}/record.
1826 * \param ser TCP/TLS session object
1827 * \param get_params GET parameters in the HTTP request.
1828 * \param path_vars Path variables extracted from the request.
1829 * \param headers HTTP headers.
1830 * \param body
1831 * \param[out] response Response to the HTTP request.
1832 */
1834 struct ast_tcptls_session_instance *ser,
1835 struct ast_variable *get_params, struct ast_variable *path_vars,
1836 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1837{
1839 struct ast_variable *i;
1840#if defined(AST_DEVMODE)
1841 int is_valid;
1842 int code;
1843#endif /* AST_DEVMODE */
1844
1845 for (i = get_params; i; i = i->next) {
1846 if (strcmp(i->name, "name") == 0) {
1847 args.name = (i->value);
1848 } else
1849 if (strcmp(i->name, "format") == 0) {
1850 args.format = (i->value);
1851 } else
1852 if (strcmp(i->name, "recorder_format") == 0) {
1853 args.recorder_format = (i->value);
1854 } else
1855 if (strcmp(i->name, "maxDurationSeconds") == 0) {
1856 args.max_duration_seconds = atoi(i->value);
1857 } else
1858 if (strcmp(i->name, "maxSilenceSeconds") == 0) {
1859 args.max_silence_seconds = atoi(i->value);
1860 } else
1861 if (strcmp(i->name, "ifExists") == 0) {
1862 args.if_exists = (i->value);
1863 } else
1864 if (strcmp(i->name, "beep") == 0) {
1865 args.beep = ast_true(i->value);
1866 } else
1867 if (strcmp(i->name, "terminateOn") == 0) {
1868 args.terminate_on = (i->value);
1869 } else
1870 {}
1871 }
1872 for (i = path_vars; i; i = i->next) {
1873 if (strcmp(i->name, "bridgeId") == 0) {
1874 args.bridge_id = (i->value);
1875 } else
1876 {}
1877 }
1880 goto fin;
1881 }
1882 ast_ari_bridges_record(headers, &args, response);
1883#if defined(AST_DEVMODE)
1884 code = response->response_code;
1885
1886 switch (code) {
1887 case 0: /* Implementation is still a stub, or the code wasn't set */
1888 is_valid = response->message == NULL;
1889 break;
1890 case 500: /* Internal Server Error */
1891 case 501: /* Not Implemented */
1892 case 400: /* Invalid parameters */
1893 case 404: /* Bridge not found */
1894 case 409: /* Bridge is not in a Stasis application; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
1895 case 422: /* The format specified is unknown on this system */
1896 is_valid = 1;
1897 break;
1898 default:
1899 if (200 <= code && code <= 299) {
1901 response->message);
1902 } else {
1903 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/record\n", code);
1904 is_valid = 0;
1905 }
1906 }
1907
1908 if (!is_valid) {
1909 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/record\n");
1910 ast_ari_response_error(response, 500,
1911 "Internal Server Error", "Response validation failed");
1912 }
1913#endif /* AST_DEVMODE */
1914
1915fin: __attribute__((unused))
1916 return;
1917}
1918
1919/*! \brief REST handler for /api-docs/bridges.json */
1921 .path_segment = "variable",
1922 .callbacks = {
1925 },
1926 .num_children = 0,
1927 .children = { }
1928};
1929/*! \brief REST handler for /api-docs/bridges.json */
1931 .path_segment = "variables",
1932 .callbacks = {
1935 },
1936 .num_children = 0,
1937 .children = { }
1938};
1939/*! \brief REST handler for /api-docs/bridges.json */
1941 .path_segment = "addChannel",
1942 .callbacks = {
1944 },
1945 .num_children = 0,
1946 .children = { }
1947};
1948/*! \brief REST handler for /api-docs/bridges.json */
1950 .path_segment = "removeChannel",
1951 .callbacks = {
1953 },
1954 .num_children = 0,
1955 .children = { }
1956};
1957/*! \brief REST handler for /api-docs/bridges.json */
1959 .path_segment = "channelId",
1960 .is_wildcard = 1,
1961 .callbacks = {
1963 },
1964 .num_children = 0,
1965 .children = { }
1966};
1967/*! \brief REST handler for /api-docs/bridges.json */
1969 .path_segment = "videoSource",
1970 .callbacks = {
1972 },
1973 .num_children = 1,
1975};
1976/*! \brief REST handler for /api-docs/bridges.json */
1978 .path_segment = "moh",
1979 .callbacks = {
1982 },
1983 .num_children = 0,
1984 .children = { }
1985};
1986/*! \brief REST handler for /api-docs/bridges.json */
1988 .path_segment = "playbackId",
1989 .is_wildcard = 1,
1990 .callbacks = {
1992 },
1993 .num_children = 0,
1994 .children = { }
1995};
1996/*! \brief REST handler for /api-docs/bridges.json */
1998 .path_segment = "play",
1999 .callbacks = {
2001 },
2002 .num_children = 1,
2003 .children = { &bridges_bridgeId_play_playbackId, }
2004};
2005/*! \brief REST handler for /api-docs/bridges.json */
2007 .path_segment = "record",
2008 .callbacks = {
2010 },
2011 .num_children = 0,
2012 .children = { }
2013};
2014/*! \brief REST handler for /api-docs/bridges.json */
2026/*! \brief REST handler for /api-docs/bridges.json */
2028 .path_segment = "bridges",
2029 .callbacks = {
2032 },
2033 .num_children = 1,
2034 .children = { &bridges_bridgeId, }
2035};
2036
2037static int unload_module(void)
2038{
2040 return 0;
2041}
2042
2043static int load_module(void)
2044{
2045 int res = 0;
2046
2047
2049 if (res) {
2050 unload_module();
2052 }
2053
2055}
2056
2057AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Bridge resources",
2058 .support_level = AST_MODULE_SUPPORT_CORE,
2059 .load = load_module,
2060 .unload = unload_module,
2061 .requires = "res_ari,res_ari_model,res_stasis,res_stasis_recording,res_stasis_playback",
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
Definition res_ari.c:155
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition res_ari.c:212
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition res_ari.c:251
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
Definition res_ari.c:132
int ast_ari_validate_variable(struct ast_json *json)
Validator for Variable.
int ast_ari_validate_playback(struct ast_json *json)
Validator for Playback.
int ast_ari_validate_live_recording(struct ast_json *json)
Validator for LiveRecording.
int ast_ari_validate_bridge(struct ast_json *json)
Validator for Bridge.
ari_validator ast_ari_validate_bridge_fn(void)
Function pointer to ast_ari_validate_bridge().
int ast_ari_validate_variables(struct ast_json *json)
Validator for Variables.
Generated file - Build validators for ARI model objects.
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
int ast_ari_validate_list(struct ast_json *json, int(*fn)(struct ast_json *))
Validator for a Swagger List[]/JSON array.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition astmm.h:241
#define ast_malloc(len)
A wrapper for malloc()
Definition astmm.h:191
#define ast_log
Definition astobj2.c:42
@ AST_HTTP_DELETE
Definition http.h:64
@ AST_HTTP_POST
Definition http.h:61
@ AST_HTTP_GET
Definition http.h:60
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define ast_app_separate_args(a, b, c, d)
#define LOG_ERROR
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
Definition json.c:78
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
Definition json.c:370
@ AST_JSON_ARRAY
Definition json.h:165
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition json.c:283
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition json.c:407
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition json.c:332
int ast_json_is_true(const struct ast_json *value)
Check if value is JSON true.
Definition json.c:263
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Definition json.c:366
Asterisk module definitions.
@ AST_MODFLAG_DEFAULT
Definition module.h:329
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition module.h:557
@ AST_MODULE_SUPPORT_CORE
Definition module.h:121
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition module.h:46
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition module.h:78
static void ast_ari_bridges_stop_moh_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/moh.
static struct stasis_rest_handlers bridges_bridgeId_play
REST handler for /api-docs/bridges.json.
static void ast_ari_bridges_destroy_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}.
static struct stasis_rest_handlers bridges_bridgeId_record
REST handler for /api-docs/bridges.json.
#define MAX_VALS
int ast_ari_bridges_get_bridge_var_parse_body(struct ast_json *body, struct ast_ari_bridges_get_bridge_var_args *args)
Body parsing function for /bridges/{bridgeId}/variable.
static void ast_ari_bridges_get_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}.
int ast_ari_bridges_add_channel_parse_body(struct ast_json *body, struct ast_ari_bridges_add_channel_args *args)
Body parsing function for /bridges/{bridgeId}/addChannel.
static void ast_ari_bridges_list_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges.
int ast_ari_bridges_set_bridge_var_parse_body(struct ast_json *body, struct ast_ari_bridges_set_bridge_var_args *args)
Body parsing function for /bridges/{bridgeId}/variable.
static void ast_ari_bridges_set_video_source_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/videoSource/{channelId}.
static struct stasis_rest_handlers bridges_bridgeId_videoSource_channelId
REST handler for /api-docs/bridges.json.
static void ast_ari_bridges_create_with_id_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}.
static void ast_ari_bridges_get_bridge_vars_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/variables.
int ast_ari_bridges_start_moh_parse_body(struct ast_json *body, struct ast_ari_bridges_start_moh_args *args)
Body parsing function for /bridges/{bridgeId}/moh.
static void ast_ari_bridges_create_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges.
int ast_ari_bridges_record_parse_body(struct ast_json *body, struct ast_ari_bridges_record_args *args)
Body parsing function for /bridges/{bridgeId}/record.
int ast_ari_bridges_get_bridge_vars_parse_body(struct ast_json *body, struct ast_ari_bridges_get_bridge_vars_args *args)
Body parsing function for /bridges/{bridgeId}/variables.
int ast_ari_bridges_create_with_id_parse_body(struct ast_json *body, struct ast_ari_bridges_create_with_id_args *args)
Body parsing function for /bridges/{bridgeId}.
static struct stasis_rest_handlers bridges_bridgeId_addChannel
REST handler for /api-docs/bridges.json.
int ast_ari_bridges_play_parse_body(struct ast_json *body, struct ast_ari_bridges_play_args *args)
Body parsing function for /bridges/{bridgeId}/play.
static void ast_ari_bridges_play_with_id_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/play/{playbackId}.
static void ast_ari_bridges_remove_channel_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
static void ast_ari_bridges_play_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/play.
static struct stasis_rest_handlers bridges_bridgeId_variables
REST handler for /api-docs/bridges.json.
int ast_ari_bridges_play_with_id_parse_body(struct ast_json *body, struct ast_ari_bridges_play_with_id_args *args)
Body parsing function for /bridges/{bridgeId}/play/{playbackId}.
static void ast_ari_bridges_start_moh_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/moh.
static void ast_ari_bridges_set_bridge_vars_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/variables.
static void ast_ari_bridges_record_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/record.
static void ast_ari_bridges_clear_video_source_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/videoSource.
static void ast_ari_bridges_get_bridge_var_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/variable.
int ast_ari_bridges_set_bridge_vars_parse_body(struct ast_json *body, struct ast_ari_bridges_set_bridge_vars_args *args)
Body parsing function for /bridges/{bridgeId}/variables.
int ast_ari_bridges_create_parse_body(struct ast_json *body, struct ast_ari_bridges_create_args *args)
Body parsing function for /bridges.
static int load_module(void)
static void ast_ari_bridges_set_bridge_var_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/variable.
static struct stasis_rest_handlers bridges_bridgeId_moh
REST handler for /api-docs/bridges.json.
static int unload_module(void)
int ast_ari_bridges_remove_channel_parse_body(struct ast_json *body, struct ast_ari_bridges_remove_channel_args *args)
Body parsing function for /bridges/{bridgeId}/removeChannel.
static struct stasis_rest_handlers bridges_bridgeId_play_playbackId
REST handler for /api-docs/bridges.json.
static struct stasis_rest_handlers bridges_bridgeId
REST handler for /api-docs/bridges.json.
static void ast_ari_bridges_add_channel_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /bridges/{bridgeId}/addChannel.
static struct stasis_rest_handlers bridges_bridgeId_removeChannel
REST handler for /api-docs/bridges.json.
static struct stasis_rest_handlers bridges_bridgeId_videoSource
REST handler for /api-docs/bridges.json.
static struct stasis_rest_handlers bridges
REST handler for /api-docs/bridges.json.
static struct stasis_rest_handlers bridges_bridgeId_variable
REST handler for /api-docs/bridges.json.
static struct @522 args
#define NULL
Definition resample.c:96
void ast_ari_bridges_add_channel(struct ast_variable *headers, struct ast_ari_bridges_add_channel_args *args, struct ast_ari_response *response)
Add a channel to a bridge.
void ast_ari_bridges_set_bridge_var(struct ast_variable *headers, struct ast_ari_bridges_set_bridge_var_args *args, struct ast_ari_response *response)
Set the value of a bridge variable or function.
void ast_ari_bridges_clear_video_source(struct ast_variable *headers, struct ast_ari_bridges_clear_video_source_args *args, struct ast_ari_response *response)
Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bri...
void ast_ari_bridges_get(struct ast_variable *headers, struct ast_ari_bridges_get_args *args, struct ast_ari_response *response)
Get bridge details.
void ast_ari_bridges_play_with_id(struct ast_variable *headers, struct ast_ari_bridges_play_with_id_args *args, struct ast_ari_response *response)
Start playback of media on a bridge.
void ast_ari_bridges_play(struct ast_variable *headers, struct ast_ari_bridges_play_args *args, struct ast_ari_response *response)
Start playback of media on a bridge.
void ast_ari_bridges_destroy(struct ast_variable *headers, struct ast_ari_bridges_destroy_args *args, struct ast_ari_response *response)
Shut down a bridge.
void ast_ari_bridges_remove_channel(struct ast_variable *headers, struct ast_ari_bridges_remove_channel_args *args, struct ast_ari_response *response)
Remove a channel from a bridge.
void ast_ari_bridges_create(struct ast_variable *headers, struct ast_ari_bridges_create_args *args, struct ast_ari_response *response)
Create a new bridge.
void ast_ari_bridges_create_with_id(struct ast_variable *headers, struct ast_ari_bridges_create_with_id_args *args, struct ast_ari_response *response)
Create a new bridge.
void ast_ari_bridges_get_bridge_vars(struct ast_variable *headers, struct ast_ari_bridges_get_bridge_vars_args *args, struct ast_ari_response *response)
Get the value of multiple bridge variables or functions.
void ast_ari_bridges_set_video_source(struct ast_variable *headers, struct ast_ari_bridges_set_video_source_args *args, struct ast_ari_response *response)
Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bri...
void ast_ari_bridges_record(struct ast_variable *headers, struct ast_ari_bridges_record_args *args, struct ast_ari_response *response)
Start a recording.
void ast_ari_bridges_start_moh(struct ast_variable *headers, struct ast_ari_bridges_start_moh_args *args, struct ast_ari_response *response)
Play music on hold to a bridge or change the MOH class that is playing.
void ast_ari_bridges_get_bridge_var(struct ast_variable *headers, struct ast_ari_bridges_get_bridge_var_args *args, struct ast_ari_response *response)
Get the value of a bridge variable or function.
void ast_ari_bridges_stop_moh(struct ast_variable *headers, struct ast_ari_bridges_stop_moh_args *args, struct ast_ari_response *response)
Stop playing music on hold to a bridge.
void ast_ari_bridges_list(struct ast_variable *headers, struct ast_ari_bridges_list_args *args, struct ast_ari_response *response)
List all active bridges in Asterisk.
void ast_ari_bridges_set_bridge_vars(struct ast_variable *headers, struct ast_ari_bridges_set_bridge_vars_args *args, struct ast_ari_response *response)
Set the values of multiple bridge variables or functions.
Generated file - declares stubs to be implemented in res/ari/resource_bridges.c.
Stasis Application API. See Stasis Application API for detailed documentation.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition utils.c:2233
struct ast_json * message
Definition ari.h:103
int response_code
Definition ari.h:108
Abstract JSON element (object, array, string, int, ...).
describes a server instance
Definition tcptls.h:151
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Handler for a single RESTful path segment.
Definition ari.h:69
const char * path_segment
Definition ari.h:71
#define ARRAY_LEN(a)
Definition utils.h:706