Endpoint resources.
More...
Go to the source code of this file.
|
static void | __reg_module (void) |
|
static void | __unreg_module (void) |
|
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_json *body, struct ast_ari_response *response) |
| Parameter parsing callback for /endpoints/{tech}/{resource}. More...
|
|
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_json *body, struct ast_ari_response *response) |
| Parameter parsing callback for /endpoints/{tech}. More...
|
|
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_json *body, struct ast_ari_response *response) |
| Parameter parsing callback for /endpoints. More...
|
|
static void | ast_ari_endpoints_send_message_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response) |
| Parameter parsing callback for /endpoints/sendMessage. More...
|
|
int | ast_ari_endpoints_send_message_parse_body (struct ast_json *body, struct ast_ari_endpoints_send_message_args *args) |
| Body parsing function for /endpoints/sendMessage. More...
|
|
static void | ast_ari_endpoints_send_message_to_endpoint_cb (struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response) |
| Parameter parsing callback for /endpoints/{tech}/{resource}/sendMessage. More...
|
|
int | ast_ari_endpoints_send_message_to_endpoint_parse_body (struct ast_json *body, struct ast_ari_endpoints_send_message_to_endpoint_args *args) |
| Body parsing function for /endpoints/{tech}/{resource}/sendMessage. More...
|
|
struct ast_module * | AST_MODULE_SELF_SYM (void) |
|
static int | load_module (void) |
|
static int | unload_module (void) |
|
|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "RESTful API module - Endpoint resources" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_ari,res_ari_model,res_stasis", } |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
static struct stasis_rest_handlers | endpoints |
| REST handler for /api-docs/endpoints.json. More...
|
|
static struct stasis_rest_handlers | endpoints_sendMessage |
| REST handler for /api-docs/endpoints.json. More...
|
|
static struct stasis_rest_handlers | endpoints_tech |
| REST handler for /api-docs/endpoints.json. More...
|
|
static struct stasis_rest_handlers | endpoints_tech_resource |
| REST handler for /api-docs/endpoints.json. More...
|
|
static struct stasis_rest_handlers | endpoints_tech_resource_sendMessage |
| REST handler for /api-docs/endpoints.json. More...
|
|
Endpoint resources.
- Author
- David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m
Definition in file res_ari_endpoints.c.
◆ MAX_VALS
◆ __reg_module()
static void __reg_module |
( |
void |
| ) |
|
|
static |
◆ __unreg_module()
static void __unreg_module |
( |
void |
| ) |
|
|
static |
◆ ast_ari_endpoints_get_cb()
Parameter parsing callback for /endpoints/{tech}/{resource}.
- Parameters
-
| ser | TCP/TLS session object |
| get_params | GET parameters in the HTTP request. |
| path_vars | Path variables extracted from the request. |
| headers | HTTP headers. |
| body | |
[out] | response | Response to the HTTP request. |
Definition at line 263 of file res_ari_endpoints.c.
270 #if defined(AST_DEVMODE)
275 for (i = path_vars; i; i = i->
next) {
276 if (strcmp(i->
name,
"tech") == 0) {
279 if (strcmp(i->
name,
"resource") == 0) {
285 #if defined(AST_DEVMODE)
299 if (200 <= code && code <= 299) {
303 ast_log(
LOG_ERROR,
"Invalid error response %d for /endpoints/{tech}/{resource}\n", code);
309 ast_log(
LOG_ERROR,
"Response validation failed for /endpoints/{tech}/{resource}\n");
311 "Internal Server Error",
"Response validation failed");
315 fin: __attribute__((unused))
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
int ast_ari_validate_endpoint(struct ast_json *json)
Validator for Endpoint.
void ast_ari_endpoints_get(struct ast_variable *headers, struct ast_ari_endpoints_get_args *args, struct ast_ari_response *response)
Details for an endpoint.
struct ast_json * message
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
References args, ast_ari_endpoints_get(), ast_ari_response_error(), ast_ari_validate_endpoint(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.
◆ ast_ari_endpoints_list_by_tech_cb()
Parameter parsing callback for /endpoints/{tech}.
- Parameters
-
| ser | TCP/TLS session object |
| get_params | GET parameters in the HTTP request. |
| path_vars | Path variables extracted from the request. |
| headers | HTTP headers. |
| body | |
[out] | response | Response to the HTTP request. |
Definition at line 203 of file res_ari_endpoints.c.
210 #if defined(AST_DEVMODE)
215 for (i = path_vars; i; i = i->
next) {
216 if (strcmp(i->
name,
"tech") == 0) {
222 #if defined(AST_DEVMODE)
235 if (200 <= code && code <= 299) {
239 ast_log(
LOG_ERROR,
"Invalid error response %d for /endpoints/{tech}\n", code);
247 "Internal Server Error",
"Response validation failed");
251 fin: __attribute__((unused))
ari_validator ast_ari_validate_endpoint_fn(void)
Function pointer to ast_ari_validate_endpoint().
int ast_ari_validate_list(struct ast_json *json, int(*fn)(struct ast_json *))
Validator for a Swagger List[]/JSON array.
void ast_ari_endpoints_list_by_tech(struct ast_variable *headers, struct ast_ari_endpoints_list_by_tech_args *args, struct ast_ari_response *response)
List available endoints for a given endpoint technology.
References args, ast_ari_endpoints_list_by_tech(), ast_ari_response_error(), ast_ari_validate_endpoint_fn(), ast_ari_validate_list(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.
◆ ast_ari_endpoints_list_cb()
Parameter parsing callback for /endpoints.
- Parameters
-
| ser | TCP/TLS session object |
| get_params | GET parameters in the HTTP request. |
| path_vars | Path variables extracted from the request. |
| headers | HTTP headers. |
| body | |
[out] | response | Response to the HTTP request. |
Definition at line 62 of file res_ari_endpoints.c.
68 #if defined(AST_DEVMODE)
74 #if defined(AST_DEVMODE)
86 if (200 <= code && code <= 299) {
98 "Internal Server Error",
"Response validation failed");
102 fin: __attribute__((unused))
void ast_ari_endpoints_list(struct ast_variable *headers, struct ast_ari_endpoints_list_args *args, struct ast_ari_response *response)
List all endpoints.
References args, ast_ari_endpoints_list(), ast_ari_response_error(), ast_ari_validate_endpoint_fn(), ast_ari_validate_list(), ast_log, LOG_ERROR, ast_ari_response::message, NULL, and ast_ari_response::response_code.
◆ ast_ari_endpoints_send_message_cb()
Parameter parsing callback for /endpoints/sendMessage.
- Parameters
-
| ser | TCP/TLS session object |
| get_params | GET parameters in the HTTP request. |
| path_vars | Path variables extracted from the request. |
| headers | HTTP headers. |
| body | |
[out] | response | Response to the HTTP request. |
Definition at line 135 of file res_ari_endpoints.c.
142 #if defined(AST_DEVMODE)
147 for (i = get_params; i; i = i->
next) {
148 if (strcmp(i->
name,
"to") == 0) {
151 if (strcmp(i->
name,
"from") == 0) {
154 if (strcmp(i->
name,
"body") == 0) {
159 args.variables = body;
161 #if defined(AST_DEVMODE)
175 if (200 <= code && code <= 299) {
179 ast_log(
LOG_ERROR,
"Invalid error response %d for /endpoints/sendMessage\n", code);
185 ast_log(
LOG_ERROR,
"Response validation failed for /endpoints/sendMessage\n");
187 "Internal Server Error",
"Response validation failed");
191 fin: __attribute__((unused))
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
void ast_ari_endpoints_send_message(struct ast_variable *headers, struct ast_ari_endpoints_send_message_args *args, struct ast_ari_response *response)
Send a message to some technology URI or endpoint.
References args, ast_ari_endpoints_send_message(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.
◆ ast_ari_endpoints_send_message_parse_body()
Body parsing function for /endpoints/sendMessage.
- Parameters
-
| body | The JSON body from which to parse parameters. |
[out] | args | The args structure to parse into. |
- Return values
-
zero | on success |
non-zero | on failure |
Definition at line 105 of file res_ari_endpoints.c.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Abstract JSON element (object, array, string, int, ...).
References args, ast_json_object_get(), and ast_json_string_get().
Referenced by ast_ari_endpoints_send_message().
◆ ast_ari_endpoints_send_message_to_endpoint_cb()
Parameter parsing callback for /endpoints/{tech}/{resource}/sendMessage.
- Parameters
-
| ser | TCP/TLS session object |
| get_params | GET parameters in the HTTP request. |
| path_vars | Path variables extracted from the request. |
| headers | HTTP headers. |
| body | |
[out] | response | Response to the HTTP request. |
Definition at line 344 of file res_ari_endpoints.c.
351 #if defined(AST_DEVMODE)
356 for (i = get_params; i; i = i->
next) {
357 if (strcmp(i->
name,
"from") == 0) {
360 if (strcmp(i->
name,
"body") == 0) {
365 for (i = path_vars; i; i = i->
next) {
366 if (strcmp(i->
name,
"tech") == 0) {
369 if (strcmp(i->
name,
"resource") == 0) {
374 args.variables = body;
376 #if defined(AST_DEVMODE)
390 if (200 <= code && code <= 299) {
394 ast_log(
LOG_ERROR,
"Invalid error response %d for /endpoints/{tech}/{resource}/sendMessage\n", code);
400 ast_log(
LOG_ERROR,
"Response validation failed for /endpoints/{tech}/{resource}/sendMessage\n");
402 "Internal Server Error",
"Response validation failed");
406 fin: __attribute__((unused))
void ast_ari_endpoints_send_message_to_endpoint(struct ast_variable *headers, struct ast_ari_endpoints_send_message_to_endpoint_args *args, struct ast_ari_response *response)
Send a message to some endpoint in a technology.
References args, ast_ari_endpoints_send_message_to_endpoint(), ast_ari_response_error(), ast_ari_validate_void(), ast_log, LOG_ERROR, ast_ari_response::message, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.
◆ ast_ari_endpoints_send_message_to_endpoint_parse_body()
◆ AST_MODULE_SELF_SYM()
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
Definition at line 464 of file res_ari_endpoints.c.
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static struct stasis_rest_handlers endpoints
REST handler for /api-docs/endpoints.json.
static int unload_module(void)
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
◆ __mod_info
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "RESTful API module - Endpoint resources" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_ari,res_ari_model,res_stasis", } |
|
static |
◆ ast_module_info
◆ endpoints
◆ endpoints_sendMessage
◆ endpoints_tech
◆ endpoints_tech_resource
◆ endpoints_tech_resource_sendMessage