Asterisk - The Open Source Telephony Project GIT-master-f36a736
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 }
163 goto fin;
164 }
165 ast_ari_bridges_create(headers, &args, response);
166#if defined(AST_DEVMODE)
167 code = response->response_code;
168
169 switch (code) {
170 case 0: /* Implementation is still a stub, or the code wasn't set */
171 is_valid = response->message == NULL;
172 break;
173 case 500: /* Internal Server Error */
174 case 501: /* Not Implemented */
175 is_valid = 1;
176 break;
177 default:
178 if (200 <= code && code <= 299) {
179 is_valid = ast_ari_validate_bridge(
180 response->message);
181 } else {
182 ast_log(LOG_ERROR, "Invalid error response %d for /bridges\n", code);
183 is_valid = 0;
184 }
185 }
186
187 if (!is_valid) {
188 ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
189 ast_ari_response_error(response, 500,
190 "Internal Server Error", "Response validation failed");
191 }
192#endif /* AST_DEVMODE */
193
194fin: __attribute__((unused))
195 return;
196}
198 struct ast_json *body,
200{
201 struct ast_json *field;
202 /* Parse query parameters out of it */
203 field = ast_json_object_get(body, "type");
204 if (field) {
205 args->type = ast_json_string_get(field);
206 }
207 field = ast_json_object_get(body, "name");
208 if (field) {
209 args->name = ast_json_string_get(field);
210 }
211 return 0;
212}
213
214/*!
215 * \brief Parameter parsing callback for /bridges/{bridgeId}.
216 * \param ser TCP/TLS session object
217 * \param get_params GET parameters in the HTTP request.
218 * \param path_vars Path variables extracted from the request.
219 * \param headers HTTP headers.
220 * \param body
221 * \param[out] response Response to the HTTP request.
222 */
224 struct ast_tcptls_session_instance *ser,
225 struct ast_variable *get_params, struct ast_variable *path_vars,
226 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
227{
229 struct ast_variable *i;
230#if defined(AST_DEVMODE)
231 int is_valid;
232 int code;
233#endif /* AST_DEVMODE */
234
235 for (i = get_params; i; i = i->next) {
236 if (strcmp(i->name, "type") == 0) {
237 args.type = (i->value);
238 } else
239 if (strcmp(i->name, "name") == 0) {
240 args.name = (i->value);
241 } else
242 {}
243 }
244 for (i = path_vars; i; i = i->next) {
245 if (strcmp(i->name, "bridgeId") == 0) {
246 args.bridge_id = (i->value);
247 } else
248 {}
249 }
252 goto fin;
253 }
254 ast_ari_bridges_create_with_id(headers, &args, response);
255#if defined(AST_DEVMODE)
256 code = response->response_code;
257
258 switch (code) {
259 case 0: /* Implementation is still a stub, or the code wasn't set */
260 is_valid = response->message == NULL;
261 break;
262 case 500: /* Internal Server Error */
263 case 501: /* Not Implemented */
264 is_valid = 1;
265 break;
266 default:
267 if (200 <= code && code <= 299) {
268 is_valid = ast_ari_validate_bridge(
269 response->message);
270 } else {
271 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
272 is_valid = 0;
273 }
274 }
275
276 if (!is_valid) {
277 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
278 ast_ari_response_error(response, 500,
279 "Internal Server Error", "Response validation failed");
280 }
281#endif /* AST_DEVMODE */
282
283fin: __attribute__((unused))
284 return;
285}
286/*!
287 * \brief Parameter parsing callback for /bridges/{bridgeId}.
288 * \param ser TCP/TLS session object
289 * \param get_params GET parameters in the HTTP request.
290 * \param path_vars Path variables extracted from the request.
291 * \param headers HTTP headers.
292 * \param body
293 * \param[out] response Response to the HTTP request.
294 */
296 struct ast_tcptls_session_instance *ser,
297 struct ast_variable *get_params, struct ast_variable *path_vars,
298 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
299{
300 struct ast_ari_bridges_get_args args = {};
301 struct ast_variable *i;
302#if defined(AST_DEVMODE)
303 int is_valid;
304 int code;
305#endif /* AST_DEVMODE */
306
307 for (i = path_vars; i; i = i->next) {
308 if (strcmp(i->name, "bridgeId") == 0) {
309 args.bridge_id = (i->value);
310 } else
311 {}
312 }
313 ast_ari_bridges_get(headers, &args, response);
314#if defined(AST_DEVMODE)
315 code = response->response_code;
316
317 switch (code) {
318 case 0: /* Implementation is still a stub, or the code wasn't set */
319 is_valid = response->message == NULL;
320 break;
321 case 500: /* Internal Server Error */
322 case 501: /* Not Implemented */
323 case 404: /* Bridge not found */
324 is_valid = 1;
325 break;
326 default:
327 if (200 <= code && code <= 299) {
328 is_valid = ast_ari_validate_bridge(
329 response->message);
330 } else {
331 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
332 is_valid = 0;
333 }
334 }
335
336 if (!is_valid) {
337 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
338 ast_ari_response_error(response, 500,
339 "Internal Server Error", "Response validation failed");
340 }
341#endif /* AST_DEVMODE */
342
343fin: __attribute__((unused))
344 return;
345}
346/*!
347 * \brief Parameter parsing callback for /bridges/{bridgeId}.
348 * \param ser TCP/TLS session object
349 * \param get_params GET parameters in the HTTP request.
350 * \param path_vars Path variables extracted from the request.
351 * \param headers HTTP headers.
352 * \param body
353 * \param[out] response Response to the HTTP request.
354 */
356 struct ast_tcptls_session_instance *ser,
357 struct ast_variable *get_params, struct ast_variable *path_vars,
358 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
359{
361 struct ast_variable *i;
362#if defined(AST_DEVMODE)
363 int is_valid;
364 int code;
365#endif /* AST_DEVMODE */
366
367 for (i = path_vars; i; i = i->next) {
368 if (strcmp(i->name, "bridgeId") == 0) {
369 args.bridge_id = (i->value);
370 } else
371 {}
372 }
373 ast_ari_bridges_destroy(headers, &args, response);
374#if defined(AST_DEVMODE)
375 code = response->response_code;
376
377 switch (code) {
378 case 0: /* Implementation is still a stub, or the code wasn't set */
379 is_valid = response->message == NULL;
380 break;
381 case 500: /* Internal Server Error */
382 case 501: /* Not Implemented */
383 case 404: /* Bridge not found */
384 is_valid = 1;
385 break;
386 default:
387 if (200 <= code && code <= 299) {
388 is_valid = ast_ari_validate_void(
389 response->message);
390 } else {
391 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
392 is_valid = 0;
393 }
394 }
395
396 if (!is_valid) {
397 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
398 ast_ari_response_error(response, 500,
399 "Internal Server Error", "Response validation failed");
400 }
401#endif /* AST_DEVMODE */
402
403fin: __attribute__((unused))
404 return;
405}
407 struct ast_json *body,
409{
410 struct ast_json *field;
411 /* Parse query parameters out of it */
412 field = ast_json_object_get(body, "channel");
413 if (field) {
414 /* If they were silly enough to both pass in a query param and a
415 * JSON body, free up the query value.
416 */
417 ast_free(args->channel);
418 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
419 /* Multiple param passed as array */
420 size_t i;
421 args->channel_count = ast_json_array_size(field);
422 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
423
424 if (!args->channel) {
425 return -1;
426 }
427
428 for (i = 0; i < args->channel_count; ++i) {
429 args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
430 }
431 } else {
432 /* Multiple param passed as single value */
433 args->channel_count = 1;
434 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
435 if (!args->channel) {
436 return -1;
437 }
438 args->channel[0] = ast_json_string_get(field);
439 }
440 }
441 field = ast_json_object_get(body, "role");
442 if (field) {
443 args->role = ast_json_string_get(field);
444 }
445 field = ast_json_object_get(body, "absorbDTMF");
446 if (field) {
447 args->absorb_dtmf = ast_json_is_true(field);
448 }
449 field = ast_json_object_get(body, "mute");
450 if (field) {
451 args->mute = ast_json_is_true(field);
452 }
453 field = ast_json_object_get(body, "inhibitConnectedLineUpdates");
454 if (field) {
455 args->inhibit_connected_line_updates = ast_json_is_true(field);
456 }
457 return 0;
458}
459
460/*!
461 * \brief Parameter parsing callback for /bridges/{bridgeId}/addChannel.
462 * \param ser TCP/TLS session object
463 * \param get_params GET parameters in the HTTP request.
464 * \param path_vars Path variables extracted from the request.
465 * \param headers HTTP headers.
466 * \param body
467 * \param[out] response Response to the HTTP request.
468 */
470 struct ast_tcptls_session_instance *ser,
471 struct ast_variable *get_params, struct ast_variable *path_vars,
472 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
473{
475 struct ast_variable *i;
476#if defined(AST_DEVMODE)
477 int is_valid;
478 int code;
479#endif /* AST_DEVMODE */
480
481 for (i = get_params; i; i = i->next) {
482 if (strcmp(i->name, "channel") == 0) {
483 /* Parse comma separated list */
484 char *vals[MAX_VALS];
485 size_t j;
486
487 args.channel_parse = ast_strdup(i->value);
488 if (!args.channel_parse) {
490 goto fin;
491 }
492
493 if (strlen(args.channel_parse) == 0) {
494 /* ast_app_separate_args can't handle "" */
495 args.channel_count = 1;
496 vals[0] = args.channel_parse;
497 } else {
498 args.channel_count = ast_app_separate_args(
499 args.channel_parse, ',', vals,
500 ARRAY_LEN(vals));
501 }
502
503 if (args.channel_count == 0) {
505 goto fin;
506 }
507
508 if (args.channel_count >= MAX_VALS) {
509 ast_ari_response_error(response, 400,
510 "Bad Request",
511 "Too many values for channel");
512 goto fin;
513 }
514
515 args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
516 if (!args.channel) {
518 goto fin;
519 }
520
521 for (j = 0; j < args.channel_count; ++j) {
522 args.channel[j] = (vals[j]);
523 }
524 } else
525 if (strcmp(i->name, "role") == 0) {
526 args.role = (i->value);
527 } else
528 if (strcmp(i->name, "absorbDTMF") == 0) {
529 args.absorb_dtmf = ast_true(i->value);
530 } else
531 if (strcmp(i->name, "mute") == 0) {
532 args.mute = ast_true(i->value);
533 } else
534 if (strcmp(i->name, "inhibitConnectedLineUpdates") == 0) {
535 args.inhibit_connected_line_updates = ast_true(i->value);
536 } else
537 {}
538 }
539 for (i = path_vars; i; i = i->next) {
540 if (strcmp(i->name, "bridgeId") == 0) {
541 args.bridge_id = (i->value);
542 } else
543 {}
544 }
547 goto fin;
548 }
549 ast_ari_bridges_add_channel(headers, &args, response);
550#if defined(AST_DEVMODE)
551 code = response->response_code;
552
553 switch (code) {
554 case 0: /* Implementation is still a stub, or the code wasn't set */
555 is_valid = response->message == NULL;
556 break;
557 case 500: /* Internal Server Error */
558 case 501: /* Not Implemented */
559 case 400: /* Channel not found */
560 case 404: /* Bridge not found */
561 case 409: /* Bridge not in Stasis application; Channel currently recording */
562 case 422: /* Channel not in Stasis application */
563 is_valid = 1;
564 break;
565 default:
566 if (200 <= code && code <= 299) {
567 is_valid = ast_ari_validate_void(
568 response->message);
569 } else {
570 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/addChannel\n", code);
571 is_valid = 0;
572 }
573 }
574
575 if (!is_valid) {
576 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/addChannel\n");
577 ast_ari_response_error(response, 500,
578 "Internal Server Error", "Response validation failed");
579 }
580#endif /* AST_DEVMODE */
581
582fin: __attribute__((unused))
583 ast_free(args.channel_parse);
584 ast_free(args.channel);
585 return;
586}
588 struct ast_json *body,
590{
591 struct ast_json *field;
592 /* Parse query parameters out of it */
593 field = ast_json_object_get(body, "channel");
594 if (field) {
595 /* If they were silly enough to both pass in a query param and a
596 * JSON body, free up the query value.
597 */
598 ast_free(args->channel);
599 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
600 /* Multiple param passed as array */
601 size_t i;
602 args->channel_count = ast_json_array_size(field);
603 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
604
605 if (!args->channel) {
606 return -1;
607 }
608
609 for (i = 0; i < args->channel_count; ++i) {
610 args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
611 }
612 } else {
613 /* Multiple param passed as single value */
614 args->channel_count = 1;
615 args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
616 if (!args->channel) {
617 return -1;
618 }
619 args->channel[0] = ast_json_string_get(field);
620 }
621 }
622 return 0;
623}
624
625/*!
626 * \brief Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
627 * \param ser TCP/TLS session object
628 * \param get_params GET parameters in the HTTP request.
629 * \param path_vars Path variables extracted from the request.
630 * \param headers HTTP headers.
631 * \param body
632 * \param[out] response Response to the HTTP request.
633 */
635 struct ast_tcptls_session_instance *ser,
636 struct ast_variable *get_params, struct ast_variable *path_vars,
637 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
638{
640 struct ast_variable *i;
641#if defined(AST_DEVMODE)
642 int is_valid;
643 int code;
644#endif /* AST_DEVMODE */
645
646 for (i = get_params; i; i = i->next) {
647 if (strcmp(i->name, "channel") == 0) {
648 /* Parse comma separated list */
649 char *vals[MAX_VALS];
650 size_t j;
651
652 args.channel_parse = ast_strdup(i->value);
653 if (!args.channel_parse) {
655 goto fin;
656 }
657
658 if (strlen(args.channel_parse) == 0) {
659 /* ast_app_separate_args can't handle "" */
660 args.channel_count = 1;
661 vals[0] = args.channel_parse;
662 } else {
663 args.channel_count = ast_app_separate_args(
664 args.channel_parse, ',', vals,
665 ARRAY_LEN(vals));
666 }
667
668 if (args.channel_count == 0) {
670 goto fin;
671 }
672
673 if (args.channel_count >= MAX_VALS) {
674 ast_ari_response_error(response, 400,
675 "Bad Request",
676 "Too many values for channel");
677 goto fin;
678 }
679
680 args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
681 if (!args.channel) {
683 goto fin;
684 }
685
686 for (j = 0; j < args.channel_count; ++j) {
687 args.channel[j] = (vals[j]);
688 }
689 } else
690 {}
691 }
692 for (i = path_vars; i; i = i->next) {
693 if (strcmp(i->name, "bridgeId") == 0) {
694 args.bridge_id = (i->value);
695 } else
696 {}
697 }
700 goto fin;
701 }
702 ast_ari_bridges_remove_channel(headers, &args, response);
703#if defined(AST_DEVMODE)
704 code = response->response_code;
705
706 switch (code) {
707 case 0: /* Implementation is still a stub, or the code wasn't set */
708 is_valid = response->message == NULL;
709 break;
710 case 500: /* Internal Server Error */
711 case 501: /* Not Implemented */
712 case 400: /* Channel not found */
713 case 404: /* Bridge not found */
714 case 409: /* Bridge not in Stasis application */
715 case 422: /* Channel not in this bridge */
716 is_valid = 1;
717 break;
718 default:
719 if (200 <= code && code <= 299) {
720 is_valid = ast_ari_validate_void(
721 response->message);
722 } else {
723 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/removeChannel\n", code);
724 is_valid = 0;
725 }
726 }
727
728 if (!is_valid) {
729 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/removeChannel\n");
730 ast_ari_response_error(response, 500,
731 "Internal Server Error", "Response validation failed");
732 }
733#endif /* AST_DEVMODE */
734
735fin: __attribute__((unused))
736 ast_free(args.channel_parse);
737 ast_free(args.channel);
738 return;
739}
740/*!
741 * \brief Parameter parsing callback for /bridges/{bridgeId}/videoSource/{channelId}.
742 * \param ser TCP/TLS session object
743 * \param get_params GET parameters in the HTTP request.
744 * \param path_vars Path variables extracted from the request.
745 * \param headers HTTP headers.
746 * \param body
747 * \param[out] response Response to the HTTP request.
748 */
750 struct ast_tcptls_session_instance *ser,
751 struct ast_variable *get_params, struct ast_variable *path_vars,
752 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
753{
755 struct ast_variable *i;
756#if defined(AST_DEVMODE)
757 int is_valid;
758 int code;
759#endif /* AST_DEVMODE */
760
761 for (i = path_vars; i; i = i->next) {
762 if (strcmp(i->name, "bridgeId") == 0) {
763 args.bridge_id = (i->value);
764 } else
765 if (strcmp(i->name, "channelId") == 0) {
766 args.channel_id = (i->value);
767 } else
768 {}
769 }
770 ast_ari_bridges_set_video_source(headers, &args, response);
771#if defined(AST_DEVMODE)
772 code = response->response_code;
773
774 switch (code) {
775 case 0: /* Implementation is still a stub, or the code wasn't set */
776 is_valid = response->message == NULL;
777 break;
778 case 500: /* Internal Server Error */
779 case 501: /* Not Implemented */
780 case 404: /* Bridge or Channel not found */
781 case 409: /* Channel not in Stasis application */
782 case 422: /* Channel not in this Bridge */
783 is_valid = 1;
784 break;
785 default:
786 if (200 <= code && code <= 299) {
787 is_valid = ast_ari_validate_void(
788 response->message);
789 } else {
790 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/videoSource/{channelId}\n", code);
791 is_valid = 0;
792 }
793 }
794
795 if (!is_valid) {
796 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/videoSource/{channelId}\n");
797 ast_ari_response_error(response, 500,
798 "Internal Server Error", "Response validation failed");
799 }
800#endif /* AST_DEVMODE */
801
802fin: __attribute__((unused))
803 return;
804}
805/*!
806 * \brief Parameter parsing callback for /bridges/{bridgeId}/videoSource.
807 * \param ser TCP/TLS session object
808 * \param get_params GET parameters in the HTTP request.
809 * \param path_vars Path variables extracted from the request.
810 * \param headers HTTP headers.
811 * \param body
812 * \param[out] response Response to the HTTP request.
813 */
815 struct ast_tcptls_session_instance *ser,
816 struct ast_variable *get_params, struct ast_variable *path_vars,
817 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
818{
820 struct ast_variable *i;
821#if defined(AST_DEVMODE)
822 int is_valid;
823 int code;
824#endif /* AST_DEVMODE */
825
826 for (i = path_vars; i; i = i->next) {
827 if (strcmp(i->name, "bridgeId") == 0) {
828 args.bridge_id = (i->value);
829 } else
830 {}
831 }
832 ast_ari_bridges_clear_video_source(headers, &args, response);
833#if defined(AST_DEVMODE)
834 code = response->response_code;
835
836 switch (code) {
837 case 0: /* Implementation is still a stub, or the code wasn't set */
838 is_valid = response->message == NULL;
839 break;
840 case 500: /* Internal Server Error */
841 case 501: /* Not Implemented */
842 case 404: /* Bridge not found */
843 is_valid = 1;
844 break;
845 default:
846 if (200 <= code && code <= 299) {
847 is_valid = ast_ari_validate_void(
848 response->message);
849 } else {
850 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/videoSource\n", code);
851 is_valid = 0;
852 }
853 }
854
855 if (!is_valid) {
856 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/videoSource\n");
857 ast_ari_response_error(response, 500,
858 "Internal Server Error", "Response validation failed");
859 }
860#endif /* AST_DEVMODE */
861
862fin: __attribute__((unused))
863 return;
864}
866 struct ast_json *body,
868{
869 struct ast_json *field;
870 /* Parse query parameters out of it */
871 field = ast_json_object_get(body, "mohClass");
872 if (field) {
873 args->moh_class = ast_json_string_get(field);
874 }
875 return 0;
876}
877
878/*!
879 * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
880 * \param ser TCP/TLS session object
881 * \param get_params GET parameters in the HTTP request.
882 * \param path_vars Path variables extracted from the request.
883 * \param headers HTTP headers.
884 * \param body
885 * \param[out] response Response to the HTTP request.
886 */
888 struct ast_tcptls_session_instance *ser,
889 struct ast_variable *get_params, struct ast_variable *path_vars,
890 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
891{
893 struct ast_variable *i;
894#if defined(AST_DEVMODE)
895 int is_valid;
896 int code;
897#endif /* AST_DEVMODE */
898
899 for (i = get_params; i; i = i->next) {
900 if (strcmp(i->name, "mohClass") == 0) {
901 args.moh_class = (i->value);
902 } else
903 {}
904 }
905 for (i = path_vars; i; i = i->next) {
906 if (strcmp(i->name, "bridgeId") == 0) {
907 args.bridge_id = (i->value);
908 } else
909 {}
910 }
913 goto fin;
914 }
915 ast_ari_bridges_start_moh(headers, &args, response);
916#if defined(AST_DEVMODE)
917 code = response->response_code;
918
919 switch (code) {
920 case 0: /* Implementation is still a stub, or the code wasn't set */
921 is_valid = response->message == NULL;
922 break;
923 case 500: /* Internal Server Error */
924 case 501: /* Not Implemented */
925 case 404: /* Bridge not found */
926 case 409: /* Bridge not in Stasis application */
927 is_valid = 1;
928 break;
929 default:
930 if (200 <= code && code <= 299) {
931 is_valid = ast_ari_validate_void(
932 response->message);
933 } else {
934 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
935 is_valid = 0;
936 }
937 }
938
939 if (!is_valid) {
940 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
941 ast_ari_response_error(response, 500,
942 "Internal Server Error", "Response validation failed");
943 }
944#endif /* AST_DEVMODE */
945
946fin: __attribute__((unused))
947 return;
948}
949/*!
950 * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
951 * \param ser TCP/TLS session object
952 * \param get_params GET parameters in the HTTP request.
953 * \param path_vars Path variables extracted from the request.
954 * \param headers HTTP headers.
955 * \param body
956 * \param[out] response Response to the HTTP request.
957 */
959 struct ast_tcptls_session_instance *ser,
960 struct ast_variable *get_params, struct ast_variable *path_vars,
961 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
962{
964 struct ast_variable *i;
965#if defined(AST_DEVMODE)
966 int is_valid;
967 int code;
968#endif /* AST_DEVMODE */
969
970 for (i = path_vars; i; i = i->next) {
971 if (strcmp(i->name, "bridgeId") == 0) {
972 args.bridge_id = (i->value);
973 } else
974 {}
975 }
976 ast_ari_bridges_stop_moh(headers, &args, response);
977#if defined(AST_DEVMODE)
978 code = response->response_code;
979
980 switch (code) {
981 case 0: /* Implementation is still a stub, or the code wasn't set */
982 is_valid = response->message == NULL;
983 break;
984 case 500: /* Internal Server Error */
985 case 501: /* Not Implemented */
986 case 404: /* Bridge not found */
987 case 409: /* Bridge not in Stasis application */
988 is_valid = 1;
989 break;
990 default:
991 if (200 <= code && code <= 299) {
992 is_valid = ast_ari_validate_void(
993 response->message);
994 } else {
995 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
996 is_valid = 0;
997 }
998 }
999
1000 if (!is_valid) {
1001 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
1002 ast_ari_response_error(response, 500,
1003 "Internal Server Error", "Response validation failed");
1004 }
1005#endif /* AST_DEVMODE */
1006
1007fin: __attribute__((unused))
1008 return;
1009}
1011 struct ast_json *body,
1013{
1014 struct ast_json *field;
1015 /* Parse query parameters out of it */
1016 field = ast_json_object_get(body, "media");
1017 if (field) {
1018 /* If they were silly enough to both pass in a query param and a
1019 * JSON body, free up the query value.
1020 */
1021 ast_free(args->media);
1022 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1023 /* Multiple param passed as array */
1024 size_t i;
1025 args->media_count = ast_json_array_size(field);
1026 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1027
1028 if (!args->media) {
1029 return -1;
1030 }
1031
1032 for (i = 0; i < args->media_count; ++i) {
1033 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1034 }
1035 } else {
1036 /* Multiple param passed as single value */
1037 args->media_count = 1;
1038 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1039 if (!args->media) {
1040 return -1;
1041 }
1042 args->media[0] = ast_json_string_get(field);
1043 }
1044 }
1045 field = ast_json_object_get(body, "lang");
1046 if (field) {
1047 args->lang = ast_json_string_get(field);
1048 }
1049 field = ast_json_object_get(body, "offsetms");
1050 if (field) {
1051 args->offsetms = ast_json_integer_get(field);
1052 }
1053 field = ast_json_object_get(body, "skipms");
1054 if (field) {
1055 args->skipms = ast_json_integer_get(field);
1056 }
1057 field = ast_json_object_get(body, "playbackId");
1058 if (field) {
1059 args->playback_id = ast_json_string_get(field);
1060 }
1061 return 0;
1062}
1063
1064/*!
1065 * \brief Parameter parsing callback for /bridges/{bridgeId}/play.
1066 * \param ser TCP/TLS session object
1067 * \param get_params GET parameters in the HTTP request.
1068 * \param path_vars Path variables extracted from the request.
1069 * \param headers HTTP headers.
1070 * \param body
1071 * \param[out] response Response to the HTTP request.
1072 */
1074 struct ast_tcptls_session_instance *ser,
1075 struct ast_variable *get_params, struct ast_variable *path_vars,
1076 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1077{
1078 struct ast_ari_bridges_play_args args = {};
1079 struct ast_variable *i;
1080#if defined(AST_DEVMODE)
1081 int is_valid;
1082 int code;
1083#endif /* AST_DEVMODE */
1084
1085 for (i = get_params; i; i = i->next) {
1086 if (strcmp(i->name, "media") == 0) {
1087 /* Parse comma separated list */
1088 char *vals[MAX_VALS];
1089 size_t j;
1090
1091 args.media_parse = ast_strdup(i->value);
1092 if (!args.media_parse) {
1094 goto fin;
1095 }
1096
1097 if (strlen(args.media_parse) == 0) {
1098 /* ast_app_separate_args can't handle "" */
1099 args.media_count = 1;
1100 vals[0] = args.media_parse;
1101 } else {
1102 args.media_count = ast_app_separate_args(
1103 args.media_parse, ',', vals,
1104 ARRAY_LEN(vals));
1105 }
1106
1107 if (args.media_count == 0) {
1109 goto fin;
1110 }
1111
1112 if (args.media_count >= MAX_VALS) {
1113 ast_ari_response_error(response, 400,
1114 "Bad Request",
1115 "Too many values for media");
1116 goto fin;
1117 }
1118
1119 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
1120 if (!args.media) {
1122 goto fin;
1123 }
1124
1125 for (j = 0; j < args.media_count; ++j) {
1126 args.media[j] = (vals[j]);
1127 }
1128 } else
1129 if (strcmp(i->name, "lang") == 0) {
1130 args.lang = (i->value);
1131 } else
1132 if (strcmp(i->name, "offsetms") == 0) {
1133 args.offsetms = atoi(i->value);
1134 } else
1135 if (strcmp(i->name, "skipms") == 0) {
1136 args.skipms = atoi(i->value);
1137 } else
1138 if (strcmp(i->name, "playbackId") == 0) {
1139 args.playback_id = (i->value);
1140 } else
1141 {}
1142 }
1143 for (i = path_vars; i; i = i->next) {
1144 if (strcmp(i->name, "bridgeId") == 0) {
1145 args.bridge_id = (i->value);
1146 } else
1147 {}
1148 }
1151 goto fin;
1152 }
1153 ast_ari_bridges_play(headers, &args, response);
1154#if defined(AST_DEVMODE)
1155 code = response->response_code;
1156
1157 switch (code) {
1158 case 0: /* Implementation is still a stub, or the code wasn't set */
1159 is_valid = response->message == NULL;
1160 break;
1161 case 500: /* Internal Server Error */
1162 case 501: /* Not Implemented */
1163 case 404: /* Bridge not found */
1164 case 409: /* Bridge not in a Stasis application */
1165 is_valid = 1;
1166 break;
1167 default:
1168 if (200 <= code && code <= 299) {
1169 is_valid = ast_ari_validate_playback(
1170 response->message);
1171 } else {
1172 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/play\n", code);
1173 is_valid = 0;
1174 }
1175 }
1176
1177 if (!is_valid) {
1178 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/play\n");
1179 ast_ari_response_error(response, 500,
1180 "Internal Server Error", "Response validation failed");
1181 }
1182#endif /* AST_DEVMODE */
1183
1184fin: __attribute__((unused))
1185 ast_free(args.media_parse);
1186 ast_free(args.media);
1187 return;
1188}
1190 struct ast_json *body,
1192{
1193 struct ast_json *field;
1194 /* Parse query parameters out of it */
1195 field = ast_json_object_get(body, "media");
1196 if (field) {
1197 /* If they were silly enough to both pass in a query param and a
1198 * JSON body, free up the query value.
1199 */
1200 ast_free(args->media);
1201 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1202 /* Multiple param passed as array */
1203 size_t i;
1204 args->media_count = ast_json_array_size(field);
1205 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1206
1207 if (!args->media) {
1208 return -1;
1209 }
1210
1211 for (i = 0; i < args->media_count; ++i) {
1212 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1213 }
1214 } else {
1215 /* Multiple param passed as single value */
1216 args->media_count = 1;
1217 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1218 if (!args->media) {
1219 return -1;
1220 }
1221 args->media[0] = ast_json_string_get(field);
1222 }
1223 }
1224 field = ast_json_object_get(body, "lang");
1225 if (field) {
1226 args->lang = ast_json_string_get(field);
1227 }
1228 field = ast_json_object_get(body, "offsetms");
1229 if (field) {
1230 args->offsetms = ast_json_integer_get(field);
1231 }
1232 field = ast_json_object_get(body, "skipms");
1233 if (field) {
1234 args->skipms = ast_json_integer_get(field);
1235 }
1236 return 0;
1237}
1238
1239/*!
1240 * \brief Parameter parsing callback for /bridges/{bridgeId}/play/{playbackId}.
1241 * \param ser TCP/TLS session object
1242 * \param get_params GET parameters in the HTTP request.
1243 * \param path_vars Path variables extracted from the request.
1244 * \param headers HTTP headers.
1245 * \param body
1246 * \param[out] response Response to the HTTP request.
1247 */
1249 struct ast_tcptls_session_instance *ser,
1250 struct ast_variable *get_params, struct ast_variable *path_vars,
1251 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1252{
1254 struct ast_variable *i;
1255#if defined(AST_DEVMODE)
1256 int is_valid;
1257 int code;
1258#endif /* AST_DEVMODE */
1259
1260 for (i = get_params; i; i = i->next) {
1261 if (strcmp(i->name, "media") == 0) {
1262 /* Parse comma separated list */
1263 char *vals[MAX_VALS];
1264 size_t j;
1265
1266 args.media_parse = ast_strdup(i->value);
1267 if (!args.media_parse) {
1269 goto fin;
1270 }
1271
1272 if (strlen(args.media_parse) == 0) {
1273 /* ast_app_separate_args can't handle "" */
1274 args.media_count = 1;
1275 vals[0] = args.media_parse;
1276 } else {
1277 args.media_count = ast_app_separate_args(
1278 args.media_parse, ',', vals,
1279 ARRAY_LEN(vals));
1280 }
1281
1282 if (args.media_count == 0) {
1284 goto fin;
1285 }
1286
1287 if (args.media_count >= MAX_VALS) {
1288 ast_ari_response_error(response, 400,
1289 "Bad Request",
1290 "Too many values for media");
1291 goto fin;
1292 }
1293
1294 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
1295 if (!args.media) {
1297 goto fin;
1298 }
1299
1300 for (j = 0; j < args.media_count; ++j) {
1301 args.media[j] = (vals[j]);
1302 }
1303 } else
1304 if (strcmp(i->name, "lang") == 0) {
1305 args.lang = (i->value);
1306 } else
1307 if (strcmp(i->name, "offsetms") == 0) {
1308 args.offsetms = atoi(i->value);
1309 } else
1310 if (strcmp(i->name, "skipms") == 0) {
1311 args.skipms = atoi(i->value);
1312 } else
1313 {}
1314 }
1315 for (i = path_vars; i; i = i->next) {
1316 if (strcmp(i->name, "bridgeId") == 0) {
1317 args.bridge_id = (i->value);
1318 } else
1319 if (strcmp(i->name, "playbackId") == 0) {
1320 args.playback_id = (i->value);
1321 } else
1322 {}
1323 }
1326 goto fin;
1327 }
1328 ast_ari_bridges_play_with_id(headers, &args, response);
1329#if defined(AST_DEVMODE)
1330 code = response->response_code;
1331
1332 switch (code) {
1333 case 0: /* Implementation is still a stub, or the code wasn't set */
1334 is_valid = response->message == NULL;
1335 break;
1336 case 500: /* Internal Server Error */
1337 case 501: /* Not Implemented */
1338 case 404: /* Bridge not found */
1339 case 409: /* Bridge not in a Stasis application */
1340 is_valid = 1;
1341 break;
1342 default:
1343 if (200 <= code && code <= 299) {
1344 is_valid = ast_ari_validate_playback(
1345 response->message);
1346 } else {
1347 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/play/{playbackId}\n", code);
1348 is_valid = 0;
1349 }
1350 }
1351
1352 if (!is_valid) {
1353 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/play/{playbackId}\n");
1354 ast_ari_response_error(response, 500,
1355 "Internal Server Error", "Response validation failed");
1356 }
1357#endif /* AST_DEVMODE */
1358
1359fin: __attribute__((unused))
1360 ast_free(args.media_parse);
1361 ast_free(args.media);
1362 return;
1363}
1365 struct ast_json *body,
1367{
1368 struct ast_json *field;
1369 /* Parse query parameters out of it */
1370 field = ast_json_object_get(body, "name");
1371 if (field) {
1372 args->name = ast_json_string_get(field);
1373 }
1374 field = ast_json_object_get(body, "format");
1375 if (field) {
1376 args->format = ast_json_string_get(field);
1377 }
1378 field = ast_json_object_get(body, "maxDurationSeconds");
1379 if (field) {
1380 args->max_duration_seconds = ast_json_integer_get(field);
1381 }
1382 field = ast_json_object_get(body, "maxSilenceSeconds");
1383 if (field) {
1384 args->max_silence_seconds = ast_json_integer_get(field);
1385 }
1386 field = ast_json_object_get(body, "ifExists");
1387 if (field) {
1388 args->if_exists = ast_json_string_get(field);
1389 }
1390 field = ast_json_object_get(body, "beep");
1391 if (field) {
1392 args->beep = ast_json_is_true(field);
1393 }
1394 field = ast_json_object_get(body, "terminateOn");
1395 if (field) {
1396 args->terminate_on = ast_json_string_get(field);
1397 }
1398 return 0;
1399}
1400
1401/*!
1402 * \brief Parameter parsing callback for /bridges/{bridgeId}/record.
1403 * \param ser TCP/TLS session object
1404 * \param get_params GET parameters in the HTTP request.
1405 * \param path_vars Path variables extracted from the request.
1406 * \param headers HTTP headers.
1407 * \param body
1408 * \param[out] response Response to the HTTP request.
1409 */
1411 struct ast_tcptls_session_instance *ser,
1412 struct ast_variable *get_params, struct ast_variable *path_vars,
1413 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1414{
1416 struct ast_variable *i;
1417#if defined(AST_DEVMODE)
1418 int is_valid;
1419 int code;
1420#endif /* AST_DEVMODE */
1421
1422 for (i = get_params; i; i = i->next) {
1423 if (strcmp(i->name, "name") == 0) {
1424 args.name = (i->value);
1425 } else
1426 if (strcmp(i->name, "format") == 0) {
1427 args.format = (i->value);
1428 } else
1429 if (strcmp(i->name, "maxDurationSeconds") == 0) {
1430 args.max_duration_seconds = atoi(i->value);
1431 } else
1432 if (strcmp(i->name, "maxSilenceSeconds") == 0) {
1433 args.max_silence_seconds = atoi(i->value);
1434 } else
1435 if (strcmp(i->name, "ifExists") == 0) {
1436 args.if_exists = (i->value);
1437 } else
1438 if (strcmp(i->name, "beep") == 0) {
1439 args.beep = ast_true(i->value);
1440 } else
1441 if (strcmp(i->name, "terminateOn") == 0) {
1442 args.terminate_on = (i->value);
1443 } else
1444 {}
1445 }
1446 for (i = path_vars; i; i = i->next) {
1447 if (strcmp(i->name, "bridgeId") == 0) {
1448 args.bridge_id = (i->value);
1449 } else
1450 {}
1451 }
1454 goto fin;
1455 }
1456 ast_ari_bridges_record(headers, &args, response);
1457#if defined(AST_DEVMODE)
1458 code = response->response_code;
1459
1460 switch (code) {
1461 case 0: /* Implementation is still a stub, or the code wasn't set */
1462 is_valid = response->message == NULL;
1463 break;
1464 case 500: /* Internal Server Error */
1465 case 501: /* Not Implemented */
1466 case 400: /* Invalid parameters */
1467 case 404: /* Bridge not found */
1468 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 */
1469 case 422: /* The format specified is unknown on this system */
1470 is_valid = 1;
1471 break;
1472 default:
1473 if (200 <= code && code <= 299) {
1475 response->message);
1476 } else {
1477 ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/record\n", code);
1478 is_valid = 0;
1479 }
1480 }
1481
1482 if (!is_valid) {
1483 ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/record\n");
1484 ast_ari_response_error(response, 500,
1485 "Internal Server Error", "Response validation failed");
1486 }
1487#endif /* AST_DEVMODE */
1488
1489fin: __attribute__((unused))
1490 return;
1491}
1492
1493/*! \brief REST handler for /api-docs/bridges.json */
1495 .path_segment = "addChannel",
1496 .callbacks = {
1498 },
1499 .num_children = 0,
1500 .children = { }
1501};
1502/*! \brief REST handler for /api-docs/bridges.json */
1504 .path_segment = "removeChannel",
1505 .callbacks = {
1507 },
1508 .num_children = 0,
1509 .children = { }
1510};
1511/*! \brief REST handler for /api-docs/bridges.json */
1513 .path_segment = "channelId",
1514 .is_wildcard = 1,
1515 .callbacks = {
1517 },
1518 .num_children = 0,
1519 .children = { }
1520};
1521/*! \brief REST handler for /api-docs/bridges.json */
1523 .path_segment = "videoSource",
1524 .callbacks = {
1526 },
1527 .num_children = 1,
1529};
1530/*! \brief REST handler for /api-docs/bridges.json */
1532 .path_segment = "moh",
1533 .callbacks = {
1536 },
1537 .num_children = 0,
1538 .children = { }
1539};
1540/*! \brief REST handler for /api-docs/bridges.json */
1542 .path_segment = "playbackId",
1543 .is_wildcard = 1,
1544 .callbacks = {
1546 },
1547 .num_children = 0,
1548 .children = { }
1549};
1550/*! \brief REST handler for /api-docs/bridges.json */
1552 .path_segment = "play",
1553 .callbacks = {
1555 },
1556 .num_children = 1,
1557 .children = { &bridges_bridgeId_play_playbackId, }
1558};
1559/*! \brief REST handler for /api-docs/bridges.json */
1561 .path_segment = "record",
1562 .callbacks = {
1564 },
1565 .num_children = 0,
1566 .children = { }
1567};
1568/*! \brief REST handler for /api-docs/bridges.json */
1570 .path_segment = "bridgeId",
1571 .is_wildcard = 1,
1572 .callbacks = {
1576 },
1577 .num_children = 6,
1579};
1580/*! \brief REST handler for /api-docs/bridges.json */
1582 .path_segment = "bridges",
1583 .callbacks = {
1586 },
1587 .num_children = 1,
1588 .children = { &bridges_bridgeId, }
1589};
1590
1591static int unload_module(void)
1592{
1594 return 0;
1595}
1596
1597static int load_module(void)
1598{
1599 int res = 0;
1600
1601
1603 if (res) {
1604 unload_module();
1606 }
1607
1609}
1610
1611AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Bridge resources",
1612 .support_level = AST_MODULE_SUPPORT_CORE,
1613 .load = load_module,
1614 .unload = unload_module,
1615 .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:202
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:259
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:298
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:179
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().
Generated file - Build validators for ARI model objects.
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
Definition: res_ari_model.c:91
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
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.
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}.
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_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.
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_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.
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 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.
#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_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 or updates an existing one.
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_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.
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:2199
struct ast_json * message
Definition: ari.h:94
int response_code
Definition: ari.h:99
Abstract JSON element (object, array, string, int, ...).
describes a server instance
Definition: tcptls.h:150
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
const char * args
#define ARRAY_LEN(a)
Definition: utils.h:666