mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
ari:Add application/json parameter support
The patch allows ARI to parse request parameters from an incoming JSON request body, instead of requiring the request to come in as query parameters (which is just weird for POST and DELETE) or form parameters (which is okay, but a bit asymmetric given that all of our responses are JSON). For any operation that does _not_ have a parameter defined of type body (i.e. "paramType": "body" in the API declaration), if a request provides a request body with a Content type of "application/json", the provided JSON document is parsed and searched for parameters. The expected fields in the provided JSON document should match the query parameters defined for the operation. If the parameter has 'allowMultiple' set, then the field in the JSON document may optionally be an array of values. (closes issue ASTERISK-22685) Review: https://reviewboard.asterisk.org/r/2994/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403177 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -539,7 +539,7 @@ void ast_ari_invoke(struct ast_tcptls_session_instance *ser,
|
||||
return;
|
||||
}
|
||||
|
||||
callback(get_params, path_vars, headers, response);
|
||||
callback(ser, get_params, path_vars, headers, response);
|
||||
if (response->message == NULL && response->response_code == 0) {
|
||||
/* Really should not happen */
|
||||
ast_log(LOG_ERROR, "ARI %s %s not implemented\n",
|
||||
|
@@ -59,10 +59,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_applications_list_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_applications_list_args args = {};
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -108,11 +110,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_applications_get_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_applications_get_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -165,11 +169,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_applications_subscribe_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_applications_subscribe_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -227,6 +234,53 @@ static void ast_ari_applications_subscribe_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "eventSource");
|
||||
if (field) {
|
||||
/* If they were silly enough to both pass in a query param and a
|
||||
* JSON body, free up the query value.
|
||||
*/
|
||||
ast_free(args.event_source);
|
||||
if (ast_json_typeof(field) == AST_JSON_ARRAY) {
|
||||
/* Multiple param passed as array */
|
||||
size_t i;
|
||||
args.event_source_count = ast_json_array_size(field);
|
||||
args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
|
||||
|
||||
if (!args.event_source) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
for (i = 0; i < args.event_source_count; ++i) {
|
||||
args.event_source[i] = ast_json_string_get(ast_json_array_get(field, i));
|
||||
}
|
||||
} else {
|
||||
/* Multiple param passed as single value */
|
||||
args.event_source_count = 1;
|
||||
args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
|
||||
if (!args.event_source) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
args.event_source[0] = ast_json_string_get(field);
|
||||
}
|
||||
}
|
||||
ast_ari_applications_subscribe(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -272,11 +326,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_applications_unsubscribe_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_applications_unsubscribe_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -334,6 +391,53 @@ static void ast_ari_applications_unsubscribe_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "eventSource");
|
||||
if (field) {
|
||||
/* If they were silly enough to both pass in a query param and a
|
||||
* JSON body, free up the query value.
|
||||
*/
|
||||
ast_free(args.event_source);
|
||||
if (ast_json_typeof(field) == AST_JSON_ARRAY) {
|
||||
/* Multiple param passed as array */
|
||||
size_t i;
|
||||
args.event_source_count = ast_json_array_size(field);
|
||||
args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
|
||||
|
||||
if (!args.event_source) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
for (i = 0; i < args.event_source_count; ++i) {
|
||||
args.event_source[i] = ast_json_string_get(ast_json_array_get(field, i));
|
||||
}
|
||||
} else {
|
||||
/* Multiple param passed as single value */
|
||||
args.event_source_count = 1;
|
||||
args.event_source = ast_malloc(sizeof(*args.event_source) * args.event_source_count);
|
||||
if (!args.event_source) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
args.event_source[0] = ast_json_string_get(field);
|
||||
}
|
||||
}
|
||||
ast_ari_applications_unsubscribe(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
|
@@ -59,11 +59,14 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_asterisk_get_info_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_asterisk_get_info_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -115,6 +118,53 @@ static void ast_ari_asterisk_get_info_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "only");
|
||||
if (field) {
|
||||
/* If they were silly enough to both pass in a query param and a
|
||||
* JSON body, free up the query value.
|
||||
*/
|
||||
ast_free(args.only);
|
||||
if (ast_json_typeof(field) == AST_JSON_ARRAY) {
|
||||
/* Multiple param passed as array */
|
||||
size_t i;
|
||||
args.only_count = ast_json_array_size(field);
|
||||
args.only = ast_malloc(sizeof(*args.only) * args.only_count);
|
||||
|
||||
if (!args.only) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
for (i = 0; i < args.only_count; ++i) {
|
||||
args.only[i] = ast_json_string_get(ast_json_array_get(field, i));
|
||||
}
|
||||
} else {
|
||||
/* Multiple param passed as single value */
|
||||
args.only_count = 1;
|
||||
args.only = ast_malloc(sizeof(*args.only) * args.only_count);
|
||||
if (!args.only) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
args.only[0] = ast_json_string_get(field);
|
||||
}
|
||||
}
|
||||
ast_ari_asterisk_get_info(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -157,11 +207,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_asterisk_get_global_var_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_asterisk_get_global_var_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -173,6 +226,26 @@ static void ast_ari_asterisk_get_global_var_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "variable");
|
||||
if (field) {
|
||||
args.variable = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_asterisk_get_global_var(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -214,11 +287,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_asterisk_set_global_var_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_asterisk_set_global_var_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -233,6 +309,30 @@ static void ast_ari_asterisk_set_global_var_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "variable");
|
||||
if (field) {
|
||||
args.variable = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "value");
|
||||
if (field) {
|
||||
args.value = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_asterisk_set_global_var(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
|
@@ -59,10 +59,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_list_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_list_args args = {};
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -108,11 +110,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_create_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_create_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -124,6 +129,26 @@ static void ast_ari_bridges_create_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "type");
|
||||
if (field) {
|
||||
args.type = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_bridges_create(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -164,11 +189,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_get_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_get_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -221,11 +248,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_destroy_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_destroy_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -278,11 +307,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_add_channel_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_add_channel_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -343,6 +375,57 @@ static void ast_ari_bridges_add_channel_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "channel");
|
||||
if (field) {
|
||||
/* If they were silly enough to both pass in a query param and a
|
||||
* JSON body, free up the query value.
|
||||
*/
|
||||
ast_free(args.channel);
|
||||
if (ast_json_typeof(field) == AST_JSON_ARRAY) {
|
||||
/* Multiple param passed as array */
|
||||
size_t i;
|
||||
args.channel_count = ast_json_array_size(field);
|
||||
args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
|
||||
|
||||
if (!args.channel) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
for (i = 0; i < args.channel_count; ++i) {
|
||||
args.channel[i] = ast_json_string_get(ast_json_array_get(field, i));
|
||||
}
|
||||
} else {
|
||||
/* Multiple param passed as single value */
|
||||
args.channel_count = 1;
|
||||
args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
|
||||
if (!args.channel) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
args.channel[0] = ast_json_string_get(field);
|
||||
}
|
||||
}
|
||||
field = ast_json_object_get(body, "role");
|
||||
if (field) {
|
||||
args.role = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_bridges_add_channel(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -389,11 +472,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_remove_channel_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_remove_channel_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -451,6 +537,53 @@ static void ast_ari_bridges_remove_channel_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "channel");
|
||||
if (field) {
|
||||
/* If they were silly enough to both pass in a query param and a
|
||||
* JSON body, free up the query value.
|
||||
*/
|
||||
ast_free(args.channel);
|
||||
if (ast_json_typeof(field) == AST_JSON_ARRAY) {
|
||||
/* Multiple param passed as array */
|
||||
size_t i;
|
||||
args.channel_count = ast_json_array_size(field);
|
||||
args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
|
||||
|
||||
if (!args.channel) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
for (i = 0; i < args.channel_count; ++i) {
|
||||
args.channel[i] = ast_json_string_get(ast_json_array_get(field, i));
|
||||
}
|
||||
} else {
|
||||
/* Multiple param passed as single value */
|
||||
args.channel_count = 1;
|
||||
args.channel = ast_malloc(sizeof(*args.channel) * args.channel_count);
|
||||
if (!args.channel) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
goto fin;
|
||||
}
|
||||
args.channel[0] = ast_json_string_get(field);
|
||||
}
|
||||
}
|
||||
ast_ari_bridges_remove_channel(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -497,11 +630,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_start_moh_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_start_moh_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -519,6 +655,26 @@ static void ast_ari_bridges_start_moh_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "mohClass");
|
||||
if (field) {
|
||||
args.moh_class = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_bridges_start_moh(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -561,11 +717,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_stop_moh_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_stop_moh_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -619,11 +777,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_play_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_play_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -650,6 +811,38 @@ static void ast_ari_bridges_play_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "media");
|
||||
if (field) {
|
||||
args.media = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "lang");
|
||||
if (field) {
|
||||
args.lang = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "offsetms");
|
||||
if (field) {
|
||||
args.offsetms = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "skipms");
|
||||
if (field) {
|
||||
args.skipms = ast_json_integer_get(field);
|
||||
}
|
||||
ast_ari_bridges_play(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -692,11 +885,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_bridges_record_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_bridges_record_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -732,6 +928,50 @@ static void ast_ari_bridges_record_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "name");
|
||||
if (field) {
|
||||
args.name = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "format");
|
||||
if (field) {
|
||||
args.format = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "maxDurationSeconds");
|
||||
if (field) {
|
||||
args.max_duration_seconds = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "maxSilenceSeconds");
|
||||
if (field) {
|
||||
args.max_silence_seconds = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "ifExists");
|
||||
if (field) {
|
||||
args.if_exists = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "beep");
|
||||
if (field) {
|
||||
args.beep = ast_json_is_true(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "terminateOn");
|
||||
if (field) {
|
||||
args.terminate_on = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_bridges_record(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
|
@@ -59,10 +59,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_list_args args = {};
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -108,11 +110,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_originate_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -145,6 +150,54 @@ static void ast_ari_channels_originate_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "endpoint");
|
||||
if (field) {
|
||||
args.endpoint = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "extension");
|
||||
if (field) {
|
||||
args.extension = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "context");
|
||||
if (field) {
|
||||
args.context = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "priority");
|
||||
if (field) {
|
||||
args.priority = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "app");
|
||||
if (field) {
|
||||
args.app = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "appArgs");
|
||||
if (field) {
|
||||
args.app_args = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "callerId");
|
||||
if (field) {
|
||||
args.caller_id = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "timeout");
|
||||
if (field) {
|
||||
args.timeout = ast_json_integer_get(field);
|
||||
}
|
||||
ast_ari_channels_originate(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -186,11 +239,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_get_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -243,11 +298,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_hangup_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -265,6 +323,26 @@ static void ast_ari_channels_hangup_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "reason");
|
||||
if (field) {
|
||||
args.reason = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_hangup(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -307,11 +385,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_continue_in_dialplan_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -335,6 +416,34 @@ static void ast_ari_channels_continue_in_dialplan_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "context");
|
||||
if (field) {
|
||||
args.context = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "extension");
|
||||
if (field) {
|
||||
args.extension = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "priority");
|
||||
if (field) {
|
||||
args.priority = ast_json_integer_get(field);
|
||||
}
|
||||
ast_ari_channels_continue_in_dialplan(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -377,11 +486,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_answer_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -435,11 +546,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_ring_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -493,11 +606,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_ring_stop_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -551,11 +666,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_send_dtmf_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -585,6 +703,42 @@ static void ast_ari_channels_send_dtmf_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "dtmf");
|
||||
if (field) {
|
||||
args.dtmf = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "before");
|
||||
if (field) {
|
||||
args.before = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "between");
|
||||
if (field) {
|
||||
args.between = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "duration");
|
||||
if (field) {
|
||||
args.duration = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "after");
|
||||
if (field) {
|
||||
args.after = ast_json_integer_get(field);
|
||||
}
|
||||
ast_ari_channels_send_dtmf(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -628,11 +782,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_mute_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -650,6 +807,26 @@ static void ast_ari_channels_mute_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "direction");
|
||||
if (field) {
|
||||
args.direction = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_mute(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -692,11 +869,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_unmute_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -714,6 +894,26 @@ static void ast_ari_channels_unmute_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "direction");
|
||||
if (field) {
|
||||
args.direction = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_unmute(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -756,11 +956,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_hold_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -814,11 +1016,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_unhold_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -872,11 +1076,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_start_moh_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -894,6 +1101,26 @@ static void ast_ari_channels_start_moh_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "mohClass");
|
||||
if (field) {
|
||||
args.moh_class = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_start_moh(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -936,11 +1163,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_stop_moh_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -994,11 +1223,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_start_silence_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -1052,11 +1283,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_stop_silence_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -1110,11 +1343,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_play_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -1141,6 +1377,38 @@ static void ast_ari_channels_play_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "media");
|
||||
if (field) {
|
||||
args.media = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "lang");
|
||||
if (field) {
|
||||
args.lang = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "offsetms");
|
||||
if (field) {
|
||||
args.offsetms = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "skipms");
|
||||
if (field) {
|
||||
args.skipms = ast_json_integer_get(field);
|
||||
}
|
||||
ast_ari_channels_play(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -1183,11 +1451,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_record_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -1223,6 +1494,50 @@ static void ast_ari_channels_record_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "name");
|
||||
if (field) {
|
||||
args.name = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "format");
|
||||
if (field) {
|
||||
args.format = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "maxDurationSeconds");
|
||||
if (field) {
|
||||
args.max_duration_seconds = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "maxSilenceSeconds");
|
||||
if (field) {
|
||||
args.max_silence_seconds = ast_json_integer_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "ifExists");
|
||||
if (field) {
|
||||
args.if_exists = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "beep");
|
||||
if (field) {
|
||||
args.beep = ast_json_is_true(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "terminateOn");
|
||||
if (field) {
|
||||
args.terminate_on = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_record(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -1267,11 +1582,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_get_channel_var_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -1289,6 +1607,26 @@ static void ast_ari_channels_get_channel_var_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "variable");
|
||||
if (field) {
|
||||
args.variable = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_get_channel_var(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -1332,11 +1670,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_set_channel_var_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -1357,6 +1698,30 @@ static void ast_ari_channels_set_channel_var_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "variable");
|
||||
if (field) {
|
||||
args.variable = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "value");
|
||||
if (field) {
|
||||
args.value = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_set_channel_var(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -1400,11 +1765,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
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_ari_response *response)
|
||||
{
|
||||
struct ast_ari_channels_snoop_channel_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -1431,6 +1799,38 @@ static void ast_ari_channels_snoop_channel_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "spy");
|
||||
if (field) {
|
||||
args.spy = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "whisper");
|
||||
if (field) {
|
||||
args.whisper = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "app");
|
||||
if (field) {
|
||||
args.app = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "appArgs");
|
||||
if (field) {
|
||||
args.app_args = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_channels_snoop_channel(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
|
@@ -59,10 +59,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_device_states_list_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_device_states_list_args args = {};
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -108,11 +110,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_device_states_get_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_device_states_get_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -164,11 +168,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_device_states_update_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_device_states_update_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -186,6 +193,26 @@ static void ast_ari_device_states_update_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "deviceState");
|
||||
if (field) {
|
||||
args.device_state = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_device_states_update(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -228,11 +255,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_device_states_delete_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_device_states_delete_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
|
@@ -59,10 +59,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_endpoints_list_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_endpoints_list_args args = {};
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -108,11 +110,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_endpoints_list_by_tech_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_endpoints_list_by_tech_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -165,11 +169,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_endpoints_get_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_endpoints_get_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
|
@@ -59,11 +59,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_playbacks_get_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_playbacks_get_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -116,11 +118,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_playbacks_stop_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_playbacks_stop_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -173,11 +177,14 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_playbacks_control_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_playbacks_control_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -195,6 +202,26 @@ static void ast_ari_playbacks_control_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "operation");
|
||||
if (field) {
|
||||
args.operation = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_playbacks_control(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
|
@@ -59,10 +59,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_list_stored_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_list_stored_args args = {};
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -108,11 +110,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_get_stored_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_get_stored_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -165,11 +169,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_delete_stored_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_delete_stored_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -222,11 +228,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_get_live_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_get_live_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -279,11 +287,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_cancel_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_cancel_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -336,11 +346,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_stop_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_stop_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -393,11 +405,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_pause_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_pause_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -451,11 +465,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_unpause_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_unpause_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -509,11 +525,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_mute_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_mute_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -567,11 +585,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_recordings_unmute_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_recordings_unmute_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
|
@@ -59,11 +59,14 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_sounds_list_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_sounds_list_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
struct ast_json *field;
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
@@ -78,6 +81,30 @@ static void ast_ari_sounds_list_cb(
|
||||
} else
|
||||
{}
|
||||
}
|
||||
/* Look for a JSON request entity */
|
||||
body = ast_http_get_json(ser, headers);
|
||||
if (!body) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
ast_ari_response_error(response, 413, "Request Entity Too Large", "Request body too large");
|
||||
goto fin;
|
||||
case ENOMEM:
|
||||
ast_ari_response_error(response, 500, "Internal Server Error", "Error processing request");
|
||||
goto fin;
|
||||
case EIO:
|
||||
ast_ari_response_error(response, 400, "Bad Request", "Error parsing request body");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
/* Parse query parameters out of it */
|
||||
field = ast_json_object_get(body, "lang");
|
||||
if (field) {
|
||||
args.lang = ast_json_string_get(field);
|
||||
}
|
||||
field = ast_json_object_get(body, "format");
|
||||
if (field) {
|
||||
args.format = ast_json_string_get(field);
|
||||
}
|
||||
ast_ari_sounds_list(headers, &args, response);
|
||||
#if defined(AST_DEVMODE)
|
||||
code = response->response_code;
|
||||
@@ -118,11 +145,13 @@ fin: __attribute__((unused))
|
||||
* \param[out] response Response to the HTTP request.
|
||||
*/
|
||||
static void ast_ari_sounds_get_cb(
|
||||
struct ast_tcptls_session_instance *ser,
|
||||
struct ast_variable *get_params, struct ast_variable *path_vars,
|
||||
struct ast_variable *headers, struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_ari_sounds_get_args args = {};
|
||||
struct ast_variable *i;
|
||||
RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
|
||||
#if defined(AST_DEVMODE)
|
||||
int is_valid;
|
||||
int code;
|
||||
|
Reference in New Issue
Block a user