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