Debian Codegraph @

res/res_ari_recordings.c

raw symbols SCIP
1 /*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2012 - 2013, Digium, Inc.
5 *
6 * David M. Lee, II <[email protected]>
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 <[email protected]>
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"
47 #include "ari/resource_recordings.h"
48 #if defined(AST_DEVMODE)
49 #include "ari/ari_model_validators.h"
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 */
63 static void ast_ari_recordings_list_stored_cb(
64 struct ast_tcptls_session_instance *ser,
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 {
68 struct ast_ari_recordings_list_stored_args args = {};
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,
89 ast_ari_validate_stored_recording_fn());
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
103 fin: __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 */
115 static void ast_ari_recordings_get_stored_cb(
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 {
120 struct ast_ari_recordings_get_stored_args args = {};
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) {
148 is_valid = ast_ari_validate_stored_recording(
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
163 fin: __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 */
175 static void ast_ari_recordings_delete_stored_cb(
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 {
180 struct ast_ari_recordings_delete_stored_args args = {};
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
223 fin: __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 */
235 static void ast_ari_recordings_get_stored_file_cb(
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 {
240 struct ast_ari_recordings_get_stored_file_args args = {};
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
284 fin: __attribute__((unused))
285 return;
286 }
287 int ast_ari_recordings_copy_stored_parse_body(
288 struct ast_json *body,
289 struct ast_ari_recordings_copy_stored_args *args)
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 */
309 static void ast_ari_recordings_copy_stored_cb(
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 {
314 struct ast_ari_recordings_copy_stored_args args = {};
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 }
333 if (ast_ari_recordings_copy_stored_parse_body(body, &args)) {
334 ast_ari_response_alloc_failed(response);
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) {
353 is_valid = ast_ari_validate_stored_recording(
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
368 fin: __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 */
380 static void ast_ari_recordings_get_live_cb(
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 {
385 struct ast_ari_recordings_get_live_args args = {};
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) {
413 is_valid = ast_ari_validate_live_recording(
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
428 fin: __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 */
440 static void ast_ari_recordings_cancel_cb(
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 {
445 struct ast_ari_recordings_cancel_args args = {};
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
488 fin: __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 */
500 static void ast_ari_recordings_stop_cb(
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 {
505 struct ast_ari_recordings_stop_args args = {};
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
548 fin: __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 */
560 static void ast_ari_recordings_pause_cb(
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 {
565 struct ast_ari_recordings_pause_args args = {};
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
609 fin: __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 */
621 static void ast_ari_recordings_unpause_cb(
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 {
626 struct ast_ari_recordings_unpause_args args = {};
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
670 fin: __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 */
682 static void ast_ari_recordings_mute_cb(
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 {
687 struct ast_ari_recordings_mute_args args = {};
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
731 fin: __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 */
743 static void ast_ari_recordings_unmute_cb(
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 {
748 struct ast_ari_recordings_unmute_args args = {};
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
792 fin: __attribute__((unused))
793 return;
794 }
795
796 /*! \brief REST handler for /api-docs/recordings.json */
797 static struct stasis_rest_handlers recordings_stored_recordingName_file = {
798 .path_segment = "file",
799 .callbacks = {
800 [AST_HTTP_GET] = ast_ari_recordings_get_stored_file_cb,
801 },
802 .num_children = 0,
803 .children = { }
804 };
805 /*! \brief REST handler for /api-docs/recordings.json */
806 static struct stasis_rest_handlers recordings_stored_recordingName_copy = {
807 .path_segment = "copy",
808 .callbacks = {
809 [AST_HTTP_POST] = ast_ari_recordings_copy_stored_cb,
810 },
811 .num_children = 0,
812 .children = { }
813 };
814 /*! \brief REST handler for /api-docs/recordings.json */
815 static struct stasis_rest_handlers recordings_stored_recordingName = {
816 .path_segment = "recordingName",
817 .is_wildcard = 1,
818 .callbacks = {
819 [AST_HTTP_GET] = ast_ari_recordings_get_stored_cb,
820 [AST_HTTP_DELETE] = ast_ari_recordings_delete_stored_cb,
821 },
822 .num_children = 2,
823 .children = { &recordings_stored_recordingName_file,&recordings_stored_recordingName_copy, }
824 };
825 /*! \brief REST handler for /api-docs/recordings.json */
826 static struct stasis_rest_handlers recordings_stored = {
827 .path_segment = "stored",
828 .callbacks = {
829 [AST_HTTP_GET] = ast_ari_recordings_list_stored_cb,
830 },
831 .num_children = 1,
832 .children = { &recordings_stored_recordingName, }
833 };
834 /*! \brief REST handler for /api-docs/recordings.json */
835 static struct stasis_rest_handlers recordings_live_recordingName_stop = {
836 .path_segment = "stop",
837 .callbacks = {
838 [AST_HTTP_POST] = ast_ari_recordings_stop_cb,
839 },
840 .num_children = 0,
841 .children = { }
842 };
843 /*! \brief REST handler for /api-docs/recordings.json */
844 static struct stasis_rest_handlers recordings_live_recordingName_pause = {
845 .path_segment = "pause",
846 .callbacks = {
847 [AST_HTTP_POST] = ast_ari_recordings_pause_cb,
848 [AST_HTTP_DELETE] = ast_ari_recordings_unpause_cb,
849 },
850 .num_children = 0,
851 .children = { }
852 };
853 /*! \brief REST handler for /api-docs/recordings.json */
854 static struct stasis_rest_handlers recordings_live_recordingName_mute = {
855 .path_segment = "mute",
856 .callbacks = {
857 [AST_HTTP_POST] = ast_ari_recordings_mute_cb,
858 [AST_HTTP_DELETE] = ast_ari_recordings_unmute_cb,
859 },
860 .num_children = 0,
861 .children = { }
862 };
863 /*! \brief REST handler for /api-docs/recordings.json */
864 static struct stasis_rest_handlers recordings_live_recordingName = {
865 .path_segment = "recordingName",
866 .is_wildcard = 1,
867 .callbacks = {
868 [AST_HTTP_GET] = ast_ari_recordings_get_live_cb,
869 [AST_HTTP_DELETE] = ast_ari_recordings_cancel_cb,
870 },
871 .num_children = 3,
872 .children = { &recordings_live_recordingName_stop,&recordings_live_recordingName_pause,&recordings_live_recordingName_mute, }
873 };
874 /*! \brief REST handler for /api-docs/recordings.json */
875 static struct stasis_rest_handlers recordings_live = {
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 */
883 static struct stasis_rest_handlers recordings = {
884 .path_segment = "recordings",
885 .callbacks = {
886 },
887 .num_children = 2,
888 .children = { &recordings_stored,&recordings_live, }
889 };
890
891 static int unload_module(void)
892 {
893 ast_ari_remove_handler(&recordings);
894 return 0;
895 }
896
897 static int load_module(void)
898 {
899 int res = 0;
900
901
902 res |= ast_ari_add_handler(&recordings);
903 if (res) {
904 unload_module();
905 return AST_MODULE_LOAD_DECLINE;
906 }
907
908 return AST_MODULE_LOAD_SUCCESS;
909 }
910
911 AST_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",
916 );