@ -41,6 +41,7 @@
ASTERISK_FILE_VERSION ( __FILE__ , " $Revision$ " )
# include "asterisk/app.h"
# include "asterisk/module.h"
# include "asterisk/stasis_app.h"
# include "ari/resource_channels.h"
@ -48,6 +49,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
# include "ari/ari_model_validators.h"
# endif
# define MAX_VALS 128
/*!
* \ brief Parameter parsing callback for / channels .
* \ param get_params GET parameters in the HTTP request .
@ -59,12 +62,12 @@ static void ast_ari_get_channels_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_get_channels_args args = { } ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_get_channels_args args = { } ;
ast_ari_get_channels ( headers , & args , response ) ;
# if defined(AST_DEVMODE)
code = response - > response_code ;
@ -93,6 +96,9 @@ static void ast_ari_get_channels_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels .
@ -105,14 +111,13 @@ static void ast_ari_originate_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_originate_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_originate_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " endpoint " ) = = 0 ) {
args . endpoint = ( i - > value ) ;
@ -169,6 +174,9 @@ static void ast_ari_originate_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } .
@ -181,14 +189,13 @@ static void ast_ari_get_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_get_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_get_channel_args args = { } ;
struct ast_variable * i ;
for ( i = path_vars ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " channelId " ) = = 0 ) {
args . channel_id = ( i - > value ) ;
@ -224,6 +231,9 @@ static void ast_ari_get_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } .
@ -236,14 +246,13 @@ static void ast_ari_delete_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_delete_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_delete_channel_args args = { } ;
struct ast_variable * i ;
for ( i = path_vars ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " channelId " ) = = 0 ) {
args . channel_id = ( i - > value ) ;
@ -279,6 +288,9 @@ static void ast_ari_delete_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / dial .
@ -291,14 +303,13 @@ static void ast_ari_dial_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_dial_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_dial_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " endpoint " ) = = 0 ) {
args . endpoint = ( i - > value ) ;
@ -350,6 +361,9 @@ static void ast_ari_dial_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / continue .
@ -362,14 +376,13 @@ static void ast_ari_continue_in_dialplan_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_continue_in_dialplan_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_continue_in_dialplan_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " context " ) = = 0 ) {
args . context = ( i - > value ) ;
@ -418,6 +431,9 @@ static void ast_ari_continue_in_dialplan_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / answer .
@ -430,14 +446,13 @@ static void ast_ari_answer_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_answer_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_answer_channel_args args = { } ;
struct ast_variable * i ;
for ( i = path_vars ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " channelId " ) = = 0 ) {
args . channel_id = ( i - > value ) ;
@ -474,6 +489,9 @@ static void ast_ari_answer_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / mute .
@ -486,14 +504,13 @@ static void ast_ari_mute_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_mute_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_mute_channel_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " direction " ) = = 0 ) {
args . direction = ( i - > value ) ;
@ -536,6 +553,9 @@ static void ast_ari_mute_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / unmute .
@ -548,14 +568,13 @@ static void ast_ari_unmute_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_unmute_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_unmute_channel_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " direction " ) = = 0 ) {
args . direction = ( i - > value ) ;
@ -598,6 +617,9 @@ static void ast_ari_unmute_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / hold .
@ -610,14 +632,13 @@ static void ast_ari_hold_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_hold_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_hold_channel_args args = { } ;
struct ast_variable * i ;
for ( i = path_vars ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " channelId " ) = = 0 ) {
args . channel_id = ( i - > value ) ;
@ -654,6 +675,9 @@ static void ast_ari_hold_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / unhold .
@ -666,14 +690,13 @@ static void ast_ari_unhold_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_unhold_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_unhold_channel_args args = { } ;
struct ast_variable * i ;
for ( i = path_vars ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " channelId " ) = = 0 ) {
args . channel_id = ( i - > value ) ;
@ -710,6 +733,9 @@ static void ast_ari_unhold_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / mohstart .
@ -722,14 +748,13 @@ static void ast_ari_moh_start_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_moh_start_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_moh_start_channel_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " mohClass " ) = = 0 ) {
args . moh_class = ( i - > value ) ;
@ -772,6 +797,9 @@ static void ast_ari_moh_start_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / mohstop .
@ -784,14 +812,13 @@ static void ast_ari_moh_stop_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_moh_stop_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_moh_stop_channel_args args = { } ;
struct ast_variable * i ;
for ( i = path_vars ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " channelId " ) = = 0 ) {
args . channel_id = ( i - > value ) ;
@ -828,6 +855,9 @@ static void ast_ari_moh_stop_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / play .
@ -840,14 +870,13 @@ static void ast_ari_play_on_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_play_on_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_play_on_channel_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " media " ) = = 0 ) {
args . media = ( i - > value ) ;
@ -899,6 +928,9 @@ static void ast_ari_play_on_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / record .
@ -911,14 +943,13 @@ static void ast_ari_record_channel_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_record_channel_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_record_channel_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " name " ) = = 0 ) {
args . name = ( i - > value ) ;
@ -980,6 +1011,9 @@ static void ast_ari_record_channel_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / variable .
@ -992,14 +1026,13 @@ static void ast_ari_get_channel_var_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_get_channel_var_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_get_channel_var_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " variable " ) = = 0 ) {
args . variable = ( i - > value ) ;
@ -1042,6 +1075,9 @@ static void ast_ari_get_channel_var_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*!
* \ brief Parameter parsing callback for / channels / { channelId } / variable .
@ -1054,14 +1090,13 @@ static void ast_ari_set_channel_var_cb(
struct ast_variable * get_params , struct ast_variable * path_vars ,
struct ast_variable * headers , struct ast_ari_response * response )
{
struct ast_set_channel_var_args args = { } ;
struct ast_variable * i ;
# if defined(AST_DEVMODE)
int is_valid ;
int code ;
# endif /* AST_DEVMODE */
struct ast_set_channel_var_args args = { } ;
struct ast_variable * i ;
for ( i = get_params ; i ; i = i - > next ) {
if ( strcmp ( i - > name , " variable " ) = = 0 ) {
args . variable = ( i - > value ) ;
@ -1107,6 +1142,9 @@ static void ast_ari_set_channel_var_cb(
" Internal Server Error " , " Response validation failed " ) ;
}
# endif /* AST_DEVMODE */
fin : __attribute__ ( ( unused ) )
return ;
}
/*! \brief REST handler for /api-docs/channels.{format} */