Asterisk - The Open Source Telephony Project GIT-master-f36a736
Data Structures | Functions
resource_mailboxes.h File Reference

Generated file - declares stubs to be implemented in res/ari/resource_mailboxes.c. More...

#include "asterisk/ari.h"
Include dependency graph for resource_mailboxes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_ari_mailboxes_delete_args
 
struct  ast_ari_mailboxes_get_args
 
struct  ast_ari_mailboxes_list_args
 
struct  ast_ari_mailboxes_update_args
 

Functions

void ast_ari_mailboxes_delete (struct ast_variable *headers, struct ast_ari_mailboxes_delete_args *args, struct ast_ari_response *response)
 Destroy a mailbox. More...
 
void ast_ari_mailboxes_get (struct ast_variable *headers, struct ast_ari_mailboxes_get_args *args, struct ast_ari_response *response)
 Retrieve the current state of a mailbox. More...
 
void ast_ari_mailboxes_list (struct ast_variable *headers, struct ast_ari_mailboxes_list_args *args, struct ast_ari_response *response)
 List all mailboxes. More...
 
void ast_ari_mailboxes_update (struct ast_variable *headers, struct ast_ari_mailboxes_update_args *args, struct ast_ari_response *response)
 Change the state of a mailbox. (Note - implicitly creates the mailbox). More...
 
int ast_ari_mailboxes_update_parse_body (struct ast_json *body, struct ast_ari_mailboxes_update_args *args)
 Body parsing function for /mailboxes/{mailboxName}. More...
 

Detailed Description

Generated file - declares stubs to be implemented in res/ari/resource_mailboxes.c.

Mailboxes resources

Author
Jonathan Rose jrose.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file resource_mailboxes.h.

Function Documentation

◆ ast_ari_mailboxes_delete()

void ast_ari_mailboxes_delete ( struct ast_variable headers,
struct ast_ari_mailboxes_delete_args args,
struct ast_ari_response response 
)

Destroy a mailbox.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 79 of file resource_mailboxes.c.

82{
83 switch (stasis_app_mailbox_delete(args->mailbox_name)) {
85 ast_ari_response_error(response, 404,
86 "Not Found", "Mailbox does not exist");
87 return;
89 ast_ari_response_error(response, 500,
90 "INternal Server Error", "Failed to delete the mailbox");
91 return;
94 }
95}
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.
Definition: res_ari.c:259
void ast_ari_response_no_content(struct ast_ari_response *response)
Fill in a No Content (204) ast_ari_response.
Definition: res_ari.c:284
enum stasis_mailbox_result stasis_app_mailbox_delete(const char *name)
Delete a mailbox controlled by ARI.
@ STASIS_MAILBOX_MISSING
@ STASIS_MAILBOX_ERROR
@ STASIS_MAILBOX_OK
const char * args

References args, ast_ari_response_error(), ast_ari_response_no_content(), stasis_app_mailbox_delete(), STASIS_MAILBOX_ERROR, STASIS_MAILBOX_MISSING, and STASIS_MAILBOX_OK.

Referenced by ast_ari_mailboxes_delete_cb().

◆ ast_ari_mailboxes_get()

void ast_ari_mailboxes_get ( struct ast_variable headers,
struct ast_ari_mailboxes_get_args args,
struct ast_ari_response response 
)

Retrieve the current state of a mailbox.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 49 of file resource_mailboxes.c.

52{
53 struct ast_json *json;
54
55 switch (stasis_app_mailbox_to_json(args->mailbox_name, &json)) {
57 ast_ari_response_error(response, 404,
58 "Not Found", "Mailbox is does not exist");
59 return;
61 ast_ari_response_error(response, 500,
62 "Internal Server Error", "Error building response");
63 return;
65 ast_ari_response_ok(response, json);
66 }
67}
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
Definition: res_ari.c:276
enum stasis_mailbox_result stasis_app_mailbox_to_json(const char *name, struct ast_json **json)
Convert mailbox to JSON.
Abstract JSON element (object, array, string, int, ...).

References args, ast_ari_response_error(), ast_ari_response_ok(), stasis_app_mailbox_to_json(), STASIS_MAILBOX_ERROR, STASIS_MAILBOX_MISSING, and STASIS_MAILBOX_OK.

Referenced by ast_ari_mailboxes_get_cb().

◆ ast_ari_mailboxes_list()

void ast_ari_mailboxes_list ( struct ast_variable headers,
struct ast_ari_mailboxes_list_args args,
struct ast_ari_response response 
)

List all mailboxes.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 35 of file resource_mailboxes.c.

38{
39 struct ast_json *json;
40
41 if (!(json = stasis_app_mailboxes_to_json())) {
42 ast_ari_response_error(response, 500,
43 "Internal Server Error", "Error building response");
44 return;
45 }
46
47 ast_ari_response_ok(response, json);
48}
struct ast_json * stasis_app_mailboxes_to_json(void)
Convert mailboxes to json array.

References ast_ari_response_error(), ast_ari_response_ok(), and stasis_app_mailboxes_to_json().

Referenced by ast_ari_mailboxes_list_cb().

◆ ast_ari_mailboxes_update()

void ast_ari_mailboxes_update ( struct ast_variable headers,
struct ast_ari_mailboxes_update_args args,
struct ast_ari_response response 
)

Change the state of a mailbox. (Note - implicitly creates the mailbox).

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 68 of file resource_mailboxes.c.

71{
72 if (stasis_app_mailbox_update(args->mailbox_name, args->old_messages, args->new_messages)) {
73 ast_ari_response_error(response, 500, "Internal Server Error", "Error updating mailbox");
74 return;
75 }
76
78}
int stasis_app_mailbox_update(const char *name, int old_messages, int new_messages)
Changes the state of a mailbox.

References args, ast_ari_response_error(), ast_ari_response_no_content(), and stasis_app_mailbox_update().

Referenced by ast_ari_mailboxes_update_cb().

◆ ast_ari_mailboxes_update_parse_body()

int ast_ari_mailboxes_update_parse_body ( struct ast_json body,
struct ast_ari_mailboxes_update_args args 
)

Body parsing function for /mailboxes/{mailboxName}.

Parameters
bodyThe JSON body from which to parse parameters.
[out]argsThe args structure to parse into.
Return values
zeroon success
non-zeroon failure

Definition at line 166 of file res_ari_mailboxes.c.

169{
170 struct ast_json *field;
171 /* Parse query parameters out of it */
172 field = ast_json_object_get(body, "oldMessages");
173 if (field) {
174 args->old_messages = ast_json_integer_get(field);
175 }
176 field = ast_json_object_get(body, "newMessages");
177 if (field) {
178 args->new_messages = ast_json_integer_get(field);
179 }
180 return 0;
181}
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:407
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:332

References args, ast_json_integer_get(), and ast_json_object_get().

Referenced by ast_ari_mailboxes_update_cb().