Asterisk - The Open Source Telephony Project GIT-master-77d630f
res_ari_channels.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 Channel 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_answer</depend>
39 <depend type="module">res_stasis_playback</depend>
40 <depend type="module">res_stasis_recording</depend>
41 <depend type="module">res_stasis_snoop</depend>
42 <support_level>core</support_level>
43 ***/
44
45#include "asterisk.h"
46
47#include "asterisk/app.h"
48#include "asterisk/module.h"
49#include "asterisk/stasis_app.h"
51#if defined(AST_DEVMODE)
53#endif
54
55#define MAX_VALS 128
56
57/*!
58 * \brief Parameter parsing callback for /channels.
59 * \param ser TCP/TLS session object
60 * \param get_params GET parameters in the HTTP request.
61 * \param path_vars Path variables extracted from the request.
62 * \param headers HTTP headers.
63 * \param body
64 * \param[out] response Response to the HTTP request.
65 */
68 struct ast_variable *get_params, struct ast_variable *path_vars,
69 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
70{
72#if defined(AST_DEVMODE)
73 int is_valid;
74 int code;
75#endif /* AST_DEVMODE */
76
77 ast_ari_channels_list(headers, &args, response);
78#if defined(AST_DEVMODE)
79 code = response->response_code;
80
81 switch (code) {
82 case 0: /* Implementation is still a stub, or the code wasn't set */
83 is_valid = response->message == NULL;
84 break;
85 case 500: /* Internal Server Error */
86 case 501: /* Not Implemented */
87 is_valid = 1;
88 break;
89 default:
90 if (200 <= code && code <= 299) {
91 is_valid = ast_ari_validate_list(response->message,
93 } else {
94 ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
95 is_valid = 0;
96 }
97 }
98
99 if (!is_valid) {
100 ast_log(LOG_ERROR, "Response validation failed for /channels\n");
101 ast_ari_response_error(response, 500,
102 "Internal Server Error", "Response validation failed");
103 }
104#endif /* AST_DEVMODE */
105
106fin: __attribute__((unused))
107 return;
108}
110 struct ast_json *body,
112{
113 struct ast_json *field;
114 /* Parse query parameters out of it */
115 field = ast_json_object_get(body, "endpoint");
116 if (field) {
117 args->endpoint = ast_json_string_get(field);
118 }
119 field = ast_json_object_get(body, "extension");
120 if (field) {
121 args->extension = ast_json_string_get(field);
122 }
123 field = ast_json_object_get(body, "context");
124 if (field) {
125 args->context = ast_json_string_get(field);
126 }
127 field = ast_json_object_get(body, "priority");
128 if (field) {
129 args->priority = ast_json_integer_get(field);
130 }
131 field = ast_json_object_get(body, "label");
132 if (field) {
133 args->label = ast_json_string_get(field);
134 }
135 field = ast_json_object_get(body, "app");
136 if (field) {
137 args->app = ast_json_string_get(field);
138 }
139 field = ast_json_object_get(body, "appArgs");
140 if (field) {
141 args->app_args = ast_json_string_get(field);
142 }
143 field = ast_json_object_get(body, "callerId");
144 if (field) {
145 args->caller_id = ast_json_string_get(field);
146 }
147 field = ast_json_object_get(body, "timeout");
148 if (field) {
149 args->timeout = ast_json_integer_get(field);
150 }
151 field = ast_json_object_get(body, "channelId");
152 if (field) {
153 args->channel_id = ast_json_string_get(field);
154 }
155 field = ast_json_object_get(body, "otherChannelId");
156 if (field) {
157 args->other_channel_id = ast_json_string_get(field);
158 }
159 field = ast_json_object_get(body, "originator");
160 if (field) {
161 args->originator = ast_json_string_get(field);
162 }
163 field = ast_json_object_get(body, "formats");
164 if (field) {
165 args->formats = ast_json_string_get(field);
166 }
167 return 0;
168}
169
170/*!
171 * \brief Parameter parsing callback for /channels.
172 * \param ser TCP/TLS session object
173 * \param get_params GET parameters in the HTTP request.
174 * \param path_vars Path variables extracted from the request.
175 * \param headers HTTP headers.
176 * \param body
177 * \param[out] response Response to the HTTP request.
178 */
180 struct ast_tcptls_session_instance *ser,
181 struct ast_variable *get_params, struct ast_variable *path_vars,
182 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
183{
185 struct ast_variable *i;
186#if defined(AST_DEVMODE)
187 int is_valid;
188 int code;
189#endif /* AST_DEVMODE */
190
191 for (i = get_params; i; i = i->next) {
192 if (strcmp(i->name, "endpoint") == 0) {
193 args.endpoint = (i->value);
194 } else
195 if (strcmp(i->name, "extension") == 0) {
196 args.extension = (i->value);
197 } else
198 if (strcmp(i->name, "context") == 0) {
199 args.context = (i->value);
200 } else
201 if (strcmp(i->name, "priority") == 0) {
202 args.priority = atol(i->value);
203 } else
204 if (strcmp(i->name, "label") == 0) {
205 args.label = (i->value);
206 } else
207 if (strcmp(i->name, "app") == 0) {
208 args.app = (i->value);
209 } else
210 if (strcmp(i->name, "appArgs") == 0) {
211 args.app_args = (i->value);
212 } else
213 if (strcmp(i->name, "callerId") == 0) {
214 args.caller_id = (i->value);
215 } else
216 if (strcmp(i->name, "timeout") == 0) {
217 args.timeout = atoi(i->value);
218 } else
219 if (strcmp(i->name, "channelId") == 0) {
220 args.channel_id = (i->value);
221 } else
222 if (strcmp(i->name, "otherChannelId") == 0) {
223 args.other_channel_id = (i->value);
224 } else
225 if (strcmp(i->name, "originator") == 0) {
226 args.originator = (i->value);
227 } else
228 if (strcmp(i->name, "formats") == 0) {
229 args.formats = (i->value);
230 } else
231 {}
232 }
233 args.variables = body;
234 ast_ari_channels_originate(headers, &args, response);
235#if defined(AST_DEVMODE)
236 code = response->response_code;
237
238 switch (code) {
239 case 0: /* Implementation is still a stub, or the code wasn't set */
240 is_valid = response->message == NULL;
241 break;
242 case 500: /* Internal Server Error */
243 case 501: /* Not Implemented */
244 case 400: /* Invalid parameters for originating a channel. */
245 case 409: /* Channel with given unique ID already exists. */
246 is_valid = 1;
247 break;
248 default:
249 if (200 <= code && code <= 299) {
250 is_valid = ast_ari_validate_channel(
251 response->message);
252 } else {
253 ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
254 is_valid = 0;
255 }
256 }
257
258 if (!is_valid) {
259 ast_log(LOG_ERROR, "Response validation failed for /channels\n");
260 ast_ari_response_error(response, 500,
261 "Internal Server Error", "Response validation failed");
262 }
263#endif /* AST_DEVMODE */
264
265fin: __attribute__((unused))
266 return;
267}
269 struct ast_json *body,
271{
272 struct ast_json *field;
273 /* Parse query parameters out of it */
274 field = ast_json_object_get(body, "endpoint");
275 if (field) {
276 args->endpoint = ast_json_string_get(field);
277 }
278 field = ast_json_object_get(body, "app");
279 if (field) {
280 args->app = ast_json_string_get(field);
281 }
282 field = ast_json_object_get(body, "appArgs");
283 if (field) {
284 args->app_args = ast_json_string_get(field);
285 }
286 field = ast_json_object_get(body, "channelId");
287 if (field) {
288 args->channel_id = ast_json_string_get(field);
289 }
290 field = ast_json_object_get(body, "otherChannelId");
291 if (field) {
292 args->other_channel_id = ast_json_string_get(field);
293 }
294 field = ast_json_object_get(body, "originator");
295 if (field) {
296 args->originator = ast_json_string_get(field);
297 }
298 field = ast_json_object_get(body, "formats");
299 if (field) {
300 args->formats = ast_json_string_get(field);
301 }
302 return 0;
303}
304
305/*!
306 * \brief Parameter parsing callback for /channels/create.
307 * \param ser TCP/TLS session object
308 * \param get_params GET parameters in the HTTP request.
309 * \param path_vars Path variables extracted from the request.
310 * \param headers HTTP headers.
311 * \param body
312 * \param[out] response Response to the HTTP request.
313 */
315 struct ast_tcptls_session_instance *ser,
316 struct ast_variable *get_params, struct ast_variable *path_vars,
317 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
318{
320 struct ast_variable *i;
321#if defined(AST_DEVMODE)
322 int is_valid;
323 int code;
324#endif /* AST_DEVMODE */
325
326 for (i = get_params; i; i = i->next) {
327 if (strcmp(i->name, "endpoint") == 0) {
328 args.endpoint = (i->value);
329 } else
330 if (strcmp(i->name, "app") == 0) {
331 args.app = (i->value);
332 } else
333 if (strcmp(i->name, "appArgs") == 0) {
334 args.app_args = (i->value);
335 } else
336 if (strcmp(i->name, "channelId") == 0) {
337 args.channel_id = (i->value);
338 } else
339 if (strcmp(i->name, "otherChannelId") == 0) {
340 args.other_channel_id = (i->value);
341 } else
342 if (strcmp(i->name, "originator") == 0) {
343 args.originator = (i->value);
344 } else
345 if (strcmp(i->name, "formats") == 0) {
346 args.formats = (i->value);
347 } else
348 {}
349 }
350 args.variables = body;
351 ast_ari_channels_create(headers, &args, response);
352#if defined(AST_DEVMODE)
353 code = response->response_code;
354
355 switch (code) {
356 case 0: /* Implementation is still a stub, or the code wasn't set */
357 is_valid = response->message == NULL;
358 break;
359 case 500: /* Internal Server Error */
360 case 501: /* Not Implemented */
361 case 409: /* Channel with given unique ID already exists. */
362 is_valid = 1;
363 break;
364 default:
365 if (200 <= code && code <= 299) {
366 is_valid = ast_ari_validate_channel(
367 response->message);
368 } else {
369 ast_log(LOG_ERROR, "Invalid error response %d for /channels/create\n", code);
370 is_valid = 0;
371 }
372 }
373
374 if (!is_valid) {
375 ast_log(LOG_ERROR, "Response validation failed for /channels/create\n");
376 ast_ari_response_error(response, 500,
377 "Internal Server Error", "Response validation failed");
378 }
379#endif /* AST_DEVMODE */
380
381fin: __attribute__((unused))
382 return;
383}
384/*!
385 * \brief Parameter parsing callback for /channels/{channelId}.
386 * \param ser TCP/TLS session object
387 * \param get_params GET parameters in the HTTP request.
388 * \param path_vars Path variables extracted from the request.
389 * \param headers HTTP headers.
390 * \param body
391 * \param[out] response Response to the HTTP request.
392 */
394 struct ast_tcptls_session_instance *ser,
395 struct ast_variable *get_params, struct ast_variable *path_vars,
396 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
397{
399 struct ast_variable *i;
400#if defined(AST_DEVMODE)
401 int is_valid;
402 int code;
403#endif /* AST_DEVMODE */
404
405 for (i = path_vars; i; i = i->next) {
406 if (strcmp(i->name, "channelId") == 0) {
407 args.channel_id = (i->value);
408 } else
409 {}
410 }
411 ast_ari_channels_get(headers, &args, response);
412#if defined(AST_DEVMODE)
413 code = response->response_code;
414
415 switch (code) {
416 case 0: /* Implementation is still a stub, or the code wasn't set */
417 is_valid = response->message == NULL;
418 break;
419 case 500: /* Internal Server Error */
420 case 501: /* Not Implemented */
421 case 404: /* Channel not found */
422 is_valid = 1;
423 break;
424 default:
425 if (200 <= code && code <= 299) {
426 is_valid = ast_ari_validate_channel(
427 response->message);
428 } else {
429 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
430 is_valid = 0;
431 }
432 }
433
434 if (!is_valid) {
435 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
436 ast_ari_response_error(response, 500,
437 "Internal Server Error", "Response validation failed");
438 }
439#endif /* AST_DEVMODE */
440
441fin: __attribute__((unused))
442 return;
443}
445 struct ast_json *body,
447{
448 struct ast_json *field;
449 /* Parse query parameters out of it */
450 field = ast_json_object_get(body, "endpoint");
451 if (field) {
452 args->endpoint = ast_json_string_get(field);
453 }
454 field = ast_json_object_get(body, "extension");
455 if (field) {
456 args->extension = ast_json_string_get(field);
457 }
458 field = ast_json_object_get(body, "context");
459 if (field) {
460 args->context = ast_json_string_get(field);
461 }
462 field = ast_json_object_get(body, "priority");
463 if (field) {
464 args->priority = ast_json_integer_get(field);
465 }
466 field = ast_json_object_get(body, "label");
467 if (field) {
468 args->label = ast_json_string_get(field);
469 }
470 field = ast_json_object_get(body, "app");
471 if (field) {
472 args->app = ast_json_string_get(field);
473 }
474 field = ast_json_object_get(body, "appArgs");
475 if (field) {
476 args->app_args = ast_json_string_get(field);
477 }
478 field = ast_json_object_get(body, "callerId");
479 if (field) {
480 args->caller_id = ast_json_string_get(field);
481 }
482 field = ast_json_object_get(body, "timeout");
483 if (field) {
484 args->timeout = ast_json_integer_get(field);
485 }
486 field = ast_json_object_get(body, "otherChannelId");
487 if (field) {
488 args->other_channel_id = ast_json_string_get(field);
489 }
490 field = ast_json_object_get(body, "originator");
491 if (field) {
492 args->originator = ast_json_string_get(field);
493 }
494 field = ast_json_object_get(body, "formats");
495 if (field) {
496 args->formats = ast_json_string_get(field);
497 }
498 return 0;
499}
500
501/*!
502 * \brief Parameter parsing callback for /channels/{channelId}.
503 * \param ser TCP/TLS session object
504 * \param get_params GET parameters in the HTTP request.
505 * \param path_vars Path variables extracted from the request.
506 * \param headers HTTP headers.
507 * \param body
508 * \param[out] response Response to the HTTP request.
509 */
511 struct ast_tcptls_session_instance *ser,
512 struct ast_variable *get_params, struct ast_variable *path_vars,
513 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
514{
516 struct ast_variable *i;
517#if defined(AST_DEVMODE)
518 int is_valid;
519 int code;
520#endif /* AST_DEVMODE */
521
522 for (i = get_params; i; i = i->next) {
523 if (strcmp(i->name, "endpoint") == 0) {
524 args.endpoint = (i->value);
525 } else
526 if (strcmp(i->name, "extension") == 0) {
527 args.extension = (i->value);
528 } else
529 if (strcmp(i->name, "context") == 0) {
530 args.context = (i->value);
531 } else
532 if (strcmp(i->name, "priority") == 0) {
533 args.priority = atol(i->value);
534 } else
535 if (strcmp(i->name, "label") == 0) {
536 args.label = (i->value);
537 } else
538 if (strcmp(i->name, "app") == 0) {
539 args.app = (i->value);
540 } else
541 if (strcmp(i->name, "appArgs") == 0) {
542 args.app_args = (i->value);
543 } else
544 if (strcmp(i->name, "callerId") == 0) {
545 args.caller_id = (i->value);
546 } else
547 if (strcmp(i->name, "timeout") == 0) {
548 args.timeout = atoi(i->value);
549 } else
550 if (strcmp(i->name, "otherChannelId") == 0) {
551 args.other_channel_id = (i->value);
552 } else
553 if (strcmp(i->name, "originator") == 0) {
554 args.originator = (i->value);
555 } else
556 if (strcmp(i->name, "formats") == 0) {
557 args.formats = (i->value);
558 } else
559 {}
560 }
561 for (i = path_vars; i; i = i->next) {
562 if (strcmp(i->name, "channelId") == 0) {
563 args.channel_id = (i->value);
564 } else
565 {}
566 }
567 args.variables = body;
568 ast_ari_channels_originate_with_id(headers, &args, response);
569#if defined(AST_DEVMODE)
570 code = response->response_code;
571
572 switch (code) {
573 case 0: /* Implementation is still a stub, or the code wasn't set */
574 is_valid = response->message == NULL;
575 break;
576 case 500: /* Internal Server Error */
577 case 501: /* Not Implemented */
578 case 400: /* Invalid parameters for originating a channel. */
579 case 409: /* Channel with given unique ID already exists. */
580 is_valid = 1;
581 break;
582 default:
583 if (200 <= code && code <= 299) {
584 is_valid = ast_ari_validate_channel(
585 response->message);
586 } else {
587 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
588 is_valid = 0;
589 }
590 }
591
592 if (!is_valid) {
593 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
594 ast_ari_response_error(response, 500,
595 "Internal Server Error", "Response validation failed");
596 }
597#endif /* AST_DEVMODE */
598
599fin: __attribute__((unused))
600 return;
601}
603 struct ast_json *body,
605{
606 struct ast_json *field;
607 /* Parse query parameters out of it */
608 field = ast_json_object_get(body, "reason_code");
609 if (field) {
610 args->reason_code = ast_json_string_get(field);
611 }
612 field = ast_json_object_get(body, "reason");
613 if (field) {
614 args->reason = ast_json_string_get(field);
615 }
616 return 0;
617}
618
619/*!
620 * \brief Parameter parsing callback for /channels/{channelId}.
621 * \param ser TCP/TLS session object
622 * \param get_params GET parameters in the HTTP request.
623 * \param path_vars Path variables extracted from the request.
624 * \param headers HTTP headers.
625 * \param body
626 * \param[out] response Response to the HTTP request.
627 */
629 struct ast_tcptls_session_instance *ser,
630 struct ast_variable *get_params, struct ast_variable *path_vars,
631 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
632{
634 struct ast_variable *i;
635#if defined(AST_DEVMODE)
636 int is_valid;
637 int code;
638#endif /* AST_DEVMODE */
639
640 for (i = get_params; i; i = i->next) {
641 if (strcmp(i->name, "reason_code") == 0) {
642 args.reason_code = (i->value);
643 } else
644 if (strcmp(i->name, "reason") == 0) {
645 args.reason = (i->value);
646 } else
647 {}
648 }
649 for (i = path_vars; i; i = i->next) {
650 if (strcmp(i->name, "channelId") == 0) {
651 args.channel_id = (i->value);
652 } else
653 {}
654 }
657 goto fin;
658 }
659 ast_ari_channels_hangup(headers, &args, response);
660#if defined(AST_DEVMODE)
661 code = response->response_code;
662
663 switch (code) {
664 case 0: /* Implementation is still a stub, or the code wasn't set */
665 is_valid = response->message == NULL;
666 break;
667 case 500: /* Internal Server Error */
668 case 501: /* Not Implemented */
669 case 400: /* Invalid reason for hangup provided */
670 case 404: /* Channel not found */
671 is_valid = 1;
672 break;
673 default:
674 if (200 <= code && code <= 299) {
675 is_valid = ast_ari_validate_void(
676 response->message);
677 } else {
678 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
679 is_valid = 0;
680 }
681 }
682
683 if (!is_valid) {
684 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
685 ast_ari_response_error(response, 500,
686 "Internal Server Error", "Response validation failed");
687 }
688#endif /* AST_DEVMODE */
689
690fin: __attribute__((unused))
691 return;
692}
694 struct ast_json *body,
696{
697 struct ast_json *field;
698 /* Parse query parameters out of it */
699 field = ast_json_object_get(body, "context");
700 if (field) {
701 args->context = ast_json_string_get(field);
702 }
703 field = ast_json_object_get(body, "extension");
704 if (field) {
705 args->extension = ast_json_string_get(field);
706 }
707 field = ast_json_object_get(body, "priority");
708 if (field) {
709 args->priority = ast_json_integer_get(field);
710 }
711 field = ast_json_object_get(body, "label");
712 if (field) {
713 args->label = ast_json_string_get(field);
714 }
715 return 0;
716}
717
718/*!
719 * \brief Parameter parsing callback for /channels/{channelId}/continue.
720 * \param ser TCP/TLS session object
721 * \param get_params GET parameters in the HTTP request.
722 * \param path_vars Path variables extracted from the request.
723 * \param headers HTTP headers.
724 * \param body
725 * \param[out] response Response to the HTTP request.
726 */
728 struct ast_tcptls_session_instance *ser,
729 struct ast_variable *get_params, struct ast_variable *path_vars,
730 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
731{
733 struct ast_variable *i;
734#if defined(AST_DEVMODE)
735 int is_valid;
736 int code;
737#endif /* AST_DEVMODE */
738
739 for (i = get_params; i; i = i->next) {
740 if (strcmp(i->name, "context") == 0) {
741 args.context = (i->value);
742 } else
743 if (strcmp(i->name, "extension") == 0) {
744 args.extension = (i->value);
745 } else
746 if (strcmp(i->name, "priority") == 0) {
747 args.priority = atoi(i->value);
748 } else
749 if (strcmp(i->name, "label") == 0) {
750 args.label = (i->value);
751 } else
752 {}
753 }
754 for (i = path_vars; i; i = i->next) {
755 if (strcmp(i->name, "channelId") == 0) {
756 args.channel_id = (i->value);
757 } else
758 {}
759 }
762 goto fin;
763 }
764 ast_ari_channels_continue_in_dialplan(headers, &args, response);
765#if defined(AST_DEVMODE)
766 code = response->response_code;
767
768 switch (code) {
769 case 0: /* Implementation is still a stub, or the code wasn't set */
770 is_valid = response->message == NULL;
771 break;
772 case 500: /* Internal Server Error */
773 case 501: /* Not Implemented */
774 case 404: /* Channel not found */
775 case 409: /* Channel not in a Stasis application */
776 case 412: /* Channel in invalid state */
777 is_valid = 1;
778 break;
779 default:
780 if (200 <= code && code <= 299) {
781 is_valid = ast_ari_validate_void(
782 response->message);
783 } else {
784 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/continue\n", code);
785 is_valid = 0;
786 }
787 }
788
789 if (!is_valid) {
790 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/continue\n");
791 ast_ari_response_error(response, 500,
792 "Internal Server Error", "Response validation failed");
793 }
794#endif /* AST_DEVMODE */
795
796fin: __attribute__((unused))
797 return;
798}
800 struct ast_json *body,
802{
803 struct ast_json *field;
804 /* Parse query parameters out of it */
805 field = ast_json_object_get(body, "app");
806 if (field) {
807 args->app = ast_json_string_get(field);
808 }
809 field = ast_json_object_get(body, "appArgs");
810 if (field) {
811 args->app_args = ast_json_string_get(field);
812 }
813 return 0;
814}
815
816/*!
817 * \brief Parameter parsing callback for /channels/{channelId}/move.
818 * \param ser TCP/TLS session object
819 * \param get_params GET parameters in the HTTP request.
820 * \param path_vars Path variables extracted from the request.
821 * \param headers HTTP headers.
822 * \param body
823 * \param[out] response Response to the HTTP request.
824 */
826 struct ast_tcptls_session_instance *ser,
827 struct ast_variable *get_params, struct ast_variable *path_vars,
828 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
829{
831 struct ast_variable *i;
832#if defined(AST_DEVMODE)
833 int is_valid;
834 int code;
835#endif /* AST_DEVMODE */
836
837 for (i = get_params; i; i = i->next) {
838 if (strcmp(i->name, "app") == 0) {
839 args.app = (i->value);
840 } else
841 if (strcmp(i->name, "appArgs") == 0) {
842 args.app_args = (i->value);
843 } else
844 {}
845 }
846 for (i = path_vars; i; i = i->next) {
847 if (strcmp(i->name, "channelId") == 0) {
848 args.channel_id = (i->value);
849 } else
850 {}
851 }
854 goto fin;
855 }
856 ast_ari_channels_move(headers, &args, response);
857#if defined(AST_DEVMODE)
858 code = response->response_code;
859
860 switch (code) {
861 case 0: /* Implementation is still a stub, or the code wasn't set */
862 is_valid = response->message == NULL;
863 break;
864 case 500: /* Internal Server Error */
865 case 501: /* Not Implemented */
866 case 404: /* Channel not found */
867 case 409: /* Channel not in a Stasis application */
868 is_valid = 1;
869 break;
870 default:
871 if (200 <= code && code <= 299) {
872 is_valid = ast_ari_validate_void(
873 response->message);
874 } else {
875 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/move\n", code);
876 is_valid = 0;
877 }
878 }
879
880 if (!is_valid) {
881 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/move\n");
882 ast_ari_response_error(response, 500,
883 "Internal Server Error", "Response validation failed");
884 }
885#endif /* AST_DEVMODE */
886
887fin: __attribute__((unused))
888 return;
889}
891 struct ast_json *body,
893{
894 struct ast_json *field;
895 /* Parse query parameters out of it */
896 field = ast_json_object_get(body, "endpoint");
897 if (field) {
898 args->endpoint = ast_json_string_get(field);
899 }
900 return 0;
901}
902
903/*!
904 * \brief Parameter parsing callback for /channels/{channelId}/redirect.
905 * \param ser TCP/TLS session object
906 * \param get_params GET parameters in the HTTP request.
907 * \param path_vars Path variables extracted from the request.
908 * \param headers HTTP headers.
909 * \param body
910 * \param[out] response Response to the HTTP request.
911 */
913 struct ast_tcptls_session_instance *ser,
914 struct ast_variable *get_params, struct ast_variable *path_vars,
915 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
916{
918 struct ast_variable *i;
919#if defined(AST_DEVMODE)
920 int is_valid;
921 int code;
922#endif /* AST_DEVMODE */
923
924 for (i = get_params; i; i = i->next) {
925 if (strcmp(i->name, "endpoint") == 0) {
926 args.endpoint = (i->value);
927 } else
928 {}
929 }
930 for (i = path_vars; i; i = i->next) {
931 if (strcmp(i->name, "channelId") == 0) {
932 args.channel_id = (i->value);
933 } else
934 {}
935 }
938 goto fin;
939 }
940 ast_ari_channels_redirect(headers, &args, response);
941#if defined(AST_DEVMODE)
942 code = response->response_code;
943
944 switch (code) {
945 case 0: /* Implementation is still a stub, or the code wasn't set */
946 is_valid = response->message == NULL;
947 break;
948 case 500: /* Internal Server Error */
949 case 501: /* Not Implemented */
950 case 400: /* Endpoint parameter not provided */
951 case 404: /* Channel or endpoint not found */
952 case 409: /* Channel not in a Stasis application */
953 case 422: /* Endpoint is not the same type as the channel */
954 case 412: /* Channel in invalid state */
955 is_valid = 1;
956 break;
957 default:
958 if (200 <= code && code <= 299) {
959 is_valid = ast_ari_validate_void(
960 response->message);
961 } else {
962 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/redirect\n", code);
963 is_valid = 0;
964 }
965 }
966
967 if (!is_valid) {
968 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/redirect\n");
969 ast_ari_response_error(response, 500,
970 "Internal Server Error", "Response validation failed");
971 }
972#endif /* AST_DEVMODE */
973
974fin: __attribute__((unused))
975 return;
976}
977/*!
978 * \brief Parameter parsing callback for /channels/{channelId}/answer.
979 * \param ser TCP/TLS session object
980 * \param get_params GET parameters in the HTTP request.
981 * \param path_vars Path variables extracted from the request.
982 * \param headers HTTP headers.
983 * \param body
984 * \param[out] response Response to the HTTP request.
985 */
987 struct ast_tcptls_session_instance *ser,
988 struct ast_variable *get_params, struct ast_variable *path_vars,
989 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
990{
992 struct ast_variable *i;
993#if defined(AST_DEVMODE)
994 int is_valid;
995 int code;
996#endif /* AST_DEVMODE */
997
998 for (i = path_vars; i; i = i->next) {
999 if (strcmp(i->name, "channelId") == 0) {
1000 args.channel_id = (i->value);
1001 } else
1002 {}
1003 }
1004 ast_ari_channels_answer(headers, &args, response);
1005#if defined(AST_DEVMODE)
1006 code = response->response_code;
1007
1008 switch (code) {
1009 case 0: /* Implementation is still a stub, or the code wasn't set */
1010 is_valid = response->message == NULL;
1011 break;
1012 case 500: /* Internal Server Error */
1013 case 501: /* Not Implemented */
1014 case 404: /* Channel not found */
1015 case 409: /* Channel not in a Stasis application */
1016 case 412: /* Channel in invalid state */
1017 is_valid = 1;
1018 break;
1019 default:
1020 if (200 <= code && code <= 299) {
1021 is_valid = ast_ari_validate_void(
1022 response->message);
1023 } else {
1024 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/answer\n", code);
1025 is_valid = 0;
1026 }
1027 }
1028
1029 if (!is_valid) {
1030 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/answer\n");
1031 ast_ari_response_error(response, 500,
1032 "Internal Server Error", "Response validation failed");
1033 }
1034#endif /* AST_DEVMODE */
1035
1036fin: __attribute__((unused))
1037 return;
1038}
1039/*!
1040 * \brief Parameter parsing callback for /channels/{channelId}/ring.
1041 * \param ser TCP/TLS session object
1042 * \param get_params GET parameters in the HTTP request.
1043 * \param path_vars Path variables extracted from the request.
1044 * \param headers HTTP headers.
1045 * \param body
1046 * \param[out] response Response to the HTTP request.
1047 */
1049 struct ast_tcptls_session_instance *ser,
1050 struct ast_variable *get_params, struct ast_variable *path_vars,
1051 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1052{
1053 struct ast_ari_channels_ring_args args = {};
1054 struct ast_variable *i;
1055#if defined(AST_DEVMODE)
1056 int is_valid;
1057 int code;
1058#endif /* AST_DEVMODE */
1059
1060 for (i = path_vars; i; i = i->next) {
1061 if (strcmp(i->name, "channelId") == 0) {
1062 args.channel_id = (i->value);
1063 } else
1064 {}
1065 }
1066 ast_ari_channels_ring(headers, &args, response);
1067#if defined(AST_DEVMODE)
1068 code = response->response_code;
1069
1070 switch (code) {
1071 case 0: /* Implementation is still a stub, or the code wasn't set */
1072 is_valid = response->message == NULL;
1073 break;
1074 case 500: /* Internal Server Error */
1075 case 501: /* Not Implemented */
1076 case 404: /* Channel not found */
1077 case 409: /* Channel not in a Stasis application */
1078 case 412: /* Channel in invalid state */
1079 is_valid = 1;
1080 break;
1081 default:
1082 if (200 <= code && code <= 299) {
1083 is_valid = ast_ari_validate_void(
1084 response->message);
1085 } else {
1086 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/ring\n", code);
1087 is_valid = 0;
1088 }
1089 }
1090
1091 if (!is_valid) {
1092 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/ring\n");
1093 ast_ari_response_error(response, 500,
1094 "Internal Server Error", "Response validation failed");
1095 }
1096#endif /* AST_DEVMODE */
1097
1098fin: __attribute__((unused))
1099 return;
1100}
1101/*!
1102 * \brief Parameter parsing callback for /channels/{channelId}/ring.
1103 * \param ser TCP/TLS session object
1104 * \param get_params GET parameters in the HTTP request.
1105 * \param path_vars Path variables extracted from the request.
1106 * \param headers HTTP headers.
1107 * \param body
1108 * \param[out] response Response to the HTTP request.
1109 */
1111 struct ast_tcptls_session_instance *ser,
1112 struct ast_variable *get_params, struct ast_variable *path_vars,
1113 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1114{
1116 struct ast_variable *i;
1117#if defined(AST_DEVMODE)
1118 int is_valid;
1119 int code;
1120#endif /* AST_DEVMODE */
1121
1122 for (i = path_vars; i; i = i->next) {
1123 if (strcmp(i->name, "channelId") == 0) {
1124 args.channel_id = (i->value);
1125 } else
1126 {}
1127 }
1128 ast_ari_channels_ring_stop(headers, &args, response);
1129#if defined(AST_DEVMODE)
1130 code = response->response_code;
1131
1132 switch (code) {
1133 case 0: /* Implementation is still a stub, or the code wasn't set */
1134 is_valid = response->message == NULL;
1135 break;
1136 case 500: /* Internal Server Error */
1137 case 501: /* Not Implemented */
1138 case 404: /* Channel not found */
1139 case 409: /* Channel not in a Stasis application */
1140 case 412: /* Channel in invalid state */
1141 is_valid = 1;
1142 break;
1143 default:
1144 if (200 <= code && code <= 299) {
1145 is_valid = ast_ari_validate_void(
1146 response->message);
1147 } else {
1148 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/ring\n", code);
1149 is_valid = 0;
1150 }
1151 }
1152
1153 if (!is_valid) {
1154 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/ring\n");
1155 ast_ari_response_error(response, 500,
1156 "Internal Server Error", "Response validation failed");
1157 }
1158#endif /* AST_DEVMODE */
1159
1160fin: __attribute__((unused))
1161 return;
1162}
1163/*!
1164 * \brief Parameter parsing callback for /channels/{channelId}/progress.
1165 * \param ser TCP/TLS session object
1166 * \param get_params GET parameters in the HTTP request.
1167 * \param path_vars Path variables extracted from the request.
1168 * \param headers HTTP headers.
1169 * \param body
1170 * \param[out] response Response to the HTTP request.
1171 */
1173 struct ast_tcptls_session_instance *ser,
1174 struct ast_variable *get_params, struct ast_variable *path_vars,
1175 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1176{
1178 struct ast_variable *i;
1179#if defined(AST_DEVMODE)
1180 int is_valid;
1181 int code;
1182#endif /* AST_DEVMODE */
1183
1184 for (i = path_vars; i; i = i->next) {
1185 if (strcmp(i->name, "channelId") == 0) {
1186 args.channel_id = (i->value);
1187 } else
1188 {}
1189 }
1190 ast_ari_channels_progress(headers, &args, response);
1191#if defined(AST_DEVMODE)
1192 code = response->response_code;
1193
1194 switch (code) {
1195 case 0: /* Implementation is still a stub, or the code wasn't set */
1196 is_valid = response->message == NULL;
1197 break;
1198 case 500: /* Internal Server Error */
1199 case 501: /* Not Implemented */
1200 case 404: /* Channel not found */
1201 case 409: /* Channel not in a Stasis application */
1202 case 412: /* Channel in invalid state */
1203 is_valid = 1;
1204 break;
1205 default:
1206 if (200 <= code && code <= 299) {
1207 is_valid = ast_ari_validate_void(
1208 response->message);
1209 } else {
1210 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/progress\n", code);
1211 is_valid = 0;
1212 }
1213 }
1214
1215 if (!is_valid) {
1216 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/progress\n");
1217 ast_ari_response_error(response, 500,
1218 "Internal Server Error", "Response validation failed");
1219 }
1220#endif /* AST_DEVMODE */
1221
1222fin: __attribute__((unused))
1223 return;
1224}
1226 struct ast_json *body,
1228{
1229 struct ast_json *field;
1230 /* Parse query parameters out of it */
1231 field = ast_json_object_get(body, "dtmf");
1232 if (field) {
1233 args->dtmf = ast_json_string_get(field);
1234 }
1235 field = ast_json_object_get(body, "before");
1236 if (field) {
1237 args->before = ast_json_integer_get(field);
1238 }
1239 field = ast_json_object_get(body, "between");
1240 if (field) {
1241 args->between = ast_json_integer_get(field);
1242 }
1243 field = ast_json_object_get(body, "duration");
1244 if (field) {
1245 args->duration = ast_json_integer_get(field);
1246 }
1247 field = ast_json_object_get(body, "after");
1248 if (field) {
1249 args->after = ast_json_integer_get(field);
1250 }
1251 return 0;
1252}
1253
1254/*!
1255 * \brief Parameter parsing callback for /channels/{channelId}/dtmf.
1256 * \param ser TCP/TLS session object
1257 * \param get_params GET parameters in the HTTP request.
1258 * \param path_vars Path variables extracted from the request.
1259 * \param headers HTTP headers.
1260 * \param body
1261 * \param[out] response Response to the HTTP request.
1262 */
1264 struct ast_tcptls_session_instance *ser,
1265 struct ast_variable *get_params, struct ast_variable *path_vars,
1266 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1267{
1269 struct ast_variable *i;
1270#if defined(AST_DEVMODE)
1271 int is_valid;
1272 int code;
1273#endif /* AST_DEVMODE */
1274
1275 for (i = get_params; i; i = i->next) {
1276 if (strcmp(i->name, "dtmf") == 0) {
1277 args.dtmf = (i->value);
1278 } else
1279 if (strcmp(i->name, "before") == 0) {
1280 args.before = atoi(i->value);
1281 } else
1282 if (strcmp(i->name, "between") == 0) {
1283 args.between = atoi(i->value);
1284 } else
1285 if (strcmp(i->name, "duration") == 0) {
1286 args.duration = atoi(i->value);
1287 } else
1288 if (strcmp(i->name, "after") == 0) {
1289 args.after = atoi(i->value);
1290 } else
1291 {}
1292 }
1293 for (i = path_vars; i; i = i->next) {
1294 if (strcmp(i->name, "channelId") == 0) {
1295 args.channel_id = (i->value);
1296 } else
1297 {}
1298 }
1301 goto fin;
1302 }
1303 ast_ari_channels_send_dtmf(headers, &args, response);
1304#if defined(AST_DEVMODE)
1305 code = response->response_code;
1306
1307 switch (code) {
1308 case 0: /* Implementation is still a stub, or the code wasn't set */
1309 is_valid = response->message == NULL;
1310 break;
1311 case 500: /* Internal Server Error */
1312 case 501: /* Not Implemented */
1313 case 400: /* DTMF is required */
1314 case 404: /* Channel not found */
1315 case 409: /* Channel not in a Stasis application */
1316 case 412: /* Channel in invalid state */
1317 is_valid = 1;
1318 break;
1319 default:
1320 if (200 <= code && code <= 299) {
1321 is_valid = ast_ari_validate_void(
1322 response->message);
1323 } else {
1324 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/dtmf\n", code);
1325 is_valid = 0;
1326 }
1327 }
1328
1329 if (!is_valid) {
1330 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/dtmf\n");
1331 ast_ari_response_error(response, 500,
1332 "Internal Server Error", "Response validation failed");
1333 }
1334#endif /* AST_DEVMODE */
1335
1336fin: __attribute__((unused))
1337 return;
1338}
1340 struct ast_json *body,
1342{
1343 struct ast_json *field;
1344 /* Parse query parameters out of it */
1345 field = ast_json_object_get(body, "direction");
1346 if (field) {
1347 args->direction = ast_json_string_get(field);
1348 }
1349 return 0;
1350}
1351
1352/*!
1353 * \brief Parameter parsing callback for /channels/{channelId}/mute.
1354 * \param ser TCP/TLS session object
1355 * \param get_params GET parameters in the HTTP request.
1356 * \param path_vars Path variables extracted from the request.
1357 * \param headers HTTP headers.
1358 * \param body
1359 * \param[out] response Response to the HTTP request.
1360 */
1362 struct ast_tcptls_session_instance *ser,
1363 struct ast_variable *get_params, struct ast_variable *path_vars,
1364 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1365{
1366 struct ast_ari_channels_mute_args args = {};
1367 struct ast_variable *i;
1368#if defined(AST_DEVMODE)
1369 int is_valid;
1370 int code;
1371#endif /* AST_DEVMODE */
1372
1373 for (i = get_params; i; i = i->next) {
1374 if (strcmp(i->name, "direction") == 0) {
1375 args.direction = (i->value);
1376 } else
1377 {}
1378 }
1379 for (i = path_vars; i; i = i->next) {
1380 if (strcmp(i->name, "channelId") == 0) {
1381 args.channel_id = (i->value);
1382 } else
1383 {}
1384 }
1387 goto fin;
1388 }
1389 ast_ari_channels_mute(headers, &args, response);
1390#if defined(AST_DEVMODE)
1391 code = response->response_code;
1392
1393 switch (code) {
1394 case 0: /* Implementation is still a stub, or the code wasn't set */
1395 is_valid = response->message == NULL;
1396 break;
1397 case 500: /* Internal Server Error */
1398 case 501: /* Not Implemented */
1399 case 404: /* Channel not found */
1400 case 409: /* Channel not in a Stasis application */
1401 case 412: /* Channel in invalid state */
1402 is_valid = 1;
1403 break;
1404 default:
1405 if (200 <= code && code <= 299) {
1406 is_valid = ast_ari_validate_void(
1407 response->message);
1408 } else {
1409 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/mute\n", code);
1410 is_valid = 0;
1411 }
1412 }
1413
1414 if (!is_valid) {
1415 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mute\n");
1416 ast_ari_response_error(response, 500,
1417 "Internal Server Error", "Response validation failed");
1418 }
1419#endif /* AST_DEVMODE */
1420
1421fin: __attribute__((unused))
1422 return;
1423}
1425 struct ast_json *body,
1427{
1428 struct ast_json *field;
1429 /* Parse query parameters out of it */
1430 field = ast_json_object_get(body, "direction");
1431 if (field) {
1432 args->direction = ast_json_string_get(field);
1433 }
1434 return 0;
1435}
1436
1437/*!
1438 * \brief Parameter parsing callback for /channels/{channelId}/mute.
1439 * \param ser TCP/TLS session object
1440 * \param get_params GET parameters in the HTTP request.
1441 * \param path_vars Path variables extracted from the request.
1442 * \param headers HTTP headers.
1443 * \param body
1444 * \param[out] response Response to the HTTP request.
1445 */
1447 struct ast_tcptls_session_instance *ser,
1448 struct ast_variable *get_params, struct ast_variable *path_vars,
1449 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1450{
1452 struct ast_variable *i;
1453#if defined(AST_DEVMODE)
1454 int is_valid;
1455 int code;
1456#endif /* AST_DEVMODE */
1457
1458 for (i = get_params; i; i = i->next) {
1459 if (strcmp(i->name, "direction") == 0) {
1460 args.direction = (i->value);
1461 } else
1462 {}
1463 }
1464 for (i = path_vars; i; i = i->next) {
1465 if (strcmp(i->name, "channelId") == 0) {
1466 args.channel_id = (i->value);
1467 } else
1468 {}
1469 }
1472 goto fin;
1473 }
1474 ast_ari_channels_unmute(headers, &args, response);
1475#if defined(AST_DEVMODE)
1476 code = response->response_code;
1477
1478 switch (code) {
1479 case 0: /* Implementation is still a stub, or the code wasn't set */
1480 is_valid = response->message == NULL;
1481 break;
1482 case 500: /* Internal Server Error */
1483 case 501: /* Not Implemented */
1484 case 404: /* Channel not found */
1485 case 409: /* Channel not in a Stasis application */
1486 case 412: /* Channel in invalid state */
1487 is_valid = 1;
1488 break;
1489 default:
1490 if (200 <= code && code <= 299) {
1491 is_valid = ast_ari_validate_void(
1492 response->message);
1493 } else {
1494 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/mute\n", code);
1495 is_valid = 0;
1496 }
1497 }
1498
1499 if (!is_valid) {
1500 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mute\n");
1501 ast_ari_response_error(response, 500,
1502 "Internal Server Error", "Response validation failed");
1503 }
1504#endif /* AST_DEVMODE */
1505
1506fin: __attribute__((unused))
1507 return;
1508}
1509/*!
1510 * \brief Parameter parsing callback for /channels/{channelId}/hold.
1511 * \param ser TCP/TLS session object
1512 * \param get_params GET parameters in the HTTP request.
1513 * \param path_vars Path variables extracted from the request.
1514 * \param headers HTTP headers.
1515 * \param body
1516 * \param[out] response Response to the HTTP request.
1517 */
1519 struct ast_tcptls_session_instance *ser,
1520 struct ast_variable *get_params, struct ast_variable *path_vars,
1521 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1522{
1523 struct ast_ari_channels_hold_args args = {};
1524 struct ast_variable *i;
1525#if defined(AST_DEVMODE)
1526 int is_valid;
1527 int code;
1528#endif /* AST_DEVMODE */
1529
1530 for (i = path_vars; i; i = i->next) {
1531 if (strcmp(i->name, "channelId") == 0) {
1532 args.channel_id = (i->value);
1533 } else
1534 {}
1535 }
1536 ast_ari_channels_hold(headers, &args, response);
1537#if defined(AST_DEVMODE)
1538 code = response->response_code;
1539
1540 switch (code) {
1541 case 0: /* Implementation is still a stub, or the code wasn't set */
1542 is_valid = response->message == NULL;
1543 break;
1544 case 500: /* Internal Server Error */
1545 case 501: /* Not Implemented */
1546 case 404: /* Channel not found */
1547 case 409: /* Channel not in a Stasis application */
1548 case 412: /* Channel in invalid state */
1549 is_valid = 1;
1550 break;
1551 default:
1552 if (200 <= code && code <= 299) {
1553 is_valid = ast_ari_validate_void(
1554 response->message);
1555 } else {
1556 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/hold\n", code);
1557 is_valid = 0;
1558 }
1559 }
1560
1561 if (!is_valid) {
1562 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/hold\n");
1563 ast_ari_response_error(response, 500,
1564 "Internal Server Error", "Response validation failed");
1565 }
1566#endif /* AST_DEVMODE */
1567
1568fin: __attribute__((unused))
1569 return;
1570}
1571/*!
1572 * \brief Parameter parsing callback for /channels/{channelId}/hold.
1573 * \param ser TCP/TLS session object
1574 * \param get_params GET parameters in the HTTP request.
1575 * \param path_vars Path variables extracted from the request.
1576 * \param headers HTTP headers.
1577 * \param body
1578 * \param[out] response Response to the HTTP request.
1579 */
1581 struct ast_tcptls_session_instance *ser,
1582 struct ast_variable *get_params, struct ast_variable *path_vars,
1583 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1584{
1586 struct ast_variable *i;
1587#if defined(AST_DEVMODE)
1588 int is_valid;
1589 int code;
1590#endif /* AST_DEVMODE */
1591
1592 for (i = path_vars; i; i = i->next) {
1593 if (strcmp(i->name, "channelId") == 0) {
1594 args.channel_id = (i->value);
1595 } else
1596 {}
1597 }
1598 ast_ari_channels_unhold(headers, &args, response);
1599#if defined(AST_DEVMODE)
1600 code = response->response_code;
1601
1602 switch (code) {
1603 case 0: /* Implementation is still a stub, or the code wasn't set */
1604 is_valid = response->message == NULL;
1605 break;
1606 case 500: /* Internal Server Error */
1607 case 501: /* Not Implemented */
1608 case 404: /* Channel not found */
1609 case 409: /* Channel not in a Stasis application */
1610 case 412: /* Channel in invalid state */
1611 is_valid = 1;
1612 break;
1613 default:
1614 if (200 <= code && code <= 299) {
1615 is_valid = ast_ari_validate_void(
1616 response->message);
1617 } else {
1618 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/hold\n", code);
1619 is_valid = 0;
1620 }
1621 }
1622
1623 if (!is_valid) {
1624 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/hold\n");
1625 ast_ari_response_error(response, 500,
1626 "Internal Server Error", "Response validation failed");
1627 }
1628#endif /* AST_DEVMODE */
1629
1630fin: __attribute__((unused))
1631 return;
1632}
1634 struct ast_json *body,
1636{
1637 struct ast_json *field;
1638 /* Parse query parameters out of it */
1639 field = ast_json_object_get(body, "mohClass");
1640 if (field) {
1641 args->moh_class = ast_json_string_get(field);
1642 }
1643 return 0;
1644}
1645
1646/*!
1647 * \brief Parameter parsing callback for /channels/{channelId}/moh.
1648 * \param ser TCP/TLS session object
1649 * \param get_params GET parameters in the HTTP request.
1650 * \param path_vars Path variables extracted from the request.
1651 * \param headers HTTP headers.
1652 * \param body
1653 * \param[out] response Response to the HTTP request.
1654 */
1656 struct ast_tcptls_session_instance *ser,
1657 struct ast_variable *get_params, struct ast_variable *path_vars,
1658 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1659{
1661 struct ast_variable *i;
1662#if defined(AST_DEVMODE)
1663 int is_valid;
1664 int code;
1665#endif /* AST_DEVMODE */
1666
1667 for (i = get_params; i; i = i->next) {
1668 if (strcmp(i->name, "mohClass") == 0) {
1669 args.moh_class = (i->value);
1670 } else
1671 {}
1672 }
1673 for (i = path_vars; i; i = i->next) {
1674 if (strcmp(i->name, "channelId") == 0) {
1675 args.channel_id = (i->value);
1676 } else
1677 {}
1678 }
1681 goto fin;
1682 }
1683 ast_ari_channels_start_moh(headers, &args, response);
1684#if defined(AST_DEVMODE)
1685 code = response->response_code;
1686
1687 switch (code) {
1688 case 0: /* Implementation is still a stub, or the code wasn't set */
1689 is_valid = response->message == NULL;
1690 break;
1691 case 500: /* Internal Server Error */
1692 case 501: /* Not Implemented */
1693 case 404: /* Channel not found */
1694 case 409: /* Channel not in a Stasis application */
1695 case 412: /* Channel in invalid state */
1696 is_valid = 1;
1697 break;
1698 default:
1699 if (200 <= code && code <= 299) {
1700 is_valid = ast_ari_validate_void(
1701 response->message);
1702 } else {
1703 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/moh\n", code);
1704 is_valid = 0;
1705 }
1706 }
1707
1708 if (!is_valid) {
1709 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/moh\n");
1710 ast_ari_response_error(response, 500,
1711 "Internal Server Error", "Response validation failed");
1712 }
1713#endif /* AST_DEVMODE */
1714
1715fin: __attribute__((unused))
1716 return;
1717}
1718/*!
1719 * \brief Parameter parsing callback for /channels/{channelId}/moh.
1720 * \param ser TCP/TLS session object
1721 * \param get_params GET parameters in the HTTP request.
1722 * \param path_vars Path variables extracted from the request.
1723 * \param headers HTTP headers.
1724 * \param body
1725 * \param[out] response Response to the HTTP request.
1726 */
1728 struct ast_tcptls_session_instance *ser,
1729 struct ast_variable *get_params, struct ast_variable *path_vars,
1730 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1731{
1733 struct ast_variable *i;
1734#if defined(AST_DEVMODE)
1735 int is_valid;
1736 int code;
1737#endif /* AST_DEVMODE */
1738
1739 for (i = path_vars; i; i = i->next) {
1740 if (strcmp(i->name, "channelId") == 0) {
1741 args.channel_id = (i->value);
1742 } else
1743 {}
1744 }
1745 ast_ari_channels_stop_moh(headers, &args, response);
1746#if defined(AST_DEVMODE)
1747 code = response->response_code;
1748
1749 switch (code) {
1750 case 0: /* Implementation is still a stub, or the code wasn't set */
1751 is_valid = response->message == NULL;
1752 break;
1753 case 500: /* Internal Server Error */
1754 case 501: /* Not Implemented */
1755 case 404: /* Channel not found */
1756 case 409: /* Channel not in a Stasis application */
1757 case 412: /* Channel in invalid state */
1758 is_valid = 1;
1759 break;
1760 default:
1761 if (200 <= code && code <= 299) {
1762 is_valid = ast_ari_validate_void(
1763 response->message);
1764 } else {
1765 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/moh\n", code);
1766 is_valid = 0;
1767 }
1768 }
1769
1770 if (!is_valid) {
1771 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/moh\n");
1772 ast_ari_response_error(response, 500,
1773 "Internal Server Error", "Response validation failed");
1774 }
1775#endif /* AST_DEVMODE */
1776
1777fin: __attribute__((unused))
1778 return;
1779}
1780/*!
1781 * \brief Parameter parsing callback for /channels/{channelId}/silence.
1782 * \param ser TCP/TLS session object
1783 * \param get_params GET parameters in the HTTP request.
1784 * \param path_vars Path variables extracted from the request.
1785 * \param headers HTTP headers.
1786 * \param body
1787 * \param[out] response Response to the HTTP request.
1788 */
1790 struct ast_tcptls_session_instance *ser,
1791 struct ast_variable *get_params, struct ast_variable *path_vars,
1792 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1793{
1795 struct ast_variable *i;
1796#if defined(AST_DEVMODE)
1797 int is_valid;
1798 int code;
1799#endif /* AST_DEVMODE */
1800
1801 for (i = path_vars; i; i = i->next) {
1802 if (strcmp(i->name, "channelId") == 0) {
1803 args.channel_id = (i->value);
1804 } else
1805 {}
1806 }
1807 ast_ari_channels_start_silence(headers, &args, response);
1808#if defined(AST_DEVMODE)
1809 code = response->response_code;
1810
1811 switch (code) {
1812 case 0: /* Implementation is still a stub, or the code wasn't set */
1813 is_valid = response->message == NULL;
1814 break;
1815 case 500: /* Internal Server Error */
1816 case 501: /* Not Implemented */
1817 case 404: /* Channel not found */
1818 case 409: /* Channel not in a Stasis application */
1819 case 412: /* Channel in invalid state */
1820 is_valid = 1;
1821 break;
1822 default:
1823 if (200 <= code && code <= 299) {
1824 is_valid = ast_ari_validate_void(
1825 response->message);
1826 } else {
1827 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/silence\n", code);
1828 is_valid = 0;
1829 }
1830 }
1831
1832 if (!is_valid) {
1833 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/silence\n");
1834 ast_ari_response_error(response, 500,
1835 "Internal Server Error", "Response validation failed");
1836 }
1837#endif /* AST_DEVMODE */
1838
1839fin: __attribute__((unused))
1840 return;
1841}
1842/*!
1843 * \brief Parameter parsing callback for /channels/{channelId}/silence.
1844 * \param ser TCP/TLS session object
1845 * \param get_params GET parameters in the HTTP request.
1846 * \param path_vars Path variables extracted from the request.
1847 * \param headers HTTP headers.
1848 * \param body
1849 * \param[out] response Response to the HTTP request.
1850 */
1852 struct ast_tcptls_session_instance *ser,
1853 struct ast_variable *get_params, struct ast_variable *path_vars,
1854 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1855{
1857 struct ast_variable *i;
1858#if defined(AST_DEVMODE)
1859 int is_valid;
1860 int code;
1861#endif /* AST_DEVMODE */
1862
1863 for (i = path_vars; i; i = i->next) {
1864 if (strcmp(i->name, "channelId") == 0) {
1865 args.channel_id = (i->value);
1866 } else
1867 {}
1868 }
1869 ast_ari_channels_stop_silence(headers, &args, response);
1870#if defined(AST_DEVMODE)
1871 code = response->response_code;
1872
1873 switch (code) {
1874 case 0: /* Implementation is still a stub, or the code wasn't set */
1875 is_valid = response->message == NULL;
1876 break;
1877 case 500: /* Internal Server Error */
1878 case 501: /* Not Implemented */
1879 case 404: /* Channel not found */
1880 case 409: /* Channel not in a Stasis application */
1881 case 412: /* Channel in invalid state */
1882 is_valid = 1;
1883 break;
1884 default:
1885 if (200 <= code && code <= 299) {
1886 is_valid = ast_ari_validate_void(
1887 response->message);
1888 } else {
1889 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/silence\n", code);
1890 is_valid = 0;
1891 }
1892 }
1893
1894 if (!is_valid) {
1895 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/silence\n");
1896 ast_ari_response_error(response, 500,
1897 "Internal Server Error", "Response validation failed");
1898 }
1899#endif /* AST_DEVMODE */
1900
1901fin: __attribute__((unused))
1902 return;
1903}
1905 struct ast_json *body,
1907{
1908 struct ast_json *field;
1909 /* Parse query parameters out of it */
1910 field = ast_json_object_get(body, "media");
1911 if (field) {
1912 /* If they were silly enough to both pass in a query param and a
1913 * JSON body, free up the query value.
1914 */
1915 ast_free(args->media);
1916 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1917 /* Multiple param passed as array */
1918 size_t i;
1919 args->media_count = ast_json_array_size(field);
1920 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1921
1922 if (!args->media) {
1923 return -1;
1924 }
1925
1926 for (i = 0; i < args->media_count; ++i) {
1927 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1928 }
1929 } else {
1930 /* Multiple param passed as single value */
1931 args->media_count = 1;
1932 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1933 if (!args->media) {
1934 return -1;
1935 }
1936 args->media[0] = ast_json_string_get(field);
1937 }
1938 }
1939 field = ast_json_object_get(body, "lang");
1940 if (field) {
1941 args->lang = ast_json_string_get(field);
1942 }
1943 field = ast_json_object_get(body, "offsetms");
1944 if (field) {
1945 args->offsetms = ast_json_integer_get(field);
1946 }
1947 field = ast_json_object_get(body, "skipms");
1948 if (field) {
1949 args->skipms = ast_json_integer_get(field);
1950 }
1951 field = ast_json_object_get(body, "playbackId");
1952 if (field) {
1953 args->playback_id = ast_json_string_get(field);
1954 }
1955 return 0;
1956}
1957
1958/*!
1959 * \brief Parameter parsing callback for /channels/{channelId}/play.
1960 * \param ser TCP/TLS session object
1961 * \param get_params GET parameters in the HTTP request.
1962 * \param path_vars Path variables extracted from the request.
1963 * \param headers HTTP headers.
1964 * \param body
1965 * \param[out] response Response to the HTTP request.
1966 */
1968 struct ast_tcptls_session_instance *ser,
1969 struct ast_variable *get_params, struct ast_variable *path_vars,
1970 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1971{
1972 struct ast_ari_channels_play_args args = {};
1973 struct ast_variable *i;
1974#if defined(AST_DEVMODE)
1975 int is_valid;
1976 int code;
1977#endif /* AST_DEVMODE */
1978
1979 for (i = get_params; i; i = i->next) {
1980 if (strcmp(i->name, "media") == 0) {
1981 /* Parse comma separated list */
1982 char *vals[MAX_VALS];
1983 size_t j;
1984
1985 args.media_parse = ast_strdup(i->value);
1986 if (!args.media_parse) {
1988 goto fin;
1989 }
1990
1991 if (strlen(args.media_parse) == 0) {
1992 /* ast_app_separate_args can't handle "" */
1993 args.media_count = 1;
1994 vals[0] = args.media_parse;
1995 } else {
1996 args.media_count = ast_app_separate_args(
1997 args.media_parse, ',', vals,
1998 ARRAY_LEN(vals));
1999 }
2000
2001 if (args.media_count == 0) {
2003 goto fin;
2004 }
2005
2006 if (args.media_count >= MAX_VALS) {
2007 ast_ari_response_error(response, 400,
2008 "Bad Request",
2009 "Too many values for media");
2010 goto fin;
2011 }
2012
2013 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
2014 if (!args.media) {
2016 goto fin;
2017 }
2018
2019 for (j = 0; j < args.media_count; ++j) {
2020 args.media[j] = (vals[j]);
2021 }
2022 } else
2023 if (strcmp(i->name, "lang") == 0) {
2024 args.lang = (i->value);
2025 } else
2026 if (strcmp(i->name, "offsetms") == 0) {
2027 args.offsetms = atoi(i->value);
2028 } else
2029 if (strcmp(i->name, "skipms") == 0) {
2030 args.skipms = atoi(i->value);
2031 } else
2032 if (strcmp(i->name, "playbackId") == 0) {
2033 args.playback_id = (i->value);
2034 } else
2035 {}
2036 }
2037 for (i = path_vars; i; i = i->next) {
2038 if (strcmp(i->name, "channelId") == 0) {
2039 args.channel_id = (i->value);
2040 } else
2041 {}
2042 }
2045 goto fin;
2046 }
2047 ast_ari_channels_play(headers, &args, response);
2048#if defined(AST_DEVMODE)
2049 code = response->response_code;
2050
2051 switch (code) {
2052 case 0: /* Implementation is still a stub, or the code wasn't set */
2053 is_valid = response->message == NULL;
2054 break;
2055 case 500: /* Internal Server Error */
2056 case 501: /* Not Implemented */
2057 case 404: /* Channel not found */
2058 case 409: /* Channel not in a Stasis application */
2059 case 412: /* Channel in invalid state */
2060 is_valid = 1;
2061 break;
2062 default:
2063 if (200 <= code && code <= 299) {
2064 is_valid = ast_ari_validate_playback(
2065 response->message);
2066 } else {
2067 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/play\n", code);
2068 is_valid = 0;
2069 }
2070 }
2071
2072 if (!is_valid) {
2073 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/play\n");
2074 ast_ari_response_error(response, 500,
2075 "Internal Server Error", "Response validation failed");
2076 }
2077#endif /* AST_DEVMODE */
2078
2079fin: __attribute__((unused))
2080 ast_free(args.media_parse);
2081 ast_free(args.media);
2082 return;
2083}
2085 struct ast_json *body,
2087{
2088 struct ast_json *field;
2089 /* Parse query parameters out of it */
2090 field = ast_json_object_get(body, "media");
2091 if (field) {
2092 /* If they were silly enough to both pass in a query param and a
2093 * JSON body, free up the query value.
2094 */
2095 ast_free(args->media);
2096 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
2097 /* Multiple param passed as array */
2098 size_t i;
2099 args->media_count = ast_json_array_size(field);
2100 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
2101
2102 if (!args->media) {
2103 return -1;
2104 }
2105
2106 for (i = 0; i < args->media_count; ++i) {
2107 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
2108 }
2109 } else {
2110 /* Multiple param passed as single value */
2111 args->media_count = 1;
2112 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
2113 if (!args->media) {
2114 return -1;
2115 }
2116 args->media[0] = ast_json_string_get(field);
2117 }
2118 }
2119 field = ast_json_object_get(body, "lang");
2120 if (field) {
2121 args->lang = ast_json_string_get(field);
2122 }
2123 field = ast_json_object_get(body, "offsetms");
2124 if (field) {
2125 args->offsetms = ast_json_integer_get(field);
2126 }
2127 field = ast_json_object_get(body, "skipms");
2128 if (field) {
2129 args->skipms = ast_json_integer_get(field);
2130 }
2131 return 0;
2132}
2133
2134/*!
2135 * \brief Parameter parsing callback for /channels/{channelId}/play/{playbackId}.
2136 * \param ser TCP/TLS session object
2137 * \param get_params GET parameters in the HTTP request.
2138 * \param path_vars Path variables extracted from the request.
2139 * \param headers HTTP headers.
2140 * \param body
2141 * \param[out] response Response to the HTTP request.
2142 */
2144 struct ast_tcptls_session_instance *ser,
2145 struct ast_variable *get_params, struct ast_variable *path_vars,
2146 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2147{
2149 struct ast_variable *i;
2150#if defined(AST_DEVMODE)
2151 int is_valid;
2152 int code;
2153#endif /* AST_DEVMODE */
2154
2155 for (i = get_params; i; i = i->next) {
2156 if (strcmp(i->name, "media") == 0) {
2157 /* Parse comma separated list */
2158 char *vals[MAX_VALS];
2159 size_t j;
2160
2161 args.media_parse = ast_strdup(i->value);
2162 if (!args.media_parse) {
2164 goto fin;
2165 }
2166
2167 if (strlen(args.media_parse) == 0) {
2168 /* ast_app_separate_args can't handle "" */
2169 args.media_count = 1;
2170 vals[0] = args.media_parse;
2171 } else {
2172 args.media_count = ast_app_separate_args(
2173 args.media_parse, ',', vals,
2174 ARRAY_LEN(vals));
2175 }
2176
2177 if (args.media_count == 0) {
2179 goto fin;
2180 }
2181
2182 if (args.media_count >= MAX_VALS) {
2183 ast_ari_response_error(response, 400,
2184 "Bad Request",
2185 "Too many values for media");
2186 goto fin;
2187 }
2188
2189 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
2190 if (!args.media) {
2192 goto fin;
2193 }
2194
2195 for (j = 0; j < args.media_count; ++j) {
2196 args.media[j] = (vals[j]);
2197 }
2198 } else
2199 if (strcmp(i->name, "lang") == 0) {
2200 args.lang = (i->value);
2201 } else
2202 if (strcmp(i->name, "offsetms") == 0) {
2203 args.offsetms = atoi(i->value);
2204 } else
2205 if (strcmp(i->name, "skipms") == 0) {
2206 args.skipms = atoi(i->value);
2207 } else
2208 {}
2209 }
2210 for (i = path_vars; i; i = i->next) {
2211 if (strcmp(i->name, "channelId") == 0) {
2212 args.channel_id = (i->value);
2213 } else
2214 if (strcmp(i->name, "playbackId") == 0) {
2215 args.playback_id = (i->value);
2216 } else
2217 {}
2218 }
2221 goto fin;
2222 }
2223 ast_ari_channels_play_with_id(headers, &args, response);
2224#if defined(AST_DEVMODE)
2225 code = response->response_code;
2226
2227 switch (code) {
2228 case 0: /* Implementation is still a stub, or the code wasn't set */
2229 is_valid = response->message == NULL;
2230 break;
2231 case 500: /* Internal Server Error */
2232 case 501: /* Not Implemented */
2233 case 404: /* Channel not found */
2234 case 409: /* Channel not in a Stasis application */
2235 case 412: /* Channel in invalid state */
2236 is_valid = 1;
2237 break;
2238 default:
2239 if (200 <= code && code <= 299) {
2240 is_valid = ast_ari_validate_playback(
2241 response->message);
2242 } else {
2243 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/play/{playbackId}\n", code);
2244 is_valid = 0;
2245 }
2246 }
2247
2248 if (!is_valid) {
2249 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/play/{playbackId}\n");
2250 ast_ari_response_error(response, 500,
2251 "Internal Server Error", "Response validation failed");
2252 }
2253#endif /* AST_DEVMODE */
2254
2255fin: __attribute__((unused))
2256 ast_free(args.media_parse);
2257 ast_free(args.media);
2258 return;
2259}
2261 struct ast_json *body,
2263{
2264 struct ast_json *field;
2265 /* Parse query parameters out of it */
2266 field = ast_json_object_get(body, "name");
2267 if (field) {
2268 args->name = ast_json_string_get(field);
2269 }
2270 field = ast_json_object_get(body, "format");
2271 if (field) {
2272 args->format = ast_json_string_get(field);
2273 }
2274 field = ast_json_object_get(body, "maxDurationSeconds");
2275 if (field) {
2276 args->max_duration_seconds = ast_json_integer_get(field);
2277 }
2278 field = ast_json_object_get(body, "maxSilenceSeconds");
2279 if (field) {
2280 args->max_silence_seconds = ast_json_integer_get(field);
2281 }
2282 field = ast_json_object_get(body, "ifExists");
2283 if (field) {
2284 args->if_exists = ast_json_string_get(field);
2285 }
2286 field = ast_json_object_get(body, "beep");
2287 if (field) {
2288 args->beep = ast_json_is_true(field);
2289 }
2290 field = ast_json_object_get(body, "terminateOn");
2291 if (field) {
2292 args->terminate_on = ast_json_string_get(field);
2293 }
2294 return 0;
2295}
2296
2297/*!
2298 * \brief Parameter parsing callback for /channels/{channelId}/record.
2299 * \param ser TCP/TLS session object
2300 * \param get_params GET parameters in the HTTP request.
2301 * \param path_vars Path variables extracted from the request.
2302 * \param headers HTTP headers.
2303 * \param body
2304 * \param[out] response Response to the HTTP request.
2305 */
2307 struct ast_tcptls_session_instance *ser,
2308 struct ast_variable *get_params, struct ast_variable *path_vars,
2309 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2310{
2312 struct ast_variable *i;
2313#if defined(AST_DEVMODE)
2314 int is_valid;
2315 int code;
2316#endif /* AST_DEVMODE */
2317
2318 for (i = get_params; i; i = i->next) {
2319 if (strcmp(i->name, "name") == 0) {
2320 args.name = (i->value);
2321 } else
2322 if (strcmp(i->name, "format") == 0) {
2323 args.format = (i->value);
2324 } else
2325 if (strcmp(i->name, "maxDurationSeconds") == 0) {
2326 args.max_duration_seconds = atoi(i->value);
2327 } else
2328 if (strcmp(i->name, "maxSilenceSeconds") == 0) {
2329 args.max_silence_seconds = atoi(i->value);
2330 } else
2331 if (strcmp(i->name, "ifExists") == 0) {
2332 args.if_exists = (i->value);
2333 } else
2334 if (strcmp(i->name, "beep") == 0) {
2335 args.beep = ast_true(i->value);
2336 } else
2337 if (strcmp(i->name, "terminateOn") == 0) {
2338 args.terminate_on = (i->value);
2339 } else
2340 {}
2341 }
2342 for (i = path_vars; i; i = i->next) {
2343 if (strcmp(i->name, "channelId") == 0) {
2344 args.channel_id = (i->value);
2345 } else
2346 {}
2347 }
2350 goto fin;
2351 }
2352 ast_ari_channels_record(headers, &args, response);
2353#if defined(AST_DEVMODE)
2354 code = response->response_code;
2355
2356 switch (code) {
2357 case 0: /* Implementation is still a stub, or the code wasn't set */
2358 is_valid = response->message == NULL;
2359 break;
2360 case 500: /* Internal Server Error */
2361 case 501: /* Not Implemented */
2362 case 400: /* Invalid parameters */
2363 case 404: /* Channel not found */
2364 case 409: /* Channel is not in a Stasis application; the channel is currently bridged with other channels; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
2365 case 422: /* The format specified is unknown on this system */
2366 is_valid = 1;
2367 break;
2368 default:
2369 if (200 <= code && code <= 299) {
2371 response->message);
2372 } else {
2373 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/record\n", code);
2374 is_valid = 0;
2375 }
2376 }
2377
2378 if (!is_valid) {
2379 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/record\n");
2380 ast_ari_response_error(response, 500,
2381 "Internal Server Error", "Response validation failed");
2382 }
2383#endif /* AST_DEVMODE */
2384
2385fin: __attribute__((unused))
2386 return;
2387}
2389 struct ast_json *body,
2391{
2392 struct ast_json *field;
2393 /* Parse query parameters out of it */
2394 field = ast_json_object_get(body, "variable");
2395 if (field) {
2396 args->variable = ast_json_string_get(field);
2397 }
2398 return 0;
2399}
2400
2401/*!
2402 * \brief Parameter parsing callback for /channels/{channelId}/variable.
2403 * \param ser TCP/TLS session object
2404 * \param get_params GET parameters in the HTTP request.
2405 * \param path_vars Path variables extracted from the request.
2406 * \param headers HTTP headers.
2407 * \param body
2408 * \param[out] response Response to the HTTP request.
2409 */
2411 struct ast_tcptls_session_instance *ser,
2412 struct ast_variable *get_params, struct ast_variable *path_vars,
2413 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2414{
2416 struct ast_variable *i;
2417#if defined(AST_DEVMODE)
2418 int is_valid;
2419 int code;
2420#endif /* AST_DEVMODE */
2421
2422 for (i = get_params; i; i = i->next) {
2423 if (strcmp(i->name, "variable") == 0) {
2424 args.variable = (i->value);
2425 } else
2426 {}
2427 }
2428 for (i = path_vars; i; i = i->next) {
2429 if (strcmp(i->name, "channelId") == 0) {
2430 args.channel_id = (i->value);
2431 } else
2432 {}
2433 }
2436 goto fin;
2437 }
2438 ast_ari_channels_get_channel_var(headers, &args, response);
2439#if defined(AST_DEVMODE)
2440 code = response->response_code;
2441
2442 switch (code) {
2443 case 0: /* Implementation is still a stub, or the code wasn't set */
2444 is_valid = response->message == NULL;
2445 break;
2446 case 500: /* Internal Server Error */
2447 case 501: /* Not Implemented */
2448 case 400: /* Missing variable parameter. */
2449 case 404: /* Channel or variable not found */
2450 case 409: /* Channel not in a Stasis application */
2451 is_valid = 1;
2452 break;
2453 default:
2454 if (200 <= code && code <= 299) {
2455 is_valid = ast_ari_validate_variable(
2456 response->message);
2457 } else {
2458 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/variable\n", code);
2459 is_valid = 0;
2460 }
2461 }
2462
2463 if (!is_valid) {
2464 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/variable\n");
2465 ast_ari_response_error(response, 500,
2466 "Internal Server Error", "Response validation failed");
2467 }
2468#endif /* AST_DEVMODE */
2469
2470fin: __attribute__((unused))
2471 return;
2472}
2474 struct ast_json *body,
2476{
2477 struct ast_json *field;
2478 /* Parse query parameters out of it */
2479 field = ast_json_object_get(body, "variable");
2480 if (field) {
2481 args->variable = ast_json_string_get(field);
2482 }
2483 field = ast_json_object_get(body, "value");
2484 if (field) {
2485 args->value = ast_json_string_get(field);
2486 }
2487 return 0;
2488}
2489
2490/*!
2491 * \brief Parameter parsing callback for /channels/{channelId}/variable.
2492 * \param ser TCP/TLS session object
2493 * \param get_params GET parameters in the HTTP request.
2494 * \param path_vars Path variables extracted from the request.
2495 * \param headers HTTP headers.
2496 * \param body
2497 * \param[out] response Response to the HTTP request.
2498 */
2500 struct ast_tcptls_session_instance *ser,
2501 struct ast_variable *get_params, struct ast_variable *path_vars,
2502 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2503{
2505 struct ast_variable *i;
2506#if defined(AST_DEVMODE)
2507 int is_valid;
2508 int code;
2509#endif /* AST_DEVMODE */
2510
2511 for (i = get_params; i; i = i->next) {
2512 if (strcmp(i->name, "variable") == 0) {
2513 args.variable = (i->value);
2514 } else
2515 if (strcmp(i->name, "value") == 0) {
2516 args.value = (i->value);
2517 } else
2518 {}
2519 }
2520 for (i = path_vars; i; i = i->next) {
2521 if (strcmp(i->name, "channelId") == 0) {
2522 args.channel_id = (i->value);
2523 } else
2524 {}
2525 }
2528 goto fin;
2529 }
2530 ast_ari_channels_set_channel_var(headers, &args, response);
2531#if defined(AST_DEVMODE)
2532 code = response->response_code;
2533
2534 switch (code) {
2535 case 0: /* Implementation is still a stub, or the code wasn't set */
2536 is_valid = response->message == NULL;
2537 break;
2538 case 500: /* Internal Server Error */
2539 case 501: /* Not Implemented */
2540 case 400: /* Missing variable parameter. */
2541 case 404: /* Channel not found */
2542 case 409: /* Channel not in a Stasis application */
2543 is_valid = 1;
2544 break;
2545 default:
2546 if (200 <= code && code <= 299) {
2547 is_valid = ast_ari_validate_void(
2548 response->message);
2549 } else {
2550 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/variable\n", code);
2551 is_valid = 0;
2552 }
2553 }
2554
2555 if (!is_valid) {
2556 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/variable\n");
2557 ast_ari_response_error(response, 500,
2558 "Internal Server Error", "Response validation failed");
2559 }
2560#endif /* AST_DEVMODE */
2561
2562fin: __attribute__((unused))
2563 return;
2564}
2566 struct ast_json *body,
2568{
2569 struct ast_json *field;
2570 /* Parse query parameters out of it */
2571 field = ast_json_object_get(body, "spy");
2572 if (field) {
2573 args->spy = ast_json_string_get(field);
2574 }
2575 field = ast_json_object_get(body, "whisper");
2576 if (field) {
2577 args->whisper = ast_json_string_get(field);
2578 }
2579 field = ast_json_object_get(body, "app");
2580 if (field) {
2581 args->app = ast_json_string_get(field);
2582 }
2583 field = ast_json_object_get(body, "appArgs");
2584 if (field) {
2585 args->app_args = ast_json_string_get(field);
2586 }
2587 field = ast_json_object_get(body, "snoopId");
2588 if (field) {
2589 args->snoop_id = ast_json_string_get(field);
2590 }
2591 return 0;
2592}
2593
2594/*!
2595 * \brief Parameter parsing callback for /channels/{channelId}/snoop.
2596 * \param ser TCP/TLS session object
2597 * \param get_params GET parameters in the HTTP request.
2598 * \param path_vars Path variables extracted from the request.
2599 * \param headers HTTP headers.
2600 * \param body
2601 * \param[out] response Response to the HTTP request.
2602 */
2604 struct ast_tcptls_session_instance *ser,
2605 struct ast_variable *get_params, struct ast_variable *path_vars,
2606 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2607{
2609 struct ast_variable *i;
2610#if defined(AST_DEVMODE)
2611 int is_valid;
2612 int code;
2613#endif /* AST_DEVMODE */
2614
2615 for (i = get_params; i; i = i->next) {
2616 if (strcmp(i->name, "spy") == 0) {
2617 args.spy = (i->value);
2618 } else
2619 if (strcmp(i->name, "whisper") == 0) {
2620 args.whisper = (i->value);
2621 } else
2622 if (strcmp(i->name, "app") == 0) {
2623 args.app = (i->value);
2624 } else
2625 if (strcmp(i->name, "appArgs") == 0) {
2626 args.app_args = (i->value);
2627 } else
2628 if (strcmp(i->name, "snoopId") == 0) {
2629 args.snoop_id = (i->value);
2630 } else
2631 {}
2632 }
2633 for (i = path_vars; i; i = i->next) {
2634 if (strcmp(i->name, "channelId") == 0) {
2635 args.channel_id = (i->value);
2636 } else
2637 {}
2638 }
2641 goto fin;
2642 }
2643 ast_ari_channels_snoop_channel(headers, &args, response);
2644#if defined(AST_DEVMODE)
2645 code = response->response_code;
2646
2647 switch (code) {
2648 case 0: /* Implementation is still a stub, or the code wasn't set */
2649 is_valid = response->message == NULL;
2650 break;
2651 case 500: /* Internal Server Error */
2652 case 501: /* Not Implemented */
2653 case 400: /* Invalid parameters */
2654 case 404: /* Channel not found */
2655 is_valid = 1;
2656 break;
2657 default:
2658 if (200 <= code && code <= 299) {
2659 is_valid = ast_ari_validate_channel(
2660 response->message);
2661 } else {
2662 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/snoop\n", code);
2663 is_valid = 0;
2664 }
2665 }
2666
2667 if (!is_valid) {
2668 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/snoop\n");
2669 ast_ari_response_error(response, 500,
2670 "Internal Server Error", "Response validation failed");
2671 }
2672#endif /* AST_DEVMODE */
2673
2674fin: __attribute__((unused))
2675 return;
2676}
2678 struct ast_json *body,
2680{
2681 struct ast_json *field;
2682 /* Parse query parameters out of it */
2683 field = ast_json_object_get(body, "spy");
2684 if (field) {
2685 args->spy = ast_json_string_get(field);
2686 }
2687 field = ast_json_object_get(body, "whisper");
2688 if (field) {
2689 args->whisper = ast_json_string_get(field);
2690 }
2691 field = ast_json_object_get(body, "app");
2692 if (field) {
2693 args->app = ast_json_string_get(field);
2694 }
2695 field = ast_json_object_get(body, "appArgs");
2696 if (field) {
2697 args->app_args = ast_json_string_get(field);
2698 }
2699 return 0;
2700}
2701
2702/*!
2703 * \brief Parameter parsing callback for /channels/{channelId}/snoop/{snoopId}.
2704 * \param ser TCP/TLS session object
2705 * \param get_params GET parameters in the HTTP request.
2706 * \param path_vars Path variables extracted from the request.
2707 * \param headers HTTP headers.
2708 * \param body
2709 * \param[out] response Response to the HTTP request.
2710 */
2712 struct ast_tcptls_session_instance *ser,
2713 struct ast_variable *get_params, struct ast_variable *path_vars,
2714 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2715{
2717 struct ast_variable *i;
2718#if defined(AST_DEVMODE)
2719 int is_valid;
2720 int code;
2721#endif /* AST_DEVMODE */
2722
2723 for (i = get_params; i; i = i->next) {
2724 if (strcmp(i->name, "spy") == 0) {
2725 args.spy = (i->value);
2726 } else
2727 if (strcmp(i->name, "whisper") == 0) {
2728 args.whisper = (i->value);
2729 } else
2730 if (strcmp(i->name, "app") == 0) {
2731 args.app = (i->value);
2732 } else
2733 if (strcmp(i->name, "appArgs") == 0) {
2734 args.app_args = (i->value);
2735 } else
2736 {}
2737 }
2738 for (i = path_vars; i; i = i->next) {
2739 if (strcmp(i->name, "channelId") == 0) {
2740 args.channel_id = (i->value);
2741 } else
2742 if (strcmp(i->name, "snoopId") == 0) {
2743 args.snoop_id = (i->value);
2744 } else
2745 {}
2746 }
2749 goto fin;
2750 }
2751 ast_ari_channels_snoop_channel_with_id(headers, &args, response);
2752#if defined(AST_DEVMODE)
2753 code = response->response_code;
2754
2755 switch (code) {
2756 case 0: /* Implementation is still a stub, or the code wasn't set */
2757 is_valid = response->message == NULL;
2758 break;
2759 case 500: /* Internal Server Error */
2760 case 501: /* Not Implemented */
2761 case 400: /* Invalid parameters */
2762 case 404: /* Channel not found */
2763 is_valid = 1;
2764 break;
2765 default:
2766 if (200 <= code && code <= 299) {
2767 is_valid = ast_ari_validate_channel(
2768 response->message);
2769 } else {
2770 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/snoop/{snoopId}\n", code);
2771 is_valid = 0;
2772 }
2773 }
2774
2775 if (!is_valid) {
2776 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/snoop/{snoopId}\n");
2777 ast_ari_response_error(response, 500,
2778 "Internal Server Error", "Response validation failed");
2779 }
2780#endif /* AST_DEVMODE */
2781
2782fin: __attribute__((unused))
2783 return;
2784}
2786 struct ast_json *body,
2788{
2789 struct ast_json *field;
2790 /* Parse query parameters out of it */
2791 field = ast_json_object_get(body, "caller");
2792 if (field) {
2793 args->caller = ast_json_string_get(field);
2794 }
2795 field = ast_json_object_get(body, "timeout");
2796 if (field) {
2797 args->timeout = ast_json_integer_get(field);
2798 }
2799 return 0;
2800}
2801
2802/*!
2803 * \brief Parameter parsing callback for /channels/{channelId}/dial.
2804 * \param ser TCP/TLS session object
2805 * \param get_params GET parameters in the HTTP request.
2806 * \param path_vars Path variables extracted from the request.
2807 * \param headers HTTP headers.
2808 * \param body
2809 * \param[out] response Response to the HTTP request.
2810 */
2812 struct ast_tcptls_session_instance *ser,
2813 struct ast_variable *get_params, struct ast_variable *path_vars,
2814 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2815{
2816 struct ast_ari_channels_dial_args args = {};
2817 struct ast_variable *i;
2818#if defined(AST_DEVMODE)
2819 int is_valid;
2820 int code;
2821#endif /* AST_DEVMODE */
2822
2823 for (i = get_params; i; i = i->next) {
2824 if (strcmp(i->name, "caller") == 0) {
2825 args.caller = (i->value);
2826 } else
2827 if (strcmp(i->name, "timeout") == 0) {
2828 args.timeout = atoi(i->value);
2829 } else
2830 {}
2831 }
2832 for (i = path_vars; i; i = i->next) {
2833 if (strcmp(i->name, "channelId") == 0) {
2834 args.channel_id = (i->value);
2835 } else
2836 {}
2837 }
2840 goto fin;
2841 }
2842 ast_ari_channels_dial(headers, &args, response);
2843#if defined(AST_DEVMODE)
2844 code = response->response_code;
2845
2846 switch (code) {
2847 case 0: /* Implementation is still a stub, or the code wasn't set */
2848 is_valid = response->message == NULL;
2849 break;
2850 case 500: /* Internal Server Error */
2851 case 501: /* Not Implemented */
2852 case 404: /* Channel cannot be found. */
2853 case 409: /* Channel cannot be dialed. */
2854 is_valid = 1;
2855 break;
2856 default:
2857 if (200 <= code && code <= 299) {
2858 is_valid = ast_ari_validate_void(
2859 response->message);
2860 } else {
2861 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/dial\n", code);
2862 is_valid = 0;
2863 }
2864 }
2865
2866 if (!is_valid) {
2867 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/dial\n");
2868 ast_ari_response_error(response, 500,
2869 "Internal Server Error", "Response validation failed");
2870 }
2871#endif /* AST_DEVMODE */
2872
2873fin: __attribute__((unused))
2874 return;
2875}
2876/*!
2877 * \brief Parameter parsing callback for /channels/{channelId}/rtp_statistics.
2878 * \param ser TCP/TLS session object
2879 * \param get_params GET parameters in the HTTP request.
2880 * \param path_vars Path variables extracted from the request.
2881 * \param headers HTTP headers.
2882 * \param body
2883 * \param[out] response Response to the HTTP request.
2884 */
2886 struct ast_tcptls_session_instance *ser,
2887 struct ast_variable *get_params, struct ast_variable *path_vars,
2888 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2889{
2891 struct ast_variable *i;
2892#if defined(AST_DEVMODE)
2893 int is_valid;
2894 int code;
2895#endif /* AST_DEVMODE */
2896
2897 for (i = path_vars; i; i = i->next) {
2898 if (strcmp(i->name, "channelId") == 0) {
2899 args.channel_id = (i->value);
2900 } else
2901 {}
2902 }
2903 ast_ari_channels_rtpstatistics(headers, &args, response);
2904#if defined(AST_DEVMODE)
2905 code = response->response_code;
2906
2907 switch (code) {
2908 case 0: /* Implementation is still a stub, or the code wasn't set */
2909 is_valid = response->message == NULL;
2910 break;
2911 case 500: /* Internal Server Error */
2912 case 501: /* Not Implemented */
2913 case 404: /* Channel cannot be found. */
2914 is_valid = 1;
2915 break;
2916 default:
2917 if (200 <= code && code <= 299) {
2918 is_valid = ast_ari_validate_rtpstat(
2919 response->message);
2920 } else {
2921 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/rtp_statistics\n", code);
2922 is_valid = 0;
2923 }
2924 }
2925
2926 if (!is_valid) {
2927 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/rtp_statistics\n");
2928 ast_ari_response_error(response, 500,
2929 "Internal Server Error", "Response validation failed");
2930 }
2931#endif /* AST_DEVMODE */
2932
2933fin: __attribute__((unused))
2934 return;
2935}
2937 struct ast_json *body,
2939{
2940 struct ast_json *field;
2941 /* Parse query parameters out of it */
2942 field = ast_json_object_get(body, "channelId");
2943 if (field) {
2944 args->channel_id = ast_json_string_get(field);
2945 }
2946 field = ast_json_object_get(body, "app");
2947 if (field) {
2948 args->app = ast_json_string_get(field);
2949 }
2950 field = ast_json_object_get(body, "external_host");
2951 if (field) {
2952 args->external_host = ast_json_string_get(field);
2953 }
2954 field = ast_json_object_get(body, "encapsulation");
2955 if (field) {
2956 args->encapsulation = ast_json_string_get(field);
2957 }
2958 field = ast_json_object_get(body, "transport");
2959 if (field) {
2960 args->transport = ast_json_string_get(field);
2961 }
2962 field = ast_json_object_get(body, "connection_type");
2963 if (field) {
2964 args->connection_type = ast_json_string_get(field);
2965 }
2966 field = ast_json_object_get(body, "format");
2967 if (field) {
2968 args->format = ast_json_string_get(field);
2969 }
2970 field = ast_json_object_get(body, "direction");
2971 if (field) {
2972 args->direction = ast_json_string_get(field);
2973 }
2974 field = ast_json_object_get(body, "data");
2975 if (field) {
2976 args->data = ast_json_string_get(field);
2977 }
2978 return 0;
2979}
2980
2981/*!
2982 * \brief Parameter parsing callback for /channels/externalMedia.
2983 * \param ser TCP/TLS session object
2984 * \param get_params GET parameters in the HTTP request.
2985 * \param path_vars Path variables extracted from the request.
2986 * \param headers HTTP headers.
2987 * \param body
2988 * \param[out] response Response to the HTTP request.
2989 */
2991 struct ast_tcptls_session_instance *ser,
2992 struct ast_variable *get_params, struct ast_variable *path_vars,
2993 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
2994{
2996 struct ast_variable *i;
2997#if defined(AST_DEVMODE)
2998 int is_valid;
2999 int code;
3000#endif /* AST_DEVMODE */
3001
3002 for (i = get_params; i; i = i->next) {
3003 if (strcmp(i->name, "channelId") == 0) {
3004 args.channel_id = (i->value);
3005 } else
3006 if (strcmp(i->name, "app") == 0) {
3007 args.app = (i->value);
3008 } else
3009 if (strcmp(i->name, "external_host") == 0) {
3010 args.external_host = (i->value);
3011 } else
3012 if (strcmp(i->name, "encapsulation") == 0) {
3013 args.encapsulation = (i->value);
3014 } else
3015 if (strcmp(i->name, "transport") == 0) {
3016 args.transport = (i->value);
3017 } else
3018 if (strcmp(i->name, "connection_type") == 0) {
3019 args.connection_type = (i->value);
3020 } else
3021 if (strcmp(i->name, "format") == 0) {
3022 args.format = (i->value);
3023 } else
3024 if (strcmp(i->name, "direction") == 0) {
3025 args.direction = (i->value);
3026 } else
3027 if (strcmp(i->name, "data") == 0) {
3028 args.data = (i->value);
3029 } else
3030 {}
3031 }
3032 args.variables = body;
3033 ast_ari_channels_external_media(headers, &args, response);
3034#if defined(AST_DEVMODE)
3035 code = response->response_code;
3036
3037 switch (code) {
3038 case 0: /* Implementation is still a stub, or the code wasn't set */
3039 is_valid = response->message == NULL;
3040 break;
3041 case 500: /* Internal Server Error */
3042 case 501: /* Not Implemented */
3043 case 400: /* Invalid parameters */
3044 case 409: /* Channel is not in a Stasis application; Channel is already bridged */
3045 is_valid = 1;
3046 break;
3047 default:
3048 if (200 <= code && code <= 299) {
3049 is_valid = ast_ari_validate_channel(
3050 response->message);
3051 } else {
3052 ast_log(LOG_ERROR, "Invalid error response %d for /channels/externalMedia\n", code);
3053 is_valid = 0;
3054 }
3055 }
3056
3057 if (!is_valid) {
3058 ast_log(LOG_ERROR, "Response validation failed for /channels/externalMedia\n");
3059 ast_ari_response_error(response, 500,
3060 "Internal Server Error", "Response validation failed");
3061 }
3062#endif /* AST_DEVMODE */
3063
3064fin: __attribute__((unused))
3065 return;
3066}
3068 struct ast_json *body,
3070{
3071 struct ast_json *field;
3072 /* Parse query parameters out of it */
3073 field = ast_json_object_get(body, "states");
3074 if (field) {
3075 args->states = ast_json_string_get(field);
3076 }
3077 return 0;
3078}
3079
3080/*!
3081 * \brief Parameter parsing callback for /channels/{channelId}/transfer_progress.
3082 * \param ser TCP/TLS session object
3083 * \param get_params GET parameters in the HTTP request.
3084 * \param path_vars Path variables extracted from the request.
3085 * \param headers HTTP headers.
3086 * \param body
3087 * \param[out] response Response to the HTTP request.
3088 */
3090 struct ast_tcptls_session_instance *ser,
3091 struct ast_variable *get_params, struct ast_variable *path_vars,
3092 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
3093{
3095 struct ast_variable *i;
3096#if defined(AST_DEVMODE)
3097 int is_valid;
3098 int code;
3099#endif /* AST_DEVMODE */
3100
3101 for (i = get_params; i; i = i->next) {
3102 if (strcmp(i->name, "states") == 0) {
3103 args.states = (i->value);
3104 } else
3105 {}
3106 }
3107 for (i = path_vars; i; i = i->next) {
3108 if (strcmp(i->name, "channelId") == 0) {
3109 args.channel_id = (i->value);
3110 } else
3111 {}
3112 }
3115 goto fin;
3116 }
3117 ast_ari_channels_transfer_progress(headers, &args, response);
3118#if defined(AST_DEVMODE)
3119 code = response->response_code;
3120
3121 switch (code) {
3122 case 0: /* Implementation is still a stub, or the code wasn't set */
3123 is_valid = response->message == NULL;
3124 break;
3125 case 500: /* Internal Server Error */
3126 case 501: /* Not Implemented */
3127 case 400: /* Endpoint parameter not provided */
3128 case 404: /* Channel or endpoint not found */
3129 case 409: /* Channel not in a Stasis application */
3130 case 412: /* Channel in invalid state */
3131 is_valid = 1;
3132 break;
3133 default:
3134 if (200 <= code && code <= 299) {
3135 is_valid = ast_ari_validate_void(
3136 response->message);
3137 } else {
3138 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/transfer_progress\n", code);
3139 is_valid = 0;
3140 }
3141 }
3142
3143 if (!is_valid) {
3144 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/transfer_progress\n");
3145 ast_ari_response_error(response, 500,
3146 "Internal Server Error", "Response validation failed");
3147 }
3148#endif /* AST_DEVMODE */
3149
3150fin: __attribute__((unused))
3151 return;
3152}
3153
3154/*! \brief REST handler for /api-docs/channels.json */
3156 .path_segment = "create",
3157 .callbacks = {
3159 },
3160 .num_children = 0,
3161 .children = { }
3162};
3163/*! \brief REST handler for /api-docs/channels.json */
3165 .path_segment = "continue",
3166 .callbacks = {
3168 },
3169 .num_children = 0,
3170 .children = { }
3171};
3172/*! \brief REST handler for /api-docs/channels.json */
3174 .path_segment = "move",
3175 .callbacks = {
3177 },
3178 .num_children = 0,
3179 .children = { }
3180};
3181/*! \brief REST handler for /api-docs/channels.json */
3183 .path_segment = "redirect",
3184 .callbacks = {
3186 },
3187 .num_children = 0,
3188 .children = { }
3189};
3190/*! \brief REST handler for /api-docs/channels.json */
3192 .path_segment = "answer",
3193 .callbacks = {
3195 },
3196 .num_children = 0,
3197 .children = { }
3198};
3199/*! \brief REST handler for /api-docs/channels.json */
3201 .path_segment = "ring",
3202 .callbacks = {
3205 },
3206 .num_children = 0,
3207 .children = { }
3208};
3209/*! \brief REST handler for /api-docs/channels.json */
3211 .path_segment = "progress",
3212 .callbacks = {
3214 },
3215 .num_children = 0,
3216 .children = { }
3217};
3218/*! \brief REST handler for /api-docs/channels.json */
3220 .path_segment = "dtmf",
3221 .callbacks = {
3223 },
3224 .num_children = 0,
3225 .children = { }
3226};
3227/*! \brief REST handler for /api-docs/channels.json */
3229 .path_segment = "mute",
3230 .callbacks = {
3233 },
3234 .num_children = 0,
3235 .children = { }
3236};
3237/*! \brief REST handler for /api-docs/channels.json */
3239 .path_segment = "hold",
3240 .callbacks = {
3243 },
3244 .num_children = 0,
3245 .children = { }
3246};
3247/*! \brief REST handler for /api-docs/channels.json */
3249 .path_segment = "moh",
3250 .callbacks = {
3253 },
3254 .num_children = 0,
3255 .children = { }
3256};
3257/*! \brief REST handler for /api-docs/channels.json */
3259 .path_segment = "silence",
3260 .callbacks = {
3263 },
3264 .num_children = 0,
3265 .children = { }
3266};
3267/*! \brief REST handler for /api-docs/channels.json */
3269 .path_segment = "playbackId",
3270 .is_wildcard = 1,
3271 .callbacks = {
3273 },
3274 .num_children = 0,
3275 .children = { }
3276};
3277/*! \brief REST handler for /api-docs/channels.json */
3279 .path_segment = "play",
3280 .callbacks = {
3282 },
3283 .num_children = 1,
3284 .children = { &channels_channelId_play_playbackId, }
3285};
3286/*! \brief REST handler for /api-docs/channels.json */
3288 .path_segment = "record",
3289 .callbacks = {
3291 },
3292 .num_children = 0,
3293 .children = { }
3294};
3295/*! \brief REST handler for /api-docs/channels.json */
3297 .path_segment = "variable",
3298 .callbacks = {
3301 },
3302 .num_children = 0,
3303 .children = { }
3304};
3305/*! \brief REST handler for /api-docs/channels.json */
3307 .path_segment = "snoopId",
3308 .is_wildcard = 1,
3309 .callbacks = {
3311 },
3312 .num_children = 0,
3313 .children = { }
3314};
3315/*! \brief REST handler for /api-docs/channels.json */
3317 .path_segment = "snoop",
3318 .callbacks = {
3320 },
3321 .num_children = 1,
3322 .children = { &channels_channelId_snoop_snoopId, }
3323};
3324/*! \brief REST handler for /api-docs/channels.json */
3326 .path_segment = "dial",
3327 .callbacks = {
3329 },
3330 .num_children = 0,
3331 .children = { }
3332};
3333/*! \brief REST handler for /api-docs/channels.json */
3335 .path_segment = "rtp_statistics",
3336 .callbacks = {
3338 },
3339 .num_children = 0,
3340 .children = { }
3341};
3342/*! \brief REST handler for /api-docs/channels.json */
3344 .path_segment = "transfer_progress",
3345 .callbacks = {
3347 },
3348 .num_children = 0,
3349 .children = { }
3350};
3351/*! \brief REST handler for /api-docs/channels.json */
3353 .path_segment = "channelId",
3354 .is_wildcard = 1,
3355 .callbacks = {
3359 },
3360 .num_children = 18,
3362};
3363/*! \brief REST handler for /api-docs/channels.json */
3365 .path_segment = "externalMedia",
3366 .callbacks = {
3368 },
3369 .num_children = 0,
3370 .children = { }
3371};
3372/*! \brief REST handler for /api-docs/channels.json */
3374 .path_segment = "channels",
3375 .callbacks = {
3378 },
3379 .num_children = 3,
3381};
3382
3383static int unload_module(void)
3384{
3386 return 0;
3387}
3388
3389static int load_module(void)
3390{
3391 int res = 0;
3392
3393
3395 if (res) {
3396 unload_module();
3398 }
3399
3401}
3402
3403AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Channel resources",
3404 .support_level = AST_MODULE_SUPPORT_CORE,
3405 .load = load_module,
3406 .unload = unload_module,
3407 .requires = "res_ari,res_ari_model,res_stasis,res_stasis_answer,res_stasis_playback,res_stasis_recording,res_stasis_snoop",
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:155
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:212
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:251
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:132
int ast_ari_validate_variable(struct ast_json *json)
Validator for Variable.
int ast_ari_validate_playback(struct ast_json *json)
Validator for Playback.
int ast_ari_validate_live_recording(struct ast_json *json)
Validator for LiveRecording.
int ast_ari_validate_channel(struct ast_json *json)
Validator for Channel.
int ast_ari_validate_rtpstat(struct ast_json *json)
Validator for RTPstat.
ari_validator ast_ari_validate_channel_fn(void)
Function pointer to ast_ari_validate_channel().
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 struct stasis_rest_handlers channels_channelId_hold
REST handler for /api-docs/channels.json.
int ast_ari_channels_move_parse_body(struct ast_json *body, struct ast_ari_channels_move_args *args)
Body parsing function for /channels/{channelId}/move.
int ast_ari_channels_send_dtmf_parse_body(struct ast_json *body, struct ast_ari_channels_send_dtmf_args *args)
Body parsing function for /channels/{channelId}/dtmf.
static void ast_ari_channels_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 /channels/{channelId}/moh.
static struct stasis_rest_handlers channels_channelId_snoop
REST handler for /api-docs/channels.json.
static void ast_ari_channels_start_silence_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 /channels/{channelId}/silence.
int ast_ari_channels_dial_parse_body(struct ast_json *body, struct ast_ari_channels_dial_args *args)
Body parsing function for /channels/{channelId}/dial.
static void ast_ari_channels_mute_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 /channels/{channelId}/mute.
static struct stasis_rest_handlers channels_channelId_silence
REST handler for /api-docs/channels.json.
int ast_ari_channels_unmute_parse_body(struct ast_json *body, struct ast_ari_channels_unmute_args *args)
Body parsing function for /channels/{channelId}/mute.
int ast_ari_channels_get_channel_var_parse_body(struct ast_json *body, struct ast_ari_channels_get_channel_var_args *args)
Body parsing function for /channels/{channelId}/variable.
static void ast_ari_channels_hangup_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 /channels/{channelId}.
static struct stasis_rest_handlers channels_channelId_mute
REST handler for /api-docs/channels.json.
static struct stasis_rest_handlers channels_create
REST handler for /api-docs/channels.json.
static void ast_ari_channels_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 /channels/{channelId}/moh.
int ast_ari_channels_snoop_channel_with_id_parse_body(struct ast_json *body, struct ast_ari_channels_snoop_channel_with_id_args *args)
Body parsing function for /channels/{channelId}/snoop/{snoopId}.
int ast_ari_channels_mute_parse_body(struct ast_json *body, struct ast_ari_channels_mute_args *args)
Body parsing function for /channels/{channelId}/mute.
static void ast_ari_channels_send_dtmf_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 /channels/{channelId}/dtmf.
static void ast_ari_channels_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 /channels/{channelId}/play.
#define MAX_VALS
int ast_ari_channels_redirect_parse_body(struct ast_json *body, struct ast_ari_channels_redirect_args *args)
Body parsing function for /channels/{channelId}/redirect.
static struct stasis_rest_handlers channels_channelId
REST handler for /api-docs/channels.json.
static struct stasis_rest_handlers channels_channelId_variable
REST handler for /api-docs/channels.json.
int ast_ari_channels_record_parse_body(struct ast_json *body, struct ast_ari_channels_record_args *args)
Body parsing function for /channels/{channelId}/record.
int ast_ari_channels_transfer_progress_parse_body(struct ast_json *body, struct ast_ari_channels_transfer_progress_args *args)
Body parsing function for /channels/{channelId}/transfer_progress.
static void ast_ari_channels_stop_silence_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 /channels/{channelId}/silence.
static void ast_ari_channels_unmute_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 /channels/{channelId}/mute.
static void ast_ari_channels_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 /channels.
int ast_ari_channels_snoop_channel_parse_body(struct ast_json *body, struct ast_ari_channels_snoop_channel_args *args)
Body parsing function for /channels/{channelId}/snoop.
static struct stasis_rest_handlers channels_channelId_answer
REST handler for /api-docs/channels.json.
static struct stasis_rest_handlers channels_channelId_record
REST handler for /api-docs/channels.json.
static struct stasis_rest_handlers channels_channelId_rtp_statistics
REST handler for /api-docs/channels.json.
static void ast_ari_channels_snoop_channel_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 /channels/{channelId}/snoop/{snoopId}.
static void ast_ari_channels_hold_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 /channels/{channelId}/hold.
static void ast_ari_channels_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 /channels/{channelId}/record.
static void ast_ari_channels_move_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 /channels/{channelId}/move.
static struct stasis_rest_handlers channels_channelId_moh
REST handler for /api-docs/channels.json.
static void ast_ari_channels_progress_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 /channels/{channelId}/progress.
static struct stasis_rest_handlers channels_channelId_play
REST handler for /api-docs/channels.json.
static void ast_ari_channels_ring_stop_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 /channels/{channelId}/ring.
static struct stasis_rest_handlers channels_channelId_continue
REST handler for /api-docs/channels.json.
static void ast_ari_channels_dial_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 /channels/{channelId}/dial.
static void ast_ari_channels_ring_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 /channels/{channelId}/ring.
int ast_ari_channels_continue_in_dialplan_parse_body(struct ast_json *body, struct ast_ari_channels_continue_in_dialplan_args *args)
Body parsing function for /channels/{channelId}/continue.
static void ast_ari_channels_originate_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 /channels.
int ast_ari_channels_originate_with_id_parse_body(struct ast_json *body, struct ast_ari_channels_originate_with_id_args *args)
Body parsing function for /channels/{channelId}.
static void ast_ari_channels_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 /channels/{channelId}/play/{playbackId}.
static void ast_ari_channels_transfer_progress_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 /channels/{channelId}/transfer_progress.
static void ast_ari_channels_snoop_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 /channels/{channelId}/snoop.
static void ast_ari_channels_set_channel_var_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /channels/{channelId}/variable.
static struct stasis_rest_handlers channels_channelId_snoop_snoopId
REST handler for /api-docs/channels.json.
int ast_ari_channels_play_with_id_parse_body(struct ast_json *body, struct ast_ari_channels_play_with_id_args *args)
Body parsing function for /channels/{channelId}/play/{playbackId}.
int ast_ari_channels_create_parse_body(struct ast_json *body, struct ast_ari_channels_create_args *args)
Body parsing function for /channels/create.
static void ast_ari_channels_rtpstatistics_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 /channels/{channelId}/rtp_statistics.
static struct stasis_rest_handlers channels_channelId_dtmf
REST handler for /api-docs/channels.json.
static void ast_ari_channels_external_media_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 /channels/externalMedia.
int ast_ari_channels_external_media_parse_body(struct ast_json *body, struct ast_ari_channels_external_media_args *args)
Body parsing function for /channels/externalMedia.
int ast_ari_channels_play_parse_body(struct ast_json *body, struct ast_ari_channels_play_args *args)
Body parsing function for /channels/{channelId}/play.
static struct stasis_rest_handlers channels_channelId_progress
REST handler for /api-docs/channels.json.
static struct stasis_rest_handlers channels_externalMedia
REST handler for /api-docs/channels.json.
int ast_ari_channels_set_channel_var_parse_body(struct ast_json *body, struct ast_ari_channels_set_channel_var_args *args)
Body parsing function for /channels/{channelId}/variable.
static void ast_ari_channels_get_channel_var_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /channels/{channelId}/variable.
static int load_module(void)
static struct stasis_rest_handlers channels_channelId_move
REST handler for /api-docs/channels.json.
int ast_ari_channels_start_moh_parse_body(struct ast_json *body, struct ast_ari_channels_start_moh_args *args)
Body parsing function for /channels/{channelId}/moh.
static int unload_module(void)
static struct stasis_rest_handlers channels_channelId_ring
REST handler for /api-docs/channels.json.
static struct stasis_rest_handlers channels_channelId_redirect
REST handler for /api-docs/channels.json.
static void ast_ari_channels_continue_in_dialplan_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 /channels/{channelId}/continue.
static struct stasis_rest_handlers channels_channelId_transfer_progress
REST handler for /api-docs/channels.json.
static struct stasis_rest_handlers channels_channelId_dial
REST handler for /api-docs/channels.json.
static void ast_ari_channels_originate_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 /channels/{channelId}.
static void ast_ari_channels_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 /channels/create.
static struct stasis_rest_handlers channels_channelId_play_playbackId
REST handler for /api-docs/channels.json.
int ast_ari_channels_originate_parse_body(struct ast_json *body, struct ast_ari_channels_originate_args *args)
Body parsing function for /channels.
static void ast_ari_channels_redirect_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 /channels/{channelId}/redirect.
static struct stasis_rest_handlers channels
REST handler for /api-docs/channels.json.
static void ast_ari_channels_unhold_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 /channels/{channelId}/hold.
static void ast_ari_channels_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 /channels/{channelId}.
static void ast_ari_channels_answer_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 /channels/{channelId}/answer.
int ast_ari_channels_hangup_parse_body(struct ast_json *body, struct ast_ari_channels_hangup_args *args)
Body parsing function for /channels/{channelId}.
#define NULL
Definition: resample.c:96
void ast_ari_channels_mute(struct ast_variable *headers, struct ast_ari_channels_mute_args *args, struct ast_ari_response *response)
Mute a channel.
void ast_ari_channels_snoop_channel_with_id(struct ast_variable *headers, struct ast_ari_channels_snoop_channel_with_id_args *args, struct ast_ari_response *response)
Start snooping.
void ast_ari_channels_continue_in_dialplan(struct ast_variable *headers, struct ast_ari_channels_continue_in_dialplan_args *args, struct ast_ari_response *response)
Exit application; continue execution in the dialplan.
void ast_ari_channels_start_moh(struct ast_variable *headers, struct ast_ari_channels_start_moh_args *args, struct ast_ari_response *response)
Play music on hold to a channel.
void ast_ari_channels_stop_moh(struct ast_variable *headers, struct ast_ari_channels_stop_moh_args *args, struct ast_ari_response *response)
Stop playing music on hold to a channel.
void ast_ari_channels_move(struct ast_variable *headers, struct ast_ari_channels_move_args *args, struct ast_ari_response *response)
Move the channel from one Stasis application to another.
void ast_ari_channels_send_dtmf(struct ast_variable *headers, struct ast_ari_channels_send_dtmf_args *args, struct ast_ari_response *response)
Send provided DTMF to a given channel.
void ast_ari_channels_unmute(struct ast_variable *headers, struct ast_ari_channels_unmute_args *args, struct ast_ari_response *response)
Unmute a channel.
void ast_ari_channels_dial(struct ast_variable *headers, struct ast_ari_channels_dial_args *args, struct ast_ari_response *response)
Dial a created channel.
void ast_ari_channels_create(struct ast_variable *headers, struct ast_ari_channels_create_args *args, struct ast_ari_response *response)
Create channel.
void ast_ari_channels_list(struct ast_variable *headers, struct ast_ari_channels_list_args *args, struct ast_ari_response *response)
List all active channels in Asterisk.
void ast_ari_channels_get(struct ast_variable *headers, struct ast_ari_channels_get_args *args, struct ast_ari_response *response)
Channel details.
void ast_ari_channels_snoop_channel(struct ast_variable *headers, struct ast_ari_channels_snoop_channel_args *args, struct ast_ari_response *response)
Start snooping.
void ast_ari_channels_transfer_progress(struct ast_variable *headers, struct ast_ari_channels_transfer_progress_args *args, struct ast_ari_response *response)
Inform the channel about the progress of the attended/blind transfer.
void ast_ari_channels_ring(struct ast_variable *headers, struct ast_ari_channels_ring_args *args, struct ast_ari_response *response)
Indicate ringing to a channel.
void ast_ari_channels_play(struct ast_variable *headers, struct ast_ari_channels_play_args *args, struct ast_ari_response *response)
Start playback of media.
void ast_ari_channels_stop_silence(struct ast_variable *headers, struct ast_ari_channels_stop_silence_args *args, struct ast_ari_response *response)
Stop playing silence to a channel.
void ast_ari_channels_external_media(struct ast_variable *headers, struct ast_ari_channels_external_media_args *args, struct ast_ari_response *response)
Start an External Media session.
void ast_ari_channels_ring_stop(struct ast_variable *headers, struct ast_ari_channels_ring_stop_args *args, struct ast_ari_response *response)
Stop ringing indication on a channel if locally generated.
void ast_ari_channels_progress(struct ast_variable *headers, struct ast_ari_channels_progress_args *args, struct ast_ari_response *response)
Indicate progress on a channel.
void ast_ari_channels_start_silence(struct ast_variable *headers, struct ast_ari_channels_start_silence_args *args, struct ast_ari_response *response)
Play silence to a channel.
void ast_ari_channels_unhold(struct ast_variable *headers, struct ast_ari_channels_unhold_args *args, struct ast_ari_response *response)
Remove a channel from hold.
void ast_ari_channels_originate(struct ast_variable *headers, struct ast_ari_channels_originate_args *args, struct ast_ari_response *response)
Create a new channel (originate).
void ast_ari_channels_redirect(struct ast_variable *headers, struct ast_ari_channels_redirect_args *args, struct ast_ari_response *response)
Redirect the channel to a different location.
void ast_ari_channels_record(struct ast_variable *headers, struct ast_ari_channels_record_args *args, struct ast_ari_response *response)
Start a recording.
void ast_ari_channels_set_channel_var(struct ast_variable *headers, struct ast_ari_channels_set_channel_var_args *args, struct ast_ari_response *response)
Set the value of a channel variable or function.
void ast_ari_channels_hold(struct ast_variable *headers, struct ast_ari_channels_hold_args *args, struct ast_ari_response *response)
Hold a channel.
void ast_ari_channels_answer(struct ast_variable *headers, struct ast_ari_channels_answer_args *args, struct ast_ari_response *response)
Answer a channel.
void ast_ari_channels_play_with_id(struct ast_variable *headers, struct ast_ari_channels_play_with_id_args *args, struct ast_ari_response *response)
Start playback of media and specify the playbackId.
void ast_ari_channels_rtpstatistics(struct ast_variable *headers, struct ast_ari_channels_rtpstatistics_args *args, struct ast_ari_response *response)
RTP stats on a channel.
void ast_ari_channels_get_channel_var(struct ast_variable *headers, struct ast_ari_channels_get_channel_var_args *args, struct ast_ari_response *response)
Get the value of a channel variable or function.
void ast_ari_channels_originate_with_id(struct ast_variable *headers, struct ast_ari_channels_originate_with_id_args *args, struct ast_ari_response *response)
Create a new channel (originate with id).
void ast_ari_channels_hangup(struct ast_variable *headers, struct ast_ari_channels_hangup_args *args, struct ast_ari_response *response)
Delete (i.e. hangup) a channel.
Generated file - declares stubs to be implemented in res/ari/resource_channels.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:2235
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:703