Newer
Older
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2012 - 2013, Digium, Inc.
*
* David M. Lee, II <dlee@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!!!! DO NOT EDIT !!!!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* This file is generated by a mustache template. Please see the original
* template in rest-api-templates/res_ari_resource.c.mustache
*/
/*! \file
*
* \brief Channel resources
*
* \author David M. Lee, II <dlee@digium.com>
*/
/*** MODULEINFO
<depend type="module">res_ari</depend>
<depend type="module">res_ari_model</depend>
<depend type="module">res_stasis</depend>
<depend type="module">res_stasis_answer</depend>
<depend type="module">res_stasis_playback</depend>
<depend type="module">res_stasis_recording</depend>
<depend type="module">res_stasis_snoop</depend>
<support_level>core</support_level>
***/
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/stasis_app.h"
#if defined(AST_DEVMODE)
#include "ari/ari_model_validators.h"
/*!
* \brief Parameter parsing callback for /channels.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \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_json *body, struct ast_ari_response *response)
struct ast_ari_channels_list_args args = {};
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
ast_ari_channels_list(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
is_valid = ast_ari_validate_list(response->message,
ast_ari_validate_channel_fn());
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
fin: __attribute__((unused))
return;
int ast_ari_channels_originate_parse_body(
struct ast_json *body,
struct ast_ari_channels_originate_args *args)
{
struct ast_json *field;
/* 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, "label");
if (field) {
args->label = 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);
}
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);
}
field = ast_json_object_get(body, "channelId");
if (field) {
args->channel_id = ast_json_string_get(field);
}
field = ast_json_object_get(body, "otherChannelId");
if (field) {
args->other_channel_id = ast_json_string_get(field);
}
field = ast_json_object_get(body, "originator");
if (field) {
args->originator = ast_json_string_get(field);
}
field = ast_json_object_get(body, "formats");
if (field) {
args->formats = ast_json_string_get(field);
}
/*!
* \brief Parameter parsing callback for /channels.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \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_json *body, struct ast_ari_response *response)
struct ast_ari_channels_originate_args args = {};
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = get_params; i; i = i->next) {
if (strcmp(i->name, "endpoint") == 0) {
args.endpoint = (i->value);
} else
if (strcmp(i->name, "extension") == 0) {
args.extension = (i->value);
} else
if (strcmp(i->name, "context") == 0) {
args.context = (i->value);
} else
if (strcmp(i->name, "priority") == 0) {
args.priority = atol(i->value);
if (strcmp(i->name, "label") == 0) {
args.label = (i->value);
} else
if (strcmp(i->name, "app") == 0) {
args.app = (i->value);
} else
if (strcmp(i->name, "appArgs") == 0) {
args.app_args = (i->value);
} else
if (strcmp(i->name, "callerId") == 0) {
args.caller_id = (i->value);
} else
if (strcmp(i->name, "timeout") == 0) {
args.timeout = atoi(i->value);
} else
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
if (strcmp(i->name, "otherChannelId") == 0) {
args.other_channel_id = (i->value);
} else
if (strcmp(i->name, "originator") == 0) {
args.originator = (i->value);
} else
if (strcmp(i->name, "formats") == 0) {
args.formats = (i->value);
} else
ast_ari_channels_originate(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 400: /* Invalid parameters for originating a channel. */
case 409: /* Channel with given unique ID already exists. */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
Joshua Colp
committed
is_valid = ast_ari_validate_channel(
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
fin: __attribute__((unused))
return;
}
int ast_ari_channels_create_parse_body(
struct ast_json *body,
struct ast_ari_channels_create_args *args)
{
struct ast_json *field;
/* 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, "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, "channelId");
if (field) {
args->channel_id = ast_json_string_get(field);
}
field = ast_json_object_get(body, "otherChannelId");
if (field) {
args->other_channel_id = ast_json_string_get(field);
}
field = ast_json_object_get(body, "originator");
if (field) {
args->originator = ast_json_string_get(field);
}
field = ast_json_object_get(body, "formats");
if (field) {
args->formats = ast_json_string_get(field);
}
return 0;
}
/*!
* \brief Parameter parsing callback for /channels/create.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \param[out] response Response to the HTTP request.
*/
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)
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
{
struct ast_ari_channels_create_args args = {};
struct ast_variable *i;
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = get_params; i; i = i->next) {
if (strcmp(i->name, "endpoint") == 0) {
args.endpoint = (i->value);
} else
if (strcmp(i->name, "app") == 0) {
args.app = (i->value);
} else
if (strcmp(i->name, "appArgs") == 0) {
args.app_args = (i->value);
} else
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
if (strcmp(i->name, "otherChannelId") == 0) {
args.other_channel_id = (i->value);
} else
if (strcmp(i->name, "originator") == 0) {
args.originator = (i->value);
} else
if (strcmp(i->name, "formats") == 0) {
args.formats = (i->value);
} else
{}
}
if (ast_ari_channels_create_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
}
ast_ari_channels_create(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 409: /* Channel with given unique ID already exists. */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
is_valid = ast_ari_validate_channel(
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/create\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/create\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
fin: __attribute__((unused))
return;
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \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_json *body, struct ast_ari_response *response)
struct ast_ari_channels_get_args args = {};
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = path_vars; i; i = i->next) {
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
{}
}
ast_ari_channels_get(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
is_valid = ast_ari_validate_channel(
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
fin: __attribute__((unused))
return;
}
int ast_ari_channels_originate_with_id_parse_body(
struct ast_json *body,
struct ast_ari_channels_originate_with_id_args *args)
{
struct ast_json *field;
/* 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, "label");
if (field) {
args->label = 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);
}
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);
}
field = ast_json_object_get(body, "otherChannelId");
if (field) {
args->other_channel_id = ast_json_string_get(field);
}
field = ast_json_object_get(body, "originator");
if (field) {
args->originator = ast_json_string_get(field);
}
field = ast_json_object_get(body, "formats");
if (field) {
args->formats = ast_json_string_get(field);
}
return 0;
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \param[out] response Response to the HTTP request.
*/
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)
{
struct ast_ari_channels_originate_with_id_args args = {};
struct ast_variable *i;
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = get_params; i; i = i->next) {
if (strcmp(i->name, "endpoint") == 0) {
args.endpoint = (i->value);
} else
if (strcmp(i->name, "extension") == 0) {
args.extension = (i->value);
} else
if (strcmp(i->name, "context") == 0) {
args.context = (i->value);
} else
if (strcmp(i->name, "priority") == 0) {
args.priority = atol(i->value);
} else
if (strcmp(i->name, "label") == 0) {
args.label = (i->value);
} else
if (strcmp(i->name, "app") == 0) {
args.app = (i->value);
} else
if (strcmp(i->name, "appArgs") == 0) {
args.app_args = (i->value);
} else
if (strcmp(i->name, "callerId") == 0) {
args.caller_id = (i->value);
} else
if (strcmp(i->name, "timeout") == 0) {
args.timeout = atoi(i->value);
} else
if (strcmp(i->name, "otherChannelId") == 0) {
args.other_channel_id = (i->value);
} else
if (strcmp(i->name, "originator") == 0) {
args.originator = (i->value);
} else
if (strcmp(i->name, "formats") == 0) {
args.formats = (i->value);
} else
{}
}
for (i = path_vars; i; i = i->next) {
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
{}
}
ast_ari_channels_originate_with_id(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 400: /* Invalid parameters for originating a channel. */
case 409: /* Channel with given unique ID already exists. */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
is_valid = ast_ari_validate_channel(
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
fin: __attribute__((unused))
return;
int ast_ari_channels_hangup_parse_body(
struct ast_json *body,
struct ast_ari_channels_hangup_args *args)
{
struct ast_json *field;
/* Parse query parameters out of it */
field = ast_json_object_get(body, "reason");
if (field) {
args->reason = ast_json_string_get(field);
}
return 0;
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \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_json *body, struct ast_ari_response *response)
struct ast_ari_channels_hangup_args args = {};
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
Joshua Colp
committed
for (i = get_params; i; i = i->next) {
if (strcmp(i->name, "reason") == 0) {
args.reason = (i->value);
} else
{}
}
for (i = path_vars; i; i = i->next) {
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
{}
}
if (ast_ari_channels_hangup_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
ast_ari_channels_hangup(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
Joshua Colp
committed
case 400: /* Invalid reason for hangup provided */
case 404: /* Channel not found */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
fin: __attribute__((unused))
return;
int ast_ari_channels_continue_in_dialplan_parse_body(
struct ast_json *body,
struct ast_ari_channels_continue_in_dialplan_args *args)
{
struct ast_json *field;
/* 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);
}
field = ast_json_object_get(body, "label");
if (field) {
args->label = ast_json_string_get(field);
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}/continue.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \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_json *body, struct ast_ari_response *response)
struct ast_ari_channels_continue_in_dialplan_args args = {};
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = get_params; i; i = i->next) {
if (strcmp(i->name, "context") == 0) {
args.context = (i->value);
} else
if (strcmp(i->name, "extension") == 0) {
args.extension = (i->value);
} else
if (strcmp(i->name, "priority") == 0) {
args.priority = atoi(i->value);
} else
if (strcmp(i->name, "label") == 0) {
args.label = (i->value);
} else
{}
}
for (i = path_vars; i; i = i->next) {
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
{}
}
if (ast_ari_channels_continue_in_dialplan_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
ast_ari_channels_continue_in_dialplan(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
case 412: /* Channel in invalid state */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/continue\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/continue\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
Matthew Jordan
committed
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
fin: __attribute__((unused))
return;
}
int ast_ari_channels_redirect_parse_body(
struct ast_json *body,
struct ast_ari_channels_redirect_args *args)
{
struct ast_json *field;
/* Parse query parameters out of it */
field = ast_json_object_get(body, "endpoint");
if (field) {
args->endpoint = ast_json_string_get(field);
}
return 0;
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}/redirect.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \param[out] response Response to the HTTP request.
*/
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)
Matthew Jordan
committed
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
{
struct ast_ari_channels_redirect_args args = {};
struct ast_variable *i;
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = get_params; i; i = i->next) {
if (strcmp(i->name, "endpoint") == 0) {
args.endpoint = (i->value);
} else
{}
}
for (i = path_vars; i; i = i->next) {
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
{}
}
if (ast_ari_channels_redirect_parse_body(body, &args)) {
ast_ari_response_alloc_failed(response);
goto fin;
}
ast_ari_channels_redirect(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 400: /* Endpoint parameter not provided */
case 404: /* Channel or endpoint not found */
case 409: /* Channel not in a Stasis application */
case 422: /* Endpoint is not the same type as the channel */
case 412: /* Channel in invalid state */
Matthew Jordan
committed
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
is_valid = ast_ari_validate_void(
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/redirect\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/redirect\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
fin: __attribute__((unused))
return;
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}/answer.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \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_json *body, struct ast_ari_response *response)
struct ast_ari_channels_answer_args args = {};
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = path_vars; i; i = i->next) {
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
{}
}
ast_ari_channels_answer(headers, &args, response);
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
case 412: /* Channel in invalid state */
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/answer\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/answer\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
Joshua Colp
committed
fin: __attribute__((unused))
return;
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}/ring.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \param[out] response Response to the HTTP request.
*/
static void ast_ari_channels_ring_cb(
struct ast_tcptls_session_instance *ser,
Joshua Colp
committed
struct ast_variable *get_params, struct ast_variable *path_vars,
struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Joshua Colp
committed
{
struct ast_ari_channels_ring_args args = {};
Joshua Colp
committed
struct ast_variable *i;
#if defined(AST_DEVMODE)
int is_valid;
int code;
#endif /* AST_DEVMODE */
for (i = path_vars; i; i = i->next) {
if (strcmp(i->name, "channelId") == 0) {
args.channel_id = (i->value);
} else
{}
}
ast_ari_channels_ring(headers, &args, response);
Joshua Colp
committed
#if defined(AST_DEVMODE)
code = response->response_code;
switch (code) {
case 0: /* Implementation is still a stub, or the code wasn't set */
is_valid = response->message == NULL;
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
case 404: /* Channel not found */
case 409: /* Channel not in a Stasis application */
case 412: /* Channel in invalid state */
Joshua Colp
committed
is_valid = 1;
break;
default:
if (200 <= code && code <= 299) {
is_valid = ast_ari_validate_void(
response->message);
} else {
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/ring\n", code);
is_valid = 0;
}
}
if (!is_valid) {
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/ring\n");
ast_ari_response_error(response, 500,
"Internal Server Error", "Response validation failed");
}
#endif /* AST_DEVMODE */
Joshua Colp
committed
fin: __attribute__((unused))
return;
}
/*!
* \brief Parameter parsing callback for /channels/{channelId}/ring.
* \param get_params GET parameters in the HTTP request.
* \param path_vars Path variables extracted from the request.
* \param headers HTTP headers.
* \param[out] response Response to the HTTP request.
*/
static void ast_ari_channels_ring_stop_cb(
struct ast_tcptls_session_instance *ser,
Joshua Colp
committed
struct ast_variable *get_params, struct ast_variable *path_vars,
struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Joshua Colp
committed
{
struct ast_ari_channels_ring_stop_args args = {};
struct ast_variable *i;
#if defined(AST_DEVMODE)