[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392317 - in /team/dlee/ari-event-remode...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 20 11:19:44 CDT 2013


Author: dlee
Date: Thu Jun 20 11:19:42 2013
New Revision: 392317

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392317
Log:
Slowly getting things in order

Modified:
    team/dlee/ari-event-remodel2/main/stasis_endpoints.c
    team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c
    team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h
    team/dlee/ari-event-remodel2/rest-api-templates/ari_model.c.mustache
    team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py
    team/dlee/ari-event-remodel2/rest-api/api-docs/endpoints.json

Modified: team/dlee/ari-event-remodel2/main/stasis_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/main/stasis_endpoints.c?view=diff&rev=392317&r1=392316&r2=392317
==============================================================================
--- team/dlee/ari-event-remodel2/main/stasis_endpoints.c (original)
+++ team/dlee/ari-event-remodel2/main/stasis_endpoints.c Thu Jun 20 11:19:42 2013
@@ -112,7 +112,7 @@
 		"technology", snapshot->tech,
 		"resource", snapshot->resource,
 		"state", ast_endpoint_state_to_string(snapshot->state),
-		"channels");
+		"channel_ids");
 
 	if (json == NULL) {
 		return NULL;

Modified: team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c?view=diff&rev=392317&r1=392316&r2=392317
==============================================================================
--- team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c (original)
+++ team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c Thu Jun 20 11:19:42 2013
@@ -45,10 +45,22 @@
 {
 	int res = 1;
 	struct ast_json_iter *iter;
+	int has_channel_ids = 0;
 	int has_resource = 0;
 	int has_technology = 0;
 
 	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
+			int prop_res;
+			has_channel_ids = 1;
+			prop_res = ari_validate_list(
+				ast_json_object_iter_value(iter),
+				ari_validate_string);
+			if (!prop_res) {
+				ast_log(LOG_ERROR, "ARI Endpoint field channel_ids failed validation\n");
+				res = 0;
+			}
+		} else
 		if (strcmp("resource", ast_json_object_iter_key(iter)) == 0) {
 			int prop_res;
 			has_resource = 1;
@@ -59,6 +71,15 @@
 				res = 0;
 			}
 		} else
+		if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
+			int prop_res;
+			prop_res = ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_res) {
+				ast_log(LOG_ERROR, "ARI Endpoint field state failed validation\n");
+				res = 0;
+			}
+		} else
 		if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
 			int prop_res;
 			has_technology = 1;
@@ -77,6 +98,10 @@
 		}
 	}
 
+	if (!has_channel_ids) {
+		ast_log(LOG_ERROR, "ARI Endpoint missing required field channel_ids\n");
+		res = 0;
+	}
 	if (!has_resource) {
 		ast_log(LOG_ERROR, "ARI Endpoint missing required field resource\n");
 		res = 0;

Modified: team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h?view=diff&rev=392317&r1=392316&r2=392317
==============================================================================
--- team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h (original)
+++ team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h Thu Jun 20 11:19:42 2013
@@ -481,7 +481,9 @@
  *
  * AsteriskInfo
  * Endpoint
+ * - channel_ids: List[string] (required)
  * - resource: string (required)
+ * - state: string
  * - technology: string (required)
  * CallerID
  * - name: string (required)

Modified: team/dlee/ari-event-remodel2/rest-api-templates/ari_model.c.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/ari_model.c.mustache?view=diff&rev=392317&r1=392316&r2=392317
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/ari_model.c.mustache (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/ari_model.c.mustache Thu Jun 20 11:19:42 2013
@@ -57,7 +57,7 @@
 {{#is_list}}
 			prop_res = ari_validate_list(
 				ast_json_object_iter_value(iter),
-				ari_validate_{{type_param}});
+				ari_validate_{{c_type_param}});
 {{/is_list}}
 {{^is_list}}
 			prop_res = ari_validate_{{snake_type}}(

Modified: team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py?view=diff&rev=392317&r1=392316&r2=392317
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py Thu Jun 20 11:19:42 2013
@@ -196,3 +196,5 @@
         if prop.name != prop.name.lower():
             raise SwaggerError("Property name should not be lowercase", context)
         prop.snake_type = snakify(prop.type)
+        if hasattr(prop, 'type_param'):
+            prop.c_type_param = snakify(prop.type_param)

Modified: team/dlee/ari-event-remodel2/rest-api/api-docs/endpoints.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api/api-docs/endpoints.json?view=diff&rev=392317&r1=392316&r2=392317
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api/api-docs/endpoints.json (original)
+++ team/dlee/ari-event-remodel2/rest-api/api-docs/endpoints.json Thu Jun 20 11:19:42 2013
@@ -80,6 +80,24 @@
 					"type": "string",
 					"description": "Identifier of the endpoint, specific to the given technology.",
 					"required": true
+				},
+				"state": {
+					"type": "string",
+					"description": "Endpoint's state",
+					"required": false,
+					"allowableValues": {
+						"valueType": "LIST",
+						"values": [
+							"unknown",
+							"offline",
+							"online"
+						]
+					}
+				},
+				"channel_ids": {
+					"type": "List[string]",
+					"description": "Id's of channels associated with this endpoint",
+					"required": true
 				}
 			}
 		}




More information about the asterisk-commits mailing list