Asterisk - The Open Source Telephony Project GIT-master-0deac78
Macros | Functions | Variables
res_ari_channels.c File Reference

Channel resources. More...

#include "asterisk.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
#include "asterisk/stasis_app.h"
#include "ari/resource_channels.h"
Include dependency graph for res_ari_channels.c:

Go to the source code of this file.

Macros

#define MAX_VALS   128
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static void ast_ari_channels_answer_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/answer. More...
 
static void ast_ari_channels_continue_in_dialplan_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/continue. More...
 
int ast_ari_channels_continue_in_dialplan_parse_body (struct ast_json *body, struct ast_ari_channels_continue_in_dialplan_args *args)
 Body parsing function for /channels/{channelId}/continue. More...
 
static void ast_ari_channels_create_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/create. More...
 
int ast_ari_channels_create_parse_body (struct ast_json *body, struct ast_ari_channels_create_args *args)
 Body parsing function for /channels/create. More...
 
static void ast_ari_channels_dial_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/dial. More...
 
int ast_ari_channels_dial_parse_body (struct ast_json *body, struct ast_ari_channels_dial_args *args)
 Body parsing function for /channels/{channelId}/dial. More...
 
static void ast_ari_channels_external_media_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/externalMedia. More...
 
int ast_ari_channels_external_media_parse_body (struct ast_json *body, struct ast_ari_channels_external_media_args *args)
 Body parsing function for /channels/externalMedia. More...
 
static void ast_ari_channels_get_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}. More...
 
static void ast_ari_channels_get_channel_var_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/variable. More...
 
int ast_ari_channels_get_channel_var_parse_body (struct ast_json *body, struct ast_ari_channels_get_channel_var_args *args)
 Body parsing function for /channels/{channelId}/variable. More...
 
static void ast_ari_channels_hangup_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}. More...
 
int ast_ari_channels_hangup_parse_body (struct ast_json *body, struct ast_ari_channels_hangup_args *args)
 Body parsing function for /channels/{channelId}. More...
 
static void ast_ari_channels_hold_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/hold. More...
 
static void ast_ari_channels_list_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels. More...
 
static void ast_ari_channels_move_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/move. More...
 
int ast_ari_channels_move_parse_body (struct ast_json *body, struct ast_ari_channels_move_args *args)
 Body parsing function for /channels/{channelId}/move. More...
 
static void ast_ari_channels_mute_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/mute. More...
 
int ast_ari_channels_mute_parse_body (struct ast_json *body, struct ast_ari_channels_mute_args *args)
 Body parsing function for /channels/{channelId}/mute. More...
 
static void ast_ari_channels_originate_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels. More...
 
int ast_ari_channels_originate_parse_body (struct ast_json *body, struct ast_ari_channels_originate_args *args)
 Body parsing function for /channels. More...
 
static void ast_ari_channels_originate_with_id_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}. More...
 
int ast_ari_channels_originate_with_id_parse_body (struct ast_json *body, struct ast_ari_channels_originate_with_id_args *args)
 Body parsing function for /channels/{channelId}. More...
 
static void ast_ari_channels_play_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/play. More...
 
int ast_ari_channels_play_parse_body (struct ast_json *body, struct ast_ari_channels_play_args *args)
 Body parsing function for /channels/{channelId}/play. More...
 
static void ast_ari_channels_play_with_id_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/play/{playbackId}. More...
 
int ast_ari_channels_play_with_id_parse_body (struct ast_json *body, struct ast_ari_channels_play_with_id_args *args)
 Body parsing function for /channels/{channelId}/play/{playbackId}. More...
 
static void ast_ari_channels_progress_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/progress. More...
 
static void ast_ari_channels_record_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/record. More...
 
int ast_ari_channels_record_parse_body (struct ast_json *body, struct ast_ari_channels_record_args *args)
 Body parsing function for /channels/{channelId}/record. More...
 
static void ast_ari_channels_redirect_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/redirect. More...
 
int ast_ari_channels_redirect_parse_body (struct ast_json *body, struct ast_ari_channels_redirect_args *args)
 Body parsing function for /channels/{channelId}/redirect. More...
 
static void ast_ari_channels_ring_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/ring. More...
 
static void ast_ari_channels_ring_stop_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/ring. More...
 
static void ast_ari_channels_rtpstatistics_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/rtp_statistics. More...
 
static void ast_ari_channels_send_dtmf_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/dtmf. More...
 
int ast_ari_channels_send_dtmf_parse_body (struct ast_json *body, struct ast_ari_channels_send_dtmf_args *args)
 Body parsing function for /channels/{channelId}/dtmf. More...
 
static void ast_ari_channels_set_channel_var_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/variable. More...
 
int ast_ari_channels_set_channel_var_parse_body (struct ast_json *body, struct ast_ari_channels_set_channel_var_args *args)
 Body parsing function for /channels/{channelId}/variable. More...
 
static void ast_ari_channels_snoop_channel_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/snoop. More...
 
int ast_ari_channels_snoop_channel_parse_body (struct ast_json *body, struct ast_ari_channels_snoop_channel_args *args)
 Body parsing function for /channels/{channelId}/snoop. More...
 
static void ast_ari_channels_snoop_channel_with_id_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/snoop/{snoopId}. More...
 
int ast_ari_channels_snoop_channel_with_id_parse_body (struct ast_json *body, struct ast_ari_channels_snoop_channel_with_id_args *args)
 Body parsing function for /channels/{channelId}/snoop/{snoopId}. More...
 
static void ast_ari_channels_start_moh_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/moh. More...
 
int ast_ari_channels_start_moh_parse_body (struct ast_json *body, struct ast_ari_channels_start_moh_args *args)
 Body parsing function for /channels/{channelId}/moh. More...
 
static void ast_ari_channels_start_silence_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/silence. More...
 
static void ast_ari_channels_stop_moh_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/moh. More...
 
static void ast_ari_channels_stop_silence_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/silence. More...
 
static void ast_ari_channels_transfer_progress_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/transfer_progress. More...
 
int ast_ari_channels_transfer_progress_parse_body (struct ast_json *body, struct ast_ari_channels_transfer_progress_args *args)
 Body parsing function for /channels/{channelId}/transfer_progress. More...
 
static void ast_ari_channels_unhold_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/hold. More...
 
static void ast_ari_channels_unmute_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 Parameter parsing callback for /channels/{channelId}/mute. More...
 
int ast_ari_channels_unmute_parse_body (struct ast_json *body, struct ast_ari_channels_unmute_args *args)
 Body parsing function for /channels/{channelId}/mute. More...
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "RESTful API module - Channel resources" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_ari,res_ari_model,res_stasis,res_stasis_answer,res_stasis_playback,res_stasis_recording,res_stasis_snoop", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct stasis_rest_handlers channels
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_answer
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_continue
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_dial
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_dtmf
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_hold
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_moh
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_move
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_mute
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_play
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_play_playbackId
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_progress
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_record
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_redirect
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_ring
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_rtp_statistics
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_silence
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_snoop
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_snoop_snoopId
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_transfer_progress
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_channelId_variable
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_create
 REST handler for /api-docs/channels.json. More...
 
static struct stasis_rest_handlers channels_externalMedia
 REST handler for /api-docs/channels.json. More...
 

Detailed Description

Channel resources.

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m

Definition in file res_ari_channels.c.

Macro Definition Documentation

◆ MAX_VALS

#define MAX_VALS   128

Definition at line 55 of file res_ari_channels.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 3408 of file res_ari_channels.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 3408 of file res_ari_channels.c.

◆ ast_ari_channels_answer_cb()

static void ast_ari_channels_answer_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/answer.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 986 of file res_ari_channels.c.

990{
992 struct ast_variable *i;
993#if defined(AST_DEVMODE)
994 int is_valid;
995 int code;
996#endif /* AST_DEVMODE */
997
998 for (i = path_vars; i; i = i->next) {
999 if (strcmp(i->name, "channelId") == 0) {
1000 args.channel_id = (i->value);
1001 } else
1002 {}
1003 }
1004 ast_ari_channels_answer(headers, &args, response);
1005#if defined(AST_DEVMODE)
1006 code = response->response_code;
1007
1008 switch (code) {
1009 case 0: /* Implementation is still a stub, or the code wasn't set */
1010 is_valid = response->message == NULL;
1011 break;
1012 case 500: /* Internal Server Error */
1013 case 501: /* Not Implemented */
1014 case 404: /* Channel not found */
1015 case 409: /* Channel not in a Stasis application */
1016 case 412: /* Channel in invalid state */
1017 is_valid = 1;
1018 break;
1019 default:
1020 if (200 <= code && code <= 299) {
1021 is_valid = ast_ari_validate_void(
1022 response->message);
1023 } else {
1024 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/answer\n", code);
1025 is_valid = 0;
1026 }
1027 }
1028
1029 if (!is_valid) {
1030 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/answer\n");
1031 ast_ari_response_error(response, 500,
1032 "Internal Server Error", "Response validation failed");
1033 }
1034#endif /* AST_DEVMODE */
1035
1036fin: __attribute__((unused))
1037 return;
1038}
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:212
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
Definition: res_ari_model.c:91
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
#define NULL
Definition: resample.c:96
void ast_ari_channels_answer(struct ast_variable *headers, struct ast_ari_channels_answer_args *args, struct ast_ari_response *response)
Answer a channel.
struct ast_json * message
Definition: ari.h:103
int response_code
Definition: ari.h:108
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
const char * args

References args, ast_ari_channels_answer(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_continue_in_dialplan_cb()

static void ast_ari_channels_continue_in_dialplan_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/continue.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 727 of file res_ari_channels.c.

731{
733 struct ast_variable *i;
734#if defined(AST_DEVMODE)
735 int is_valid;
736 int code;
737#endif /* AST_DEVMODE */
738
739 for (i = get_params; i; i = i->next) {
740 if (strcmp(i->name, "context") == 0) {
741 args.context = (i->value);
742 } else
743 if (strcmp(i->name, "extension") == 0) {
744 args.extension = (i->value);
745 } else
746 if (strcmp(i->name, "priority") == 0) {
747 args.priority = atoi(i->value);
748 } else
749 if (strcmp(i->name, "label") == 0) {
750 args.label = (i->value);
751 } else
752 {}
753 }
754 for (i = path_vars; i; i = i->next) {
755 if (strcmp(i->name, "channelId") == 0) {
756 args.channel_id = (i->value);
757 } else
758 {}
759 }
762 goto fin;
763 }
764 ast_ari_channels_continue_in_dialplan(headers, &args, response);
765#if defined(AST_DEVMODE)
766 code = response->response_code;
767
768 switch (code) {
769 case 0: /* Implementation is still a stub, or the code wasn't set */
770 is_valid = response->message == NULL;
771 break;
772 case 500: /* Internal Server Error */
773 case 501: /* Not Implemented */
774 case 404: /* Channel not found */
775 case 409: /* Channel not in a Stasis application */
776 case 412: /* Channel in invalid state */
777 is_valid = 1;
778 break;
779 default:
780 if (200 <= code && code <= 299) {
781 is_valid = ast_ari_validate_void(
782 response->message);
783 } else {
784 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/continue\n", code);
785 is_valid = 0;
786 }
787 }
788
789 if (!is_valid) {
790 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/continue\n");
791 ast_ari_response_error(response, 500,
792 "Internal Server Error", "Response validation failed");
793 }
794#endif /* AST_DEVMODE */
795
796fin: __attribute__((unused))
797 return;
798}
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:251
int ast_ari_channels_continue_in_dialplan_parse_body(struct ast_json *body, struct ast_ari_channels_continue_in_dialplan_args *args)
Body parsing function for /channels/{channelId}/continue.
void ast_ari_channels_continue_in_dialplan(struct ast_variable *headers, struct ast_ari_channels_continue_in_dialplan_args *args, struct ast_ari_response *response)
Exit application; continue execution in the dialplan.

References args, ast_ari_channels_continue_in_dialplan(), ast_ari_channels_continue_in_dialplan_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_continue_in_dialplan_parse_body()

int ast_ari_channels_continue_in_dialplan_parse_body ( struct ast_json body,
struct ast_ari_channels_continue_in_dialplan_args args 
)

Body parsing function for /channels/{channelId}/continue.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 693 of file res_ari_channels.c.

696{
697 struct ast_json *field;
698 /* Parse query parameters out of it */
699 field = ast_json_object_get(body, "context");
700 if (field) {
701 args->context = ast_json_string_get(field);
702 }
703 field = ast_json_object_get(body, "extension");
704 if (field) {
705 args->extension = ast_json_string_get(field);
706 }
707 field = ast_json_object_get(body, "priority");
708 if (field) {
709 args->priority = ast_json_integer_get(field);
710 }
711 field = ast_json_object_get(body, "label");
712 if (field) {
713 args->label = ast_json_string_get(field);
714 }
715 return 0;
716}
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
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:332
Abstract JSON element (object, array, string, int, ...).

References args, ast_json_integer_get(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_continue_in_dialplan_cb().

◆ ast_ari_channels_create_cb()

static void ast_ari_channels_create_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/create.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 314 of file res_ari_channels.c.

318{
320 struct ast_variable *i;
321#if defined(AST_DEVMODE)
322 int is_valid;
323 int code;
324#endif /* AST_DEVMODE */
325
326 for (i = get_params; i; i = i->next) {
327 if (strcmp(i->name, "endpoint") == 0) {
328 args.endpoint = (i->value);
329 } else
330 if (strcmp(i->name, "app") == 0) {
331 args.app = (i->value);
332 } else
333 if (strcmp(i->name, "appArgs") == 0) {
334 args.app_args = (i->value);
335 } else
336 if (strcmp(i->name, "channelId") == 0) {
337 args.channel_id = (i->value);
338 } else
339 if (strcmp(i->name, "otherChannelId") == 0) {
340 args.other_channel_id = (i->value);
341 } else
342 if (strcmp(i->name, "originator") == 0) {
343 args.originator = (i->value);
344 } else
345 if (strcmp(i->name, "formats") == 0) {
346 args.formats = (i->value);
347 } else
348 {}
349 }
350 args.variables = body;
351 ast_ari_channels_create(headers, &args, response);
352#if defined(AST_DEVMODE)
353 code = response->response_code;
354
355 switch (code) {
356 case 0: /* Implementation is still a stub, or the code wasn't set */
357 is_valid = response->message == NULL;
358 break;
359 case 500: /* Internal Server Error */
360 case 501: /* Not Implemented */
361 case 409: /* Channel with given unique ID already exists. */
362 is_valid = 1;
363 break;
364 default:
365 if (200 <= code && code <= 299) {
366 is_valid = ast_ari_validate_channel(
367 response->message);
368 } else {
369 ast_log(LOG_ERROR, "Invalid error response %d for /channels/create\n", code);
370 is_valid = 0;
371 }
372 }
373
374 if (!is_valid) {
375 ast_log(LOG_ERROR, "Response validation failed for /channels/create\n");
376 ast_ari_response_error(response, 500,
377 "Internal Server Error", "Response validation failed");
378 }
379#endif /* AST_DEVMODE */
380
381fin: __attribute__((unused))
382 return;
383}
int ast_ari_validate_channel(struct ast_json *json)
Validator for Channel.
void ast_ari_channels_create(struct ast_variable *headers, struct ast_ari_channels_create_args *args, struct ast_ari_response *response)
Create channel.

References args, ast_ari_channels_create(), ast_ari_response_error(), ast_ari_validate_channel(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_create_parse_body()

int ast_ari_channels_create_parse_body ( struct ast_json body,
struct ast_ari_channels_create_args args 
)

Body parsing function for /channels/create.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 268 of file res_ari_channels.c.

271{
272 struct ast_json *field;
273 /* Parse query parameters out of it */
274 field = ast_json_object_get(body, "endpoint");
275 if (field) {
276 args->endpoint = ast_json_string_get(field);
277 }
278 field = ast_json_object_get(body, "app");
279 if (field) {
280 args->app = ast_json_string_get(field);
281 }
282 field = ast_json_object_get(body, "appArgs");
283 if (field) {
284 args->app_args = ast_json_string_get(field);
285 }
286 field = ast_json_object_get(body, "channelId");
287 if (field) {
288 args->channel_id = ast_json_string_get(field);
289 }
290 field = ast_json_object_get(body, "otherChannelId");
291 if (field) {
292 args->other_channel_id = ast_json_string_get(field);
293 }
294 field = ast_json_object_get(body, "originator");
295 if (field) {
296 args->originator = ast_json_string_get(field);
297 }
298 field = ast_json_object_get(body, "formats");
299 if (field) {
300 args->formats = ast_json_string_get(field);
301 }
302 return 0;
303}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_create().

◆ ast_ari_channels_dial_cb()

static void ast_ari_channels_dial_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/dial.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2811 of file res_ari_channels.c.

2815{
2816 struct ast_ari_channels_dial_args args = {};
2817 struct ast_variable *i;
2818#if defined(AST_DEVMODE)
2819 int is_valid;
2820 int code;
2821#endif /* AST_DEVMODE */
2822
2823 for (i = get_params; i; i = i->next) {
2824 if (strcmp(i->name, "caller") == 0) {
2825 args.caller = (i->value);
2826 } else
2827 if (strcmp(i->name, "timeout") == 0) {
2828 args.timeout = atoi(i->value);
2829 } else
2830 {}
2831 }
2832 for (i = path_vars; i; i = i->next) {
2833 if (strcmp(i->name, "channelId") == 0) {
2834 args.channel_id = (i->value);
2835 } else
2836 {}
2837 }
2840 goto fin;
2841 }
2842 ast_ari_channels_dial(headers, &args, response);
2843#if defined(AST_DEVMODE)
2844 code = response->response_code;
2845
2846 switch (code) {
2847 case 0: /* Implementation is still a stub, or the code wasn't set */
2848 is_valid = response->message == NULL;
2849 break;
2850 case 500: /* Internal Server Error */
2851 case 501: /* Not Implemented */
2852 case 404: /* Channel cannot be found. */
2853 case 409: /* Channel cannot be dialed. */
2854 is_valid = 1;
2855 break;
2856 default:
2857 if (200 <= code && code <= 299) {
2858 is_valid = ast_ari_validate_void(
2859 response->message);
2860 } else {
2861 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/dial\n", code);
2862 is_valid = 0;
2863 }
2864 }
2865
2866 if (!is_valid) {
2867 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/dial\n");
2868 ast_ari_response_error(response, 500,
2869 "Internal Server Error", "Response validation failed");
2870 }
2871#endif /* AST_DEVMODE */
2872
2873fin: __attribute__((unused))
2874 return;
2875}
int ast_ari_channels_dial_parse_body(struct ast_json *body, struct ast_ari_channels_dial_args *args)
Body parsing function for /channels/{channelId}/dial.
void ast_ari_channels_dial(struct ast_variable *headers, struct ast_ari_channels_dial_args *args, struct ast_ari_response *response)
Dial a created channel.

References args, ast_ari_channels_dial(), ast_ari_channels_dial_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_dial_parse_body()

int ast_ari_channels_dial_parse_body ( struct ast_json body,
struct ast_ari_channels_dial_args args 
)

Body parsing function for /channels/{channelId}/dial.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2785 of file res_ari_channels.c.

2788{
2789 struct ast_json *field;
2790 /* Parse query parameters out of it */
2791 field = ast_json_object_get(body, "caller");
2792 if (field) {
2793 args->caller = ast_json_string_get(field);
2794 }
2795 field = ast_json_object_get(body, "timeout");
2796 if (field) {
2797 args->timeout = ast_json_integer_get(field);
2798 }
2799 return 0;
2800}

References args, ast_json_integer_get(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_dial_cb().

◆ ast_ari_channels_external_media_cb()

static void ast_ari_channels_external_media_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/externalMedia.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2990 of file res_ari_channels.c.

2994{
2996 struct ast_variable *i;
2997#if defined(AST_DEVMODE)
2998 int is_valid;
2999 int code;
3000#endif /* AST_DEVMODE */
3001
3002 for (i = get_params; i; i = i->next) {
3003 if (strcmp(i->name, "channelId") == 0) {
3004 args.channel_id = (i->value);
3005 } else
3006 if (strcmp(i->name, "app") == 0) {
3007 args.app = (i->value);
3008 } else
3009 if (strcmp(i->name, "external_host") == 0) {
3010 args.external_host = (i->value);
3011 } else
3012 if (strcmp(i->name, "encapsulation") == 0) {
3013 args.encapsulation = (i->value);
3014 } else
3015 if (strcmp(i->name, "transport") == 0) {
3016 args.transport = (i->value);
3017 } else
3018 if (strcmp(i->name, "connection_type") == 0) {
3019 args.connection_type = (i->value);
3020 } else
3021 if (strcmp(i->name, "format") == 0) {
3022 args.format = (i->value);
3023 } else
3024 if (strcmp(i->name, "direction") == 0) {
3025 args.direction = (i->value);
3026 } else
3027 if (strcmp(i->name, "data") == 0) {
3028 args.data = (i->value);
3029 } else
3030 {}
3031 }
3032 args.variables = body;
3033 ast_ari_channels_external_media(headers, &args, response);
3034#if defined(AST_DEVMODE)
3035 code = response->response_code;
3036
3037 switch (code) {
3038 case 0: /* Implementation is still a stub, or the code wasn't set */
3039 is_valid = response->message == NULL;
3040 break;
3041 case 500: /* Internal Server Error */
3042 case 501: /* Not Implemented */
3043 case 400: /* Invalid parameters */
3044 case 409: /* Channel is not in a Stasis application; Channel is already bridged */
3045 is_valid = 1;
3046 break;
3047 default:
3048 if (200 <= code && code <= 299) {
3049 is_valid = ast_ari_validate_channel(
3050 response->message);
3051 } else {
3052 ast_log(LOG_ERROR, "Invalid error response %d for /channels/externalMedia\n", code);
3053 is_valid = 0;
3054 }
3055 }
3056
3057 if (!is_valid) {
3058 ast_log(LOG_ERROR, "Response validation failed for /channels/externalMedia\n");
3059 ast_ari_response_error(response, 500,
3060 "Internal Server Error", "Response validation failed");
3061 }
3062#endif /* AST_DEVMODE */
3063
3064fin: __attribute__((unused))
3065 return;
3066}
void ast_ari_channels_external_media(struct ast_variable *headers, struct ast_ari_channels_external_media_args *args, struct ast_ari_response *response)
Start an External Media session.

References args, ast_ari_channels_external_media(), ast_ari_response_error(), ast_ari_validate_channel(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_external_media_parse_body()

int ast_ari_channels_external_media_parse_body ( struct ast_json body,
struct ast_ari_channels_external_media_args args 
)

Body parsing function for /channels/externalMedia.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2936 of file res_ari_channels.c.

2939{
2940 struct ast_json *field;
2941 /* Parse query parameters out of it */
2942 field = ast_json_object_get(body, "channelId");
2943 if (field) {
2944 args->channel_id = ast_json_string_get(field);
2945 }
2946 field = ast_json_object_get(body, "app");
2947 if (field) {
2948 args->app = ast_json_string_get(field);
2949 }
2950 field = ast_json_object_get(body, "external_host");
2951 if (field) {
2952 args->external_host = ast_json_string_get(field);
2953 }
2954 field = ast_json_object_get(body, "encapsulation");
2955 if (field) {
2956 args->encapsulation = ast_json_string_get(field);
2957 }
2958 field = ast_json_object_get(body, "transport");
2959 if (field) {
2960 args->transport = ast_json_string_get(field);
2961 }
2962 field = ast_json_object_get(body, "connection_type");
2963 if (field) {
2964 args->connection_type = ast_json_string_get(field);
2965 }
2966 field = ast_json_object_get(body, "format");
2967 if (field) {
2968 args->format = ast_json_string_get(field);
2969 }
2970 field = ast_json_object_get(body, "direction");
2971 if (field) {
2972 args->direction = ast_json_string_get(field);
2973 }
2974 field = ast_json_object_get(body, "data");
2975 if (field) {
2976 args->data = ast_json_string_get(field);
2977 }
2978 return 0;
2979}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_external_media().

◆ ast_ari_channels_get_cb()

static void ast_ari_channels_get_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 393 of file res_ari_channels.c.

397{
399 struct ast_variable *i;
400#if defined(AST_DEVMODE)
401 int is_valid;
402 int code;
403#endif /* AST_DEVMODE */
404
405 for (i = path_vars; i; i = i->next) {
406 if (strcmp(i->name, "channelId") == 0) {
407 args.channel_id = (i->value);
408 } else
409 {}
410 }
411 ast_ari_channels_get(headers, &args, response);
412#if defined(AST_DEVMODE)
413 code = response->response_code;
414
415 switch (code) {
416 case 0: /* Implementation is still a stub, or the code wasn't set */
417 is_valid = response->message == NULL;
418 break;
419 case 500: /* Internal Server Error */
420 case 501: /* Not Implemented */
421 case 404: /* Channel not found */
422 is_valid = 1;
423 break;
424 default:
425 if (200 <= code && code <= 299) {
426 is_valid = ast_ari_validate_channel(
427 response->message);
428 } else {
429 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
430 is_valid = 0;
431 }
432 }
433
434 if (!is_valid) {
435 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
436 ast_ari_response_error(response, 500,
437 "Internal Server Error", "Response validation failed");
438 }
439#endif /* AST_DEVMODE */
440
441fin: __attribute__((unused))
442 return;
443}
void ast_ari_channels_get(struct ast_variable *headers, struct ast_ari_channels_get_args *args, struct ast_ari_response *response)
Channel details.

References args, ast_ari_channels_get(), ast_ari_response_error(), ast_ari_validate_channel(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_get_channel_var_cb()

static void ast_ari_channels_get_channel_var_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/variable.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2410 of file res_ari_channels.c.

2414{
2416 struct ast_variable *i;
2417#if defined(AST_DEVMODE)
2418 int is_valid;
2419 int code;
2420#endif /* AST_DEVMODE */
2421
2422 for (i = get_params; i; i = i->next) {
2423 if (strcmp(i->name, "variable") == 0) {
2424 args.variable = (i->value);
2425 } else
2426 {}
2427 }
2428 for (i = path_vars; i; i = i->next) {
2429 if (strcmp(i->name, "channelId") == 0) {
2430 args.channel_id = (i->value);
2431 } else
2432 {}
2433 }
2436 goto fin;
2437 }
2438 ast_ari_channels_get_channel_var(headers, &args, response);
2439#if defined(AST_DEVMODE)
2440 code = response->response_code;
2441
2442 switch (code) {
2443 case 0: /* Implementation is still a stub, or the code wasn't set */
2444 is_valid = response->message == NULL;
2445 break;
2446 case 500: /* Internal Server Error */
2447 case 501: /* Not Implemented */
2448 case 400: /* Missing variable parameter. */
2449 case 404: /* Channel or variable not found */
2450 case 409: /* Channel not in a Stasis application */
2451 is_valid = 1;
2452 break;
2453 default:
2454 if (200 <= code && code <= 299) {
2455 is_valid = ast_ari_validate_variable(
2456 response->message);
2457 } else {
2458 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/variable\n", code);
2459 is_valid = 0;
2460 }
2461 }
2462
2463 if (!is_valid) {
2464 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/variable\n");
2465 ast_ari_response_error(response, 500,
2466 "Internal Server Error", "Response validation failed");
2467 }
2468#endif /* AST_DEVMODE */
2469
2470fin: __attribute__((unused))
2471 return;
2472}
int ast_ari_validate_variable(struct ast_json *json)
Validator for Variable.
int ast_ari_channels_get_channel_var_parse_body(struct ast_json *body, struct ast_ari_channels_get_channel_var_args *args)
Body parsing function for /channels/{channelId}/variable.
void ast_ari_channels_get_channel_var(struct ast_variable *headers, struct ast_ari_channels_get_channel_var_args *args, struct ast_ari_response *response)
Get the value of a channel variable or function.

References args, ast_ari_channels_get_channel_var(), ast_ari_channels_get_channel_var_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_variable(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_get_channel_var_parse_body()

int ast_ari_channels_get_channel_var_parse_body ( struct ast_json body,
struct ast_ari_channels_get_channel_var_args args 
)

Body parsing function for /channels/{channelId}/variable.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2388 of file res_ari_channels.c.

2391{
2392 struct ast_json *field;
2393 /* Parse query parameters out of it */
2394 field = ast_json_object_get(body, "variable");
2395 if (field) {
2396 args->variable = ast_json_string_get(field);
2397 }
2398 return 0;
2399}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_get_channel_var_cb().

◆ ast_ari_channels_hangup_cb()

static void ast_ari_channels_hangup_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 628 of file res_ari_channels.c.

632{
634 struct ast_variable *i;
635#if defined(AST_DEVMODE)
636 int is_valid;
637 int code;
638#endif /* AST_DEVMODE */
639
640 for (i = get_params; i; i = i->next) {
641 if (strcmp(i->name, "reason_code") == 0) {
642 args.reason_code = (i->value);
643 } else
644 if (strcmp(i->name, "reason") == 0) {
645 args.reason = (i->value);
646 } else
647 {}
648 }
649 for (i = path_vars; i; i = i->next) {
650 if (strcmp(i->name, "channelId") == 0) {
651 args.channel_id = (i->value);
652 } else
653 {}
654 }
657 goto fin;
658 }
659 ast_ari_channels_hangup(headers, &args, response);
660#if defined(AST_DEVMODE)
661 code = response->response_code;
662
663 switch (code) {
664 case 0: /* Implementation is still a stub, or the code wasn't set */
665 is_valid = response->message == NULL;
666 break;
667 case 500: /* Internal Server Error */
668 case 501: /* Not Implemented */
669 case 400: /* Invalid reason for hangup provided */
670 case 404: /* Channel not found */
671 is_valid = 1;
672 break;
673 default:
674 if (200 <= code && code <= 299) {
675 is_valid = ast_ari_validate_void(
676 response->message);
677 } else {
678 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
679 is_valid = 0;
680 }
681 }
682
683 if (!is_valid) {
684 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
685 ast_ari_response_error(response, 500,
686 "Internal Server Error", "Response validation failed");
687 }
688#endif /* AST_DEVMODE */
689
690fin: __attribute__((unused))
691 return;
692}
int ast_ari_channels_hangup_parse_body(struct ast_json *body, struct ast_ari_channels_hangup_args *args)
Body parsing function for /channels/{channelId}.
void ast_ari_channels_hangup(struct ast_variable *headers, struct ast_ari_channels_hangup_args *args, struct ast_ari_response *response)
Delete (i.e. hangup) a channel.

References args, ast_ari_channels_hangup(), ast_ari_channels_hangup_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_hangup_parse_body()

int ast_ari_channels_hangup_parse_body ( struct ast_json body,
struct ast_ari_channels_hangup_args args 
)

Body parsing function for /channels/{channelId}.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 602 of file res_ari_channels.c.

605{
606 struct ast_json *field;
607 /* Parse query parameters out of it */
608 field = ast_json_object_get(body, "reason_code");
609 if (field) {
610 args->reason_code = ast_json_string_get(field);
611 }
612 field = ast_json_object_get(body, "reason");
613 if (field) {
614 args->reason = ast_json_string_get(field);
615 }
616 return 0;
617}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_hangup_cb().

◆ ast_ari_channels_hold_cb()

static void ast_ari_channels_hold_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/hold.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1518 of file res_ari_channels.c.

1522{
1523 struct ast_ari_channels_hold_args args = {};
1524 struct ast_variable *i;
1525#if defined(AST_DEVMODE)
1526 int is_valid;
1527 int code;
1528#endif /* AST_DEVMODE */
1529
1530 for (i = path_vars; i; i = i->next) {
1531 if (strcmp(i->name, "channelId") == 0) {
1532 args.channel_id = (i->value);
1533 } else
1534 {}
1535 }
1536 ast_ari_channels_hold(headers, &args, response);
1537#if defined(AST_DEVMODE)
1538 code = response->response_code;
1539
1540 switch (code) {
1541 case 0: /* Implementation is still a stub, or the code wasn't set */
1542 is_valid = response->message == NULL;
1543 break;
1544 case 500: /* Internal Server Error */
1545 case 501: /* Not Implemented */
1546 case 404: /* Channel not found */
1547 case 409: /* Channel not in a Stasis application */
1548 case 412: /* Channel in invalid state */
1549 is_valid = 1;
1550 break;
1551 default:
1552 if (200 <= code && code <= 299) {
1553 is_valid = ast_ari_validate_void(
1554 response->message);
1555 } else {
1556 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/hold\n", code);
1557 is_valid = 0;
1558 }
1559 }
1560
1561 if (!is_valid) {
1562 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/hold\n");
1563 ast_ari_response_error(response, 500,
1564 "Internal Server Error", "Response validation failed");
1565 }
1566#endif /* AST_DEVMODE */
1567
1568fin: __attribute__((unused))
1569 return;
1570}
void ast_ari_channels_hold(struct ast_variable *headers, struct ast_ari_channels_hold_args *args, struct ast_ari_response *response)
Hold a channel.

References args, ast_ari_channels_hold(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_list_cb()

static void ast_ari_channels_list_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 66 of file res_ari_channels.c.

70{
72#if defined(AST_DEVMODE)
73 int is_valid;
74 int code;
75#endif /* AST_DEVMODE */
76
77 ast_ari_channels_list(headers, &args, response);
78#if defined(AST_DEVMODE)
79 code = response->response_code;
80
81 switch (code) {
82 case 0: /* Implementation is still a stub, or the code wasn't set */
83 is_valid = response->message == NULL;
84 break;
85 case 500: /* Internal Server Error */
86 case 501: /* Not Implemented */
87 is_valid = 1;
88 break;
89 default:
90 if (200 <= code && code <= 299) {
91 is_valid = ast_ari_validate_list(response->message,
93 } else {
94 ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
95 is_valid = 0;
96 }
97 }
98
99 if (!is_valid) {
100 ast_log(LOG_ERROR, "Response validation failed for /channels\n");
101 ast_ari_response_error(response, 500,
102 "Internal Server Error", "Response validation failed");
103 }
104#endif /* AST_DEVMODE */
105
106fin: __attribute__((unused))
107 return;
108}
ari_validator ast_ari_validate_channel_fn(void)
Function pointer to ast_ari_validate_channel().
int ast_ari_validate_list(struct ast_json *json, int(*fn)(struct ast_json *))
Validator for a Swagger List[]/JSON array.
void ast_ari_channels_list(struct ast_variable *headers, struct ast_ari_channels_list_args *args, struct ast_ari_response *response)
List all active channels in Asterisk.

References args, ast_ari_channels_list(), ast_ari_response_error(), ast_ari_validate_channel_fn(), ast_ari_validate_list(), ast_log, LOG_ERROR, ast_ari_response::message, NULL, and ast_ari_response::response_code.

◆ ast_ari_channels_move_cb()

static void ast_ari_channels_move_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/move.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 825 of file res_ari_channels.c.

829{
831 struct ast_variable *i;
832#if defined(AST_DEVMODE)
833 int is_valid;
834 int code;
835#endif /* AST_DEVMODE */
836
837 for (i = get_params; i; i = i->next) {
838 if (strcmp(i->name, "app") == 0) {
839 args.app = (i->value);
840 } else
841 if (strcmp(i->name, "appArgs") == 0) {
842 args.app_args = (i->value);
843 } else
844 {}
845 }
846 for (i = path_vars; i; i = i->next) {
847 if (strcmp(i->name, "channelId") == 0) {
848 args.channel_id = (i->value);
849 } else
850 {}
851 }
854 goto fin;
855 }
856 ast_ari_channels_move(headers, &args, response);
857#if defined(AST_DEVMODE)
858 code = response->response_code;
859
860 switch (code) {
861 case 0: /* Implementation is still a stub, or the code wasn't set */
862 is_valid = response->message == NULL;
863 break;
864 case 500: /* Internal Server Error */
865 case 501: /* Not Implemented */
866 case 404: /* Channel not found */
867 case 409: /* Channel not in a Stasis application */
868 is_valid = 1;
869 break;
870 default:
871 if (200 <= code && code <= 299) {
872 is_valid = ast_ari_validate_void(
873 response->message);
874 } else {
875 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/move\n", code);
876 is_valid = 0;
877 }
878 }
879
880 if (!is_valid) {
881 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/move\n");
882 ast_ari_response_error(response, 500,
883 "Internal Server Error", "Response validation failed");
884 }
885#endif /* AST_DEVMODE */
886
887fin: __attribute__((unused))
888 return;
889}
int ast_ari_channels_move_parse_body(struct ast_json *body, struct ast_ari_channels_move_args *args)
Body parsing function for /channels/{channelId}/move.
void ast_ari_channels_move(struct ast_variable *headers, struct ast_ari_channels_move_args *args, struct ast_ari_response *response)
Move the channel from one Stasis application to another.

References args, ast_ari_channels_move(), ast_ari_channels_move_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_move_parse_body()

int ast_ari_channels_move_parse_body ( struct ast_json body,
struct ast_ari_channels_move_args args 
)

Body parsing function for /channels/{channelId}/move.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 799 of file res_ari_channels.c.

802{
803 struct ast_json *field;
804 /* Parse query parameters out of it */
805 field = ast_json_object_get(body, "app");
806 if (field) {
807 args->app = ast_json_string_get(field);
808 }
809 field = ast_json_object_get(body, "appArgs");
810 if (field) {
811 args->app_args = ast_json_string_get(field);
812 }
813 return 0;
814}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_move_cb().

◆ ast_ari_channels_mute_cb()

static void ast_ari_channels_mute_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/mute.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1361 of file res_ari_channels.c.

1365{
1366 struct ast_ari_channels_mute_args args = {};
1367 struct ast_variable *i;
1368#if defined(AST_DEVMODE)
1369 int is_valid;
1370 int code;
1371#endif /* AST_DEVMODE */
1372
1373 for (i = get_params; i; i = i->next) {
1374 if (strcmp(i->name, "direction") == 0) {
1375 args.direction = (i->value);
1376 } else
1377 {}
1378 }
1379 for (i = path_vars; i; i = i->next) {
1380 if (strcmp(i->name, "channelId") == 0) {
1381 args.channel_id = (i->value);
1382 } else
1383 {}
1384 }
1387 goto fin;
1388 }
1389 ast_ari_channels_mute(headers, &args, response);
1390#if defined(AST_DEVMODE)
1391 code = response->response_code;
1392
1393 switch (code) {
1394 case 0: /* Implementation is still a stub, or the code wasn't set */
1395 is_valid = response->message == NULL;
1396 break;
1397 case 500: /* Internal Server Error */
1398 case 501: /* Not Implemented */
1399 case 404: /* Channel not found */
1400 case 409: /* Channel not in a Stasis application */
1401 case 412: /* Channel in invalid state */
1402 is_valid = 1;
1403 break;
1404 default:
1405 if (200 <= code && code <= 299) {
1406 is_valid = ast_ari_validate_void(
1407 response->message);
1408 } else {
1409 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/mute\n", code);
1410 is_valid = 0;
1411 }
1412 }
1413
1414 if (!is_valid) {
1415 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mute\n");
1416 ast_ari_response_error(response, 500,
1417 "Internal Server Error", "Response validation failed");
1418 }
1419#endif /* AST_DEVMODE */
1420
1421fin: __attribute__((unused))
1422 return;
1423}
int ast_ari_channels_mute_parse_body(struct ast_json *body, struct ast_ari_channels_mute_args *args)
Body parsing function for /channels/{channelId}/mute.
void ast_ari_channels_mute(struct ast_variable *headers, struct ast_ari_channels_mute_args *args, struct ast_ari_response *response)
Mute a channel.

References args, ast_ari_channels_mute(), ast_ari_channels_mute_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_mute_parse_body()

int ast_ari_channels_mute_parse_body ( struct ast_json body,
struct ast_ari_channels_mute_args args 
)

Body parsing function for /channels/{channelId}/mute.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1339 of file res_ari_channels.c.

1342{
1343 struct ast_json *field;
1344 /* Parse query parameters out of it */
1345 field = ast_json_object_get(body, "direction");
1346 if (field) {
1347 args->direction = ast_json_string_get(field);
1348 }
1349 return 0;
1350}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_mute_cb().

◆ ast_ari_channels_originate_cb()

static void ast_ari_channels_originate_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 179 of file res_ari_channels.c.

183{
185 struct ast_variable *i;
186#if defined(AST_DEVMODE)
187 int is_valid;
188 int code;
189#endif /* AST_DEVMODE */
190
191 for (i = get_params; i; i = i->next) {
192 if (strcmp(i->name, "endpoint") == 0) {
193 args.endpoint = (i->value);
194 } else
195 if (strcmp(i->name, "extension") == 0) {
196 args.extension = (i->value);
197 } else
198 if (strcmp(i->name, "context") == 0) {
199 args.context = (i->value);
200 } else
201 if (strcmp(i->name, "priority") == 0) {
202 args.priority = atol(i->value);
203 } else
204 if (strcmp(i->name, "label") == 0) {
205 args.label = (i->value);
206 } else
207 if (strcmp(i->name, "app") == 0) {
208 args.app = (i->value);
209 } else
210 if (strcmp(i->name, "appArgs") == 0) {
211 args.app_args = (i->value);
212 } else
213 if (strcmp(i->name, "callerId") == 0) {
214 args.caller_id = (i->value);
215 } else
216 if (strcmp(i->name, "timeout") == 0) {
217 args.timeout = atoi(i->value);
218 } else
219 if (strcmp(i->name, "channelId") == 0) {
220 args.channel_id = (i->value);
221 } else
222 if (strcmp(i->name, "otherChannelId") == 0) {
223 args.other_channel_id = (i->value);
224 } else
225 if (strcmp(i->name, "originator") == 0) {
226 args.originator = (i->value);
227 } else
228 if (strcmp(i->name, "formats") == 0) {
229 args.formats = (i->value);
230 } else
231 {}
232 }
233 args.variables = body;
234 ast_ari_channels_originate(headers, &args, response);
235#if defined(AST_DEVMODE)
236 code = response->response_code;
237
238 switch (code) {
239 case 0: /* Implementation is still a stub, or the code wasn't set */
240 is_valid = response->message == NULL;
241 break;
242 case 500: /* Internal Server Error */
243 case 501: /* Not Implemented */
244 case 400: /* Invalid parameters for originating a channel. */
245 case 409: /* Channel with given unique ID already exists. */
246 is_valid = 1;
247 break;
248 default:
249 if (200 <= code && code <= 299) {
250 is_valid = ast_ari_validate_channel(
251 response->message);
252 } else {
253 ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
254 is_valid = 0;
255 }
256 }
257
258 if (!is_valid) {
259 ast_log(LOG_ERROR, "Response validation failed for /channels\n");
260 ast_ari_response_error(response, 500,
261 "Internal Server Error", "Response validation failed");
262 }
263#endif /* AST_DEVMODE */
264
265fin: __attribute__((unused))
266 return;
267}
void ast_ari_channels_originate(struct ast_variable *headers, struct ast_ari_channels_originate_args *args, struct ast_ari_response *response)
Create a new channel (originate).

References args, ast_ari_channels_originate(), ast_ari_response_error(), ast_ari_validate_channel(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_originate_parse_body()

int ast_ari_channels_originate_parse_body ( struct ast_json body,
struct ast_ari_channels_originate_args args 
)

Body parsing function for /channels.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 109 of file res_ari_channels.c.

112{
113 struct ast_json *field;
114 /* Parse query parameters out of it */
115 field = ast_json_object_get(body, "endpoint");
116 if (field) {
117 args->endpoint = ast_json_string_get(field);
118 }
119 field = ast_json_object_get(body, "extension");
120 if (field) {
121 args->extension = ast_json_string_get(field);
122 }
123 field = ast_json_object_get(body, "context");
124 if (field) {
125 args->context = ast_json_string_get(field);
126 }
127 field = ast_json_object_get(body, "priority");
128 if (field) {
129 args->priority = ast_json_integer_get(field);
130 }
131 field = ast_json_object_get(body, "label");
132 if (field) {
133 args->label = ast_json_string_get(field);
134 }
135 field = ast_json_object_get(body, "app");
136 if (field) {
137 args->app = ast_json_string_get(field);
138 }
139 field = ast_json_object_get(body, "appArgs");
140 if (field) {
141 args->app_args = ast_json_string_get(field);
142 }
143 field = ast_json_object_get(body, "callerId");
144 if (field) {
145 args->caller_id = ast_json_string_get(field);
146 }
147 field = ast_json_object_get(body, "timeout");
148 if (field) {
149 args->timeout = ast_json_integer_get(field);
150 }
151 field = ast_json_object_get(body, "channelId");
152 if (field) {
153 args->channel_id = ast_json_string_get(field);
154 }
155 field = ast_json_object_get(body, "otherChannelId");
156 if (field) {
157 args->other_channel_id = ast_json_string_get(field);
158 }
159 field = ast_json_object_get(body, "originator");
160 if (field) {
161 args->originator = ast_json_string_get(field);
162 }
163 field = ast_json_object_get(body, "formats");
164 if (field) {
165 args->formats = ast_json_string_get(field);
166 }
167 return 0;
168}

References args, ast_json_integer_get(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_originate().

◆ ast_ari_channels_originate_with_id_cb()

static void ast_ari_channels_originate_with_id_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 510 of file res_ari_channels.c.

514{
516 struct ast_variable *i;
517#if defined(AST_DEVMODE)
518 int is_valid;
519 int code;
520#endif /* AST_DEVMODE */
521
522 for (i = get_params; i; i = i->next) {
523 if (strcmp(i->name, "endpoint") == 0) {
524 args.endpoint = (i->value);
525 } else
526 if (strcmp(i->name, "extension") == 0) {
527 args.extension = (i->value);
528 } else
529 if (strcmp(i->name, "context") == 0) {
530 args.context = (i->value);
531 } else
532 if (strcmp(i->name, "priority") == 0) {
533 args.priority = atol(i->value);
534 } else
535 if (strcmp(i->name, "label") == 0) {
536 args.label = (i->value);
537 } else
538 if (strcmp(i->name, "app") == 0) {
539 args.app = (i->value);
540 } else
541 if (strcmp(i->name, "appArgs") == 0) {
542 args.app_args = (i->value);
543 } else
544 if (strcmp(i->name, "callerId") == 0) {
545 args.caller_id = (i->value);
546 } else
547 if (strcmp(i->name, "timeout") == 0) {
548 args.timeout = atoi(i->value);
549 } else
550 if (strcmp(i->name, "otherChannelId") == 0) {
551 args.other_channel_id = (i->value);
552 } else
553 if (strcmp(i->name, "originator") == 0) {
554 args.originator = (i->value);
555 } else
556 if (strcmp(i->name, "formats") == 0) {
557 args.formats = (i->value);
558 } else
559 {}
560 }
561 for (i = path_vars; i; i = i->next) {
562 if (strcmp(i->name, "channelId") == 0) {
563 args.channel_id = (i->value);
564 } else
565 {}
566 }
567 args.variables = body;
568 ast_ari_channels_originate_with_id(headers, &args, response);
569#if defined(AST_DEVMODE)
570 code = response->response_code;
571
572 switch (code) {
573 case 0: /* Implementation is still a stub, or the code wasn't set */
574 is_valid = response->message == NULL;
575 break;
576 case 500: /* Internal Server Error */
577 case 501: /* Not Implemented */
578 case 400: /* Invalid parameters for originating a channel. */
579 case 409: /* Channel with given unique ID already exists. */
580 is_valid = 1;
581 break;
582 default:
583 if (200 <= code && code <= 299) {
584 is_valid = ast_ari_validate_channel(
585 response->message);
586 } else {
587 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
588 is_valid = 0;
589 }
590 }
591
592 if (!is_valid) {
593 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
594 ast_ari_response_error(response, 500,
595 "Internal Server Error", "Response validation failed");
596 }
597#endif /* AST_DEVMODE */
598
599fin: __attribute__((unused))
600 return;
601}
void ast_ari_channels_originate_with_id(struct ast_variable *headers, struct ast_ari_channels_originate_with_id_args *args, struct ast_ari_response *response)
Create a new channel (originate with id).

References args, ast_ari_channels_originate_with_id(), ast_ari_response_error(), ast_ari_validate_channel(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_originate_with_id_parse_body()

int ast_ari_channels_originate_with_id_parse_body ( struct ast_json body,
struct ast_ari_channels_originate_with_id_args args 
)

Body parsing function for /channels/{channelId}.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 444 of file res_ari_channels.c.

447{
448 struct ast_json *field;
449 /* Parse query parameters out of it */
450 field = ast_json_object_get(body, "endpoint");
451 if (field) {
452 args->endpoint = ast_json_string_get(field);
453 }
454 field = ast_json_object_get(body, "extension");
455 if (field) {
456 args->extension = ast_json_string_get(field);
457 }
458 field = ast_json_object_get(body, "context");
459 if (field) {
460 args->context = ast_json_string_get(field);
461 }
462 field = ast_json_object_get(body, "priority");
463 if (field) {
464 args->priority = ast_json_integer_get(field);
465 }
466 field = ast_json_object_get(body, "label");
467 if (field) {
468 args->label = ast_json_string_get(field);
469 }
470 field = ast_json_object_get(body, "app");
471 if (field) {
472 args->app = ast_json_string_get(field);
473 }
474 field = ast_json_object_get(body, "appArgs");
475 if (field) {
476 args->app_args = ast_json_string_get(field);
477 }
478 field = ast_json_object_get(body, "callerId");
479 if (field) {
480 args->caller_id = ast_json_string_get(field);
481 }
482 field = ast_json_object_get(body, "timeout");
483 if (field) {
484 args->timeout = ast_json_integer_get(field);
485 }
486 field = ast_json_object_get(body, "otherChannelId");
487 if (field) {
488 args->other_channel_id = ast_json_string_get(field);
489 }
490 field = ast_json_object_get(body, "originator");
491 if (field) {
492 args->originator = ast_json_string_get(field);
493 }
494 field = ast_json_object_get(body, "formats");
495 if (field) {
496 args->formats = ast_json_string_get(field);
497 }
498 return 0;
499}

References args, ast_json_integer_get(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_originate_with_id().

◆ ast_ari_channels_play_cb()

static void ast_ari_channels_play_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/play.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1967 of file res_ari_channels.c.

1971{
1972 struct ast_ari_channels_play_args args = {};
1973 struct ast_variable *i;
1974#if defined(AST_DEVMODE)
1975 int is_valid;
1976 int code;
1977#endif /* AST_DEVMODE */
1978
1979 for (i = get_params; i; i = i->next) {
1980 if (strcmp(i->name, "media") == 0) {
1981 /* Parse comma separated list */
1982 char *vals[MAX_VALS];
1983 size_t j;
1984
1985 args.media_parse = ast_strdup(i->value);
1986 if (!args.media_parse) {
1988 goto fin;
1989 }
1990
1991 if (strlen(args.media_parse) == 0) {
1992 /* ast_app_separate_args can't handle "" */
1993 args.media_count = 1;
1994 vals[0] = args.media_parse;
1995 } else {
1996 args.media_count = ast_app_separate_args(
1997 args.media_parse, ',', vals,
1998 ARRAY_LEN(vals));
1999 }
2000
2001 if (args.media_count == 0) {
2003 goto fin;
2004 }
2005
2006 if (args.media_count >= MAX_VALS) {
2007 ast_ari_response_error(response, 400,
2008 "Bad Request",
2009 "Too many values for media");
2010 goto fin;
2011 }
2012
2013 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
2014 if (!args.media) {
2016 goto fin;
2017 }
2018
2019 for (j = 0; j < args.media_count; ++j) {
2020 args.media[j] = (vals[j]);
2021 }
2022 } else
2023 if (strcmp(i->name, "lang") == 0) {
2024 args.lang = (i->value);
2025 } else
2026 if (strcmp(i->name, "offsetms") == 0) {
2027 args.offsetms = atoi(i->value);
2028 } else
2029 if (strcmp(i->name, "skipms") == 0) {
2030 args.skipms = atoi(i->value);
2031 } else
2032 if (strcmp(i->name, "playbackId") == 0) {
2033 args.playback_id = (i->value);
2034 } else
2035 {}
2036 }
2037 for (i = path_vars; i; i = i->next) {
2038 if (strcmp(i->name, "channelId") == 0) {
2039 args.channel_id = (i->value);
2040 } else
2041 {}
2042 }
2045 goto fin;
2046 }
2047 ast_ari_channels_play(headers, &args, response);
2048#if defined(AST_DEVMODE)
2049 code = response->response_code;
2050
2051 switch (code) {
2052 case 0: /* Implementation is still a stub, or the code wasn't set */
2053 is_valid = response->message == NULL;
2054 break;
2055 case 500: /* Internal Server Error */
2056 case 501: /* Not Implemented */
2057 case 404: /* Channel not found */
2058 case 409: /* Channel not in a Stasis application */
2059 case 412: /* Channel in invalid state */
2060 is_valid = 1;
2061 break;
2062 default:
2063 if (200 <= code && code <= 299) {
2064 is_valid = ast_ari_validate_playback(
2065 response->message);
2066 } else {
2067 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/play\n", code);
2068 is_valid = 0;
2069 }
2070 }
2071
2072 if (!is_valid) {
2073 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/play\n");
2074 ast_ari_response_error(response, 500,
2075 "Internal Server Error", "Response validation failed");
2076 }
2077#endif /* AST_DEVMODE */
2078
2079fin: __attribute__((unused))
2080 ast_free(args.media_parse);
2081 ast_free(args.media);
2082 return;
2083}
int ast_ari_validate_playback(struct ast_json *json)
Validator for Playback.
#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_app_separate_args(a, b, c, d)
#define MAX_VALS
int ast_ari_channels_play_parse_body(struct ast_json *body, struct ast_ari_channels_play_args *args)
Body parsing function for /channels/{channelId}/play.
void ast_ari_channels_play(struct ast_variable *headers, struct ast_ari_channels_play_args *args, struct ast_ari_response *response)
Start playback of media.
#define ARRAY_LEN(a)
Definition: utils.h:703

References args, ARRAY_LEN, ast_app_separate_args, ast_ari_channels_play(), ast_ari_channels_play_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_playback(), ast_free, ast_log, ast_malloc, ast_strdup, LOG_ERROR, MAX_VALS, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_play_parse_body()

int ast_ari_channels_play_parse_body ( struct ast_json body,
struct ast_ari_channels_play_args args 
)

Body parsing function for /channels/{channelId}/play.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1904 of file res_ari_channels.c.

1907{
1908 struct ast_json *field;
1909 /* Parse query parameters out of it */
1910 field = ast_json_object_get(body, "media");
1911 if (field) {
1912 /* If they were silly enough to both pass in a query param and a
1913 * JSON body, free up the query value.
1914 */
1915 ast_free(args->media);
1916 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
1917 /* Multiple param passed as array */
1918 size_t i;
1919 args->media_count = ast_json_array_size(field);
1920 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1921
1922 if (!args->media) {
1923 return -1;
1924 }
1925
1926 for (i = 0; i < args->media_count; ++i) {
1927 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
1928 }
1929 } else {
1930 /* Multiple param passed as single value */
1931 args->media_count = 1;
1932 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
1933 if (!args->media) {
1934 return -1;
1935 }
1936 args->media[0] = ast_json_string_get(field);
1937 }
1938 }
1939 field = ast_json_object_get(body, "lang");
1940 if (field) {
1941 args->lang = ast_json_string_get(field);
1942 }
1943 field = ast_json_object_get(body, "offsetms");
1944 if (field) {
1945 args->offsetms = ast_json_integer_get(field);
1946 }
1947 field = ast_json_object_get(body, "skipms");
1948 if (field) {
1949 args->skipms = ast_json_integer_get(field);
1950 }
1951 field = ast_json_object_get(body, "playbackId");
1952 if (field) {
1953 args->playback_id = ast_json_string_get(field);
1954 }
1955 return 0;
1956}
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
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Definition: json.c:366

References args, ast_free, AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_json_typeof(), and ast_malloc.

Referenced by ast_ari_channels_play_cb().

◆ ast_ari_channels_play_with_id_cb()

static void ast_ari_channels_play_with_id_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/play/{playbackId}.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2143 of file res_ari_channels.c.

2147{
2149 struct ast_variable *i;
2150#if defined(AST_DEVMODE)
2151 int is_valid;
2152 int code;
2153#endif /* AST_DEVMODE */
2154
2155 for (i = get_params; i; i = i->next) {
2156 if (strcmp(i->name, "media") == 0) {
2157 /* Parse comma separated list */
2158 char *vals[MAX_VALS];
2159 size_t j;
2160
2161 args.media_parse = ast_strdup(i->value);
2162 if (!args.media_parse) {
2164 goto fin;
2165 }
2166
2167 if (strlen(args.media_parse) == 0) {
2168 /* ast_app_separate_args can't handle "" */
2169 args.media_count = 1;
2170 vals[0] = args.media_parse;
2171 } else {
2172 args.media_count = ast_app_separate_args(
2173 args.media_parse, ',', vals,
2174 ARRAY_LEN(vals));
2175 }
2176
2177 if (args.media_count == 0) {
2179 goto fin;
2180 }
2181
2182 if (args.media_count >= MAX_VALS) {
2183 ast_ari_response_error(response, 400,
2184 "Bad Request",
2185 "Too many values for media");
2186 goto fin;
2187 }
2188
2189 args.media = ast_malloc(sizeof(*args.media) * args.media_count);
2190 if (!args.media) {
2192 goto fin;
2193 }
2194
2195 for (j = 0; j < args.media_count; ++j) {
2196 args.media[j] = (vals[j]);
2197 }
2198 } else
2199 if (strcmp(i->name, "lang") == 0) {
2200 args.lang = (i->value);
2201 } else
2202 if (strcmp(i->name, "offsetms") == 0) {
2203 args.offsetms = atoi(i->value);
2204 } else
2205 if (strcmp(i->name, "skipms") == 0) {
2206 args.skipms = atoi(i->value);
2207 } else
2208 {}
2209 }
2210 for (i = path_vars; i; i = i->next) {
2211 if (strcmp(i->name, "channelId") == 0) {
2212 args.channel_id = (i->value);
2213 } else
2214 if (strcmp(i->name, "playbackId") == 0) {
2215 args.playback_id = (i->value);
2216 } else
2217 {}
2218 }
2221 goto fin;
2222 }
2223 ast_ari_channels_play_with_id(headers, &args, response);
2224#if defined(AST_DEVMODE)
2225 code = response->response_code;
2226
2227 switch (code) {
2228 case 0: /* Implementation is still a stub, or the code wasn't set */
2229 is_valid = response->message == NULL;
2230 break;
2231 case 500: /* Internal Server Error */
2232 case 501: /* Not Implemented */
2233 case 404: /* Channel not found */
2234 case 409: /* Channel not in a Stasis application */
2235 case 412: /* Channel in invalid state */
2236 is_valid = 1;
2237 break;
2238 default:
2239 if (200 <= code && code <= 299) {
2240 is_valid = ast_ari_validate_playback(
2241 response->message);
2242 } else {
2243 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/play/{playbackId}\n", code);
2244 is_valid = 0;
2245 }
2246 }
2247
2248 if (!is_valid) {
2249 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/play/{playbackId}\n");
2250 ast_ari_response_error(response, 500,
2251 "Internal Server Error", "Response validation failed");
2252 }
2253#endif /* AST_DEVMODE */
2254
2255fin: __attribute__((unused))
2256 ast_free(args.media_parse);
2257 ast_free(args.media);
2258 return;
2259}
int ast_ari_channels_play_with_id_parse_body(struct ast_json *body, struct ast_ari_channels_play_with_id_args *args)
Body parsing function for /channels/{channelId}/play/{playbackId}.
void ast_ari_channels_play_with_id(struct ast_variable *headers, struct ast_ari_channels_play_with_id_args *args, struct ast_ari_response *response)
Start playback of media and specify the playbackId.

References args, ARRAY_LEN, ast_app_separate_args, ast_ari_channels_play_with_id(), ast_ari_channels_play_with_id_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_playback(), ast_free, ast_log, ast_malloc, ast_strdup, LOG_ERROR, MAX_VALS, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_play_with_id_parse_body()

int ast_ari_channels_play_with_id_parse_body ( struct ast_json body,
struct ast_ari_channels_play_with_id_args args 
)

Body parsing function for /channels/{channelId}/play/{playbackId}.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2084 of file res_ari_channels.c.

2087{
2088 struct ast_json *field;
2089 /* Parse query parameters out of it */
2090 field = ast_json_object_get(body, "media");
2091 if (field) {
2092 /* If they were silly enough to both pass in a query param and a
2093 * JSON body, free up the query value.
2094 */
2095 ast_free(args->media);
2096 if (ast_json_typeof(field) == AST_JSON_ARRAY) {
2097 /* Multiple param passed as array */
2098 size_t i;
2099 args->media_count = ast_json_array_size(field);
2100 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
2101
2102 if (!args->media) {
2103 return -1;
2104 }
2105
2106 for (i = 0; i < args->media_count; ++i) {
2107 args->media[i] = ast_json_string_get(ast_json_array_get(field, i));
2108 }
2109 } else {
2110 /* Multiple param passed as single value */
2111 args->media_count = 1;
2112 args->media = ast_malloc(sizeof(*args->media) * args->media_count);
2113 if (!args->media) {
2114 return -1;
2115 }
2116 args->media[0] = ast_json_string_get(field);
2117 }
2118 }
2119 field = ast_json_object_get(body, "lang");
2120 if (field) {
2121 args->lang = ast_json_string_get(field);
2122 }
2123 field = ast_json_object_get(body, "offsetms");
2124 if (field) {
2125 args->offsetms = ast_json_integer_get(field);
2126 }
2127 field = ast_json_object_get(body, "skipms");
2128 if (field) {
2129 args->skipms = ast_json_integer_get(field);
2130 }
2131 return 0;
2132}

References args, ast_free, AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_json_typeof(), and ast_malloc.

Referenced by ast_ari_channels_play_with_id_cb().

◆ ast_ari_channels_progress_cb()

static void ast_ari_channels_progress_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 
)
static

Parameter parsing callback for /channels/{channelId}/progress.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1172 of file res_ari_channels.c.

1176{
1178 struct ast_variable *i;
1179#if defined(AST_DEVMODE)
1180 int is_valid;
1181 int code;
1182#endif /* AST_DEVMODE */
1183
1184 for (i = path_vars; i; i = i->next) {
1185 if (strcmp(i->name, "channelId") == 0) {
1186 args.channel_id = (i->value);
1187 } else
1188 {}
1189 }
1190 ast_ari_channels_progress(headers, &args, response);
1191#if defined(AST_DEVMODE)
1192 code = response->response_code;
1193
1194 switch (code) {
1195 case 0: /* Implementation is still a stub, or the code wasn't set */
1196 is_valid = response->message == NULL;
1197 break;
1198 case 500: /* Internal Server Error */
1199 case 501: /* Not Implemented */
1200 case 404: /* Channel not found */
1201 case 409: /* Channel not in a Stasis application */
1202 case 412: /* Channel in invalid state */
1203 is_valid = 1;
1204 break;
1205 default:
1206 if (200 <= code && code <= 299) {
1207 is_valid = ast_ari_validate_void(
1208 response->message);
1209 } else {
1210 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/progress\n", code);
1211 is_valid = 0;
1212 }
1213 }
1214
1215 if (!is_valid) {
1216 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/progress\n");
1217 ast_ari_response_error(response, 500,
1218 "Internal Server Error", "Response validation failed");
1219 }
1220#endif /* AST_DEVMODE */
1221
1222fin: __attribute__((unused))
1223 return;
1224}
void ast_ari_channels_progress(struct ast_variable *headers, struct ast_ari_channels_progress_args *args, struct ast_ari_response *response)
Indicate progress on a channel.

References args, ast_ari_channels_progress(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_record_cb()

static void ast_ari_channels_record_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/record.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2306 of file res_ari_channels.c.

2310{
2312 struct ast_variable *i;
2313#if defined(AST_DEVMODE)
2314 int is_valid;
2315 int code;
2316#endif /* AST_DEVMODE */
2317
2318 for (i = get_params; i; i = i->next) {
2319 if (strcmp(i->name, "name") == 0) {
2320 args.name = (i->value);
2321 } else
2322 if (strcmp(i->name, "format") == 0) {
2323 args.format = (i->value);
2324 } else
2325 if (strcmp(i->name, "maxDurationSeconds") == 0) {
2326 args.max_duration_seconds = atoi(i->value);
2327 } else
2328 if (strcmp(i->name, "maxSilenceSeconds") == 0) {
2329 args.max_silence_seconds = atoi(i->value);
2330 } else
2331 if (strcmp(i->name, "ifExists") == 0) {
2332 args.if_exists = (i->value);
2333 } else
2334 if (strcmp(i->name, "beep") == 0) {
2335 args.beep = ast_true(i->value);
2336 } else
2337 if (strcmp(i->name, "terminateOn") == 0) {
2338 args.terminate_on = (i->value);
2339 } else
2340 {}
2341 }
2342 for (i = path_vars; i; i = i->next) {
2343 if (strcmp(i->name, "channelId") == 0) {
2344 args.channel_id = (i->value);
2345 } else
2346 {}
2347 }
2350 goto fin;
2351 }
2352 ast_ari_channels_record(headers, &args, response);
2353#if defined(AST_DEVMODE)
2354 code = response->response_code;
2355
2356 switch (code) {
2357 case 0: /* Implementation is still a stub, or the code wasn't set */
2358 is_valid = response->message == NULL;
2359 break;
2360 case 500: /* Internal Server Error */
2361 case 501: /* Not Implemented */
2362 case 400: /* Invalid parameters */
2363 case 404: /* Channel not found */
2364 case 409: /* Channel is not in a Stasis application; the channel is currently bridged with other channels; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
2365 case 422: /* The format specified is unknown on this system */
2366 is_valid = 1;
2367 break;
2368 default:
2369 if (200 <= code && code <= 299) {
2371 response->message);
2372 } else {
2373 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/record\n", code);
2374 is_valid = 0;
2375 }
2376 }
2377
2378 if (!is_valid) {
2379 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/record\n");
2380 ast_ari_response_error(response, 500,
2381 "Internal Server Error", "Response validation failed");
2382 }
2383#endif /* AST_DEVMODE */
2384
2385fin: __attribute__((unused))
2386 return;
2387}
int ast_ari_validate_live_recording(struct ast_json *json)
Validator for LiveRecording.
int ast_ari_channels_record_parse_body(struct ast_json *body, struct ast_ari_channels_record_args *args)
Body parsing function for /channels/{channelId}/record.
void ast_ari_channels_record(struct ast_variable *headers, struct ast_ari_channels_record_args *args, struct ast_ari_response *response)
Start a recording.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: utils.c:2235

References args, ast_ari_channels_record(), ast_ari_channels_record_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_live_recording(), ast_log, ast_true(), LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_record_parse_body()

int ast_ari_channels_record_parse_body ( struct ast_json body,
struct ast_ari_channels_record_args args 
)

Body parsing function for /channels/{channelId}/record.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2260 of file res_ari_channels.c.

2263{
2264 struct ast_json *field;
2265 /* Parse query parameters out of it */
2266 field = ast_json_object_get(body, "name");
2267 if (field) {
2268 args->name = ast_json_string_get(field);
2269 }
2270 field = ast_json_object_get(body, "format");
2271 if (field) {
2272 args->format = ast_json_string_get(field);
2273 }
2274 field = ast_json_object_get(body, "maxDurationSeconds");
2275 if (field) {
2276 args->max_duration_seconds = ast_json_integer_get(field);
2277 }
2278 field = ast_json_object_get(body, "maxSilenceSeconds");
2279 if (field) {
2280 args->max_silence_seconds = ast_json_integer_get(field);
2281 }
2282 field = ast_json_object_get(body, "ifExists");
2283 if (field) {
2284 args->if_exists = ast_json_string_get(field);
2285 }
2286 field = ast_json_object_get(body, "beep");
2287 if (field) {
2288 args->beep = ast_json_is_true(field);
2289 }
2290 field = ast_json_object_get(body, "terminateOn");
2291 if (field) {
2292 args->terminate_on = ast_json_string_get(field);
2293 }
2294 return 0;
2295}
int ast_json_is_true(const struct ast_json *value)
Check if value is JSON true.
Definition: json.c:263

References args, ast_json_integer_get(), ast_json_is_true(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_record_cb().

◆ ast_ari_channels_redirect_cb()

static void ast_ari_channels_redirect_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/redirect.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 912 of file res_ari_channels.c.

916{
918 struct ast_variable *i;
919#if defined(AST_DEVMODE)
920 int is_valid;
921 int code;
922#endif /* AST_DEVMODE */
923
924 for (i = get_params; i; i = i->next) {
925 if (strcmp(i->name, "endpoint") == 0) {
926 args.endpoint = (i->value);
927 } else
928 {}
929 }
930 for (i = path_vars; i; i = i->next) {
931 if (strcmp(i->name, "channelId") == 0) {
932 args.channel_id = (i->value);
933 } else
934 {}
935 }
938 goto fin;
939 }
940 ast_ari_channels_redirect(headers, &args, response);
941#if defined(AST_DEVMODE)
942 code = response->response_code;
943
944 switch (code) {
945 case 0: /* Implementation is still a stub, or the code wasn't set */
946 is_valid = response->message == NULL;
947 break;
948 case 500: /* Internal Server Error */
949 case 501: /* Not Implemented */
950 case 400: /* Endpoint parameter not provided */
951 case 404: /* Channel or endpoint not found */
952 case 409: /* Channel not in a Stasis application */
953 case 422: /* Endpoint is not the same type as the channel */
954 case 412: /* Channel in invalid state */
955 is_valid = 1;
956 break;
957 default:
958 if (200 <= code && code <= 299) {
959 is_valid = ast_ari_validate_void(
960 response->message);
961 } else {
962 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/redirect\n", code);
963 is_valid = 0;
964 }
965 }
966
967 if (!is_valid) {
968 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/redirect\n");
969 ast_ari_response_error(response, 500,
970 "Internal Server Error", "Response validation failed");
971 }
972#endif /* AST_DEVMODE */
973
974fin: __attribute__((unused))
975 return;
976}
int ast_ari_channels_redirect_parse_body(struct ast_json *body, struct ast_ari_channels_redirect_args *args)
Body parsing function for /channels/{channelId}/redirect.
void ast_ari_channels_redirect(struct ast_variable *headers, struct ast_ari_channels_redirect_args *args, struct ast_ari_response *response)
Redirect the channel to a different location.

References args, ast_ari_channels_redirect(), ast_ari_channels_redirect_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_redirect_parse_body()

int ast_ari_channels_redirect_parse_body ( struct ast_json body,
struct ast_ari_channels_redirect_args args 
)

Body parsing function for /channels/{channelId}/redirect.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 890 of file res_ari_channels.c.

893{
894 struct ast_json *field;
895 /* Parse query parameters out of it */
896 field = ast_json_object_get(body, "endpoint");
897 if (field) {
898 args->endpoint = ast_json_string_get(field);
899 }
900 return 0;
901}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_redirect_cb().

◆ ast_ari_channels_ring_cb()

static void ast_ari_channels_ring_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/ring.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1048 of file res_ari_channels.c.

1052{
1053 struct ast_ari_channels_ring_args args = {};
1054 struct ast_variable *i;
1055#if defined(AST_DEVMODE)
1056 int is_valid;
1057 int code;
1058#endif /* AST_DEVMODE */
1059
1060 for (i = path_vars; i; i = i->next) {
1061 if (strcmp(i->name, "channelId") == 0) {
1062 args.channel_id = (i->value);
1063 } else
1064 {}
1065 }
1066 ast_ari_channels_ring(headers, &args, response);
1067#if defined(AST_DEVMODE)
1068 code = response->response_code;
1069
1070 switch (code) {
1071 case 0: /* Implementation is still a stub, or the code wasn't set */
1072 is_valid = response->message == NULL;
1073 break;
1074 case 500: /* Internal Server Error */
1075 case 501: /* Not Implemented */
1076 case 404: /* Channel not found */
1077 case 409: /* Channel not in a Stasis application */
1078 case 412: /* Channel in invalid state */
1079 is_valid = 1;
1080 break;
1081 default:
1082 if (200 <= code && code <= 299) {
1083 is_valid = ast_ari_validate_void(
1084 response->message);
1085 } else {
1086 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/ring\n", code);
1087 is_valid = 0;
1088 }
1089 }
1090
1091 if (!is_valid) {
1092 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/ring\n");
1093 ast_ari_response_error(response, 500,
1094 "Internal Server Error", "Response validation failed");
1095 }
1096#endif /* AST_DEVMODE */
1097
1098fin: __attribute__((unused))
1099 return;
1100}
void ast_ari_channels_ring(struct ast_variable *headers, struct ast_ari_channels_ring_args *args, struct ast_ari_response *response)
Indicate ringing to a channel.

References args, ast_ari_channels_ring(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_ring_stop_cb()

static void ast_ari_channels_ring_stop_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/ring.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1110 of file res_ari_channels.c.

1114{
1116 struct ast_variable *i;
1117#if defined(AST_DEVMODE)
1118 int is_valid;
1119 int code;
1120#endif /* AST_DEVMODE */
1121
1122 for (i = path_vars; i; i = i->next) {
1123 if (strcmp(i->name, "channelId") == 0) {
1124 args.channel_id = (i->value);
1125 } else
1126 {}
1127 }
1128 ast_ari_channels_ring_stop(headers, &args, response);
1129#if defined(AST_DEVMODE)
1130 code = response->response_code;
1131
1132 switch (code) {
1133 case 0: /* Implementation is still a stub, or the code wasn't set */
1134 is_valid = response->message == NULL;
1135 break;
1136 case 500: /* Internal Server Error */
1137 case 501: /* Not Implemented */
1138 case 404: /* Channel not found */
1139 case 409: /* Channel not in a Stasis application */
1140 case 412: /* Channel in invalid state */
1141 is_valid = 1;
1142 break;
1143 default:
1144 if (200 <= code && code <= 299) {
1145 is_valid = ast_ari_validate_void(
1146 response->message);
1147 } else {
1148 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/ring\n", code);
1149 is_valid = 0;
1150 }
1151 }
1152
1153 if (!is_valid) {
1154 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/ring\n");
1155 ast_ari_response_error(response, 500,
1156 "Internal Server Error", "Response validation failed");
1157 }
1158#endif /* AST_DEVMODE */
1159
1160fin: __attribute__((unused))
1161 return;
1162}
void ast_ari_channels_ring_stop(struct ast_variable *headers, struct ast_ari_channels_ring_stop_args *args, struct ast_ari_response *response)
Stop ringing indication on a channel if locally generated.

References args, ast_ari_channels_ring_stop(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_rtpstatistics_cb()

static void ast_ari_channels_rtpstatistics_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/rtp_statistics.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2885 of file res_ari_channels.c.

2889{
2891 struct ast_variable *i;
2892#if defined(AST_DEVMODE)
2893 int is_valid;
2894 int code;
2895#endif /* AST_DEVMODE */
2896
2897 for (i = path_vars; i; i = i->next) {
2898 if (strcmp(i->name, "channelId") == 0) {
2899 args.channel_id = (i->value);
2900 } else
2901 {}
2902 }
2903 ast_ari_channels_rtpstatistics(headers, &args, response);
2904#if defined(AST_DEVMODE)
2905 code = response->response_code;
2906
2907 switch (code) {
2908 case 0: /* Implementation is still a stub, or the code wasn't set */
2909 is_valid = response->message == NULL;
2910 break;
2911 case 500: /* Internal Server Error */
2912 case 501: /* Not Implemented */
2913 case 404: /* Channel cannot be found. */
2914 is_valid = 1;
2915 break;
2916 default:
2917 if (200 <= code && code <= 299) {
2918 is_valid = ast_ari_validate_rtpstat(
2919 response->message);
2920 } else {
2921 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/rtp_statistics\n", code);
2922 is_valid = 0;
2923 }
2924 }
2925
2926 if (!is_valid) {
2927 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/rtp_statistics\n");
2928 ast_ari_response_error(response, 500,
2929 "Internal Server Error", "Response validation failed");
2930 }
2931#endif /* AST_DEVMODE */
2932
2933fin: __attribute__((unused))
2934 return;
2935}
int ast_ari_validate_rtpstat(struct ast_json *json)
Validator for RTPstat.
void ast_ari_channels_rtpstatistics(struct ast_variable *headers, struct ast_ari_channels_rtpstatistics_args *args, struct ast_ari_response *response)
RTP stats on a channel.

References args, ast_ari_channels_rtpstatistics(), ast_ari_response_error(), ast_ari_validate_rtpstat(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_send_dtmf_cb()

static void ast_ari_channels_send_dtmf_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/dtmf.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1263 of file res_ari_channels.c.

1267{
1269 struct ast_variable *i;
1270#if defined(AST_DEVMODE)
1271 int is_valid;
1272 int code;
1273#endif /* AST_DEVMODE */
1274
1275 for (i = get_params; i; i = i->next) {
1276 if (strcmp(i->name, "dtmf") == 0) {
1277 args.dtmf = (i->value);
1278 } else
1279 if (strcmp(i->name, "before") == 0) {
1280 args.before = atoi(i->value);
1281 } else
1282 if (strcmp(i->name, "between") == 0) {
1283 args.between = atoi(i->value);
1284 } else
1285 if (strcmp(i->name, "duration") == 0) {
1286 args.duration = atoi(i->value);
1287 } else
1288 if (strcmp(i->name, "after") == 0) {
1289 args.after = atoi(i->value);
1290 } else
1291 {}
1292 }
1293 for (i = path_vars; i; i = i->next) {
1294 if (strcmp(i->name, "channelId") == 0) {
1295 args.channel_id = (i->value);
1296 } else
1297 {}
1298 }
1301 goto fin;
1302 }
1303 ast_ari_channels_send_dtmf(headers, &args, response);
1304#if defined(AST_DEVMODE)
1305 code = response->response_code;
1306
1307 switch (code) {
1308 case 0: /* Implementation is still a stub, or the code wasn't set */
1309 is_valid = response->message == NULL;
1310 break;
1311 case 500: /* Internal Server Error */
1312 case 501: /* Not Implemented */
1313 case 400: /* DTMF is required */
1314 case 404: /* Channel not found */
1315 case 409: /* Channel not in a Stasis application */
1316 case 412: /* Channel in invalid state */
1317 is_valid = 1;
1318 break;
1319 default:
1320 if (200 <= code && code <= 299) {
1321 is_valid = ast_ari_validate_void(
1322 response->message);
1323 } else {
1324 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/dtmf\n", code);
1325 is_valid = 0;
1326 }
1327 }
1328
1329 if (!is_valid) {
1330 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/dtmf\n");
1331 ast_ari_response_error(response, 500,
1332 "Internal Server Error", "Response validation failed");
1333 }
1334#endif /* AST_DEVMODE */
1335
1336fin: __attribute__((unused))
1337 return;
1338}
int ast_ari_channels_send_dtmf_parse_body(struct ast_json *body, struct ast_ari_channels_send_dtmf_args *args)
Body parsing function for /channels/{channelId}/dtmf.
void ast_ari_channels_send_dtmf(struct ast_variable *headers, struct ast_ari_channels_send_dtmf_args *args, struct ast_ari_response *response)
Send provided DTMF to a given channel.

References args, ast_ari_channels_send_dtmf(), ast_ari_channels_send_dtmf_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_send_dtmf_parse_body()

int ast_ari_channels_send_dtmf_parse_body ( struct ast_json body,
struct ast_ari_channels_send_dtmf_args args 
)

Body parsing function for /channels/{channelId}/dtmf.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1225 of file res_ari_channels.c.

1228{
1229 struct ast_json *field;
1230 /* Parse query parameters out of it */
1231 field = ast_json_object_get(body, "dtmf");
1232 if (field) {
1233 args->dtmf = ast_json_string_get(field);
1234 }
1235 field = ast_json_object_get(body, "before");
1236 if (field) {
1237 args->before = ast_json_integer_get(field);
1238 }
1239 field = ast_json_object_get(body, "between");
1240 if (field) {
1241 args->between = ast_json_integer_get(field);
1242 }
1243 field = ast_json_object_get(body, "duration");
1244 if (field) {
1245 args->duration = ast_json_integer_get(field);
1246 }
1247 field = ast_json_object_get(body, "after");
1248 if (field) {
1249 args->after = ast_json_integer_get(field);
1250 }
1251 return 0;
1252}

References args, ast_json_integer_get(), ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_send_dtmf_cb().

◆ ast_ari_channels_set_channel_var_cb()

static void ast_ari_channels_set_channel_var_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/variable.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2499 of file res_ari_channels.c.

2503{
2505 struct ast_variable *i;
2506#if defined(AST_DEVMODE)
2507 int is_valid;
2508 int code;
2509#endif /* AST_DEVMODE */
2510
2511 for (i = get_params; i; i = i->next) {
2512 if (strcmp(i->name, "variable") == 0) {
2513 args.variable = (i->value);
2514 } else
2515 if (strcmp(i->name, "value") == 0) {
2516 args.value = (i->value);
2517 } else
2518 {}
2519 }
2520 for (i = path_vars; i; i = i->next) {
2521 if (strcmp(i->name, "channelId") == 0) {
2522 args.channel_id = (i->value);
2523 } else
2524 {}
2525 }
2528 goto fin;
2529 }
2530 ast_ari_channels_set_channel_var(headers, &args, response);
2531#if defined(AST_DEVMODE)
2532 code = response->response_code;
2533
2534 switch (code) {
2535 case 0: /* Implementation is still a stub, or the code wasn't set */
2536 is_valid = response->message == NULL;
2537 break;
2538 case 500: /* Internal Server Error */
2539 case 501: /* Not Implemented */
2540 case 400: /* Missing variable parameter. */
2541 case 404: /* Channel not found */
2542 case 409: /* Channel not in a Stasis application */
2543 is_valid = 1;
2544 break;
2545 default:
2546 if (200 <= code && code <= 299) {
2547 is_valid = ast_ari_validate_void(
2548 response->message);
2549 } else {
2550 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/variable\n", code);
2551 is_valid = 0;
2552 }
2553 }
2554
2555 if (!is_valid) {
2556 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/variable\n");
2557 ast_ari_response_error(response, 500,
2558 "Internal Server Error", "Response validation failed");
2559 }
2560#endif /* AST_DEVMODE */
2561
2562fin: __attribute__((unused))
2563 return;
2564}
int ast_ari_channels_set_channel_var_parse_body(struct ast_json *body, struct ast_ari_channels_set_channel_var_args *args)
Body parsing function for /channels/{channelId}/variable.
void ast_ari_channels_set_channel_var(struct ast_variable *headers, struct ast_ari_channels_set_channel_var_args *args, struct ast_ari_response *response)
Set the value of a channel variable or function.

References args, ast_ari_channels_set_channel_var(), ast_ari_channels_set_channel_var_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_set_channel_var_parse_body()

int ast_ari_channels_set_channel_var_parse_body ( struct ast_json body,
struct ast_ari_channels_set_channel_var_args args 
)

Body parsing function for /channels/{channelId}/variable.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2473 of file res_ari_channels.c.

2476{
2477 struct ast_json *field;
2478 /* Parse query parameters out of it */
2479 field = ast_json_object_get(body, "variable");
2480 if (field) {
2481 args->variable = ast_json_string_get(field);
2482 }
2483 field = ast_json_object_get(body, "value");
2484 if (field) {
2485 args->value = ast_json_string_get(field);
2486 }
2487 return 0;
2488}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_set_channel_var_cb().

◆ ast_ari_channels_snoop_channel_cb()

static void ast_ari_channels_snoop_channel_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/snoop.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2603 of file res_ari_channels.c.

2607{
2609 struct ast_variable *i;
2610#if defined(AST_DEVMODE)
2611 int is_valid;
2612 int code;
2613#endif /* AST_DEVMODE */
2614
2615 for (i = get_params; i; i = i->next) {
2616 if (strcmp(i->name, "spy") == 0) {
2617 args.spy = (i->value);
2618 } else
2619 if (strcmp(i->name, "whisper") == 0) {
2620 args.whisper = (i->value);
2621 } else
2622 if (strcmp(i->name, "app") == 0) {
2623 args.app = (i->value);
2624 } else
2625 if (strcmp(i->name, "appArgs") == 0) {
2626 args.app_args = (i->value);
2627 } else
2628 if (strcmp(i->name, "snoopId") == 0) {
2629 args.snoop_id = (i->value);
2630 } else
2631 {}
2632 }
2633 for (i = path_vars; i; i = i->next) {
2634 if (strcmp(i->name, "channelId") == 0) {
2635 args.channel_id = (i->value);
2636 } else
2637 {}
2638 }
2641 goto fin;
2642 }
2643 ast_ari_channels_snoop_channel(headers, &args, response);
2644#if defined(AST_DEVMODE)
2645 code = response->response_code;
2646
2647 switch (code) {
2648 case 0: /* Implementation is still a stub, or the code wasn't set */
2649 is_valid = response->message == NULL;
2650 break;
2651 case 500: /* Internal Server Error */
2652 case 501: /* Not Implemented */
2653 case 400: /* Invalid parameters */
2654 case 404: /* Channel not found */
2655 is_valid = 1;
2656 break;
2657 default:
2658 if (200 <= code && code <= 299) {
2659 is_valid = ast_ari_validate_channel(
2660 response->message);
2661 } else {
2662 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/snoop\n", code);
2663 is_valid = 0;
2664 }
2665 }
2666
2667 if (!is_valid) {
2668 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/snoop\n");
2669 ast_ari_response_error(response, 500,
2670 "Internal Server Error", "Response validation failed");
2671 }
2672#endif /* AST_DEVMODE */
2673
2674fin: __attribute__((unused))
2675 return;
2676}
int ast_ari_channels_snoop_channel_parse_body(struct ast_json *body, struct ast_ari_channels_snoop_channel_args *args)
Body parsing function for /channels/{channelId}/snoop.
void ast_ari_channels_snoop_channel(struct ast_variable *headers, struct ast_ari_channels_snoop_channel_args *args, struct ast_ari_response *response)
Start snooping.

References args, ast_ari_channels_snoop_channel(), ast_ari_channels_snoop_channel_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_channel(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_snoop_channel_parse_body()

int ast_ari_channels_snoop_channel_parse_body ( struct ast_json body,
struct ast_ari_channels_snoop_channel_args args 
)

Body parsing function for /channels/{channelId}/snoop.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2565 of file res_ari_channels.c.

2568{
2569 struct ast_json *field;
2570 /* Parse query parameters out of it */
2571 field = ast_json_object_get(body, "spy");
2572 if (field) {
2573 args->spy = ast_json_string_get(field);
2574 }
2575 field = ast_json_object_get(body, "whisper");
2576 if (field) {
2577 args->whisper = ast_json_string_get(field);
2578 }
2579 field = ast_json_object_get(body, "app");
2580 if (field) {
2581 args->app = ast_json_string_get(field);
2582 }
2583 field = ast_json_object_get(body, "appArgs");
2584 if (field) {
2585 args->app_args = ast_json_string_get(field);
2586 }
2587 field = ast_json_object_get(body, "snoopId");
2588 if (field) {
2589 args->snoop_id = ast_json_string_get(field);
2590 }
2591 return 0;
2592}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_snoop_channel_cb().

◆ ast_ari_channels_snoop_channel_with_id_cb()

static void ast_ari_channels_snoop_channel_with_id_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/snoop/{snoopId}.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 2711 of file res_ari_channels.c.

2715{
2717 struct ast_variable *i;
2718#if defined(AST_DEVMODE)
2719 int is_valid;
2720 int code;
2721#endif /* AST_DEVMODE */
2722
2723 for (i = get_params; i; i = i->next) {
2724 if (strcmp(i->name, "spy") == 0) {
2725 args.spy = (i->value);
2726 } else
2727 if (strcmp(i->name, "whisper") == 0) {
2728 args.whisper = (i->value);
2729 } else
2730 if (strcmp(i->name, "app") == 0) {
2731 args.app = (i->value);
2732 } else
2733 if (strcmp(i->name, "appArgs") == 0) {
2734 args.app_args = (i->value);
2735 } else
2736 {}
2737 }
2738 for (i = path_vars; i; i = i->next) {
2739 if (strcmp(i->name, "channelId") == 0) {
2740 args.channel_id = (i->value);
2741 } else
2742 if (strcmp(i->name, "snoopId") == 0) {
2743 args.snoop_id = (i->value);
2744 } else
2745 {}
2746 }
2749 goto fin;
2750 }
2751 ast_ari_channels_snoop_channel_with_id(headers, &args, response);
2752#if defined(AST_DEVMODE)
2753 code = response->response_code;
2754
2755 switch (code) {
2756 case 0: /* Implementation is still a stub, or the code wasn't set */
2757 is_valid = response->message == NULL;
2758 break;
2759 case 500: /* Internal Server Error */
2760 case 501: /* Not Implemented */
2761 case 400: /* Invalid parameters */
2762 case 404: /* Channel not found */
2763 is_valid = 1;
2764 break;
2765 default:
2766 if (200 <= code && code <= 299) {
2767 is_valid = ast_ari_validate_channel(
2768 response->message);
2769 } else {
2770 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/snoop/{snoopId}\n", code);
2771 is_valid = 0;
2772 }
2773 }
2774
2775 if (!is_valid) {
2776 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/snoop/{snoopId}\n");
2777 ast_ari_response_error(response, 500,
2778 "Internal Server Error", "Response validation failed");
2779 }
2780#endif /* AST_DEVMODE */
2781
2782fin: __attribute__((unused))
2783 return;
2784}
int ast_ari_channels_snoop_channel_with_id_parse_body(struct ast_json *body, struct ast_ari_channels_snoop_channel_with_id_args *args)
Body parsing function for /channels/{channelId}/snoop/{snoopId}.
void ast_ari_channels_snoop_channel_with_id(struct ast_variable *headers, struct ast_ari_channels_snoop_channel_with_id_args *args, struct ast_ari_response *response)
Start snooping.

References args, ast_ari_channels_snoop_channel_with_id(), ast_ari_channels_snoop_channel_with_id_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_channel(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_snoop_channel_with_id_parse_body()

int ast_ari_channels_snoop_channel_with_id_parse_body ( struct ast_json body,
struct ast_ari_channels_snoop_channel_with_id_args args 
)

Body parsing function for /channels/{channelId}/snoop/{snoopId}.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 2677 of file res_ari_channels.c.

2680{
2681 struct ast_json *field;
2682 /* Parse query parameters out of it */
2683 field = ast_json_object_get(body, "spy");
2684 if (field) {
2685 args->spy = ast_json_string_get(field);
2686 }
2687 field = ast_json_object_get(body, "whisper");
2688 if (field) {
2689 args->whisper = ast_json_string_get(field);
2690 }
2691 field = ast_json_object_get(body, "app");
2692 if (field) {
2693 args->app = ast_json_string_get(field);
2694 }
2695 field = ast_json_object_get(body, "appArgs");
2696 if (field) {
2697 args->app_args = ast_json_string_get(field);
2698 }
2699 return 0;
2700}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_snoop_channel_with_id_cb().

◆ ast_ari_channels_start_moh_cb()

static void ast_ari_channels_start_moh_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/moh.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1655 of file res_ari_channels.c.

1659{
1661 struct ast_variable *i;
1662#if defined(AST_DEVMODE)
1663 int is_valid;
1664 int code;
1665#endif /* AST_DEVMODE */
1666
1667 for (i = get_params; i; i = i->next) {
1668 if (strcmp(i->name, "mohClass") == 0) {
1669 args.moh_class = (i->value);
1670 } else
1671 {}
1672 }
1673 for (i = path_vars; i; i = i->next) {
1674 if (strcmp(i->name, "channelId") == 0) {
1675 args.channel_id = (i->value);
1676 } else
1677 {}
1678 }
1681 goto fin;
1682 }
1683 ast_ari_channels_start_moh(headers, &args, response);
1684#if defined(AST_DEVMODE)
1685 code = response->response_code;
1686
1687 switch (code) {
1688 case 0: /* Implementation is still a stub, or the code wasn't set */
1689 is_valid = response->message == NULL;
1690 break;
1691 case 500: /* Internal Server Error */
1692 case 501: /* Not Implemented */
1693 case 404: /* Channel not found */
1694 case 409: /* Channel not in a Stasis application */
1695 case 412: /* Channel in invalid state */
1696 is_valid = 1;
1697 break;
1698 default:
1699 if (200 <= code && code <= 299) {
1700 is_valid = ast_ari_validate_void(
1701 response->message);
1702 } else {
1703 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/moh\n", code);
1704 is_valid = 0;
1705 }
1706 }
1707
1708 if (!is_valid) {
1709 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/moh\n");
1710 ast_ari_response_error(response, 500,
1711 "Internal Server Error", "Response validation failed");
1712 }
1713#endif /* AST_DEVMODE */
1714
1715fin: __attribute__((unused))
1716 return;
1717}
int ast_ari_channels_start_moh_parse_body(struct ast_json *body, struct ast_ari_channels_start_moh_args *args)
Body parsing function for /channels/{channelId}/moh.
void ast_ari_channels_start_moh(struct ast_variable *headers, struct ast_ari_channels_start_moh_args *args, struct ast_ari_response *response)
Play music on hold to a channel.

References args, ast_ari_channels_start_moh(), ast_ari_channels_start_moh_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_start_moh_parse_body()

int ast_ari_channels_start_moh_parse_body ( struct ast_json body,
struct ast_ari_channels_start_moh_args args 
)

Body parsing function for /channels/{channelId}/moh.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1633 of file res_ari_channels.c.

1636{
1637 struct ast_json *field;
1638 /* Parse query parameters out of it */
1639 field = ast_json_object_get(body, "mohClass");
1640 if (field) {
1641 args->moh_class = ast_json_string_get(field);
1642 }
1643 return 0;
1644}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_start_moh_cb().

◆ ast_ari_channels_start_silence_cb()

static void ast_ari_channels_start_silence_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/silence.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1789 of file res_ari_channels.c.

1793{
1795 struct ast_variable *i;
1796#if defined(AST_DEVMODE)
1797 int is_valid;
1798 int code;
1799#endif /* AST_DEVMODE */
1800
1801 for (i = path_vars; i; i = i->next) {
1802 if (strcmp(i->name, "channelId") == 0) {
1803 args.channel_id = (i->value);
1804 } else
1805 {}
1806 }
1807 ast_ari_channels_start_silence(headers, &args, response);
1808#if defined(AST_DEVMODE)
1809 code = response->response_code;
1810
1811 switch (code) {
1812 case 0: /* Implementation is still a stub, or the code wasn't set */
1813 is_valid = response->message == NULL;
1814 break;
1815 case 500: /* Internal Server Error */
1816 case 501: /* Not Implemented */
1817 case 404: /* Channel not found */
1818 case 409: /* Channel not in a Stasis application */
1819 case 412: /* Channel in invalid state */
1820 is_valid = 1;
1821 break;
1822 default:
1823 if (200 <= code && code <= 299) {
1824 is_valid = ast_ari_validate_void(
1825 response->message);
1826 } else {
1827 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/silence\n", code);
1828 is_valid = 0;
1829 }
1830 }
1831
1832 if (!is_valid) {
1833 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/silence\n");
1834 ast_ari_response_error(response, 500,
1835 "Internal Server Error", "Response validation failed");
1836 }
1837#endif /* AST_DEVMODE */
1838
1839fin: __attribute__((unused))
1840 return;
1841}
void ast_ari_channels_start_silence(struct ast_variable *headers, struct ast_ari_channels_start_silence_args *args, struct ast_ari_response *response)
Play silence to a channel.

References args, ast_ari_channels_start_silence(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_stop_moh_cb()

static void ast_ari_channels_stop_moh_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/moh.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1727 of file res_ari_channels.c.

1731{
1733 struct ast_variable *i;
1734#if defined(AST_DEVMODE)
1735 int is_valid;
1736 int code;
1737#endif /* AST_DEVMODE */
1738
1739 for (i = path_vars; i; i = i->next) {
1740 if (strcmp(i->name, "channelId") == 0) {
1741 args.channel_id = (i->value);
1742 } else
1743 {}
1744 }
1745 ast_ari_channels_stop_moh(headers, &args, response);
1746#if defined(AST_DEVMODE)
1747 code = response->response_code;
1748
1749 switch (code) {
1750 case 0: /* Implementation is still a stub, or the code wasn't set */
1751 is_valid = response->message == NULL;
1752 break;
1753 case 500: /* Internal Server Error */
1754 case 501: /* Not Implemented */
1755 case 404: /* Channel not found */
1756 case 409: /* Channel not in a Stasis application */
1757 case 412: /* Channel in invalid state */
1758 is_valid = 1;
1759 break;
1760 default:
1761 if (200 <= code && code <= 299) {
1762 is_valid = ast_ari_validate_void(
1763 response->message);
1764 } else {
1765 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/moh\n", code);
1766 is_valid = 0;
1767 }
1768 }
1769
1770 if (!is_valid) {
1771 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/moh\n");
1772 ast_ari_response_error(response, 500,
1773 "Internal Server Error", "Response validation failed");
1774 }
1775#endif /* AST_DEVMODE */
1776
1777fin: __attribute__((unused))
1778 return;
1779}
void ast_ari_channels_stop_moh(struct ast_variable *headers, struct ast_ari_channels_stop_moh_args *args, struct ast_ari_response *response)
Stop playing music on hold to a channel.

References args, ast_ari_channels_stop_moh(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_stop_silence_cb()

static void ast_ari_channels_stop_silence_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/silence.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1851 of file res_ari_channels.c.

1855{
1857 struct ast_variable *i;
1858#if defined(AST_DEVMODE)
1859 int is_valid;
1860 int code;
1861#endif /* AST_DEVMODE */
1862
1863 for (i = path_vars; i; i = i->next) {
1864 if (strcmp(i->name, "channelId") == 0) {
1865 args.channel_id = (i->value);
1866 } else
1867 {}
1868 }
1869 ast_ari_channels_stop_silence(headers, &args, response);
1870#if defined(AST_DEVMODE)
1871 code = response->response_code;
1872
1873 switch (code) {
1874 case 0: /* Implementation is still a stub, or the code wasn't set */
1875 is_valid = response->message == NULL;
1876 break;
1877 case 500: /* Internal Server Error */
1878 case 501: /* Not Implemented */
1879 case 404: /* Channel not found */
1880 case 409: /* Channel not in a Stasis application */
1881 case 412: /* Channel in invalid state */
1882 is_valid = 1;
1883 break;
1884 default:
1885 if (200 <= code && code <= 299) {
1886 is_valid = ast_ari_validate_void(
1887 response->message);
1888 } else {
1889 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/silence\n", code);
1890 is_valid = 0;
1891 }
1892 }
1893
1894 if (!is_valid) {
1895 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/silence\n");
1896 ast_ari_response_error(response, 500,
1897 "Internal Server Error", "Response validation failed");
1898 }
1899#endif /* AST_DEVMODE */
1900
1901fin: __attribute__((unused))
1902 return;
1903}
void ast_ari_channels_stop_silence(struct ast_variable *headers, struct ast_ari_channels_stop_silence_args *args, struct ast_ari_response *response)
Stop playing silence to a channel.

References args, ast_ari_channels_stop_silence(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_transfer_progress_cb()

static void ast_ari_channels_transfer_progress_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 
)
static

Parameter parsing callback for /channels/{channelId}/transfer_progress.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 3089 of file res_ari_channels.c.

3093{
3095 struct ast_variable *i;
3096#if defined(AST_DEVMODE)
3097 int is_valid;
3098 int code;
3099#endif /* AST_DEVMODE */
3100
3101 for (i = get_params; i; i = i->next) {
3102 if (strcmp(i->name, "states") == 0) {
3103 args.states = (i->value);
3104 } else
3105 {}
3106 }
3107 for (i = path_vars; i; i = i->next) {
3108 if (strcmp(i->name, "channelId") == 0) {
3109 args.channel_id = (i->value);
3110 } else
3111 {}
3112 }
3115 goto fin;
3116 }
3117 ast_ari_channels_transfer_progress(headers, &args, response);
3118#if defined(AST_DEVMODE)
3119 code = response->response_code;
3120
3121 switch (code) {
3122 case 0: /* Implementation is still a stub, or the code wasn't set */
3123 is_valid = response->message == NULL;
3124 break;
3125 case 500: /* Internal Server Error */
3126 case 501: /* Not Implemented */
3127 case 400: /* Endpoint parameter not provided */
3128 case 404: /* Channel or endpoint not found */
3129 case 409: /* Channel not in a Stasis application */
3130 case 412: /* Channel in invalid state */
3131 is_valid = 1;
3132 break;
3133 default:
3134 if (200 <= code && code <= 299) {
3135 is_valid = ast_ari_validate_void(
3136 response->message);
3137 } else {
3138 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/transfer_progress\n", code);
3139 is_valid = 0;
3140 }
3141 }
3142
3143 if (!is_valid) {
3144 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/transfer_progress\n");
3145 ast_ari_response_error(response, 500,
3146 "Internal Server Error", "Response validation failed");
3147 }
3148#endif /* AST_DEVMODE */
3149
3150fin: __attribute__((unused))
3151 return;
3152}
int ast_ari_channels_transfer_progress_parse_body(struct ast_json *body, struct ast_ari_channels_transfer_progress_args *args)
Body parsing function for /channels/{channelId}/transfer_progress.
void ast_ari_channels_transfer_progress(struct ast_variable *headers, struct ast_ari_channels_transfer_progress_args *args, struct ast_ari_response *response)
Inform the channel about the progress of the attended/blind transfer.

References args, ast_ari_channels_transfer_progress(), ast_ari_channels_transfer_progress_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_transfer_progress_parse_body()

int ast_ari_channels_transfer_progress_parse_body ( struct ast_json body,
struct ast_ari_channels_transfer_progress_args args 
)

Body parsing function for /channels/{channelId}/transfer_progress.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 3067 of file res_ari_channels.c.

3070{
3071 struct ast_json *field;
3072 /* Parse query parameters out of it */
3073 field = ast_json_object_get(body, "states");
3074 if (field) {
3075 args->states = ast_json_string_get(field);
3076 }
3077 return 0;
3078}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_transfer_progress_cb().

◆ ast_ari_channels_unhold_cb()

static void ast_ari_channels_unhold_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/hold.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1580 of file res_ari_channels.c.

1584{
1586 struct ast_variable *i;
1587#if defined(AST_DEVMODE)
1588 int is_valid;
1589 int code;
1590#endif /* AST_DEVMODE */
1591
1592 for (i = path_vars; i; i = i->next) {
1593 if (strcmp(i->name, "channelId") == 0) {
1594 args.channel_id = (i->value);
1595 } else
1596 {}
1597 }
1598 ast_ari_channels_unhold(headers, &args, response);
1599#if defined(AST_DEVMODE)
1600 code = response->response_code;
1601
1602 switch (code) {
1603 case 0: /* Implementation is still a stub, or the code wasn't set */
1604 is_valid = response->message == NULL;
1605 break;
1606 case 500: /* Internal Server Error */
1607 case 501: /* Not Implemented */
1608 case 404: /* Channel not found */
1609 case 409: /* Channel not in a Stasis application */
1610 case 412: /* Channel in invalid state */
1611 is_valid = 1;
1612 break;
1613 default:
1614 if (200 <= code && code <= 299) {
1615 is_valid = ast_ari_validate_void(
1616 response->message);
1617 } else {
1618 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/hold\n", code);
1619 is_valid = 0;
1620 }
1621 }
1622
1623 if (!is_valid) {
1624 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/hold\n");
1625 ast_ari_response_error(response, 500,
1626 "Internal Server Error", "Response validation failed");
1627 }
1628#endif /* AST_DEVMODE */
1629
1630fin: __attribute__((unused))
1631 return;
1632}
void ast_ari_channels_unhold(struct ast_variable *headers, struct ast_ari_channels_unhold_args *args, struct ast_ari_response *response)
Remove a channel from hold.

References args, ast_ari_channels_unhold(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_unmute_cb()

static void ast_ari_channels_unmute_cb ( struct ast_tcptls_session_instance ser,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Parameter parsing callback for /channels/{channelId}/mute.

Parameters
serTCP/TLS session object
get_paramsGET parameters in the HTTP request.
path_varsPath variables extracted from the request.
headersHTTP headers.
body
[out]responseResponse to the HTTP request.

Definition at line 1446 of file res_ari_channels.c.

1450{
1452 struct ast_variable *i;
1453#if defined(AST_DEVMODE)
1454 int is_valid;
1455 int code;
1456#endif /* AST_DEVMODE */
1457
1458 for (i = get_params; i; i = i->next) {
1459 if (strcmp(i->name, "direction") == 0) {
1460 args.direction = (i->value);
1461 } else
1462 {}
1463 }
1464 for (i = path_vars; i; i = i->next) {
1465 if (strcmp(i->name, "channelId") == 0) {
1466 args.channel_id = (i->value);
1467 } else
1468 {}
1469 }
1472 goto fin;
1473 }
1474 ast_ari_channels_unmute(headers, &args, response);
1475#if defined(AST_DEVMODE)
1476 code = response->response_code;
1477
1478 switch (code) {
1479 case 0: /* Implementation is still a stub, or the code wasn't set */
1480 is_valid = response->message == NULL;
1481 break;
1482 case 500: /* Internal Server Error */
1483 case 501: /* Not Implemented */
1484 case 404: /* Channel not found */
1485 case 409: /* Channel not in a Stasis application */
1486 case 412: /* Channel in invalid state */
1487 is_valid = 1;
1488 break;
1489 default:
1490 if (200 <= code && code <= 299) {
1491 is_valid = ast_ari_validate_void(
1492 response->message);
1493 } else {
1494 ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/mute\n", code);
1495 is_valid = 0;
1496 }
1497 }
1498
1499 if (!is_valid) {
1500 ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mute\n");
1501 ast_ari_response_error(response, 500,
1502 "Internal Server Error", "Response validation failed");
1503 }
1504#endif /* AST_DEVMODE */
1505
1506fin: __attribute__((unused))
1507 return;
1508}
int ast_ari_channels_unmute_parse_body(struct ast_json *body, struct ast_ari_channels_unmute_args *args)
Body parsing function for /channels/{channelId}/mute.
void ast_ari_channels_unmute(struct ast_variable *headers, struct ast_ari_channels_unmute_args *args, struct ast_ari_response *response)
Unmute a channel.

References args, ast_ari_channels_unmute(), ast_ari_channels_unmute_parse_body(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

◆ ast_ari_channels_unmute_parse_body()

int ast_ari_channels_unmute_parse_body ( struct ast_json body,
struct ast_ari_channels_unmute_args args 
)

Body parsing function for /channels/{channelId}/mute.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 1424 of file res_ari_channels.c.

1427{
1428 struct ast_json *field;
1429 /* Parse query parameters out of it */
1430 field = ast_json_object_get(body, "direction");
1431 if (field) {
1432 args->direction = ast_json_string_get(field);
1433 }
1434 return 0;
1435}

References args, ast_json_object_get(), and ast_json_string_get().

Referenced by ast_ari_channels_unmute_cb().

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 3408 of file res_ari_channels.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 3389 of file res_ari_channels.c.

3390{
3391 int res = 0;
3392
3393
3395 if (res) {
3396 unload_module();
3398 }
3399
3401}
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:132
@ 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 int unload_module(void)
static struct stasis_rest_handlers channels
REST handler for /api-docs/channels.json.

References ast_ari_add_handler(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, channels, and unload_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 3383 of file res_ari_channels.c.

3384{
3386 return 0;
3387}
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
Definition: res_ari.c:155

References ast_ari_remove_handler(), and channels.

Referenced by load_module().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "RESTful API module - Channel resources" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_ari,res_ari_model,res_stasis,res_stasis_answer,res_stasis_playback,res_stasis_recording,res_stasis_snoop", }
static

Definition at line 3408 of file res_ari_channels.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 3408 of file res_ari_channels.c.

◆ channels

struct stasis_rest_handlers channels
static

REST handler for /api-docs/channels.json.

Definition at line 3373 of file res_ari_channels.c.

Referenced by load_module(), and unload_module().

◆ channels_channelId

struct stasis_rest_handlers channels_channelId
static

REST handler for /api-docs/channels.json.

Definition at line 3352 of file res_ari_channels.c.

◆ channels_channelId_answer

struct stasis_rest_handlers channels_channelId_answer
static

REST handler for /api-docs/channels.json.

Definition at line 3191 of file res_ari_channels.c.

◆ channels_channelId_continue

struct stasis_rest_handlers channels_channelId_continue
static

REST handler for /api-docs/channels.json.

Definition at line 3164 of file res_ari_channels.c.

◆ channels_channelId_dial

struct stasis_rest_handlers channels_channelId_dial
static

REST handler for /api-docs/channels.json.

Definition at line 3325 of file res_ari_channels.c.

◆ channels_channelId_dtmf

struct stasis_rest_handlers channels_channelId_dtmf
static

REST handler for /api-docs/channels.json.

Definition at line 3219 of file res_ari_channels.c.

◆ channels_channelId_hold

struct stasis_rest_handlers channels_channelId_hold
static

REST handler for /api-docs/channels.json.

Definition at line 3238 of file res_ari_channels.c.

◆ channels_channelId_moh

struct stasis_rest_handlers channels_channelId_moh
static

REST handler for /api-docs/channels.json.

Definition at line 3248 of file res_ari_channels.c.

◆ channels_channelId_move

struct stasis_rest_handlers channels_channelId_move
static

REST handler for /api-docs/channels.json.

Definition at line 3173 of file res_ari_channels.c.

◆ channels_channelId_mute

struct stasis_rest_handlers channels_channelId_mute
static

REST handler for /api-docs/channels.json.

Definition at line 3228 of file res_ari_channels.c.

◆ channels_channelId_play

struct stasis_rest_handlers channels_channelId_play
static

REST handler for /api-docs/channels.json.

Definition at line 3278 of file res_ari_channels.c.

◆ channels_channelId_play_playbackId

struct stasis_rest_handlers channels_channelId_play_playbackId
static

REST handler for /api-docs/channels.json.

Definition at line 3268 of file res_ari_channels.c.

◆ channels_channelId_progress

struct stasis_rest_handlers channels_channelId_progress
static

REST handler for /api-docs/channels.json.

Definition at line 3210 of file res_ari_channels.c.

◆ channels_channelId_record

struct stasis_rest_handlers channels_channelId_record
static

REST handler for /api-docs/channels.json.

Definition at line 3287 of file res_ari_channels.c.

◆ channels_channelId_redirect

struct stasis_rest_handlers channels_channelId_redirect
static

REST handler for /api-docs/channels.json.

Definition at line 3182 of file res_ari_channels.c.

◆ channels_channelId_ring

struct stasis_rest_handlers channels_channelId_ring
static

REST handler for /api-docs/channels.json.

Definition at line 3200 of file res_ari_channels.c.

◆ channels_channelId_rtp_statistics

struct stasis_rest_handlers channels_channelId_rtp_statistics
static

REST handler for /api-docs/channels.json.

Definition at line 3334 of file res_ari_channels.c.

◆ channels_channelId_silence

struct stasis_rest_handlers channels_channelId_silence
static

REST handler for /api-docs/channels.json.

Definition at line 3258 of file res_ari_channels.c.

◆ channels_channelId_snoop

struct stasis_rest_handlers channels_channelId_snoop
static

REST handler for /api-docs/channels.json.

Definition at line 3316 of file res_ari_channels.c.

◆ channels_channelId_snoop_snoopId

struct stasis_rest_handlers channels_channelId_snoop_snoopId
static

REST handler for /api-docs/channels.json.

Definition at line 3306 of file res_ari_channels.c.

◆ channels_channelId_transfer_progress

struct stasis_rest_handlers channels_channelId_transfer_progress
static

REST handler for /api-docs/channels.json.

Definition at line 3343 of file res_ari_channels.c.

◆ channels_channelId_variable

struct stasis_rest_handlers channels_channelId_variable
static

REST handler for /api-docs/channels.json.

Definition at line 3296 of file res_ari_channels.c.

◆ channels_create

struct stasis_rest_handlers channels_create
static

REST handler for /api-docs/channels.json.

Definition at line 3155 of file res_ari_channels.c.

◆ channels_externalMedia

struct stasis_rest_handlers channels_externalMedia
static

REST handler for /api-docs/channels.json.

Definition at line 3364 of file res_ari_channels.c.