Asterisk - The Open Source Telephony Project  18.5.0
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.

References ast_ari_response_error(), ast_ari_response_no_content(), ast_ari_mailboxes_delete_args::mailbox_name, stasis_app_mailbox_delete(), STASIS_MAILBOX_ERROR, STASIS_MAILBOX_MISSING, and STASIS_MAILBOX_OK.

Referenced by ast_ari_mailboxes_delete_cb().

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;
92  case STASIS_MAILBOX_OK:
94  }
95 }
enum stasis_mailbox_result stasis_app_mailbox_delete(const char *name)
Delete a mailbox controlled by ARI.
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

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

References ast_ari_response_error(), ast_ari_response_ok(), ast_ari_mailboxes_get_args::mailbox_name, stasis_app_mailbox_to_json(), STASIS_MAILBOX_ERROR, STASIS_MAILBOX_MISSING, and STASIS_MAILBOX_OK.

Referenced by ast_ari_mailboxes_get_cb().

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;
64  case STASIS_MAILBOX_OK:
65  ast_ari_response_ok(response, json);
66  }
67 }
enum stasis_mailbox_result stasis_app_mailbox_to_json(const char *name, struct ast_json **json)
Convert mailbox to JSON.
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
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
Abstract JSON element (object, array, string, int, ...).

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

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

Referenced by ast_ari_mailboxes_list_cb().

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 }
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
struct ast_json * stasis_app_mailboxes_to_json(void)
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
Abstract JSON element (object, array, string, int, ...).

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

References ast_ari_response_error(), ast_ari_response_no_content(), ast_ari_mailboxes_update_args::mailbox_name, ast_ari_mailboxes_update_args::new_messages, ast_ari_mailboxes_update_args::old_messages, and stasis_app_mailbox_update().

Referenced by ast_ari_mailboxes_update_cb().

71 {
73  ast_ari_response_error(response, 500, "Internal Server Error", "Error updating mailbox");
74  return;
75  }
76 
78 }
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
int stasis_app_mailbox_update(const char *name, int old_messages, int new_messages)
Changes the state of a mailbox.

◆ 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 162 of file res_ari_mailboxes.c.

References ast_json_integer_get(), ast_json_object_get(), ast_ari_mailboxes_update_args::new_messages, and ast_ari_mailboxes_update_args::old_messages.

Referenced by ast_ari_mailboxes_update_cb().

165 {
166  struct ast_json *field;
167  /* Parse query parameters out of it */
168  field = ast_json_object_get(body, "oldMessages");
169  if (field) {
170  args->old_messages = ast_json_integer_get(field);
171  }
172  field = ast_json_object_get(body, "newMessages");
173  if (field) {
174  args->new_messages = ast_json_integer_get(field);
175  }
176  return 0;
177 }
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
Abstract JSON element (object, array, string, int, ...).
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322