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