Asterisk - The Open Source Telephony Project GIT-master-f36a736
res_ari_asterisk.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 Asterisk 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 <support_level>core</support_level>
39 ***/
40
41#include "asterisk.h"
42
43#include "asterisk/app.h"
44#include "asterisk/module.h"
45#include "asterisk/stasis_app.h"
47#if defined(AST_DEVMODE)
49#endif
50
51#define MAX_VALS 128
52
53/*!
54 * \brief Parameter parsing callback for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
55 * \param ser TCP/TLS session object
56 * \param get_params GET parameters in the HTTP request.
57 * \param path_vars Path variables extracted from the request.
58 * \param headers HTTP headers.
59 * \param body
60 * \param[out] response Response to the HTTP request.
61 */
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{
68 struct ast_variable *i;
69#if defined(AST_DEVMODE)
70 int is_valid;
71 int code;
72#endif /* AST_DEVMODE */
73
74 for (i = path_vars; i; i = i->next) {
75 if (strcmp(i->name, "configClass") == 0) {
76 args.config_class = (i->value);
77 } else
78 if (strcmp(i->name, "objectType") == 0) {
79 args.object_type = (i->value);
80 } else
81 if (strcmp(i->name, "id") == 0) {
82 args.id = (i->value);
83 } else
84 {}
85 }
86 ast_ari_asterisk_get_object(headers, &args, response);
87#if defined(AST_DEVMODE)
88 code = response->response_code;
89
90 switch (code) {
91 case 0: /* Implementation is still a stub, or the code wasn't set */
92 is_valid = response->message == NULL;
93 break;
94 case 500: /* Internal Server Error */
95 case 501: /* Not Implemented */
96 case 404: /* {configClass|objectType|id} not found */
97 is_valid = 1;
98 break;
99 default:
100 if (200 <= code && code <= 299) {
101 is_valid = ast_ari_validate_list(response->message,
103 } else {
104 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n", code);
105 is_valid = 0;
106 }
107 }
108
109 if (!is_valid) {
110 ast_log(LOG_ERROR, "Response validation failed for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n");
111 ast_ari_response_error(response, 500,
112 "Internal Server Error", "Response validation failed");
113 }
114#endif /* AST_DEVMODE */
115
116fin: __attribute__((unused))
117 return;
118}
120 struct ast_json *body,
122{
123 /* Parse query parameters out of it */
124 return 0;
125}
126
127/*!
128 * \brief Parameter parsing callback for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
129 * \param ser TCP/TLS session object
130 * \param get_params GET parameters in the HTTP request.
131 * \param path_vars Path variables extracted from the request.
132 * \param headers HTTP headers.
133 * \param body
134 * \param[out] response Response to the HTTP request.
135 */
137 struct ast_tcptls_session_instance *ser,
138 struct ast_variable *get_params, struct ast_variable *path_vars,
139 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
140{
142 struct ast_variable *i;
143#if defined(AST_DEVMODE)
144 int is_valid;
145 int code;
146#endif /* AST_DEVMODE */
147
148 for (i = path_vars; i; i = i->next) {
149 if (strcmp(i->name, "configClass") == 0) {
150 args.config_class = (i->value);
151 } else
152 if (strcmp(i->name, "objectType") == 0) {
153 args.object_type = (i->value);
154 } else
155 if (strcmp(i->name, "id") == 0) {
156 args.id = (i->value);
157 } else
158 {}
159 }
160 args.fields = body;
161 ast_ari_asterisk_update_object(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 case 400: /* Bad request body */
172 case 403: /* Could not create or update object */
173 case 404: /* {configClass|objectType} not found */
174 is_valid = 1;
175 break;
176 default:
177 if (200 <= code && code <= 299) {
178 is_valid = ast_ari_validate_list(response->message,
180 } else {
181 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n", code);
182 is_valid = 0;
183 }
184 }
185
186 if (!is_valid) {
187 ast_log(LOG_ERROR, "Response validation failed for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n");
188 ast_ari_response_error(response, 500,
189 "Internal Server Error", "Response validation failed");
190 }
191#endif /* AST_DEVMODE */
192
193fin: __attribute__((unused))
194 return;
195}
196/*!
197 * \brief Parameter parsing callback for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
198 * \param ser TCP/TLS session object
199 * \param get_params GET parameters in the HTTP request.
200 * \param path_vars Path variables extracted from the request.
201 * \param headers HTTP headers.
202 * \param body
203 * \param[out] response Response to the HTTP request.
204 */
206 struct ast_tcptls_session_instance *ser,
207 struct ast_variable *get_params, struct ast_variable *path_vars,
208 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
209{
211 struct ast_variable *i;
212#if defined(AST_DEVMODE)
213 int is_valid;
214 int code;
215#endif /* AST_DEVMODE */
216
217 for (i = path_vars; i; i = i->next) {
218 if (strcmp(i->name, "configClass") == 0) {
219 args.config_class = (i->value);
220 } else
221 if (strcmp(i->name, "objectType") == 0) {
222 args.object_type = (i->value);
223 } else
224 if (strcmp(i->name, "id") == 0) {
225 args.id = (i->value);
226 } else
227 {}
228 }
229 ast_ari_asterisk_delete_object(headers, &args, response);
230#if defined(AST_DEVMODE)
231 code = response->response_code;
232
233 switch (code) {
234 case 0: /* Implementation is still a stub, or the code wasn't set */
235 is_valid = response->message == NULL;
236 break;
237 case 500: /* Internal Server Error */
238 case 501: /* Not Implemented */
239 case 403: /* Could not delete object */
240 case 404: /* {configClass|objectType|id} not found */
241 is_valid = 1;
242 break;
243 default:
244 if (200 <= code && code <= 299) {
245 is_valid = ast_ari_validate_void(
246 response->message);
247 } else {
248 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n", code);
249 is_valid = 0;
250 }
251 }
252
253 if (!is_valid) {
254 ast_log(LOG_ERROR, "Response validation failed for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n");
255 ast_ari_response_error(response, 500,
256 "Internal Server Error", "Response validation failed");
257 }
258#endif /* AST_DEVMODE */
259
260fin: __attribute__((unused))
261 return;
262}
264 struct ast_json *body,
266{
267 struct ast_json *field;
268 /* Parse query parameters out of it */
269 field = ast_json_object_get(body, "only");
270 if (field) {
271 /* If they were silly enough to both pass in a query param and a
272 * JSON body, free up the query value.
273 */
274 ast_free(args->only);
275 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
276 /* Multiple param passed as array */
277 size_t i;
278 args->only_count = ast_json_array_size(field);
279 args->only = ast_malloc(sizeof(*args->only) * args->only_count);
280
281 if (!args->only) {
282 return -1;
283 }
284
285 for (i = 0; i < args->only_count; ++i) {
286 args->only[i] = ast_json_string_get(ast_json_array_get(field, i));
287 }
288 } else {
289 /* Multiple param passed as single value */
290 args->only_count = 1;
291 args->only = ast_malloc(sizeof(*args->only) * args->only_count);
292 if (!args->only) {
293 return -1;
294 }
295 args->only[0] = ast_json_string_get(field);
296 }
297 }
298 return 0;
299}
300
301/*!
302 * \brief Parameter parsing callback for /asterisk/info.
303 * \param ser TCP/TLS session object
304 * \param get_params GET parameters in the HTTP request.
305 * \param path_vars Path variables extracted from the request.
306 * \param headers HTTP headers.
307 * \param body
308 * \param[out] response Response to the HTTP request.
309 */
311 struct ast_tcptls_session_instance *ser,
312 struct ast_variable *get_params, struct ast_variable *path_vars,
313 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
314{
316 struct ast_variable *i;
317#if defined(AST_DEVMODE)
318 int is_valid;
319 int code;
320#endif /* AST_DEVMODE */
321
322 for (i = get_params; i; i = i->next) {
323 if (strcmp(i->name, "only") == 0) {
324 /* Parse comma separated list */
325 char *vals[MAX_VALS];
326 size_t j;
327
328 args.only_parse = ast_strdup(i->value);
329 if (!args.only_parse) {
331 goto fin;
332 }
333
334 if (strlen(args.only_parse) == 0) {
335 /* ast_app_separate_args can't handle "" */
336 args.only_count = 1;
337 vals[0] = args.only_parse;
338 } else {
339 args.only_count = ast_app_separate_args(
340 args.only_parse, ',', vals,
341 ARRAY_LEN(vals));
342 }
343
344 if (args.only_count == 0) {
346 goto fin;
347 }
348
349 if (args.only_count >= MAX_VALS) {
350 ast_ari_response_error(response, 400,
351 "Bad Request",
352 "Too many values for only");
353 goto fin;
354 }
355
356 args.only = ast_malloc(sizeof(*args.only) * args.only_count);
357 if (!args.only) {
359 goto fin;
360 }
361
362 for (j = 0; j < args.only_count; ++j) {
363 args.only[j] = (vals[j]);
364 }
365 } else
366 {}
367 }
370 goto fin;
371 }
372 ast_ari_asterisk_get_info(headers, &args, response);
373#if defined(AST_DEVMODE)
374 code = response->response_code;
375
376 switch (code) {
377 case 0: /* Implementation is still a stub, or the code wasn't set */
378 is_valid = response->message == NULL;
379 break;
380 case 500: /* Internal Server Error */
381 case 501: /* Not Implemented */
382 is_valid = 1;
383 break;
384 default:
385 if (200 <= code && code <= 299) {
387 response->message);
388 } else {
389 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/info\n", code);
390 is_valid = 0;
391 }
392 }
393
394 if (!is_valid) {
395 ast_log(LOG_ERROR, "Response validation failed for /asterisk/info\n");
396 ast_ari_response_error(response, 500,
397 "Internal Server Error", "Response validation failed");
398 }
399#endif /* AST_DEVMODE */
400
401fin: __attribute__((unused))
402 ast_free(args.only_parse);
403 ast_free(args.only);
404 return;
405}
406/*!
407 * \brief Parameter parsing callback for /asterisk/ping.
408 * \param ser TCP/TLS session object
409 * \param get_params GET parameters in the HTTP request.
410 * \param path_vars Path variables extracted from the request.
411 * \param headers HTTP headers.
412 * \param body
413 * \param[out] response Response to the HTTP request.
414 */
416 struct ast_tcptls_session_instance *ser,
417 struct ast_variable *get_params, struct ast_variable *path_vars,
418 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
419{
421#if defined(AST_DEVMODE)
422 int is_valid;
423 int code;
424#endif /* AST_DEVMODE */
425
426 ast_ari_asterisk_ping(headers, &args, response);
427#if defined(AST_DEVMODE)
428 code = response->response_code;
429
430 switch (code) {
431 case 0: /* Implementation is still a stub, or the code wasn't set */
432 is_valid = response->message == NULL;
433 break;
434 case 500: /* Internal Server Error */
435 case 501: /* Not Implemented */
436 is_valid = 1;
437 break;
438 default:
439 if (200 <= code && code <= 299) {
441 response->message);
442 } else {
443 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/ping\n", code);
444 is_valid = 0;
445 }
446 }
447
448 if (!is_valid) {
449 ast_log(LOG_ERROR, "Response validation failed for /asterisk/ping\n");
450 ast_ari_response_error(response, 500,
451 "Internal Server Error", "Response validation failed");
452 }
453#endif /* AST_DEVMODE */
454
455fin: __attribute__((unused))
456 return;
457}
458/*!
459 * \brief Parameter parsing callback for /asterisk/modules.
460 * \param ser TCP/TLS session object
461 * \param get_params GET parameters in the HTTP request.
462 * \param path_vars Path variables extracted from the request.
463 * \param headers HTTP headers.
464 * \param body
465 * \param[out] response Response to the HTTP request.
466 */
468 struct ast_tcptls_session_instance *ser,
469 struct ast_variable *get_params, struct ast_variable *path_vars,
470 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
471{
473#if defined(AST_DEVMODE)
474 int is_valid;
475 int code;
476#endif /* AST_DEVMODE */
477
478 ast_ari_asterisk_list_modules(headers, &args, response);
479#if defined(AST_DEVMODE)
480 code = response->response_code;
481
482 switch (code) {
483 case 0: /* Implementation is still a stub, or the code wasn't set */
484 is_valid = response->message == NULL;
485 break;
486 case 500: /* Internal Server Error */
487 case 501: /* Not Implemented */
488 is_valid = 1;
489 break;
490 default:
491 if (200 <= code && code <= 299) {
492 is_valid = ast_ari_validate_list(response->message,
494 } else {
495 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/modules\n", code);
496 is_valid = 0;
497 }
498 }
499
500 if (!is_valid) {
501 ast_log(LOG_ERROR, "Response validation failed for /asterisk/modules\n");
502 ast_ari_response_error(response, 500,
503 "Internal Server Error", "Response validation failed");
504 }
505#endif /* AST_DEVMODE */
506
507fin: __attribute__((unused))
508 return;
509}
510/*!
511 * \brief Parameter parsing callback for /asterisk/modules/{moduleName}.
512 * \param ser TCP/TLS session object
513 * \param get_params GET parameters in the HTTP request.
514 * \param path_vars Path variables extracted from the request.
515 * \param headers HTTP headers.
516 * \param body
517 * \param[out] response Response to the HTTP request.
518 */
520 struct ast_tcptls_session_instance *ser,
521 struct ast_variable *get_params, struct ast_variable *path_vars,
522 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
523{
525 struct ast_variable *i;
526#if defined(AST_DEVMODE)
527 int is_valid;
528 int code;
529#endif /* AST_DEVMODE */
530
531 for (i = path_vars; i; i = i->next) {
532 if (strcmp(i->name, "moduleName") == 0) {
533 args.module_name = (i->value);
534 } else
535 {}
536 }
537 ast_ari_asterisk_get_module(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 404: /* Module could not be found in running modules. */
548 case 409: /* Module information could not be retrieved. */
549 is_valid = 1;
550 break;
551 default:
552 if (200 <= code && code <= 299) {
553 is_valid = ast_ari_validate_module(
554 response->message);
555 } else {
556 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
557 is_valid = 0;
558 }
559 }
560
561 if (!is_valid) {
562 ast_log(LOG_ERROR, "Response validation failed for /asterisk/modules/{moduleName}\n");
563 ast_ari_response_error(response, 500,
564 "Internal Server Error", "Response validation failed");
565 }
566#endif /* AST_DEVMODE */
567
568fin: __attribute__((unused))
569 return;
570}
571/*!
572 * \brief Parameter parsing callback for /asterisk/modules/{moduleName}.
573 * \param ser TCP/TLS session object
574 * \param get_params GET parameters in the HTTP request.
575 * \param path_vars Path variables extracted from the request.
576 * \param headers HTTP headers.
577 * \param body
578 * \param[out] response Response to the HTTP request.
579 */
581 struct ast_tcptls_session_instance *ser,
582 struct ast_variable *get_params, struct ast_variable *path_vars,
583 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
584{
586 struct ast_variable *i;
587#if defined(AST_DEVMODE)
588 int is_valid;
589 int code;
590#endif /* AST_DEVMODE */
591
592 for (i = path_vars; i; i = i->next) {
593 if (strcmp(i->name, "moduleName") == 0) {
594 args.module_name = (i->value);
595 } else
596 {}
597 }
598 ast_ari_asterisk_load_module(headers, &args, response);
599#if defined(AST_DEVMODE)
600 code = response->response_code;
601
602 switch (code) {
603 case 0: /* Implementation is still a stub, or the code wasn't set */
604 is_valid = response->message == NULL;
605 break;
606 case 500: /* Internal Server Error */
607 case 501: /* Not Implemented */
608 case 409: /* Module could not be loaded. */
609 is_valid = 1;
610 break;
611 default:
612 if (200 <= code && code <= 299) {
613 is_valid = ast_ari_validate_void(
614 response->message);
615 } else {
616 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
617 is_valid = 0;
618 }
619 }
620
621 if (!is_valid) {
622 ast_log(LOG_ERROR, "Response validation failed for /asterisk/modules/{moduleName}\n");
623 ast_ari_response_error(response, 500,
624 "Internal Server Error", "Response validation failed");
625 }
626#endif /* AST_DEVMODE */
627
628fin: __attribute__((unused))
629 return;
630}
631/*!
632 * \brief Parameter parsing callback for /asterisk/modules/{moduleName}.
633 * \param ser TCP/TLS session object
634 * \param get_params GET parameters in the HTTP request.
635 * \param path_vars Path variables extracted from the request.
636 * \param headers HTTP headers.
637 * \param body
638 * \param[out] response Response to the HTTP request.
639 */
641 struct ast_tcptls_session_instance *ser,
642 struct ast_variable *get_params, struct ast_variable *path_vars,
643 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
644{
646 struct ast_variable *i;
647#if defined(AST_DEVMODE)
648 int is_valid;
649 int code;
650#endif /* AST_DEVMODE */
651
652 for (i = path_vars; i; i = i->next) {
653 if (strcmp(i->name, "moduleName") == 0) {
654 args.module_name = (i->value);
655 } else
656 {}
657 }
658 ast_ari_asterisk_unload_module(headers, &args, response);
659#if defined(AST_DEVMODE)
660 code = response->response_code;
661
662 switch (code) {
663 case 0: /* Implementation is still a stub, or the code wasn't set */
664 is_valid = response->message == NULL;
665 break;
666 case 500: /* Internal Server Error */
667 case 501: /* Not Implemented */
668 case 404: /* Module not found in running modules. */
669 case 409: /* Module could not be unloaded. */
670 is_valid = 1;
671 break;
672 default:
673 if (200 <= code && code <= 299) {
674 is_valid = ast_ari_validate_void(
675 response->message);
676 } else {
677 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
678 is_valid = 0;
679 }
680 }
681
682 if (!is_valid) {
683 ast_log(LOG_ERROR, "Response validation failed for /asterisk/modules/{moduleName}\n");
684 ast_ari_response_error(response, 500,
685 "Internal Server Error", "Response validation failed");
686 }
687#endif /* AST_DEVMODE */
688
689fin: __attribute__((unused))
690 return;
691}
692/*!
693 * \brief Parameter parsing callback for /asterisk/modules/{moduleName}.
694 * \param ser TCP/TLS session object
695 * \param get_params GET parameters in the HTTP request.
696 * \param path_vars Path variables extracted from the request.
697 * \param headers HTTP headers.
698 * \param body
699 * \param[out] response Response to the HTTP request.
700 */
702 struct ast_tcptls_session_instance *ser,
703 struct ast_variable *get_params, struct ast_variable *path_vars,
704 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
705{
707 struct ast_variable *i;
708#if defined(AST_DEVMODE)
709 int is_valid;
710 int code;
711#endif /* AST_DEVMODE */
712
713 for (i = path_vars; i; i = i->next) {
714 if (strcmp(i->name, "moduleName") == 0) {
715 args.module_name = (i->value);
716 } else
717 {}
718 }
719 ast_ari_asterisk_reload_module(headers, &args, response);
720#if defined(AST_DEVMODE)
721 code = response->response_code;
722
723 switch (code) {
724 case 0: /* Implementation is still a stub, or the code wasn't set */
725 is_valid = response->message == NULL;
726 break;
727 case 500: /* Internal Server Error */
728 case 501: /* Not Implemented */
729 case 404: /* Module not found in running modules. */
730 case 409: /* Module could not be reloaded. */
731 is_valid = 1;
732 break;
733 default:
734 if (200 <= code && code <= 299) {
735 is_valid = ast_ari_validate_void(
736 response->message);
737 } else {
738 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
739 is_valid = 0;
740 }
741 }
742
743 if (!is_valid) {
744 ast_log(LOG_ERROR, "Response validation failed for /asterisk/modules/{moduleName}\n");
745 ast_ari_response_error(response, 500,
746 "Internal Server Error", "Response validation failed");
747 }
748#endif /* AST_DEVMODE */
749
750fin: __attribute__((unused))
751 return;
752}
753/*!
754 * \brief Parameter parsing callback for /asterisk/logging.
755 * \param ser TCP/TLS session object
756 * \param get_params GET parameters in the HTTP request.
757 * \param path_vars Path variables extracted from the request.
758 * \param headers HTTP headers.
759 * \param body
760 * \param[out] response Response to the HTTP request.
761 */
763 struct ast_tcptls_session_instance *ser,
764 struct ast_variable *get_params, struct ast_variable *path_vars,
765 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
766{
768#if defined(AST_DEVMODE)
769 int is_valid;
770 int code;
771#endif /* AST_DEVMODE */
772
773 ast_ari_asterisk_list_log_channels(headers, &args, response);
774#if defined(AST_DEVMODE)
775 code = response->response_code;
776
777 switch (code) {
778 case 0: /* Implementation is still a stub, or the code wasn't set */
779 is_valid = response->message == NULL;
780 break;
781 case 500: /* Internal Server Error */
782 case 501: /* Not Implemented */
783 is_valid = 1;
784 break;
785 default:
786 if (200 <= code && code <= 299) {
787 is_valid = ast_ari_validate_list(response->message,
789 } else {
790 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/logging\n", code);
791 is_valid = 0;
792 }
793 }
794
795 if (!is_valid) {
796 ast_log(LOG_ERROR, "Response validation failed for /asterisk/logging\n");
797 ast_ari_response_error(response, 500,
798 "Internal Server Error", "Response validation failed");
799 }
800#endif /* AST_DEVMODE */
801
802fin: __attribute__((unused))
803 return;
804}
806 struct ast_json *body,
808{
809 struct ast_json *field;
810 /* Parse query parameters out of it */
811 field = ast_json_object_get(body, "configuration");
812 if (field) {
813 args->configuration = ast_json_string_get(field);
814 }
815 return 0;
816}
817
818/*!
819 * \brief Parameter parsing callback for /asterisk/logging/{logChannelName}.
820 * \param ser TCP/TLS session object
821 * \param get_params GET parameters in the HTTP request.
822 * \param path_vars Path variables extracted from the request.
823 * \param headers HTTP headers.
824 * \param body
825 * \param[out] response Response to the HTTP request.
826 */
828 struct ast_tcptls_session_instance *ser,
829 struct ast_variable *get_params, struct ast_variable *path_vars,
830 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
831{
833 struct ast_variable *i;
834#if defined(AST_DEVMODE)
835 int is_valid;
836 int code;
837#endif /* AST_DEVMODE */
838
839 for (i = get_params; i; i = i->next) {
840 if (strcmp(i->name, "configuration") == 0) {
841 args.configuration = (i->value);
842 } else
843 {}
844 }
845 for (i = path_vars; i; i = i->next) {
846 if (strcmp(i->name, "logChannelName") == 0) {
847 args.log_channel_name = (i->value);
848 } else
849 {}
850 }
853 goto fin;
854 }
855 ast_ari_asterisk_add_log(headers, &args, response);
856#if defined(AST_DEVMODE)
857 code = response->response_code;
858
859 switch (code) {
860 case 0: /* Implementation is still a stub, or the code wasn't set */
861 is_valid = response->message == NULL;
862 break;
863 case 500: /* Internal Server Error */
864 case 501: /* Not Implemented */
865 case 400: /* Bad request body */
866 case 409: /* Log channel could not be created. */
867 is_valid = 1;
868 break;
869 default:
870 if (200 <= code && code <= 299) {
871 is_valid = ast_ari_validate_void(
872 response->message);
873 } else {
874 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/logging/{logChannelName}\n", code);
875 is_valid = 0;
876 }
877 }
878
879 if (!is_valid) {
880 ast_log(LOG_ERROR, "Response validation failed for /asterisk/logging/{logChannelName}\n");
881 ast_ari_response_error(response, 500,
882 "Internal Server Error", "Response validation failed");
883 }
884#endif /* AST_DEVMODE */
885
886fin: __attribute__((unused))
887 return;
888}
889/*!
890 * \brief Parameter parsing callback for /asterisk/logging/{logChannelName}.
891 * \param ser TCP/TLS session object
892 * \param get_params GET parameters in the HTTP request.
893 * \param path_vars Path variables extracted from the request.
894 * \param headers HTTP headers.
895 * \param body
896 * \param[out] response Response to the HTTP request.
897 */
899 struct ast_tcptls_session_instance *ser,
900 struct ast_variable *get_params, struct ast_variable *path_vars,
901 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
902{
904 struct ast_variable *i;
905#if defined(AST_DEVMODE)
906 int is_valid;
907 int code;
908#endif /* AST_DEVMODE */
909
910 for (i = path_vars; i; i = i->next) {
911 if (strcmp(i->name, "logChannelName") == 0) {
912 args.log_channel_name = (i->value);
913 } else
914 {}
915 }
916 ast_ari_asterisk_delete_log(headers, &args, response);
917#if defined(AST_DEVMODE)
918 code = response->response_code;
919
920 switch (code) {
921 case 0: /* Implementation is still a stub, or the code wasn't set */
922 is_valid = response->message == NULL;
923 break;
924 case 500: /* Internal Server Error */
925 case 501: /* Not Implemented */
926 case 404: /* Log channel does not exist. */
927 is_valid = 1;
928 break;
929 default:
930 if (200 <= code && code <= 299) {
931 is_valid = ast_ari_validate_void(
932 response->message);
933 } else {
934 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/logging/{logChannelName}\n", code);
935 is_valid = 0;
936 }
937 }
938
939 if (!is_valid) {
940 ast_log(LOG_ERROR, "Response validation failed for /asterisk/logging/{logChannelName}\n");
941 ast_ari_response_error(response, 500,
942 "Internal Server Error", "Response validation failed");
943 }
944#endif /* AST_DEVMODE */
945
946fin: __attribute__((unused))
947 return;
948}
949/*!
950 * \brief Parameter parsing callback for /asterisk/logging/{logChannelName}/rotate.
951 * \param ser TCP/TLS session object
952 * \param get_params GET parameters in the HTTP request.
953 * \param path_vars Path variables extracted from the request.
954 * \param headers HTTP headers.
955 * \param body
956 * \param[out] response Response to the HTTP request.
957 */
959 struct ast_tcptls_session_instance *ser,
960 struct ast_variable *get_params, struct ast_variable *path_vars,
961 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
962{
964 struct ast_variable *i;
965#if defined(AST_DEVMODE)
966 int is_valid;
967 int code;
968#endif /* AST_DEVMODE */
969
970 for (i = path_vars; i; i = i->next) {
971 if (strcmp(i->name, "logChannelName") == 0) {
972 args.log_channel_name = (i->value);
973 } else
974 {}
975 }
976 ast_ari_asterisk_rotate_log(headers, &args, response);
977#if defined(AST_DEVMODE)
978 code = response->response_code;
979
980 switch (code) {
981 case 0: /* Implementation is still a stub, or the code wasn't set */
982 is_valid = response->message == NULL;
983 break;
984 case 500: /* Internal Server Error */
985 case 501: /* Not Implemented */
986 case 404: /* Log channel does not exist. */
987 is_valid = 1;
988 break;
989 default:
990 if (200 <= code && code <= 299) {
991 is_valid = ast_ari_validate_void(
992 response->message);
993 } else {
994 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/logging/{logChannelName}/rotate\n", code);
995 is_valid = 0;
996 }
997 }
998
999 if (!is_valid) {
1000 ast_log(LOG_ERROR, "Response validation failed for /asterisk/logging/{logChannelName}/rotate\n");
1001 ast_ari_response_error(response, 500,
1002 "Internal Server Error", "Response validation failed");
1003 }
1004#endif /* AST_DEVMODE */
1005
1006fin: __attribute__((unused))
1007 return;
1008}
1010 struct ast_json *body,
1012{
1013 struct ast_json *field;
1014 /* Parse query parameters out of it */
1015 field = ast_json_object_get(body, "variable");
1016 if (field) {
1017 args->variable = ast_json_string_get(field);
1018 }
1019 return 0;
1020}
1021
1022/*!
1023 * \brief Parameter parsing callback for /asterisk/variable.
1024 * \param ser TCP/TLS session object
1025 * \param get_params GET parameters in the HTTP request.
1026 * \param path_vars Path variables extracted from the request.
1027 * \param headers HTTP headers.
1028 * \param body
1029 * \param[out] response Response to the HTTP request.
1030 */
1032 struct ast_tcptls_session_instance *ser,
1033 struct ast_variable *get_params, struct ast_variable *path_vars,
1034 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1035{
1037 struct ast_variable *i;
1038#if defined(AST_DEVMODE)
1039 int is_valid;
1040 int code;
1041#endif /* AST_DEVMODE */
1042
1043 for (i = get_params; i; i = i->next) {
1044 if (strcmp(i->name, "variable") == 0) {
1045 args.variable = (i->value);
1046 } else
1047 {}
1048 }
1051 goto fin;
1052 }
1053 ast_ari_asterisk_get_global_var(headers, &args, response);
1054#if defined(AST_DEVMODE)
1055 code = response->response_code;
1056
1057 switch (code) {
1058 case 0: /* Implementation is still a stub, or the code wasn't set */
1059 is_valid = response->message == NULL;
1060 break;
1061 case 500: /* Internal Server Error */
1062 case 501: /* Not Implemented */
1063 case 400: /* Missing variable parameter. */
1064 is_valid = 1;
1065 break;
1066 default:
1067 if (200 <= code && code <= 299) {
1068 is_valid = ast_ari_validate_variable(
1069 response->message);
1070 } else {
1071 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/variable\n", code);
1072 is_valid = 0;
1073 }
1074 }
1075
1076 if (!is_valid) {
1077 ast_log(LOG_ERROR, "Response validation failed for /asterisk/variable\n");
1078 ast_ari_response_error(response, 500,
1079 "Internal Server Error", "Response validation failed");
1080 }
1081#endif /* AST_DEVMODE */
1082
1083fin: __attribute__((unused))
1084 return;
1085}
1087 struct ast_json *body,
1089{
1090 struct ast_json *field;
1091 /* Parse query parameters out of it */
1092 field = ast_json_object_get(body, "variable");
1093 if (field) {
1094 args->variable = ast_json_string_get(field);
1095 }
1096 field = ast_json_object_get(body, "value");
1097 if (field) {
1098 args->value = ast_json_string_get(field);
1099 }
1100 return 0;
1101}
1102
1103/*!
1104 * \brief Parameter parsing callback for /asterisk/variable.
1105 * \param ser TCP/TLS session object
1106 * \param get_params GET parameters in the HTTP request.
1107 * \param path_vars Path variables extracted from the request.
1108 * \param headers HTTP headers.
1109 * \param body
1110 * \param[out] response Response to the HTTP request.
1111 */
1113 struct ast_tcptls_session_instance *ser,
1114 struct ast_variable *get_params, struct ast_variable *path_vars,
1115 struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
1116{
1118 struct ast_variable *i;
1119#if defined(AST_DEVMODE)
1120 int is_valid;
1121 int code;
1122#endif /* AST_DEVMODE */
1123
1124 for (i = get_params; i; i = i->next) {
1125 if (strcmp(i->name, "variable") == 0) {
1126 args.variable = (i->value);
1127 } else
1128 if (strcmp(i->name, "value") == 0) {
1129 args.value = (i->value);
1130 } else
1131 {}
1132 }
1135 goto fin;
1136 }
1137 ast_ari_asterisk_set_global_var(headers, &args, response);
1138#if defined(AST_DEVMODE)
1139 code = response->response_code;
1140
1141 switch (code) {
1142 case 0: /* Implementation is still a stub, or the code wasn't set */
1143 is_valid = response->message == NULL;
1144 break;
1145 case 500: /* Internal Server Error */
1146 case 501: /* Not Implemented */
1147 case 400: /* Missing variable parameter. */
1148 is_valid = 1;
1149 break;
1150 default:
1151 if (200 <= code && code <= 299) {
1152 is_valid = ast_ari_validate_void(
1153 response->message);
1154 } else {
1155 ast_log(LOG_ERROR, "Invalid error response %d for /asterisk/variable\n", code);
1156 is_valid = 0;
1157 }
1158 }
1159
1160 if (!is_valid) {
1161 ast_log(LOG_ERROR, "Response validation failed for /asterisk/variable\n");
1162 ast_ari_response_error(response, 500,
1163 "Internal Server Error", "Response validation failed");
1164 }
1165#endif /* AST_DEVMODE */
1166
1167fin: __attribute__((unused))
1168 return;
1169}
1170
1171/*! \brief REST handler for /api-docs/asterisk.json */
1173 .path_segment = "id",
1174 .is_wildcard = 1,
1175 .callbacks = {
1179 },
1180 .num_children = 0,
1181 .children = { }
1182};
1183/*! \brief REST handler for /api-docs/asterisk.json */
1185 .path_segment = "objectType",
1186 .is_wildcard = 1,
1187 .callbacks = {
1188 },
1189 .num_children = 1,
1191};
1192/*! \brief REST handler for /api-docs/asterisk.json */
1194 .path_segment = "configClass",
1195 .is_wildcard = 1,
1196 .callbacks = {
1197 },
1198 .num_children = 1,
1200};
1201/*! \brief REST handler for /api-docs/asterisk.json */
1203 .path_segment = "dynamic",
1204 .callbacks = {
1205 },
1206 .num_children = 1,
1207 .children = { &asterisk_config_dynamic_configClass, }
1208};
1209/*! \brief REST handler for /api-docs/asterisk.json */
1211 .path_segment = "config",
1212 .callbacks = {
1213 },
1214 .num_children = 1,
1215 .children = { &asterisk_config_dynamic, }
1216};
1217/*! \brief REST handler for /api-docs/asterisk.json */
1219 .path_segment = "info",
1220 .callbacks = {
1222 },
1223 .num_children = 0,
1224 .children = { }
1225};
1226/*! \brief REST handler for /api-docs/asterisk.json */
1228 .path_segment = "ping",
1229 .callbacks = {
1231 },
1232 .num_children = 0,
1233 .children = { }
1234};
1235/*! \brief REST handler for /api-docs/asterisk.json */
1237 .path_segment = "moduleName",
1238 .is_wildcard = 1,
1239 .callbacks = {
1244 },
1245 .num_children = 0,
1246 .children = { }
1247};
1248/*! \brief REST handler for /api-docs/asterisk.json */
1250 .path_segment = "modules",
1251 .callbacks = {
1253 },
1254 .num_children = 1,
1255 .children = { &asterisk_modules_moduleName, }
1256};
1257/*! \brief REST handler for /api-docs/asterisk.json */
1259 .path_segment = "rotate",
1260 .callbacks = {
1262 },
1263 .num_children = 0,
1264 .children = { }
1265};
1266/*! \brief REST handler for /api-docs/asterisk.json */
1268 .path_segment = "logChannelName",
1269 .is_wildcard = 1,
1270 .callbacks = {
1273 },
1274 .num_children = 1,
1276};
1277/*! \brief REST handler for /api-docs/asterisk.json */
1279 .path_segment = "logging",
1280 .callbacks = {
1282 },
1283 .num_children = 1,
1284 .children = { &asterisk_logging_logChannelName, }
1285};
1286/*! \brief REST handler for /api-docs/asterisk.json */
1288 .path_segment = "variable",
1289 .callbacks = {
1292 },
1293 .num_children = 0,
1294 .children = { }
1295};
1296/*! \brief REST handler for /api-docs/asterisk.json */
1298 .path_segment = "asterisk",
1299 .callbacks = {
1300 },
1301 .num_children = 6,
1303};
1304
1305static int unload_module(void)
1306{
1308 return 0;
1309}
1310
1311static int load_module(void)
1312{
1313 int res = 0;
1314
1315
1317 if (res) {
1318 unload_module();
1320 }
1321
1323}
1324
1325AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Asterisk resources",
1326 .support_level = AST_MODULE_SUPPORT_CORE,
1327 .load = load_module,
1328 .unload = unload_module,
1329 .requires = "res_ari,res_ari_model,res_stasis",
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:202
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:179
int ast_ari_validate_variable(struct ast_json *json)
Validator for Variable.
int ast_ari_validate_module(struct ast_json *json)
Validator for Module.
ari_validator ast_ari_validate_config_tuple_fn(void)
Function pointer to ast_ari_validate_config_tuple().
int ast_ari_validate_asterisk_info(struct ast_json *json)
Validator for AsteriskInfo.
int ast_ari_validate_asterisk_ping(struct ast_json *json)
Validator for AsteriskPing.
ari_validator ast_ari_validate_log_channel_fn(void)
Function pointer to ast_ari_validate_log_channel().
ari_validator ast_ari_validate_module_fn(void)
Function pointer to ast_ari_validate_module().
Generated file - Build validators for ARI model objects.
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
Definition: res_ari_model.c:91
int ast_ari_validate_list(struct ast_json *json, int(*fn)(struct ast_json *))
Validator for a Swagger List[]/JSON array.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define ast_log
Definition: astobj2.c:42
@ AST_HTTP_PUT
Definition: http.h:63
@ AST_HTTP_DELETE
Definition: http.h:64
@ AST_HTTP_POST
Definition: http.h:61
@ AST_HTTP_GET
Definition: http.h:60
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define ast_app_separate_args(a, b, c, d)
#define LOG_ERROR
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
Definition: json.c:78
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
Definition: json.c:370
@ AST_JSON_ARRAY
Definition: json.h:165
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:283
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:407
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Definition: json.c:366
Asterisk module definitions.
@ AST_MODFLAG_DEFAULT
Definition: module.h:329
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:557
@ AST_MODULE_SUPPORT_CORE
Definition: module.h:121
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static struct stasis_rest_handlers asterisk_logging_logChannelName_rotate
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_config_dynamic
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_config_dynamic_configClass
REST handler for /api-docs/asterisk.json.
static void ast_ari_asterisk_reload_module_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 /asterisk/modules/{moduleName}.
static struct stasis_rest_handlers asterisk_logging
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk
REST handler for /api-docs/asterisk.json.
static void ast_ari_asterisk_update_object_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 /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
static void ast_ari_asterisk_delete_object_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 /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
#define MAX_VALS
static struct stasis_rest_handlers asterisk_ping
REST handler for /api-docs/asterisk.json.
static void ast_ari_asterisk_unload_module_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 /asterisk/modules/{moduleName}.
static struct stasis_rest_handlers asterisk_config_dynamic_configClass_objectType_id
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_modules_moduleName
REST handler for /api-docs/asterisk.json.
static void ast_ari_asterisk_get_object_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 /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
static void ast_ari_asterisk_list_modules_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 /asterisk/modules.
static void ast_ari_asterisk_list_log_channels_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 /asterisk/logging.
static struct stasis_rest_handlers asterisk_modules
REST handler for /api-docs/asterisk.json.
static void ast_ari_asterisk_delete_log_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 /asterisk/logging/{logChannelName}.
int ast_ari_asterisk_add_log_parse_body(struct ast_json *body, struct ast_ari_asterisk_add_log_args *args)
Body parsing function for /asterisk/logging/{logChannelName}.
int ast_ari_asterisk_get_global_var_parse_body(struct ast_json *body, struct ast_ari_asterisk_get_global_var_args *args)
Body parsing function for /asterisk/variable.
static void ast_ari_asterisk_ping_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 /asterisk/ping.
static void ast_ari_asterisk_rotate_log_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 /asterisk/logging/{logChannelName}/rotate.
int ast_ari_asterisk_get_info_parse_body(struct ast_json *body, struct ast_ari_asterisk_get_info_args *args)
Body parsing function for /asterisk/info.
static struct stasis_rest_handlers asterisk_info
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_logging_logChannelName
REST handler for /api-docs/asterisk.json.
static void ast_ari_asterisk_get_module_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 /asterisk/modules/{moduleName}.
static void ast_ari_asterisk_get_info_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 /asterisk/info.
static struct stasis_rest_handlers asterisk_variable
REST handler for /api-docs/asterisk.json.
static int load_module(void)
int ast_ari_asterisk_set_global_var_parse_body(struct ast_json *body, struct ast_ari_asterisk_set_global_var_args *args)
Body parsing function for /asterisk/variable.
static int unload_module(void)
static void ast_ari_asterisk_add_log_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 /asterisk/logging/{logChannelName}.
static void ast_ari_asterisk_load_module_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 /asterisk/modules/{moduleName}.
static void ast_ari_asterisk_get_global_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 /asterisk/variable.
int ast_ari_asterisk_update_object_parse_body(struct ast_json *body, struct ast_ari_asterisk_update_object_args *args)
Body parsing function for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
static void ast_ari_asterisk_set_global_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 /asterisk/variable.
static struct stasis_rest_handlers asterisk_config_dynamic_configClass_objectType
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_config
REST handler for /api-docs/asterisk.json.
#define NULL
Definition: resample.c:96
void ast_ari_asterisk_unload_module(struct ast_variable *headers, struct ast_ari_asterisk_unload_module_args *args, struct ast_ari_response *response)
Unload an Asterisk module.
void ast_ari_asterisk_set_global_var(struct ast_variable *headers, struct ast_ari_asterisk_set_global_var_args *args, struct ast_ari_response *response)
Set the value of a global variable.
void ast_ari_asterisk_get_global_var(struct ast_variable *headers, struct ast_ari_asterisk_get_global_var_args *args, struct ast_ari_response *response)
Get the value of a global variable.
void ast_ari_asterisk_delete_object(struct ast_variable *headers, struct ast_ari_asterisk_delete_object_args *args, struct ast_ari_response *response)
Delete a dynamic configuration object.
void ast_ari_asterisk_get_module(struct ast_variable *headers, struct ast_ari_asterisk_get_module_args *args, struct ast_ari_response *response)
Get Asterisk module information.
void ast_ari_asterisk_rotate_log(struct ast_variable *headers, struct ast_ari_asterisk_rotate_log_args *args, struct ast_ari_response *response)
Rotates a log channel.
void ast_ari_asterisk_add_log(struct ast_variable *headers, struct ast_ari_asterisk_add_log_args *args, struct ast_ari_response *response)
Adds a log channel.
void ast_ari_asterisk_ping(struct ast_variable *headers, struct ast_ari_asterisk_ping_args *args, struct ast_ari_response *response)
Response pong message.
void ast_ari_asterisk_update_object(struct ast_variable *headers, struct ast_ari_asterisk_update_object_args *args, struct ast_ari_response *response)
Create or update a dynamic configuration object.
void ast_ari_asterisk_get_info(struct ast_variable *headers, struct ast_ari_asterisk_get_info_args *args, struct ast_ari_response *response)
Gets Asterisk system information.
void ast_ari_asterisk_delete_log(struct ast_variable *headers, struct ast_ari_asterisk_delete_log_args *args, struct ast_ari_response *response)
Deletes a log channel.
void ast_ari_asterisk_load_module(struct ast_variable *headers, struct ast_ari_asterisk_load_module_args *args, struct ast_ari_response *response)
Load an Asterisk module.
void ast_ari_asterisk_reload_module(struct ast_variable *headers, struct ast_ari_asterisk_reload_module_args *args, struct ast_ari_response *response)
Reload an Asterisk module.
void ast_ari_asterisk_list_modules(struct ast_variable *headers, struct ast_ari_asterisk_list_modules_args *args, struct ast_ari_response *response)
List Asterisk modules.
void ast_ari_asterisk_list_log_channels(struct ast_variable *headers, struct ast_ari_asterisk_list_log_channels_args *args, struct ast_ari_response *response)
Gets Asterisk log channel information.
void ast_ari_asterisk_get_object(struct ast_variable *headers, struct ast_ari_asterisk_get_object_args *args, struct ast_ari_response *response)
Retrieve a dynamic configuration object.
Generated file - declares stubs to be implemented in res/ari/resource_asterisk.c.
Stasis Application API. See Stasis Application API for detailed documentation.
struct ast_json * message
Definition: ari.h:94
int response_code
Definition: ari.h:99
Abstract JSON element (object, array, string, int, ...).
describes a server instance
Definition: tcptls.h:150
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Handler for a single RESTful path segment.
Definition: ari.h:69
const char * path_segment
Definition: ari.h:71
const char * args
#define ARRAY_LEN(a)
Definition: utils.h:666