Asterisk - The Open Source Telephony Project GIT-master-a358458
res_ari_recordings.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 Recording resources
30 *
31 * \author David M. Lee, II <dlee@digium.com>
32 */
33
34/*** MODULEINFO
35 <depend type="module">res_ari</depend>
36 <depend type="module">res_ari_model</depend>
37 <depend type="module">res_stasis</depend>
38 <depend type="module">res_stasis_recording</depend>
39 <support_level>core</support_level>
40 ***/
41
42#include "asterisk.h"
43
44#include "asterisk/app.h"
45#include "asterisk/module.h"
46#include "asterisk/stasis_app.h"
48#if defined(AST_DEVMODE)
50#endif
51
52#define MAX_VALS 128
53
54/*!
55 * \brief Parameter parsing callback for /recordings/stored.
56 * \param ser TCP/TLS session object
57 * \param get_params GET parameters in the HTTP request.
58 * \param path_vars Path variables extracted from the request.
59 * \param headers HTTP headers.
60 * \param body
61 * \param[out] response Response to the HTTP request.
62 */
65 struct ast_variable *get_params, struct ast_variable *path_vars,
66 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
67{
69#if defined(AST_DEVMODE)
70 int is_valid;
71 int code;
72#endif /* AST_DEVMODE */
73
74 ast_ari_recordings_list_stored(headers, &args, response);
75#if defined(AST_DEVMODE)
76 code = response->response_code;
77
78 switch (code) {
79 case 0: /* Implementation is still a stub, or the code wasn't set */
80 is_valid = response->message == NULL;
81 break;
82 case 500: /* Internal Server Error */
83 case 501: /* Not Implemented */
84 is_valid = 1;
85 break;
86 default:
87 if (200 <= code && code <= 299) {
88 is_valid = ast_ari_validate_list(response->message,
90 } else {
91 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored\n", code);
92 is_valid = 0;
93 }
94 }
95
96 if (!is_valid) {
97 ast_log(LOG_ERROR, "Response validation failed for /recordings/stored\n");
98 ast_ari_response_error(response, 500,
99 "Internal Server Error", "Response validation failed");
100 }
101#endif /* AST_DEVMODE */
102
103fin: __attribute__((unused))
104 return;
105}
106/*!
107 * \brief Parameter parsing callback for /recordings/stored/{recordingName}.
108 * \param ser TCP/TLS session object
109 * \param get_params GET parameters in the HTTP request.
110 * \param path_vars Path variables extracted from the request.
111 * \param headers HTTP headers.
112 * \param body
113 * \param[out] response Response to the HTTP request.
114 */
116 struct ast_tcptls_session_instance *ser,
117 struct ast_variable *get_params, struct ast_variable *path_vars,
118 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
119{
121 struct ast_variable *i;
122#if defined(AST_DEVMODE)
123 int is_valid;
124 int code;
125#endif /* AST_DEVMODE */
126
127 for (i = path_vars; i; i = i->next) {
128 if (strcmp(i->name, "recordingName") == 0) {
129 args.recording_name = (i->value);
130 } else
131 {}
132 }
133 ast_ari_recordings_get_stored(headers, &args, response);
134#if defined(AST_DEVMODE)
135 code = response->response_code;
136
137 switch (code) {
138 case 0: /* Implementation is still a stub, or the code wasn't set */
139 is_valid = response->message == NULL;
140 break;
141 case 500: /* Internal Server Error */
142 case 501: /* Not Implemented */
143 case 404: /* Recording not found */
144 is_valid = 1;
145 break;
146 default:
147 if (200 <= code && code <= 299) {
149 response->message);
150 } else {
151 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored/{recordingName}\n", code);
152 is_valid = 0;
153 }
154 }
155
156 if (!is_valid) {
157 ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingName}\n");
158 ast_ari_response_error(response, 500,
159 "Internal Server Error", "Response validation failed");
160 }
161#endif /* AST_DEVMODE */
162
163fin: __attribute__((unused))
164 return;
165}
166/*!
167 * \brief Parameter parsing callback for /recordings/stored/{recordingName}.
168 * \param ser TCP/TLS session object
169 * \param get_params GET parameters in the HTTP request.
170 * \param path_vars Path variables extracted from the request.
171 * \param headers HTTP headers.
172 * \param body
173 * \param[out] response Response to the HTTP request.
174 */
176 struct ast_tcptls_session_instance *ser,
177 struct ast_variable *get_params, struct ast_variable *path_vars,
178 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
179{
181 struct ast_variable *i;
182#if defined(AST_DEVMODE)
183 int is_valid;
184 int code;
185#endif /* AST_DEVMODE */
186
187 for (i = path_vars; i; i = i->next) {
188 if (strcmp(i->name, "recordingName") == 0) {
189 args.recording_name = (i->value);
190 } else
191 {}
192 }
193 ast_ari_recordings_delete_stored(headers, &args, response);
194#if defined(AST_DEVMODE)
195 code = response->response_code;
196
197 switch (code) {
198 case 0: /* Implementation is still a stub, or the code wasn't set */
199 is_valid = response->message == NULL;
200 break;
201 case 500: /* Internal Server Error */
202 case 501: /* Not Implemented */
203 case 404: /* Recording not found */
204 is_valid = 1;
205 break;
206 default:
207 if (200 <= code && code <= 299) {
208 is_valid = ast_ari_validate_void(
209 response->message);
210 } else {
211 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored/{recordingName}\n", code);
212 is_valid = 0;
213 }
214 }
215
216 if (!is_valid) {
217 ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingName}\n");
218 ast_ari_response_error(response, 500,
219 "Internal Server Error", "Response validation failed");
220 }
221#endif /* AST_DEVMODE */
222
223fin: __attribute__((unused))
224 return;
225}
226/*!
227 * \brief Parameter parsing callback for /recordings/stored/{recordingName}/file.
228 * \param ser TCP/TLS session object
229 * \param get_params GET parameters in the HTTP request.
230 * \param path_vars Path variables extracted from the request.
231 * \param headers HTTP headers.
232 * \param body
233 * \param[out] response Response to the HTTP request.
234 */
236 struct ast_tcptls_session_instance *ser,
237 struct ast_variable *get_params, struct ast_variable *path_vars,
238 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
239{
241 struct ast_variable *i;
242#if defined(AST_DEVMODE)
243 int is_valid;
244 int code;
245#endif /* AST_DEVMODE */
246
247 for (i = path_vars; i; i = i->next) {
248 if (strcmp(i->name, "recordingName") == 0) {
249 args.recording_name = (i->value);
250 } else
251 {}
252 }
253 ast_ari_recordings_get_stored_file(ser, headers, &args, response);
254#if defined(AST_DEVMODE)
255 code = response->response_code;
256
257 switch (code) {
258 case 0: /* Implementation is still a stub, or the code wasn't set */
259 is_valid = response->message == NULL;
260 break;
261 case 500: /* Internal Server Error */
262 case 501: /* Not Implemented */
263 case 403: /* The recording file could not be opened */
264 case 404: /* Recording not found */
265 is_valid = 1;
266 break;
267 default:
268 if (200 <= code && code <= 299) {
269 /* No validation on a raw binary response */
270 is_valid = 1;
271 } else {
272 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored/{recordingName}/file\n", code);
273 is_valid = 0;
274 }
275 }
276
277 if (!is_valid) {
278 ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingName}/file\n");
279 ast_ari_response_error(response, 500,
280 "Internal Server Error", "Response validation failed");
281 }
282#endif /* AST_DEVMODE */
283
284fin: __attribute__((unused))
285 return;
286}
288 struct ast_json *body,
290{
291 struct ast_json *field;
292 /* Parse query parameters out of it */
293 field = ast_json_object_get(body, "destinationRecordingName");
294 if (field) {
295 args->destination_recording_name = ast_json_string_get(field);
296 }
297 return 0;
298}
299
300/*!
301 * \brief Parameter parsing callback for /recordings/stored/{recordingName}/copy.
302 * \param ser TCP/TLS session object
303 * \param get_params GET parameters in the HTTP request.
304 * \param path_vars Path variables extracted from the request.
305 * \param headers HTTP headers.
306 * \param body
307 * \param[out] response Response to the HTTP request.
308 */
310 struct ast_tcptls_session_instance *ser,
311 struct ast_variable *get_params, struct ast_variable *path_vars,
312 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
313{
315 struct ast_variable *i;
316#if defined(AST_DEVMODE)
317 int is_valid;
318 int code;
319#endif /* AST_DEVMODE */
320
321 for (i = get_params; i; i = i->next) {
322 if (strcmp(i->name, "destinationRecordingName") == 0) {
323 args.destination_recording_name = (i->value);
324 } else
325 {}
326 }
327 for (i = path_vars; i; i = i->next) {
328 if (strcmp(i->name, "recordingName") == 0) {
329 args.recording_name = (i->value);
330 } else
331 {}
332 }
335 goto fin;
336 }
337 ast_ari_recordings_copy_stored(headers, &args, response);
338#if defined(AST_DEVMODE)
339 code = response->response_code;
340
341 switch (code) {
342 case 0: /* Implementation is still a stub, or the code wasn't set */
343 is_valid = response->message == NULL;
344 break;
345 case 500: /* Internal Server Error */
346 case 501: /* Not Implemented */
347 case 404: /* Recording not found */
348 case 409: /* A recording with the same name already exists on the system */
349 is_valid = 1;
350 break;
351 default:
352 if (200 <= code && code <= 299) {
354 response->message);
355 } else {
356 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/stored/{recordingName}/copy\n", code);
357 is_valid = 0;
358 }
359 }
360
361 if (!is_valid) {
362 ast_log(LOG_ERROR, "Response validation failed for /recordings/stored/{recordingName}/copy\n");
363 ast_ari_response_error(response, 500,
364 "Internal Server Error", "Response validation failed");
365 }
366#endif /* AST_DEVMODE */
367
368fin: __attribute__((unused))
369 return;
370}
371/*!
372 * \brief Parameter parsing callback for /recordings/live/{recordingName}.
373 * \param ser TCP/TLS session object
374 * \param get_params GET parameters in the HTTP request.
375 * \param path_vars Path variables extracted from the request.
376 * \param headers HTTP headers.
377 * \param body
378 * \param[out] response Response to the HTTP request.
379 */
381 struct ast_tcptls_session_instance *ser,
382 struct ast_variable *get_params, struct ast_variable *path_vars,
383 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
384{
386 struct ast_variable *i;
387#if defined(AST_DEVMODE)
388 int is_valid;
389 int code;
390#endif /* AST_DEVMODE */
391
392 for (i = path_vars; i; i = i->next) {
393 if (strcmp(i->name, "recordingName") == 0) {
394 args.recording_name = (i->value);
395 } else
396 {}
397 }
398 ast_ari_recordings_get_live(headers, &args, response);
399#if defined(AST_DEVMODE)
400 code = response->response_code;
401
402 switch (code) {
403 case 0: /* Implementation is still a stub, or the code wasn't set */
404 is_valid = response->message == NULL;
405 break;
406 case 500: /* Internal Server Error */
407 case 501: /* Not Implemented */
408 case 404: /* Recording not found */
409 is_valid = 1;
410 break;
411 default:
412 if (200 <= code && code <= 299) {
414 response->message);
415 } else {
416 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingName}\n", code);
417 is_valid = 0;
418 }
419 }
420
421 if (!is_valid) {
422 ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingName}\n");
423 ast_ari_response_error(response, 500,
424 "Internal Server Error", "Response validation failed");
425 }
426#endif /* AST_DEVMODE */
427
428fin: __attribute__((unused))
429 return;
430}
431/*!
432 * \brief Parameter parsing callback for /recordings/live/{recordingName}.
433 * \param ser TCP/TLS session object
434 * \param get_params GET parameters in the HTTP request.
435 * \param path_vars Path variables extracted from the request.
436 * \param headers HTTP headers.
437 * \param body
438 * \param[out] response Response to the HTTP request.
439 */
441 struct ast_tcptls_session_instance *ser,
442 struct ast_variable *get_params, struct ast_variable *path_vars,
443 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
444{
446 struct ast_variable *i;
447#if defined(AST_DEVMODE)
448 int is_valid;
449 int code;
450#endif /* AST_DEVMODE */
451
452 for (i = path_vars; i; i = i->next) {
453 if (strcmp(i->name, "recordingName") == 0) {
454 args.recording_name = (i->value);
455 } else
456 {}
457 }
458 ast_ari_recordings_cancel(headers, &args, response);
459#if defined(AST_DEVMODE)
460 code = response->response_code;
461
462 switch (code) {
463 case 0: /* Implementation is still a stub, or the code wasn't set */
464 is_valid = response->message == NULL;
465 break;
466 case 500: /* Internal Server Error */
467 case 501: /* Not Implemented */
468 case 404: /* Recording not found */
469 is_valid = 1;
470 break;
471 default:
472 if (200 <= code && code <= 299) {
473 is_valid = ast_ari_validate_void(
474 response->message);
475 } else {
476 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingName}\n", code);
477 is_valid = 0;
478 }
479 }
480
481 if (!is_valid) {
482 ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingName}\n");
483 ast_ari_response_error(response, 500,
484 "Internal Server Error", "Response validation failed");
485 }
486#endif /* AST_DEVMODE */
487
488fin: __attribute__((unused))
489 return;
490}
491/*!
492 * \brief Parameter parsing callback for /recordings/live/{recordingName}/stop.
493 * \param ser TCP/TLS session object
494 * \param get_params GET parameters in the HTTP request.
495 * \param path_vars Path variables extracted from the request.
496 * \param headers HTTP headers.
497 * \param body
498 * \param[out] response Response to the HTTP request.
499 */
501 struct ast_tcptls_session_instance *ser,
502 struct ast_variable *get_params, struct ast_variable *path_vars,
503 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
504{
506 struct ast_variable *i;
507#if defined(AST_DEVMODE)
508 int is_valid;
509 int code;
510#endif /* AST_DEVMODE */
511
512 for (i = path_vars; i; i = i->next) {
513 if (strcmp(i->name, "recordingName") == 0) {
514 args.recording_name = (i->value);
515 } else
516 {}
517 }
518 ast_ari_recordings_stop(headers, &args, response);
519#if defined(AST_DEVMODE)
520 code = response->response_code;
521
522 switch (code) {
523 case 0: /* Implementation is still a stub, or the code wasn't set */
524 is_valid = response->message == NULL;
525 break;
526 case 500: /* Internal Server Error */
527 case 501: /* Not Implemented */
528 case 404: /* Recording not found */
529 is_valid = 1;
530 break;
531 default:
532 if (200 <= code && code <= 299) {
533 is_valid = ast_ari_validate_void(
534 response->message);
535 } else {
536 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingName}/stop\n", code);
537 is_valid = 0;
538 }
539 }
540
541 if (!is_valid) {
542 ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingName}/stop\n");
543 ast_ari_response_error(response, 500,
544 "Internal Server Error", "Response validation failed");
545 }
546#endif /* AST_DEVMODE */
547
548fin: __attribute__((unused))
549 return;
550}
551/*!
552 * \brief Parameter parsing callback for /recordings/live/{recordingName}/pause.
553 * \param ser TCP/TLS session object
554 * \param get_params GET parameters in the HTTP request.
555 * \param path_vars Path variables extracted from the request.
556 * \param headers HTTP headers.
557 * \param body
558 * \param[out] response Response to the HTTP request.
559 */
561 struct ast_tcptls_session_instance *ser,
562 struct ast_variable *get_params, struct ast_variable *path_vars,
563 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
564{
566 struct ast_variable *i;
567#if defined(AST_DEVMODE)
568 int is_valid;
569 int code;
570#endif /* AST_DEVMODE */
571
572 for (i = path_vars; i; i = i->next) {
573 if (strcmp(i->name, "recordingName") == 0) {
574 args.recording_name = (i->value);
575 } else
576 {}
577 }
578 ast_ari_recordings_pause(headers, &args, response);
579#if defined(AST_DEVMODE)
580 code = response->response_code;
581
582 switch (code) {
583 case 0: /* Implementation is still a stub, or the code wasn't set */
584 is_valid = response->message == NULL;
585 break;
586 case 500: /* Internal Server Error */
587 case 501: /* Not Implemented */
588 case 404: /* Recording not found */
589 case 409: /* Recording not in session */
590 is_valid = 1;
591 break;
592 default:
593 if (200 <= code && code <= 299) {
594 is_valid = ast_ari_validate_void(
595 response->message);
596 } else {
597 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingName}/pause\n", code);
598 is_valid = 0;
599 }
600 }
601
602 if (!is_valid) {
603 ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingName}/pause\n");
604 ast_ari_response_error(response, 500,
605 "Internal Server Error", "Response validation failed");
606 }
607#endif /* AST_DEVMODE */
608
609fin: __attribute__((unused))
610 return;
611}
612/*!
613 * \brief Parameter parsing callback for /recordings/live/{recordingName}/pause.
614 * \param ser TCP/TLS session object
615 * \param get_params GET parameters in the HTTP request.
616 * \param path_vars Path variables extracted from the request.
617 * \param headers HTTP headers.
618 * \param body
619 * \param[out] response Response to the HTTP request.
620 */
622 struct ast_tcptls_session_instance *ser,
623 struct ast_variable *get_params, struct ast_variable *path_vars,
624 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
625{
627 struct ast_variable *i;
628#if defined(AST_DEVMODE)
629 int is_valid;
630 int code;
631#endif /* AST_DEVMODE */
632
633 for (i = path_vars; i; i = i->next) {
634 if (strcmp(i->name, "recordingName") == 0) {
635 args.recording_name = (i->value);
636 } else
637 {}
638 }
639 ast_ari_recordings_unpause(headers, &args, response);
640#if defined(AST_DEVMODE)
641 code = response->response_code;
642
643 switch (code) {
644 case 0: /* Implementation is still a stub, or the code wasn't set */
645 is_valid = response->message == NULL;
646 break;
647 case 500: /* Internal Server Error */
648 case 501: /* Not Implemented */
649 case 404: /* Recording not found */
650 case 409: /* Recording not in session */
651 is_valid = 1;
652 break;
653 default:
654 if (200 <= code && code <= 299) {
655 is_valid = ast_ari_validate_void(
656 response->message);
657 } else {
658 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingName}/pause\n", code);
659 is_valid = 0;
660 }
661 }
662
663 if (!is_valid) {
664 ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingName}/pause\n");
665 ast_ari_response_error(response, 500,
666 "Internal Server Error", "Response validation failed");
667 }
668#endif /* AST_DEVMODE */
669
670fin: __attribute__((unused))
671 return;
672}
673/*!
674 * \brief Parameter parsing callback for /recordings/live/{recordingName}/mute.
675 * \param ser TCP/TLS session object
676 * \param get_params GET parameters in the HTTP request.
677 * \param path_vars Path variables extracted from the request.
678 * \param headers HTTP headers.
679 * \param body
680 * \param[out] response Response to the HTTP request.
681 */
683 struct ast_tcptls_session_instance *ser,
684 struct ast_variable *get_params, struct ast_variable *path_vars,
685 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
686{
688 struct ast_variable *i;
689#if defined(AST_DEVMODE)
690 int is_valid;
691 int code;
692#endif /* AST_DEVMODE */
693
694 for (i = path_vars; i; i = i->next) {
695 if (strcmp(i->name, "recordingName") == 0) {
696 args.recording_name = (i->value);
697 } else
698 {}
699 }
700 ast_ari_recordings_mute(headers, &args, response);
701#if defined(AST_DEVMODE)
702 code = response->response_code;
703
704 switch (code) {
705 case 0: /* Implementation is still a stub, or the code wasn't set */
706 is_valid = response->message == NULL;
707 break;
708 case 500: /* Internal Server Error */
709 case 501: /* Not Implemented */
710 case 404: /* Recording not found */
711 case 409: /* Recording not in session */
712 is_valid = 1;
713 break;
714 default:
715 if (200 <= code && code <= 299) {
716 is_valid = ast_ari_validate_void(
717 response->message);
718 } else {
719 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingName}/mute\n", code);
720 is_valid = 0;
721 }
722 }
723
724 if (!is_valid) {
725 ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingName}/mute\n");
726 ast_ari_response_error(response, 500,
727 "Internal Server Error", "Response validation failed");
728 }
729#endif /* AST_DEVMODE */
730
731fin: __attribute__((unused))
732 return;
733}
734/*!
735 * \brief Parameter parsing callback for /recordings/live/{recordingName}/mute.
736 * \param ser TCP/TLS session object
737 * \param get_params GET parameters in the HTTP request.
738 * \param path_vars Path variables extracted from the request.
739 * \param headers HTTP headers.
740 * \param body
741 * \param[out] response Response to the HTTP request.
742 */
744 struct ast_tcptls_session_instance *ser,
745 struct ast_variable *get_params, struct ast_variable *path_vars,
746 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
747{
749 struct ast_variable *i;
750#if defined(AST_DEVMODE)
751 int is_valid;
752 int code;
753#endif /* AST_DEVMODE */
754
755 for (i = path_vars; i; i = i->next) {
756 if (strcmp(i->name, "recordingName") == 0) {
757 args.recording_name = (i->value);
758 } else
759 {}
760 }
761 ast_ari_recordings_unmute(headers, &args, response);
762#if defined(AST_DEVMODE)
763 code = response->response_code;
764
765 switch (code) {
766 case 0: /* Implementation is still a stub, or the code wasn't set */
767 is_valid = response->message == NULL;
768 break;
769 case 500: /* Internal Server Error */
770 case 501: /* Not Implemented */
771 case 404: /* Recording not found */
772 case 409: /* Recording not in session */
773 is_valid = 1;
774 break;
775 default:
776 if (200 <= code && code <= 299) {
777 is_valid = ast_ari_validate_void(
778 response->message);
779 } else {
780 ast_log(LOG_ERROR, "Invalid error response %d for /recordings/live/{recordingName}/mute\n", code);
781 is_valid = 0;
782 }
783 }
784
785 if (!is_valid) {
786 ast_log(LOG_ERROR, "Response validation failed for /recordings/live/{recordingName}/mute\n");
787 ast_ari_response_error(response, 500,
788 "Internal Server Error", "Response validation failed");
789 }
790#endif /* AST_DEVMODE */
791
792fin: __attribute__((unused))
793 return;
794}
795
796/*! \brief REST handler for /api-docs/recordings.json */
798 .path_segment = "file",
799 .callbacks = {
801 },
802 .num_children = 0,
803 .children = { }
804};
805/*! \brief REST handler for /api-docs/recordings.json */
807 .path_segment = "copy",
808 .callbacks = {
810 },
811 .num_children = 0,
812 .children = { }
813};
814/*! \brief REST handler for /api-docs/recordings.json */
816 .path_segment = "recordingName",
817 .is_wildcard = 1,
818 .callbacks = {
821 },
822 .num_children = 2,
824};
825/*! \brief REST handler for /api-docs/recordings.json */
827 .path_segment = "stored",
828 .callbacks = {
830 },
831 .num_children = 1,
832 .children = { &recordings_stored_recordingName, }
833};
834/*! \brief REST handler for /api-docs/recordings.json */
836 .path_segment = "stop",
837 .callbacks = {
839 },
840 .num_children = 0,
841 .children = { }
842};
843/*! \brief REST handler for /api-docs/recordings.json */
845 .path_segment = "pause",
846 .callbacks = {
849 },
850 .num_children = 0,
851 .children = { }
852};
853/*! \brief REST handler for /api-docs/recordings.json */
855 .path_segment = "mute",
856 .callbacks = {
859 },
860 .num_children = 0,
861 .children = { }
862};
863/*! \brief REST handler for /api-docs/recordings.json */
865 .path_segment = "recordingName",
866 .is_wildcard = 1,
867 .callbacks = {
870 },
871 .num_children = 3,
873};
874/*! \brief REST handler for /api-docs/recordings.json */
876 .path_segment = "live",
877 .callbacks = {
878 },
879 .num_children = 1,
880 .children = { &recordings_live_recordingName, }
881};
882/*! \brief REST handler for /api-docs/recordings.json */
884 .path_segment = "recordings",
885 .callbacks = {
886 },
887 .num_children = 2,
888 .children = { &recordings_stored,&recordings_live, }
889};
890
891static int unload_module(void)
892{
894 return 0;
895}
896
897static int load_module(void)
898{
899 int res = 0;
900
901
903 if (res) {
906 }
907
909}
910
911AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Recording resources",
912 .support_level = AST_MODULE_SUPPORT_CORE,
913 .load = load_module,
914 .unload = unload_module,
915 .requires = "res_ari,res_ari_model,res_stasis,res_stasis_recording",
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:202
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:179
int ast_ari_validate_live_recording(struct ast_json *json)
Validator for LiveRecording.
ari_validator ast_ari_validate_stored_recording_fn(void)
Function pointer to ast_ari_validate_stored_recording().
int ast_ari_validate_stored_recording(struct ast_json *json)
Validator for StoredRecording.
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_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 LOG_ERROR
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
Asterisk module definitions.
@ AST_MODFLAG_DEFAULT
Definition: module.h:315
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:543
@ 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 recordings_stored_recordingName_copy
REST handler for /api-docs/recordings.json.
int ast_ari_recordings_copy_stored_parse_body(struct ast_json *body, struct ast_ari_recordings_copy_stored_args *args)
Body parsing function for /recordings/stored/{recordingName}/copy.
static void ast_ari_recordings_delete_stored_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 /recordings/stored/{recordingName}.
static struct stasis_rest_handlers recordings_stored
REST handler for /api-docs/recordings.json.
static struct stasis_rest_handlers recordings_live_recordingName_mute
REST handler for /api-docs/recordings.json.
static void ast_ari_recordings_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 /recordings/live/{recordingName}/stop.
static void ast_ari_recordings_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 /recordings/live/{recordingName}/mute.
static void ast_ari_recordings_unpause_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 /recordings/live/{recordingName}/pause.
static void ast_ari_recordings_list_stored_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 /recordings/stored.
static void ast_ari_recordings_get_stored_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 /recordings/stored/{recordingName}.
static void ast_ari_recordings_get_stored_file_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 /recordings/stored/{recordingName}/file.
static struct stasis_rest_handlers recordings_live
REST handler for /api-docs/recordings.json.
static struct stasis_rest_handlers recordings_stored_recordingName
REST handler for /api-docs/recordings.json.
static struct stasis_rest_handlers recordings_live_recordingName_pause
REST handler for /api-docs/recordings.json.
static void ast_ari_recordings_copy_stored_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 /recordings/stored/{recordingName}/copy.
static void ast_ari_recordings_cancel_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 /recordings/live/{recordingName}.
static struct stasis_rest_handlers recordings_stored_recordingName_file
REST handler for /api-docs/recordings.json.
static struct stasis_rest_handlers recordings_live_recordingName
REST handler for /api-docs/recordings.json.
static void ast_ari_recordings_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 /recordings/live/{recordingName}/mute.
static void ast_ari_recordings_pause_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 /recordings/live/{recordingName}/pause.
static int load_module(void)
static int unload_module(void)
static struct stasis_rest_handlers recordings
REST handler for /api-docs/recordings.json.
static void ast_ari_recordings_get_live_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 /recordings/live/{recordingName}.
static struct stasis_rest_handlers recordings_live_recordingName_stop
REST handler for /api-docs/recordings.json.
#define NULL
Definition: resample.c:96
void ast_ari_recordings_unmute(struct ast_variable *headers, struct ast_ari_recordings_unmute_args *args, struct ast_ari_response *response)
Unmute a live recording.
void ast_ari_recordings_cancel(struct ast_variable *headers, struct ast_ari_recordings_cancel_args *args, struct ast_ari_response *response)
Stop a live recording and discard it.
void ast_ari_recordings_pause(struct ast_variable *headers, struct ast_ari_recordings_pause_args *args, struct ast_ari_response *response)
Pause a live recording.
void ast_ari_recordings_copy_stored(struct ast_variable *headers, struct ast_ari_recordings_copy_stored_args *args, struct ast_ari_response *response)
Copy a stored recording.
void ast_ari_recordings_unpause(struct ast_variable *headers, struct ast_ari_recordings_unpause_args *args, struct ast_ari_response *response)
Unpause a live recording.
void ast_ari_recordings_mute(struct ast_variable *headers, struct ast_ari_recordings_mute_args *args, struct ast_ari_response *response)
Mute a live recording.
void ast_ari_recordings_delete_stored(struct ast_variable *headers, struct ast_ari_recordings_delete_stored_args *args, struct ast_ari_response *response)
Delete a stored recording.
void ast_ari_recordings_get_stored(struct ast_variable *headers, struct ast_ari_recordings_get_stored_args *args, struct ast_ari_response *response)
Get a stored recording's details.
void ast_ari_recordings_get_live(struct ast_variable *headers, struct ast_ari_recordings_get_live_args *args, struct ast_ari_response *response)
List live recordings.
void ast_ari_recordings_get_stored_file(struct ast_tcptls_session_instance *ser, struct ast_variable *headers, struct ast_ari_recordings_get_stored_file_args *args, struct ast_ari_response *response)
Get the file associated with the stored recording.
void ast_ari_recordings_list_stored(struct ast_variable *headers, struct ast_ari_recordings_list_stored_args *args, struct ast_ari_response *response)
List recordings that are complete.
void ast_ari_recordings_stop(struct ast_variable *headers, struct ast_ari_recordings_stop_args *args, struct ast_ari_response *response)
Stop a live recording and store it.
Generated file - declares stubs to be implemented in res/ari/resource_recordings.c.
Stasis Application API. See Stasis Application API for detailed documentation.
struct ast_json * message
Definition: ari.h:94
int response_code
Definition: ari.h:99
Abstract JSON element (object, array, string, int, ...).
describes a server instance
Definition: tcptls.h:150
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Handler for a single RESTful path segment.
Definition: ari.h:69
const char * path_segment
Definition: ari.h:71
const char * args