76    for (; get_params != 
NULL; get_params = get_params->
next) {
 
   80    for (; path_vars != 
NULL; path_vars = path_vars->
next) {
 
   84    for (; headers != 
NULL; headers = headers->
next) {
 
 
   97#define HANDLER(name, response_code)                    \ 
   98    static void name(struct ast_tcptls_session_instance *ser,   \ 
   99        struct ast_variable *get_params,            \ 
  100        struct ast_variable *path_vars,             \ 
  101        struct ast_variable *headers,               \ 
  102        struct ast_json *body,                      \ 
  103        struct ast_ari_response *response)          \ 
  105        handler(#name, response_code, get_params, path_vars, headers, body, response); \ 
 
  140    .children = { &
bang }
 
 
  206    const char *basePath;
 
  210        info->name = __func__;
 
  211        info->category = 
"/res/ari/";
 
  212        info->summary = 
"Test simple API get.";
 
  213        info->description = 
"Test ARI binding logic.";
 
  222    ast_test_validate(
test, 200 == response->response_code);
 
  226    ast_test_validate(
test, 
NULL != basePathJson);
 
  228    ast_test_validate(
test, 0 == strcmp(
"http://stasis.asterisk.org/ari", basePath));
 
 
  241        info->name = __func__;
 
  242        info->category = 
"/res/ari/";
 
  243        info->summary = 
"Test API get without a Host header";
 
  244        info->description = 
"Test ARI binding logic.";
 
  252    ast_test_validate(
test, 200 == response->response_code);
 
  256    ast_test_validate(
test, 
NULL == basePathJson);
 
 
  268        info->name = __func__;
 
  269        info->category = 
"/res/ari/";
 
  270        info->summary = 
"Test API get for invalid resource";
 
  271        info->description = 
"Test ARI binding logic.";
 
  279    ast_test_validate(
test, 404 == response->response_code);
 
 
  291        info->name = __func__;
 
  292        info->category = 
"/res/ari/";
 
  293        info->summary = 
"Test API get for a file outside the rest-api path";
 
  294        info->description = 
"Test ARI binding logic.";
 
  302    ast_test_validate(
test, 404 == response->response_code);
 
 
  317        info->name = __func__;
 
  318        info->category = 
"/res/ari/";
 
  319        info->summary = 
"Test simple GET of an HTTP resource.";
 
  320        info->description = 
"Test ARI binding logic.";
 
  338    expected = 
ast_json_pack(
"{s: s, s: {s: s, s: s}, s: {s: s, s: s}, s: {}}",
 
  352    ast_test_validate(
test, 200 == response->response_code);
 
 
  368        info->name = __func__;
 
  369        info->category = 
"/res/ari/";
 
  370        info->summary = 
"Test GET of a wildcard resource.";
 
  371        info->description = 
"Test ARI binding logic.";
 
  390    ast_test_validate(
test, 200 == response->response_code);
 
 
  406        info->name = __func__;
 
  407        info->category = 
"/res/ari/";
 
  408        info->summary = 
"Test DELETE of an HTTP resource.";
 
  409        info->description = 
"Test ARI binding logic.";
 
  418                 "name", 
"bang_delete",
 
  428    ast_test_validate(
test, 204 == response->response_code);
 
 
  444        info->name = __func__;
 
  445        info->category = 
"/res/ari/";
 
  446        info->summary = 
"Test POST of an HTTP resource.";
 
  447        info->description = 
"Test ARI binding logic.";
 
  465    expected = 
ast_json_pack(
"{s: s, s: {s: s, s: s}, s: {s: s, s: s}, s: {}}",
 
  479    ast_test_validate(
test, 200 == response->response_code);
 
 
  494        info->name = __func__;
 
  495        info->category = 
"/res/ari/";
 
  496        info->summary = 
"Test POST on a resource that doesn't support it.";
 
  497        info->description = 
"Test ARI binding logic.";
 
  509    ast_test_validate(
test, 405 == response->response_code);
 
 
  523        info->name = __func__;
 
  524        info->category = 
"/res/ari/";
 
  525        info->summary = 
"Test GET on a resource that does not exist.";
 
  526        info->description = 
"Test ARI binding logic.";
 
  538    ast_test_validate(
test, 404 == response->response_code);
 
 
  577    .
requires = 
"res_ari",
 
Asterisk RESTful API hooks.
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
void ast_ari_get_docs(const char *uri, const char *prefix, struct ast_variable *headers, struct ast_ari_response *response)
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
enum ast_ari_invoke_result ast_ari_invoke(struct ast_tcptls_session_instance *ser, enum ast_ari_invoke_source source, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_variable_new(name, value, filename)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
struct ast_json * ast_json_null(void)
Get the JSON null value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
int ast_json_equal(const struct ast_json *lhs, const struct ast_json *rhs)
Compare two JSON objects.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
struct ast_json * message
Abstract JSON element (object, array, string, int, ...).
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Handler for a single RESTful path segment.
const char * path_segment
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
static void response_free(struct ast_ari_response *resp)
#define HANDLER(name, response_code)
static void * setup_invocation_test(void)
static struct stasis_rest_handlers test_root
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
static struct ast_ari_response * response_alloc(void)
static struct stasis_rest_handlers bar
static int invocation_count
static struct stasis_rest_handlers bam
static int load_module(void)
static int unload_module(void)
static void tear_down_invocation_test(void *ignore)
static struct stasis_rest_handlers bang
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.