Asterisk - The Open Source Telephony Project GIT-master-a358458
Functions
resource_mailboxes.c File Reference

/api-docs/mailboxes.{format} implementation- Mailboxes resources More...

#include "asterisk.h"
#include "asterisk/stasis_app_mailbox.h"
#include "resource_mailboxes.h"
Include dependency graph for resource_mailboxes.c:

Go to the source code of this file.

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...
 

Detailed Description

/api-docs/mailboxes.{format} implementation- Mailboxes resources

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

Definition in file resource_mailboxes.c.

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().