Asterisk - The Open Source Telephony Project  GIT-master-a1fa8df
res_ari_bridges.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2012 - 2013, Digium, Inc.
5  *
6  * David M. Lee, II <dlee@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*
20  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21  * !!!!! DO NOT EDIT !!!!!
22  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23  * This file is generated by a mustache template. Please see the original
24  * template in rest-api-templates/res_ari_resource.c.mustache
25  */
26 
27 /*! \file
28  *
29  * \brief Bridge resources
30  *
31  * \author David M. Lee, II <dlee@digium.com>
32  */
33 
34 /*** MODULEINFO
35  <depend type="module">res_ari</depend>
36  <depend type="module">res_ari_model</depend>
37  <depend type="module">res_stasis</depend>
38  <depend type="module">res_stasis_recording</depend>
39  <depend type="module">res_stasis_playback</depend>
40  <support_level>core</support_level>
41  ***/
42 
43 #include "asterisk.h"
44 
45 #include "asterisk/app.h"
46 #include "asterisk/module.h"
47 #include "asterisk/stasis_app.h"
48 #include "ari/resource_bridges.h"
49 #if defined(AST_DEVMODE)
51 #endif
52 
53 #define MAX_VALS 128
54 
55 /*!
56  * \brief Parameter parsing callback for /bridges.
57  * \param get_params GET parameters in the HTTP request.
58  * \param path_vars Path variables extracted from the request.
59  * \param headers HTTP headers.
60  * \param[out] response Response to the HTTP request.
61  */
63  struct ast_tcptls_session_instance *ser,
64  struct ast_variable *get_params, struct ast_variable *path_vars,
65  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
66 {
67  struct ast_ari_bridges_list_args args = {};
68 #if defined(AST_DEVMODE)
69  int is_valid;
70  int code;
71 #endif /* AST_DEVMODE */
72 
73  ast_ari_bridges_list(headers, &args, response);
74 #if defined(AST_DEVMODE)
75  code = response->response_code;
76 
77  switch (code) {
78  case 0: /* Implementation is still a stub, or the code wasn't set */
79  is_valid = response->message == NULL;
80  break;
81  case 500: /* Internal Server Error */
82  case 501: /* Not Implemented */
83  is_valid = 1;
84  break;
85  default:
86  if (200 <= code && code <= 299) {
87  is_valid = ast_ari_validate_list(response->message,
89  } else {
90  ast_log(LOG_ERROR, "Invalid error response %d for /bridges\n", code);
91  is_valid = 0;
92  }
93  }
94 
95  if (!is_valid) {
96  ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
97  ast_ari_response_error(response, 500,
98  "Internal Server Error", "Response validation failed");
99  }
100 #endif /* AST_DEVMODE */
101 
102 fin: __attribute__((unused))
103  return;
104 }
106  struct ast_json *body,
108 {
109  struct ast_json *field;
110  /* Parse query parameters out of it */
111  field = ast_json_object_get(body, "type");
112  if (field) {
113  args->type = ast_json_string_get(field);
114  }
115  field = ast_json_object_get(body, "bridgeId");
116  if (field) {
117  args->bridge_id = ast_json_string_get(field);
118  }
119  field = ast_json_object_get(body, "name");
120  if (field) {
121  args->name = ast_json_string_get(field);
122  }
123  return 0;
124 }
125 
126 /*!
127  * \brief Parameter parsing callback for /bridges.
128  * \param get_params GET parameters in the HTTP request.
129  * \param path_vars Path variables extracted from the request.
130  * \param headers HTTP headers.
131  * \param[out] response Response to the HTTP request.
132  */
134  struct ast_tcptls_session_instance *ser,
135  struct ast_variable *get_params, struct ast_variable *path_vars,
136  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
137 {
138  struct ast_ari_bridges_create_args args = {};
139  struct ast_variable *i;
140 #if defined(AST_DEVMODE)
141  int is_valid;
142  int code;
143 #endif /* AST_DEVMODE */
144 
145  for (i = get_params; i; i = i->next) {
146  if (strcmp(i->name, "type") == 0) {
147  args.type = (i->value);
148  } else
149  if (strcmp(i->name, "bridgeId") == 0) {
150  args.bridge_id = (i->value);
151  } else
152  if (strcmp(i->name, "name") == 0) {
153  args.name = (i->value);
154  } else
155  {}
156  }
157  if (ast_ari_bridges_create_parse_body(body, &args)) {
159  goto fin;
160  }
161  ast_ari_bridges_create(headers, &args, response);
162 #if defined(AST_DEVMODE)
163  code = response->response_code;
164 
165  switch (code) {
166  case 0: /* Implementation is still a stub, or the code wasn't set */
167  is_valid = response->message == NULL;
168  break;
169  case 500: /* Internal Server Error */
170  case 501: /* Not Implemented */
171  is_valid = 1;
172  break;
173  default:
174  if (200 <= code && code <= 299) {
175  is_valid = ast_ari_validate_bridge(
176  response->message);
177  } else {
178  ast_log(LOG_ERROR, "Invalid error response %d for /bridges\n", code);
179  is_valid = 0;
180  }
181  }
182 
183  if (!is_valid) {
184  ast_log(LOG_ERROR, "Response validation failed for /bridges\n");
185  ast_ari_response_error(response, 500,
186  "Internal Server Error", "Response validation failed");
187  }
188 #endif /* AST_DEVMODE */
189 
190 fin: __attribute__((unused))
191  return;
192 }
194  struct ast_json *body,
196 {
197  struct ast_json *field;
198  /* Parse query parameters out of it */
199  field = ast_json_object_get(body, "type");
200  if (field) {
201  args->type = ast_json_string_get(field);
202  }
203  field = ast_json_object_get(body, "name");
204  if (field) {
205  args->name = ast_json_string_get(field);
206  }
207  return 0;
208 }
209 
210 /*!
211  * \brief Parameter parsing callback for /bridges/{bridgeId}.
212  * \param get_params GET parameters in the HTTP request.
213  * \param path_vars Path variables extracted from the request.
214  * \param headers HTTP headers.
215  * \param[out] response Response to the HTTP request.
216  */
218  struct ast_tcptls_session_instance *ser,
219  struct ast_variable *get_params, struct ast_variable *path_vars,
220  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
221 {
222  struct ast_ari_bridges_create_with_id_args args = {};
223  struct ast_variable *i;
224 #if defined(AST_DEVMODE)
225  int is_valid;
226  int code;
227 #endif /* AST_DEVMODE */
228 
229  for (i = get_params; i; i = i->next) {
230  if (strcmp(i->name, "type") == 0) {
231  args.type = (i->value);
232  } else
233  if (strcmp(i->name, "name") == 0) {
234  args.name = (i->value);
235  } else
236  {}
237  }
238  for (i = path_vars; i; i = i->next) {
239  if (strcmp(i->name, "bridgeId") == 0) {
240  args.bridge_id = (i->value);
241  } else
242  {}
243  }
246  goto fin;
247  }
248  ast_ari_bridges_create_with_id(headers, &args, response);
249 #if defined(AST_DEVMODE)
250  code = response->response_code;
251 
252  switch (code) {
253  case 0: /* Implementation is still a stub, or the code wasn't set */
254  is_valid = response->message == NULL;
255  break;
256  case 500: /* Internal Server Error */
257  case 501: /* Not Implemented */
258  is_valid = 1;
259  break;
260  default:
261  if (200 <= code && code <= 299) {
262  is_valid = ast_ari_validate_bridge(
263  response->message);
264  } else {
265  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
266  is_valid = 0;
267  }
268  }
269 
270  if (!is_valid) {
271  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
272  ast_ari_response_error(response, 500,
273  "Internal Server Error", "Response validation failed");
274  }
275 #endif /* AST_DEVMODE */
276 
277 fin: __attribute__((unused))
278  return;
279 }
280 /*!
281  * \brief Parameter parsing callback for /bridges/{bridgeId}.
282  * \param get_params GET parameters in the HTTP request.
283  * \param path_vars Path variables extracted from the request.
284  * \param headers HTTP headers.
285  * \param[out] response Response to the HTTP request.
286  */
288  struct ast_tcptls_session_instance *ser,
289  struct ast_variable *get_params, struct ast_variable *path_vars,
290  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
291 {
292  struct ast_ari_bridges_get_args args = {};
293  struct ast_variable *i;
294 #if defined(AST_DEVMODE)
295  int is_valid;
296  int code;
297 #endif /* AST_DEVMODE */
298 
299  for (i = path_vars; i; i = i->next) {
300  if (strcmp(i->name, "bridgeId") == 0) {
301  args.bridge_id = (i->value);
302  } else
303  {}
304  }
305  ast_ari_bridges_get(headers, &args, response);
306 #if defined(AST_DEVMODE)
307  code = response->response_code;
308 
309  switch (code) {
310  case 0: /* Implementation is still a stub, or the code wasn't set */
311  is_valid = response->message == NULL;
312  break;
313  case 500: /* Internal Server Error */
314  case 501: /* Not Implemented */
315  case 404: /* Bridge not found */
316  is_valid = 1;
317  break;
318  default:
319  if (200 <= code && code <= 299) {
320  is_valid = ast_ari_validate_bridge(
321  response->message);
322  } else {
323  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
324  is_valid = 0;
325  }
326  }
327 
328  if (!is_valid) {
329  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
330  ast_ari_response_error(response, 500,
331  "Internal Server Error", "Response validation failed");
332  }
333 #endif /* AST_DEVMODE */
334 
335 fin: __attribute__((unused))
336  return;
337 }
338 /*!
339  * \brief Parameter parsing callback for /bridges/{bridgeId}.
340  * \param get_params GET parameters in the HTTP request.
341  * \param path_vars Path variables extracted from the request.
342  * \param headers HTTP headers.
343  * \param[out] response Response to the HTTP request.
344  */
346  struct ast_tcptls_session_instance *ser,
347  struct ast_variable *get_params, struct ast_variable *path_vars,
348  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
349 {
350  struct ast_ari_bridges_destroy_args args = {};
351  struct ast_variable *i;
352 #if defined(AST_DEVMODE)
353  int is_valid;
354  int code;
355 #endif /* AST_DEVMODE */
356 
357  for (i = path_vars; i; i = i->next) {
358  if (strcmp(i->name, "bridgeId") == 0) {
359  args.bridge_id = (i->value);
360  } else
361  {}
362  }
363  ast_ari_bridges_destroy(headers, &args, response);
364 #if defined(AST_DEVMODE)
365  code = response->response_code;
366 
367  switch (code) {
368  case 0: /* Implementation is still a stub, or the code wasn't set */
369  is_valid = response->message == NULL;
370  break;
371  case 500: /* Internal Server Error */
372  case 501: /* Not Implemented */
373  case 404: /* Bridge not found */
374  is_valid = 1;
375  break;
376  default:
377  if (200 <= code && code <= 299) {
378  is_valid = ast_ari_validate_void(
379  response->message);
380  } else {
381  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}\n", code);
382  is_valid = 0;
383  }
384  }
385 
386  if (!is_valid) {
387  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}\n");
388  ast_ari_response_error(response, 500,
389  "Internal Server Error", "Response validation failed");
390  }
391 #endif /* AST_DEVMODE */
392 
393 fin: __attribute__((unused))
394  return;
395 }
397  struct ast_json *body,
399 {
400  struct ast_json *field;
401  /* Parse query parameters out of it */
402  field = ast_json_object_get(body, "channel");
403  if (field) {
404  /* If they were silly enough to both pass in a query param and a
405  * JSON body, free up the query value.
406  */
407  ast_free(args->channel);
408  if (ast_json_typeof(field) == AST_JSON_ARRAY) {
409  /* Multiple param passed as array */
410  size_t i;
411  args->channel_count = ast_json_array_size(field);
412  args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
413 
414  if (!args->channel) {
415  return -1;
416  }
417 
418  for (i = 0; i < args->channel_count; ++i) {
419  args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
420  }
421  } else {
422  /* Multiple param passed as single value */
423  args->channel_count = 1;
424  args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
425  if (!args->channel) {
426  return -1;
427  }
428  args->channel[0] = ast_json_string_get(field);
429  }
430  }
431  field = ast_json_object_get(body, "role");
432  if (field) {
433  args->role = ast_json_string_get(field);
434  }
435  field = ast_json_object_get(body, "absorbDTMF");
436  if (field) {
437  args->absorb_dtmf = ast_json_is_true(field);
438  }
439  field = ast_json_object_get(body, "mute");
440  if (field) {
441  args->mute = ast_json_is_true(field);
442  }
443  field = ast_json_object_get(body, "inhibitConnectedLineUpdates");
444  if (field) {
446  }
447  return 0;
448 }
449 
450 /*!
451  * \brief Parameter parsing callback for /bridges/{bridgeId}/addChannel.
452  * \param get_params GET parameters in the HTTP request.
453  * \param path_vars Path variables extracted from the request.
454  * \param headers HTTP headers.
455  * \param[out] response Response to the HTTP request.
456  */
458  struct ast_tcptls_session_instance *ser,
459  struct ast_variable *get_params, struct ast_variable *path_vars,
460  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
461 {
462  struct ast_ari_bridges_add_channel_args args = {};
463  struct ast_variable *i;
464 #if defined(AST_DEVMODE)
465  int is_valid;
466  int code;
467 #endif /* AST_DEVMODE */
468 
469  for (i = get_params; i; i = i->next) {
470  if (strcmp(i->name, "channel") == 0) {
471  /* Parse comma separated list */
472  char *vals[MAX_VALS];
473  size_t j;
474 
475  args.channel_parse = ast_strdup(i->value);
476  if (!args.channel_parse) {
478  goto fin;
479  }
480 
481  if (strlen(args.channel_parse) == 0) {
482  /* ast_app_separate_args can't handle "" */
483  args.channel_count = 1;
484  vals[0] = args.channel_parse;
485  } else {
487  args.channel_parse, ',', vals,
488  ARRAY_LEN(vals));
489  }
490 
491  if (args.channel_count == 0) {
493  goto fin;
494  }
495 
496  if (args.channel_count >= MAX_VALS) {
497  ast_ari_response_error(response, 400,
498  "Bad Request",
499  "Too many values for channel");
500  goto fin;
501  }
502 
503  args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
504  if (!args.channel) {
506  goto fin;
507  }
508 
509  for (j = 0; j < args.channel_count; ++j) {
510  args.channel[j] = (vals[j]);
511  }
512  } else
513  if (strcmp(i->name, "role") == 0) {
514  args.role = (i->value);
515  } else
516  if (strcmp(i->name, "absorbDTMF") == 0) {
517  args.absorb_dtmf = ast_true(i->value);
518  } else
519  if (strcmp(i->name, "mute") == 0) {
520  args.mute = ast_true(i->value);
521  } else
522  if (strcmp(i->name, "inhibitConnectedLineUpdates") == 0) {
524  } else
525  {}
526  }
527  for (i = path_vars; i; i = i->next) {
528  if (strcmp(i->name, "bridgeId") == 0) {
529  args.bridge_id = (i->value);
530  } else
531  {}
532  }
533  if (ast_ari_bridges_add_channel_parse_body(body, &args)) {
535  goto fin;
536  }
537  ast_ari_bridges_add_channel(headers, &args, response);
538 #if defined(AST_DEVMODE)
539  code = response->response_code;
540 
541  switch (code) {
542  case 0: /* Implementation is still a stub, or the code wasn't set */
543  is_valid = response->message == NULL;
544  break;
545  case 500: /* Internal Server Error */
546  case 501: /* Not Implemented */
547  case 400: /* Channel not found */
548  case 404: /* Bridge not found */
549  case 409: /* Bridge not in Stasis application; Channel currently recording */
550  case 422: /* Channel not in Stasis application */
551  is_valid = 1;
552  break;
553  default:
554  if (200 <= code && code <= 299) {
555  is_valid = ast_ari_validate_void(
556  response->message);
557  } else {
558  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/addChannel\n", code);
559  is_valid = 0;
560  }
561  }
562 
563  if (!is_valid) {
564  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/addChannel\n");
565  ast_ari_response_error(response, 500,
566  "Internal Server Error", "Response validation failed");
567  }
568 #endif /* AST_DEVMODE */
569 
570 fin: __attribute__((unused))
571  ast_free(args.channel_parse);
572  ast_free(args.channel);
573  return;
574 }
576  struct ast_json *body,
578 {
579  struct ast_json *field;
580  /* Parse query parameters out of it */
581  field = ast_json_object_get(body, "channel");
582  if (field) {
583  /* If they were silly enough to both pass in a query param and a
584  * JSON body, free up the query value.
585  */
586  ast_free(args->channel);
587  if (ast_json_typeof(field) == AST_JSON_ARRAY) {
588  /* Multiple param passed as array */
589  size_t i;
590  args->channel_count = ast_json_array_size(field);
591  args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
592 
593  if (!args->channel) {
594  return -1;
595  }
596 
597  for (i = 0; i < args->channel_count; ++i) {
598  args->channel[i] = ast_json_string_get(ast_json_array_get(field, i));
599  }
600  } else {
601  /* Multiple param passed as single value */
602  args->channel_count = 1;
603  args->channel = ast_malloc(sizeof(*args->channel) * args->channel_count);
604  if (!args->channel) {
605  return -1;
606  }
607  args->channel[0] = ast_json_string_get(field);
608  }
609  }
610  return 0;
611 }
612 
613 /*!
614  * \brief Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
615  * \param get_params GET parameters in the HTTP request.
616  * \param path_vars Path variables extracted from the request.
617  * \param headers HTTP headers.
618  * \param[out] response Response to the HTTP request.
619  */
621  struct ast_tcptls_session_instance *ser,
622  struct ast_variable *get_params, struct ast_variable *path_vars,
623  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
624 {
625  struct ast_ari_bridges_remove_channel_args args = {};
626  struct ast_variable *i;
627 #if defined(AST_DEVMODE)
628  int is_valid;
629  int code;
630 #endif /* AST_DEVMODE */
631 
632  for (i = get_params; i; i = i->next) {
633  if (strcmp(i->name, "channel") == 0) {
634  /* Parse comma separated list */
635  char *vals[MAX_VALS];
636  size_t j;
637 
638  args.channel_parse = ast_strdup(i->value);
639  if (!args.channel_parse) {
641  goto fin;
642  }
643 
644  if (strlen(args.channel_parse) == 0) {
645  /* ast_app_separate_args can't handle "" */
646  args.channel_count = 1;
647  vals[0] = args.channel_parse;
648  } else {
650  args.channel_parse, ',', vals,
651  ARRAY_LEN(vals));
652  }
653 
654  if (args.channel_count == 0) {
656  goto fin;
657  }
658 
659  if (args.channel_count >= MAX_VALS) {
660  ast_ari_response_error(response, 400,
661  "Bad Request",
662  "Too many values for channel");
663  goto fin;
664  }
665 
666  args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
667  if (!args.channel) {
669  goto fin;
670  }
671 
672  for (j = 0; j < args.channel_count; ++j) {
673  args.channel[j] = (vals[j]);
674  }
675  } else
676  {}
677  }
678  for (i = path_vars; i; i = i->next) {
679  if (strcmp(i->name, "bridgeId") == 0) {
680  args.bridge_id = (i->value);
681  } else
682  {}
683  }
686  goto fin;
687  }
688  ast_ari_bridges_remove_channel(headers, &args, response);
689 #if defined(AST_DEVMODE)
690  code = response->response_code;
691 
692  switch (code) {
693  case 0: /* Implementation is still a stub, or the code wasn't set */
694  is_valid = response->message == NULL;
695  break;
696  case 500: /* Internal Server Error */
697  case 501: /* Not Implemented */
698  case 400: /* Channel not found */
699  case 404: /* Bridge not found */
700  case 409: /* Bridge not in Stasis application */
701  case 422: /* Channel not in this bridge */
702  is_valid = 1;
703  break;
704  default:
705  if (200 <= code && code <= 299) {
706  is_valid = ast_ari_validate_void(
707  response->message);
708  } else {
709  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/removeChannel\n", code);
710  is_valid = 0;
711  }
712  }
713 
714  if (!is_valid) {
715  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/removeChannel\n");
716  ast_ari_response_error(response, 500,
717  "Internal Server Error", "Response validation failed");
718  }
719 #endif /* AST_DEVMODE */
720 
721 fin: __attribute__((unused))
722  ast_free(args.channel_parse);
723  ast_free(args.channel);
724  return;
725 }
726 /*!
727  * \brief Parameter parsing callback for /bridges/{bridgeId}/videoSource/{channelId}.
728  * \param get_params GET parameters in the HTTP request.
729  * \param path_vars Path variables extracted from the request.
730  * \param headers HTTP headers.
731  * \param[out] response Response to the HTTP request.
732  */
734  struct ast_tcptls_session_instance *ser,
735  struct ast_variable *get_params, struct ast_variable *path_vars,
736  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
737 {
738  struct ast_ari_bridges_set_video_source_args args = {};
739  struct ast_variable *i;
740 #if defined(AST_DEVMODE)
741  int is_valid;
742  int code;
743 #endif /* AST_DEVMODE */
744 
745  for (i = path_vars; i; i = i->next) {
746  if (strcmp(i->name, "bridgeId") == 0) {
747  args.bridge_id = (i->value);
748  } else
749  if (strcmp(i->name, "channelId") == 0) {
750  args.channel_id = (i->value);
751  } else
752  {}
753  }
754  ast_ari_bridges_set_video_source(headers, &args, response);
755 #if defined(AST_DEVMODE)
756  code = response->response_code;
757 
758  switch (code) {
759  case 0: /* Implementation is still a stub, or the code wasn't set */
760  is_valid = response->message == NULL;
761  break;
762  case 500: /* Internal Server Error */
763  case 501: /* Not Implemented */
764  case 404: /* Bridge or Channel not found */
765  case 409: /* Channel not in Stasis application */
766  case 422: /* Channel not in this Bridge */
767  is_valid = 1;
768  break;
769  default:
770  if (200 <= code && code <= 299) {
771  is_valid = ast_ari_validate_void(
772  response->message);
773  } else {
774  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/videoSource/{channelId}\n", code);
775  is_valid = 0;
776  }
777  }
778 
779  if (!is_valid) {
780  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/videoSource/{channelId}\n");
781  ast_ari_response_error(response, 500,
782  "Internal Server Error", "Response validation failed");
783  }
784 #endif /* AST_DEVMODE */
785 
786 fin: __attribute__((unused))
787  return;
788 }
789 /*!
790  * \brief Parameter parsing callback for /bridges/{bridgeId}/videoSource.
791  * \param get_params GET parameters in the HTTP request.
792  * \param path_vars Path variables extracted from the request.
793  * \param headers HTTP headers.
794  * \param[out] response Response to the HTTP request.
795  */
797  struct ast_tcptls_session_instance *ser,
798  struct ast_variable *get_params, struct ast_variable *path_vars,
799  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
800 {
802  struct ast_variable *i;
803 #if defined(AST_DEVMODE)
804  int is_valid;
805  int code;
806 #endif /* AST_DEVMODE */
807 
808  for (i = path_vars; i; i = i->next) {
809  if (strcmp(i->name, "bridgeId") == 0) {
810  args.bridge_id = (i->value);
811  } else
812  {}
813  }
814  ast_ari_bridges_clear_video_source(headers, &args, response);
815 #if defined(AST_DEVMODE)
816  code = response->response_code;
817 
818  switch (code) {
819  case 0: /* Implementation is still a stub, or the code wasn't set */
820  is_valid = response->message == NULL;
821  break;
822  case 500: /* Internal Server Error */
823  case 501: /* Not Implemented */
824  case 404: /* Bridge not found */
825  is_valid = 1;
826  break;
827  default:
828  if (200 <= code && code <= 299) {
829  is_valid = ast_ari_validate_void(
830  response->message);
831  } else {
832  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/videoSource\n", code);
833  is_valid = 0;
834  }
835  }
836 
837  if (!is_valid) {
838  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/videoSource\n");
839  ast_ari_response_error(response, 500,
840  "Internal Server Error", "Response validation failed");
841  }
842 #endif /* AST_DEVMODE */
843 
844 fin: __attribute__((unused))
845  return;
846 }
848  struct ast_json *body,
850 {
851  struct ast_json *field;
852  /* Parse query parameters out of it */
853  field = ast_json_object_get(body, "mohClass");
854  if (field) {
855  args->moh_class = ast_json_string_get(field);
856  }
857  return 0;
858 }
859 
860 /*!
861  * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
862  * \param get_params GET parameters in the HTTP request.
863  * \param path_vars Path variables extracted from the request.
864  * \param headers HTTP headers.
865  * \param[out] response Response to the HTTP request.
866  */
868  struct ast_tcptls_session_instance *ser,
869  struct ast_variable *get_params, struct ast_variable *path_vars,
870  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
871 {
872  struct ast_ari_bridges_start_moh_args args = {};
873  struct ast_variable *i;
874 #if defined(AST_DEVMODE)
875  int is_valid;
876  int code;
877 #endif /* AST_DEVMODE */
878 
879  for (i = get_params; i; i = i->next) {
880  if (strcmp(i->name, "mohClass") == 0) {
881  args.moh_class = (i->value);
882  } else
883  {}
884  }
885  for (i = path_vars; i; i = i->next) {
886  if (strcmp(i->name, "bridgeId") == 0) {
887  args.bridge_id = (i->value);
888  } else
889  {}
890  }
891  if (ast_ari_bridges_start_moh_parse_body(body, &args)) {
893  goto fin;
894  }
895  ast_ari_bridges_start_moh(headers, &args, response);
896 #if defined(AST_DEVMODE)
897  code = response->response_code;
898 
899  switch (code) {
900  case 0: /* Implementation is still a stub, or the code wasn't set */
901  is_valid = response->message == NULL;
902  break;
903  case 500: /* Internal Server Error */
904  case 501: /* Not Implemented */
905  case 404: /* Bridge not found */
906  case 409: /* Bridge not in Stasis application */
907  is_valid = 1;
908  break;
909  default:
910  if (200 <= code && code <= 299) {
911  is_valid = ast_ari_validate_void(
912  response->message);
913  } else {
914  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
915  is_valid = 0;
916  }
917  }
918 
919  if (!is_valid) {
920  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
921  ast_ari_response_error(response, 500,
922  "Internal Server Error", "Response validation failed");
923  }
924 #endif /* AST_DEVMODE */
925 
926 fin: __attribute__((unused))
927  return;
928 }
929 /*!
930  * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
931  * \param get_params GET parameters in the HTTP request.
932  * \param path_vars Path variables extracted from the request.
933  * \param headers HTTP headers.
934  * \param[out] response Response to the HTTP request.
935  */
937  struct ast_tcptls_session_instance *ser,
938  struct ast_variable *get_params, struct ast_variable *path_vars,
939  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
940 {
941  struct ast_ari_bridges_stop_moh_args args = {};
942  struct ast_variable *i;
943 #if defined(AST_DEVMODE)
944  int is_valid;
945  int code;
946 #endif /* AST_DEVMODE */
947 
948  for (i = path_vars; i; i = i->next) {
949  if (strcmp(i->name, "bridgeId") == 0) {
950  args.bridge_id = (i->value);
951  } else
952  {}
953  }
954  ast_ari_bridges_stop_moh(headers, &args, response);
955 #if defined(AST_DEVMODE)
956  code = response->response_code;
957 
958  switch (code) {
959  case 0: /* Implementation is still a stub, or the code wasn't set */
960  is_valid = response->message == NULL;
961  break;
962  case 500: /* Internal Server Error */
963  case 501: /* Not Implemented */
964  case 404: /* Bridge not found */
965  case 409: /* Bridge not in Stasis application */
966  is_valid = 1;
967  break;
968  default:
969  if (200 <= code && code <= 299) {
970  is_valid = ast_ari_validate_void(
971  response->message);
972  } else {
973  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
974  is_valid = 0;
975  }
976  }
977 
978  if (!is_valid) {
979  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
980  ast_ari_response_error(response, 500,
981  "Internal Server Error", "Response validation failed");
982  }
983 #endif /* AST_DEVMODE */
984 
985 fin: __attribute__((unused))
986  return;
987 }
989  struct ast_json *body,
991 {
992  struct ast_json *field;
993  /* Parse query parameters out of it */
994  field = ast_json_object_get(body, "media");
995  if (field) {
996  /* If they were silly enough to both pass in a query param and a
997  * JSON body, free up the query value.
998  */
999  ast_free(args->media);
1000  if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1001  /* Multiple param passed as array */
1002  size_t i;
1003  args->media_count = ast_json_array_size(field);
1004  args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1005 
1006  if (!args->media) {
1007  return -1;
1008  }
1009 
1010  for (i = 0; i < args->media_count; ++i) {
1011  args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1012  }
1013  } else {
1014  /* Multiple param passed as single value */
1015  args->media_count = 1;
1016  args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1017  if (!args->media) {
1018  return -1;
1019  }
1020  args->media[0] = ast_json_string_get(field);
1021  }
1022  }
1023  field = ast_json_object_get(body, "lang");
1024  if (field) {
1025  args->lang = ast_json_string_get(field);
1026  }
1027  field = ast_json_object_get(body, "offsetms");
1028  if (field) {
1029  args->offsetms = ast_json_integer_get(field);
1030  }
1031  field = ast_json_object_get(body, "skipms");
1032  if (field) {
1033  args->skipms = ast_json_integer_get(field);
1034  }
1035  field = ast_json_object_get(body, "playbackId");
1036  if (field) {
1037  args->playback_id = ast_json_string_get(field);
1038  }
1039  return 0;
1040 }
1041 
1042 /*!
1043  * \brief Parameter parsing callback for /bridges/{bridgeId}/play.
1044  * \param get_params GET parameters in the HTTP request.
1045  * \param path_vars Path variables extracted from the request.
1046  * \param headers HTTP headers.
1047  * \param[out] response Response to the HTTP request.
1048  */
1050  struct ast_tcptls_session_instance *ser,
1051  struct ast_variable *get_params, struct ast_variable *path_vars,
1052  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1053 {
1054  struct ast_ari_bridges_play_args args = {};
1055  struct ast_variable *i;
1056 #if defined(AST_DEVMODE)
1057  int is_valid;
1058  int code;
1059 #endif /* AST_DEVMODE */
1060 
1061  for (i = get_params; i; i = i->next) {
1062  if (strcmp(i->name, "media") == 0) {
1063  /* Parse comma separated list */
1064  char *vals[MAX_VALS];
1065  size_t j;
1066 
1067  args.media_parse = ast_strdup(i->value);
1068  if (!args.media_parse) {
1070  goto fin;
1071  }
1072 
1073  if (strlen(args.media_parse) == 0) {
1074  /* ast_app_separate_args can't handle "" */
1075  args.media_count = 1;
1076  vals[0] = args.media_parse;
1077  } else {
1079  args.media_parse, ',', vals,
1080  ARRAY_LEN(vals));
1081  }
1082 
1083  if (args.media_count == 0) {
1085  goto fin;
1086  }
1087 
1088  if (args.media_count >= MAX_VALS) {
1089  ast_ari_response_error(response, 400,
1090  "Bad Request",
1091  "Too many values for media");
1092  goto fin;
1093  }
1094 
1095  args.media = ast_malloc(sizeof(*args.media) * args.media_count);
1096  if (!args.media) {
1098  goto fin;
1099  }
1100 
1101  for (j = 0; j < args.media_count; ++j) {
1102  args.media[j] = (vals[j]);
1103  }
1104  } else
1105  if (strcmp(i->name, "lang") == 0) {
1106  args.lang = (i->value);
1107  } else
1108  if (strcmp(i->name, "offsetms") == 0) {
1109  args.offsetms = atoi(i->value);
1110  } else
1111  if (strcmp(i->name, "skipms") == 0) {
1112  args.skipms = atoi(i->value);
1113  } else
1114  if (strcmp(i->name, "playbackId") == 0) {
1115  args.playback_id = (i->value);
1116  } else
1117  {}
1118  }
1119  for (i = path_vars; i; i = i->next) {
1120  if (strcmp(i->name, "bridgeId") == 0) {
1121  args.bridge_id = (i->value);
1122  } else
1123  {}
1124  }
1125  if (ast_ari_bridges_play_parse_body(body, &args)) {
1127  goto fin;
1128  }
1129  ast_ari_bridges_play(headers, &args, response);
1130 #if defined(AST_DEVMODE)
1131  code = response->response_code;
1132 
1133  switch (code) {
1134  case 0: /* Implementation is still a stub, or the code wasn't set */
1135  is_valid = response->message == NULL;
1136  break;
1137  case 500: /* Internal Server Error */
1138  case 501: /* Not Implemented */
1139  case 404: /* Bridge not found */
1140  case 409: /* Bridge not in a Stasis application */
1141  is_valid = 1;
1142  break;
1143  default:
1144  if (200 <= code && code <= 299) {
1145  is_valid = ast_ari_validate_playback(
1146  response->message);
1147  } else {
1148  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/play\n", code);
1149  is_valid = 0;
1150  }
1151  }
1152 
1153  if (!is_valid) {
1154  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/play\n");
1155  ast_ari_response_error(response, 500,
1156  "Internal Server Error", "Response validation failed");
1157  }
1158 #endif /* AST_DEVMODE */
1159 
1160 fin: __attribute__((unused))
1161  ast_free(args.media_parse);
1162  ast_free(args.media);
1163  return;
1164 }
1166  struct ast_json *body,
1168 {
1169  struct ast_json *field;
1170  /* Parse query parameters out of it */
1171  field = ast_json_object_get(body, "media");
1172  if (field) {
1173  /* If they were silly enough to both pass in a query param and a
1174  * JSON body, free up the query value.
1175  */
1176  ast_free(args->media);
1177  if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1178  /* Multiple param passed as array */
1179  size_t i;
1180  args->media_count = ast_json_array_size(field);
1181  args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1182 
1183  if (!args->media) {
1184  return -1;
1185  }
1186 
1187  for (i = 0; i < args->media_count; ++i) {
1188  args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1189  }
1190  } else {
1191  /* Multiple param passed as single value */
1192  args->media_count = 1;
1193  args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1194  if (!args->media) {
1195  return -1;
1196  }
1197  args->media[0] = ast_json_string_get(field);
1198  }
1199  }
1200  field = ast_json_object_get(body, "lang");
1201  if (field) {
1202  args->lang = ast_json_string_get(field);
1203  }
1204  field = ast_json_object_get(body, "offsetms");
1205  if (field) {
1206  args->offsetms = ast_json_integer_get(field);
1207  }
1208  field = ast_json_object_get(body, "skipms");
1209  if (field) {
1210  args->skipms = ast_json_integer_get(field);
1211  }
1212  return 0;
1213 }
1214 
1215 /*!
1216  * \brief Parameter parsing callback for /bridges/{bridgeId}/play/{playbackId}.
1217  * \param get_params GET parameters in the HTTP request.
1218  * \param path_vars Path variables extracted from the request.
1219  * \param headers HTTP headers.
1220  * \param[out] response Response to the HTTP request.
1221  */
1223  struct ast_tcptls_session_instance *ser,
1224  struct ast_variable *get_params, struct ast_variable *path_vars,
1225  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1226 {
1227  struct ast_ari_bridges_play_with_id_args args = {};
1228  struct ast_variable *i;
1229 #if defined(AST_DEVMODE)
1230  int is_valid;
1231  int code;
1232 #endif /* AST_DEVMODE */
1233 
1234  for (i = get_params; i; i = i->next) {
1235  if (strcmp(i->name, "media") == 0) {
1236  /* Parse comma separated list */
1237  char *vals[MAX_VALS];
1238  size_t j;
1239 
1240  args.media_parse = ast_strdup(i->value);
1241  if (!args.media_parse) {
1243  goto fin;
1244  }
1245 
1246  if (strlen(args.media_parse) == 0) {
1247  /* ast_app_separate_args can't handle "" */
1248  args.media_count = 1;
1249  vals[0] = args.media_parse;
1250  } else {
1252  args.media_parse, ',', vals,
1253  ARRAY_LEN(vals));
1254  }
1255 
1256  if (args.media_count == 0) {
1258  goto fin;
1259  }
1260 
1261  if (args.media_count >= MAX_VALS) {
1262  ast_ari_response_error(response, 400,
1263  "Bad Request",
1264  "Too many values for media");
1265  goto fin;
1266  }
1267 
1268  args.media = ast_malloc(sizeof(*args.media) * args.media_count);
1269  if (!args.media) {
1271  goto fin;
1272  }
1273 
1274  for (j = 0; j < args.media_count; ++j) {
1275  args.media[j] = (vals[j]);
1276  }
1277  } else
1278  if (strcmp(i->name, "lang") == 0) {
1279  args.lang = (i->value);
1280  } else
1281  if (strcmp(i->name, "offsetms") == 0) {
1282  args.offsetms = atoi(i->value);
1283  } else
1284  if (strcmp(i->name, "skipms") == 0) {
1285  args.skipms = atoi(i->value);
1286  } else
1287  {}
1288  }
1289  for (i = path_vars; i; i = i->next) {
1290  if (strcmp(i->name, "bridgeId") == 0) {
1291  args.bridge_id = (i->value);
1292  } else
1293  if (strcmp(i->name, "playbackId") == 0) {
1294  args.playback_id = (i->value);
1295  } else
1296  {}
1297  }
1298  if (ast_ari_bridges_play_with_id_parse_body(body, &args)) {
1300  goto fin;
1301  }
1302  ast_ari_bridges_play_with_id(headers, &args, response);
1303 #if defined(AST_DEVMODE)
1304  code = response->response_code;
1305 
1306  switch (code) {
1307  case 0: /* Implementation is still a stub, or the code wasn't set */
1308  is_valid = response->message == NULL;
1309  break;
1310  case 500: /* Internal Server Error */
1311  case 501: /* Not Implemented */
1312  case 404: /* Bridge not found */
1313  case 409: /* Bridge not in a Stasis application */
1314  is_valid = 1;
1315  break;
1316  default:
1317  if (200 <= code && code <= 299) {
1318  is_valid = ast_ari_validate_playback(
1319  response->message);
1320  } else {
1321  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/play/{playbackId}\n", code);
1322  is_valid = 0;
1323  }
1324  }
1325 
1326  if (!is_valid) {
1327  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/play/{playbackId}\n");
1328  ast_ari_response_error(response, 500,
1329  "Internal Server Error", "Response validation failed");
1330  }
1331 #endif /* AST_DEVMODE */
1332 
1333 fin: __attribute__((unused))
1334  ast_free(args.media_parse);
1335  ast_free(args.media);
1336  return;
1337 }
1339  struct ast_json *body,
1341 {
1342  struct ast_json *field;
1343  /* Parse query parameters out of it */
1344  field = ast_json_object_get(body, "name");
1345  if (field) {
1346  args->name = ast_json_string_get(field);
1347  }
1348  field = ast_json_object_get(body, "format");
1349  if (field) {
1350  args->format = ast_json_string_get(field);
1351  }
1352  field = ast_json_object_get(body, "maxDurationSeconds");
1353  if (field) {
1355  }
1356  field = ast_json_object_get(body, "maxSilenceSeconds");
1357  if (field) {
1359  }
1360  field = ast_json_object_get(body, "ifExists");
1361  if (field) {
1362  args->if_exists = ast_json_string_get(field);
1363  }
1364  field = ast_json_object_get(body, "beep");
1365  if (field) {
1366  args->beep = ast_json_is_true(field);
1367  }
1368  field = ast_json_object_get(body, "terminateOn");
1369  if (field) {
1370  args->terminate_on = ast_json_string_get(field);
1371  }
1372  return 0;
1373 }
1374 
1375 /*!
1376  * \brief Parameter parsing callback for /bridges/{bridgeId}/record.
1377  * \param get_params GET parameters in the HTTP request.
1378  * \param path_vars Path variables extracted from the request.
1379  * \param headers HTTP headers.
1380  * \param[out] response Response to the HTTP request.
1381  */
1383  struct ast_tcptls_session_instance *ser,
1384  struct ast_variable *get_params, struct ast_variable *path_vars,
1385  struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1386 {
1387  struct ast_ari_bridges_record_args args = {};
1388  struct ast_variable *i;
1389 #if defined(AST_DEVMODE)
1390  int is_valid;
1391  int code;
1392 #endif /* AST_DEVMODE */
1393 
1394  for (i = get_params; i; i = i->next) {
1395  if (strcmp(i->name, "name") == 0) {
1396  args.name = (i->value);
1397  } else
1398  if (strcmp(i->name, "format") == 0) {
1399  args.format = (i->value);
1400  } else
1401  if (strcmp(i->name, "maxDurationSeconds") == 0) {
1402  args.max_duration_seconds = atoi(i->value);
1403  } else
1404  if (strcmp(i->name, "maxSilenceSeconds") == 0) {
1405  args.max_silence_seconds = atoi(i->value);
1406  } else
1407  if (strcmp(i->name, "ifExists") == 0) {
1408  args.if_exists = (i->value);
1409  } else
1410  if (strcmp(i->name, "beep") == 0) {
1411  args.beep = ast_true(i->value);
1412  } else
1413  if (strcmp(i->name, "terminateOn") == 0) {
1414  args.terminate_on = (i->value);
1415  } else
1416  {}
1417  }
1418  for (i = path_vars; i; i = i->next) {
1419  if (strcmp(i->name, "bridgeId") == 0) {
1420  args.bridge_id = (i->value);
1421  } else
1422  {}
1423  }
1424  if (ast_ari_bridges_record_parse_body(body, &args)) {
1426  goto fin;
1427  }
1428  ast_ari_bridges_record(headers, &args, response);
1429 #if defined(AST_DEVMODE)
1430  code = response->response_code;
1431 
1432  switch (code) {
1433  case 0: /* Implementation is still a stub, or the code wasn't set */
1434  is_valid = response->message == NULL;
1435  break;
1436  case 500: /* Internal Server Error */
1437  case 501: /* Not Implemented */
1438  case 400: /* Invalid parameters */
1439  case 404: /* Bridge not found */
1440  case 409: /* Bridge is not in a Stasis application; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
1441  case 422: /* The format specified is unknown on this system */
1442  is_valid = 1;
1443  break;
1444  default:
1445  if (200 <= code && code <= 299) {
1447  response->message);
1448  } else {
1449  ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/record\n", code);
1450  is_valid = 0;
1451  }
1452  }
1453 
1454  if (!is_valid) {
1455  ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/record\n");
1456  ast_ari_response_error(response, 500,
1457  "Internal Server Error", "Response validation failed");
1458  }
1459 #endif /* AST_DEVMODE */
1460 
1461 fin: __attribute__((unused))
1462  return;
1463 }
1464 
1465 /*! \brief REST handler for /api-docs/bridges.json */
1467  .path_segment = "addChannel",
1468  .callbacks = {
1470  },
1471  .num_children = 0,
1472  .children = { }
1473 };
1474 /*! \brief REST handler for /api-docs/bridges.json */
1476  .path_segment = "removeChannel",
1477  .callbacks = {
1479  },
1480  .num_children = 0,
1481  .children = { }
1482 };
1483 /*! \brief REST handler for /api-docs/bridges.json */
1485  .path_segment = "channelId",
1486  .is_wildcard = 1,
1487  .callbacks = {
1489  },
1490  .num_children = 0,
1491  .children = { }
1492 };
1493 /*! \brief REST handler for /api-docs/bridges.json */
1495  .path_segment = "videoSource",
1496  .callbacks = {
1498  },
1499  .num_children = 1,
1500  .children = { &bridges_bridgeId_videoSource_channelId, }
1501 };
1502 /*! \brief REST handler for /api-docs/bridges.json */
1504  .path_segment = "moh",
1505  .callbacks = {
1508  },
1509  .num_children = 0,
1510  .children = { }
1511 };
1512 /*! \brief REST handler for /api-docs/bridges.json */
1514  .path_segment = "playbackId",
1515  .is_wildcard = 1,
1516  .callbacks = {
1518  },
1519  .num_children = 0,
1520  .children = { }
1521 };
1522 /*! \brief REST handler for /api-docs/bridges.json */
1524  .path_segment = "play",
1525  .callbacks = {
1527  },
1528  .num_children = 1,
1529  .children = { &bridges_bridgeId_play_playbackId, }
1530 };
1531 /*! \brief REST handler for /api-docs/bridges.json */
1533  .path_segment = "record",
1534  .callbacks = {
1536  },
1537  .num_children = 0,
1538  .children = { }
1539 };
1540 /*! \brief REST handler for /api-docs/bridges.json */
1542  .path_segment = "bridgeId",
1543  .is_wildcard = 1,
1544  .callbacks = {
1548  },
1549  .num_children = 6,
1551 };
1552 /*! \brief REST handler for /api-docs/bridges.json */
1554  .path_segment = "bridges",
1555  .callbacks = {
1558  },
1559  .num_children = 1,
1560  .children = { &bridges_bridgeId, }
1561 };
1562 
1563 static int unload_module(void)
1564 {
1565  ast_ari_remove_handler(&bridges);
1566  return 0;
1567 }
1568 
1569 static int load_module(void)
1570 {
1571  int res = 0;
1572 
1573 
1574  res |= ast_ari_add_handler(&bridges);
1575  if (res) {
1576  unload_module();
1577  return AST_MODULE_LOAD_DECLINE;
1578  }
1579 
1580  return AST_MODULE_LOAD_SUCCESS;
1581 }
1582 
1583 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Bridge resources",
1584  .support_level = AST_MODULE_SUPPORT_CORE,
1585  .load = load_module,
1586  .unload = unload_module,
1587  .requires = "res_ari,res_ari_model,res_stasis,res_stasis_recording,res_stasis_playback",
1588 );
static void ast_ari_bridges_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 /bridges/{bridgeId}/moh.
struct ast_variable * next
int ast_ari_bridges_start_moh_parse_body(struct ast_json *body, struct ast_ari_bridges_start_moh_args *args)
Body parsing function for /bridges/{bridgeId}/moh.
void ast_ari_bridges_start_moh(struct ast_variable *headers, struct ast_ari_bridges_start_moh_args *args, struct ast_ari_response *response)
Play music on hold to a bridge or change the MOH class that is playing.
Asterisk main include file. File version handling, generic pbx functions.
static void ast_ari_bridges_remove_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 /bridges/{bridgeId}/removeChannel.
void ast_ari_bridges_play_with_id(struct ast_variable *headers, struct ast_ari_bridges_play_with_id_args *args, struct ast_ari_response *response)
Start playback of media on a bridge.
void ast_ari_bridges_get(struct ast_variable *headers, struct ast_ari_bridges_get_args *args, struct ast_ari_response *response)
Get bridge details.
static struct stasis_rest_handlers bridges_bridgeId_record
REST handler for /api-docs/bridges.json.
static struct stasis_rest_handlers bridges_bridgeId_videoSource
REST handler for /api-docs/bridges.json.
void ast_ari_bridges_add_channel(struct ast_variable *headers, struct ast_ari_bridges_add_channel_args *args, struct ast_ari_response *response)
Add a channel to a bridge.
static void ast_ari_bridges_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 /bridges.
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_bridges_remove_channel(struct ast_variable *headers, struct ast_ari_bridges_remove_channel_args *args, struct ast_ari_response *response)
Remove a channel from a bridge.
void ast_ari_bridges_create(struct ast_variable *headers, struct ast_ari_bridges_create_args *args, struct ast_ari_response *response)
Create a new bridge.
static void ast_ari_bridges_create_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 /bridges/{bridgeId}.
Generated file - Build validators for ARI model objects.
static struct stasis_rest_handlers bridges_bridgeId_moh
REST handler for /api-docs/bridges.json.
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
static void ast_ari_bridges_add_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 /bridges/{bridgeId}/addChannel.
const char * args
static void ast_ari_bridges_clear_video_source_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 /bridges/{bridgeId}/videoSource.
#define NULL
Definition: resample.c:96
int ast_ari_bridges_play_parse_body(struct ast_json *body, struct ast_ari_bridges_play_args *args)
Body parsing function for /bridges/{bridgeId}/play.
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_bridges_play(struct ast_variable *headers, struct ast_ari_bridges_play_args *args, struct ast_ari_response *response)
Start playback of media on a bridge.
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
Definition: res_ari_model.c:91
int response_code
Definition: ari.h:98
ari_validator ast_ari_validate_bridge_fn(void)
Function pointer to ast_ari_validate_bridge().
static int unload_module(void)
static struct stasis_rest_handlers bridges_bridgeId_play_playbackId
REST handler for /api-docs/bridges.json.
static void ast_ari_bridges_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 /bridges/{bridgeId}/record.
#define MAX_VALS
#define ast_log
Definition: astobj2.c:42
int ast_ari_bridges_create_with_id_parse_body(struct ast_json *body, struct ast_ari_bridges_create_with_id_args *args)
Body parsing function for /bridges/{bridgeId}.
void ast_ari_bridges_stop_moh(struct ast_variable *headers, struct ast_ari_bridges_stop_moh_args *args, struct ast_ari_response *response)
Stop playing music on hold to a bridge.
static void ast_ari_bridges_set_video_source_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 /bridges/{bridgeId}/videoSource/{channelId}.
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
static void ast_ari_bridges_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 /bridges/{bridgeId}/play.
int ast_ari_validate_playback(struct ast_json *json)
Validator for Playback.
#define ARRAY_LEN(a)
Definition: utils.h:639
static struct stasis_rest_handlers bridges_bridgeId_play
REST handler for /api-docs/bridges.json.
static struct stasis_rest_handlers bridges_bridgeId_videoSource_channelId
REST handler for /api-docs/bridges.json.
describes a server instance
Definition: tcptls.h:149
void ast_ari_bridges_destroy(struct ast_variable *headers, struct ast_ari_bridges_destroy_args *args, struct ast_ari_response *response)
Shut down a bridge.
#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
int ast_ari_bridges_add_channel_parse_body(struct ast_json *body, struct ast_ari_bridges_add_channel_args *args)
Body parsing function for /bridges/{bridgeId}/addChannel.
static struct stasis_rest_handlers bridges_bridgeId
REST handler for /api-docs/bridges.json.
int ast_ari_validate_bridge(struct ast_json *json)
Validator for Bridge.
int ast_ari_bridges_play_with_id_parse_body(struct ast_json *body, struct ast_ari_bridges_play_with_id_args *args)
Body parsing function for /bridges/{bridgeId}/play/{playbackId}.
static void ast_ari_bridges_destroy_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 /bridges/{bridgeId}.
void ast_ari_bridges_clear_video_source(struct ast_variable *headers, struct ast_ari_bridges_clear_video_source_args *args, struct ast_ari_response *response)
Removes any explicit video source in a multi-party mixing bridge. This operation has no effect on bri...
int ast_ari_bridges_remove_channel_parse_body(struct ast_json *body, struct ast_ari_bridges_remove_channel_args *args)
Body parsing function for /bridges/{bridgeId}/removeChannel.
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:202
void ast_ari_bridges_list(struct ast_variable *headers, struct ast_ari_bridges_list_args *args, struct ast_ari_response *response)
List all active bridges in Asterisk.
static struct stasis_rest_handlers bridges
REST handler for /api-docs/bridges.json.
#define ast_free(a)
Definition: astmm.h:182
static void ast_ari_bridges_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 /bridges.
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
void ast_ari_bridges_create_with_id(struct ast_variable *headers, struct ast_ari_bridges_create_with_id_args *args, struct ast_ari_response *response)
Create a new bridge or updates an existing one.
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
static struct stasis_rest_handlers bridges_bridgeId_addChannel
REST handler for /api-docs/bridges.json.
static struct stasis_rest_handlers bridges_bridgeId_removeChannel
REST handler for /api-docs/bridges.json.
int ast_ari_validate_live_recording(struct ast_json *json)
Validator for LiveRecording.
struct ast_json * message
Definition: ari.h:93
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
Generated file - declares stubs to be implemented in res/ari/resource_bridges.c.
const char * path_segment
Definition: ari.h:70
void ast_ari_bridges_record(struct ast_variable *headers, struct ast_ari_bridges_record_args *args, struct ast_ari_response *response)
Start a recording.
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
static void ast_ari_bridges_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 /bridges/{bridgeId}/play/{playbackId}.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Definition: json.c:356
Abstract JSON element (object, array, string, int, ...).
static void ast_ari_bridges_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 /bridges/{bridgeId}/moh.
Stasis Application API. See Stasis Application API for detailed documentation.
void ast_ari_bridges_set_video_source(struct ast_variable *headers, struct ast_ari_bridges_set_video_source_args *args, struct ast_ari_response *response)
Set a channel as the video source in a multi-party mixing bridge. This operation has no effect on bri...
static void ast_ari_bridges_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 /bridges/{bridgeId}.
int ast_ari_validate_list(struct ast_json *json, int(*fn)(struct ast_json *))
Validator for a Swagger List[]/JSON array.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Asterisk module definitions.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322
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...
int ast_ari_bridges_record_parse_body(struct ast_json *body, struct ast_ari_bridges_record_args *args)
Body parsing function for /bridges/{bridgeId}/record.
Handler for a single RESTful path segment.
Definition: ari.h:68
static int load_module(void)
#define ast_app_separate_args(a, b, c, d)
int ast_ari_bridges_create_parse_body(struct ast_json *body, struct ast_ari_bridges_create_args *args)
Body parsing function for /bridges.