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