[asterisk-commits] jrose: trunk r405554 - in /trunk: ./ include/asterisk/ res/ res/ari/ rest-api...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 14 17:45:02 CST 2014
Author: jrose
Date: Tue Jan 14 17:44:57 2014
New Revision: 405554
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405554
Log:
ARI: Add mailboxes resource for controlling and polling external MWI
Adds the following AMI commands:
PUT mailboxes/mailboxName
modifies mailbox state and implicitly creates new mailboxes
GET mailboxes/mailboxName
retrieves a JSON representation of a single mailbox if it exists
GET mailboxes
retrieves a JSON array of all mailboxes
DELETE mailbox/mailboxName
deletes a mailbox
Note that res_mwi_external must be loaded for these functions to
actually do anything.
Review: https://reviewboard.asterisk.org/r/3117/
........
Merged revisions 405553 from http://svn.asterisk.org/svn/asterisk/branches/12
Added:
trunk/include/asterisk/stasis_app_mailbox.h
- copied unchanged from r405553, branches/12/include/asterisk/stasis_app_mailbox.h
trunk/res/ari/resource_mailboxes.c
- copied unchanged from r405553, branches/12/res/ari/resource_mailboxes.c
trunk/res/ari/resource_mailboxes.h
- copied unchanged from r405553, branches/12/res/ari/resource_mailboxes.h
trunk/res/res_ari_mailboxes.c
- copied unchanged from r405553, branches/12/res/res_ari_mailboxes.c
trunk/res/res_stasis_mailbox.c
- copied unchanged from r405553, branches/12/res/res_stasis_mailbox.c
trunk/res/res_stasis_mailbox.exports.in
- copied unchanged from r405553, branches/12/res/res_stasis_mailbox.exports.in
trunk/rest-api/api-docs/mailboxes.json
- copied unchanged from r405553, branches/12/rest-api/api-docs/mailboxes.json
Modified:
trunk/ (props changed)
trunk/res/ari.make
trunk/res/ari/ari_model_validators.c
trunk/res/ari/ari_model_validators.h
trunk/rest-api/resources.json
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/res/ari.make
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari.make?view=diff&rev=405554&r1=405553&r2=405554
==============================================================================
--- trunk/res/ari.make (original)
+++ trunk/res/ari.make Tue Jan 14 17:44:57 2014
@@ -49,6 +49,10 @@
ari/resource_device_states.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_device_states)
+res_ari_mailboxes.so: ari/resource_mailboxes.o
+
+ari/resource_mailboxes.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_mailboxes)
+
res_ari_events.so: ari/resource_events.o
ari/resource_events.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_events)
Modified: trunk/res/ari/ari_model_validators.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/ari_model_validators.c?view=diff&rev=405554&r1=405553&r2=405554
==============================================================================
--- trunk/res/ari/ari_model_validators.c (original)
+++ trunk/res/ari/ari_model_validators.c Tue Jan 14 17:44:57 2014
@@ -1419,6 +1419,76 @@
return ast_ari_validate_device_state;
}
+int ast_ari_validate_mailbox(struct ast_json *json)
+{
+ int res = 1;
+ struct ast_json_iter *iter;
+ int has_name = 0;
+ int has_new_messages = 0;
+ int has_old_messages = 0;
+
+ for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+ if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ has_name = 1;
+ prop_is_valid = ast_ari_validate_string(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI Mailbox field name failed validation\n");
+ res = 0;
+ }
+ } else
+ if (strcmp("new_messages", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ has_new_messages = 1;
+ prop_is_valid = ast_ari_validate_int(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI Mailbox field new_messages failed validation\n");
+ res = 0;
+ }
+ } else
+ if (strcmp("old_messages", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ has_old_messages = 1;
+ prop_is_valid = ast_ari_validate_int(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI Mailbox field old_messages failed validation\n");
+ res = 0;
+ }
+ } else
+ {
+ ast_log(LOG_ERROR,
+ "ARI Mailbox has undocumented field %s\n",
+ ast_json_object_iter_key(iter));
+ res = 0;
+ }
+ }
+
+ if (!has_name) {
+ ast_log(LOG_ERROR, "ARI Mailbox missing required field name\n");
+ res = 0;
+ }
+
+ if (!has_new_messages) {
+ ast_log(LOG_ERROR, "ARI Mailbox missing required field new_messages\n");
+ res = 0;
+ }
+
+ if (!has_old_messages) {
+ ast_log(LOG_ERROR, "ARI Mailbox missing required field old_messages\n");
+ res = 0;
+ }
+
+ return res;
+}
+
+ari_validator ast_ari_validate_mailbox_fn(void)
+{
+ return ast_ari_validate_mailbox;
+}
+
int ast_ari_validate_application_replaced(struct ast_json *json)
{
int res = 1;
Modified: trunk/res/ari/ari_model_validators.h
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/ari_model_validators.h?view=diff&rev=405554&r1=405553&r2=405554
==============================================================================
--- trunk/res/ari/ari_model_validators.h (original)
+++ trunk/res/ari/ari_model_validators.h Tue Jan 14 17:44:57 2014
@@ -497,6 +497,24 @@
* See \ref ast_ari_model_validators.h for more details.
*/
ari_validator ast_ari_validate_device_state_fn(void);
+
+/*!
+ * \brief Validator for Mailbox.
+ *
+ * Represents the state of a mailbox.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_mailbox(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ast_ari_validate_mailbox().
+ *
+ * See \ref ast_ari_model_validators.h for more details.
+ */
+ari_validator ast_ari_validate_mailbox_fn(void);
/*!
* \brief Validator for ApplicationReplaced.
@@ -1111,6 +1129,10 @@
* DeviceState
* - name: string (required)
* - state: string (required)
+ * Mailbox
+ * - name: string (required)
+ * - new_messages: int (required)
+ * - old_messages: int (required)
* ApplicationReplaced
* - type: string (required)
* - application: string (required)
Modified: trunk/rest-api/resources.json
URL: http://svnview.digium.com/svn/asterisk/trunk/rest-api/resources.json?view=diff&rev=405554&r1=405553&r2=405554
==============================================================================
--- trunk/rest-api/resources.json (original)
+++ trunk/rest-api/resources.json Tue Jan 14 17:44:57 2014
@@ -39,6 +39,10 @@
"description": "Device state resources"
},
{
+ "path": "/api-docs/mailboxes.{format}",
+ "description": "Mailboxes resources"
+ },
+ {
"path": "/api-docs/events.{format}",
"description": "WebSocket resource"
},
More information about the asterisk-commits
mailing list