[asterisk-commits] kmoore: branch kmoore/stasis-bridging-channel_events r387792 - in /team/kmoor...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 6 17:16:41 CDT 2013


Author: kmoore
Date: Mon May  6 17:16:39 2013
New Revision: 387792

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387792
Log:
Cleanups from review

Modified:
    team/kmoore/stasis-bridging-channel_events/res/res_stasis.c
    team/kmoore/stasis-bridging-channel_events/res/stasis_http/resource_events.h
    team/kmoore/stasis-bridging-channel_events/rest-api-templates/asterisk_processor.py
    team/kmoore/stasis-bridging-channel_events/rest-api-templates/res_stasis_http_resource.c.mustache
    team/kmoore/stasis-bridging-channel_events/rest-api-templates/stasis_http_resource.h.mustache
    team/kmoore/stasis-bridging-channel_events/rest-api-templates/swagger_model.py
    team/kmoore/stasis-bridging-channel_events/rest-api/api-docs/events.json

Modified: team/kmoore/stasis-bridging-channel_events/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/res/res_stasis.c?view=diff&rev=387792&r1=387791&r2=387792
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/res/res_stasis.c (original)
+++ team/kmoore/stasis-bridging-channel_events/res/res_stasis.c Mon May  6 17:16:39 2013
@@ -527,8 +527,8 @@
 		return stasis_json_event_channel_created_create(snapshot);
 	} else if (!new_snapshot) {
 		json = ast_json_pack("{s: i, s: s}",
-			"Cause", snapshot->hangupcause,
-			"Cause-txt", ast_cause2str(snapshot->hangupcause));
+			"cause", snapshot->hangupcause,
+			"cause_txt", ast_cause2str(snapshot->hangupcause));
 		if (!json) {
 			return NULL;
 		}
@@ -561,8 +561,8 @@
 	}
 
 	json = ast_json_pack("{s: s, s: s}",
-		"Application", new_snapshot->appl,
-		"ApplicationData", new_snapshot->data);
+		"application", new_snapshot->appl,
+		"application_data", new_snapshot->data);
 	if (!json) {
 		return NULL;
 	}
@@ -586,8 +586,8 @@
 	}
 
 	json = ast_json_pack("{s: i, s: s}",
-		"CallerPresentation", new_snapshot->caller_pres,
-		"CallerPresentation-txt", ast_describe_caller_presentation(new_snapshot->caller_pres));
+		"caller_presentation", new_snapshot->caller_pres,
+		"caller_presentation_txt", ast_describe_caller_presentation(new_snapshot->caller_pres));
 	if (!json) {
 		return NULL;
 	}

Modified: team/kmoore/stasis-bridging-channel_events/res/stasis_http/resource_events.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/res/stasis_http/resource_events.h?view=diff&rev=387792&r1=387791&r2=387792
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/res/stasis_http/resource_events.h (original)
+++ team/kmoore/stasis-bridging-channel_events/res/stasis_http/resource_events.h Mon May  6 17:16:39 2013
@@ -300,56 +300,57 @@
 /*
  * JSON models
  *
- * ChannelUserevent (channel_userevent)
- * - channel - The channel that signaled the user event.
+ * ChannelUserevent
  * - eventname: string (required)
  * - Body: string (required)
- * BridgeCreated (bridge_created)
- * - bridge - of the bridge variety
- * ChannelDestroyed (channel_destroyed)
- * - channel - of the channel variety
+ * BridgeCreated
+ * ChannelDestroyed
  * - Cause-txt: string (required)
  * - Cause: integer (required)
- * ChannelSnapshot (channel_snapshot)
- * - channel - of the channel variety
- * ChannelCallerId (channel_caller_id)
- * - channel - The channel that changed Caller ID.
+ * ChannelSnapshot
+ * ChannelCallerId
  * - CallerPresentation-txt: string (required)
  * - CallerPresentation: integer (required)
- * ChannelHangupRequest (channel_hangup_request)
- * - channel - The channel on which the hangup was requested.
+ * ChannelHangupRequest
  * - soft: integer
  * - cause: integer
- * BridgeDestroyed (bridge_destroyed)
- * - bridge - of the bridge variety
- * ApplicationReplaced (application_replaced)
+ * BridgeDestroyed
+ * ApplicationReplaced
  * - application: string (required)
- * ChannelVarset (channel_varset)
- * - channel - The channel on which the variable was set.
+ * ChannelVarset
  * - variable: string (required)
  * - value: string (required)
- * ChannelLeftBridge (channel_left_bridge)
- * - channel - of the channel variety
- * - bridge - of the bridge variety
- * ChannelCreated (channel_created)
- * - channel - of the channel variety
- * StasisStart (stasis_start)
- * - channel - of the channel variety
+ * ChannelLeftBridge
+ * ChannelCreated
+ * StasisStart
  * - args: List[string] (required)
- * ChannelDialplan (channel_dialplan)
- * - channel - The channel that changed dialplan location.
+ * ChannelDialplan
  * - Application: string (required)
  * - ApplicationData: string (required)
- * ChannelStateChange (channel_state_change)
- * - channel - of the channel variety
- * ChannelEnteredBridge (channel_entered_bridge)
- * - channel - of the channel variety
- * - bridge - of the bridge variety
- * ChannelDtmfReceived (channel_dtmf_received)
- * - channel - The channel on which DTMF was received
+ * ChannelStateChange
+ * ChannelEnteredBridge
+ * ChannelDtmfReceived
  * - digit: string (required)
- * StasisEnd (stasis_end)
- * - channel - of the channel variety
+ * Event
+ * - stasis_start: StasisStart
+ * - channel_created: ChannelCreated
+ * - channel_destroyed: ChannelDestroyed
+ * - channel_entered_bridge: ChannelEnteredBridge
+ * - channel_left_bridge: ChannelLeftBridge
+ * - channel_dialplan: ChannelDialplan
+ * - channel_varset: ChannelVarset
+ * - application_replaced: ApplicationReplaced
+ * - channel_state_change: ChannelStateChange
+ * - bridge_created: BridgeCreated
+ * - application: string (required)
+ * - channel_hangup_request: ChannelHangupRequest
+ * - channel_userevent: ChannelUserevent
+ * - channel_snapshot: ChannelSnapshot
+ * - channel_dtmf_received: ChannelDtmfReceived
+ * - channel_caller_id: ChannelCallerId
+ * - bridge_destroyed: BridgeDestroyed
+ * - stasis_end: StasisEnd
+ * StasisEnd
  */
 
 #endif /* _ASTERISK_RESOURCE_EVENTS_H */

Modified: team/kmoore/stasis-bridging-channel_events/rest-api-templates/asterisk_processor.py
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/rest-api-templates/asterisk_processor.py?view=diff&rev=387792&r1=387791&r2=387792
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/rest-api-templates/asterisk_processor.py (original)
+++ team/kmoore/stasis-bridging-channel_events/rest-api-templates/asterisk_processor.py Mon May  6 17:16:39 2013
@@ -106,13 +106,6 @@
         """Gets count of children.
         """
         return len(self.__children)
-
-def is_chan_or_bridge(prop):
-    if prop.name == 'channel' and prop.type == 'Channel':
-        return True
-    if prop.name == 'bridge' and prop.type == 'Bridge':
-        return True
-    return False
 
 class AsteriskProcessor(SwaggerPostProcessor):
     """A SwaggerPostProcessor which adds fields needed to generate Asterisk
@@ -151,10 +144,17 @@
                 segment = resource_api.root_path.get_child(api.path.split('/'))
                 for operation in api.operations:
                     segment.operations.append(operation)
-            if resource_api.api_declaration.is_events:
-                resource_api.api_declaration.models = \
+            resource_api.api_declaration.has_events = False
+            for model in resource_api.api_declaration.models:
+                if model.id == "Event":
+                    resource_api.api_declaration.has_events = True
+                    break
+            if resource_api.api_declaration.has_events:
+                resource_api.api_declaration.events = \
                     [self.process_model(model, context) for model in \
                         resource_api.api_declaration.models if model.id != "Event"]
+            else:
+                resource_api.api_declaration.events = []
 
             # Since every API path should start with /[resource], root should
             # have exactly one child.

Modified: team/kmoore/stasis-bridging-channel_events/rest-api-templates/res_stasis_http_resource.c.mustache
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/rest-api-templates/res_stasis_http_resource.c.mustache?view=diff&rev=387792&r1=387791&r2=387792
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/rest-api-templates/res_stasis_http_resource.c.mustache (original)
+++ team/kmoore/stasis-bridging-channel_events/rest-api-templates/res_stasis_http_resource.c.mustache Mon May  6 17:16:39 2013
@@ -47,10 +47,10 @@
 
 #include "asterisk/module.h"
 #include "stasis_http/resource_{{name}}.h"
-{{#is_events}}
+{{#has_events}}
 #include "asterisk/stasis_channels.h"
 #include "asterisk/stasis_bridging.h"
-{{/is_events}}
+{{/has_events}}
 
 {{#apis}}
 {{#operations}}
@@ -100,8 +100,8 @@
 {{> rest_handler}}
 {{/root_path}}
 
-{{#is_events}}
-{{#models}}
+{{#has_events}}
+{{#events}}
 {{> event_function_decl}}
 	)
 {
@@ -181,8 +181,8 @@
 	return ast_json_ref(message);
 }
 
-{{/models}}
-{{/is_events}}
+{{/events}}
+{{/has_events}}
 static int load_module(void)
 {
 	return stasis_http_add_handler(&{{root_full_name}});

Modified: team/kmoore/stasis-bridging-channel_events/rest-api-templates/stasis_http_resource.h.mustache
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/rest-api-templates/stasis_http_resource.h.mustache?view=diff&rev=387792&r1=387791&r2=387792
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/rest-api-templates/stasis_http_resource.h.mustache (original)
+++ team/kmoore/stasis-bridging-channel_events/rest-api-templates/stasis_http_resource.h.mustache Mon May  6 17:16:39 2013
@@ -64,11 +64,11 @@
 {{/operations}}
 {{/apis}}
 
-{{#is_events}}
+{{#has_events}}
 struct ast_channel_snapshot;
 struct ast_bridge_snapshot;
 
-{{#models}}
+{{#events}}
 /*!
  * \brief {{description}}
 {{#notes}}
@@ -95,30 +95,16 @@
 {{> event_function_decl}}
 	);
 
-{{/models}}
-{{/is_events}}
+{{/events}}
+{{/has_events}}
 /*
  * JSON models
  *
 {{#models}}
-{{#is_events}}
- * {{id}} ({{c_id}})
-{{#channel}}
- * - channel - {{#channel_desc}}{{channel_desc}}{{/channel_desc}}{{^channel_desc}}of the channel variety{{/channel_desc}}
-{{/channel}}
-{{#bridge}}
- * - bridge - {{#bridge_desc}}{{bridge_desc}}{{/bridge_desc}}{{^bridge_desc}}of the bridge variety{{/bridge_desc}}
-{{/bridge}}
-{{#properties}}
- * - {{name}}: {{type}}{{#required}} (required){{/required}}
-{{/properties}}
-{{/is_events}}
-{{^is_events}}
  * {{id}}
 {{#properties}}
  * - {{name}}: {{type}}{{#required}} (required){{/required}}
 {{/properties}}
-{{/is_events}}
 {{/models}} */
 
 #endif /* _ASTERISK_RESOURCE_{{name_caps}}_H */

Modified: team/kmoore/stasis-bridging-channel_events/rest-api-templates/swagger_model.py
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/rest-api-templates/swagger_model.py?view=diff&rev=387792&r1=387791&r2=387792
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/rest-api-templates/swagger_model.py (original)
+++ team/kmoore/stasis-bridging-channel_events/rest-api-templates/swagger_model.py Mon May  6 17:16:39 2013
@@ -295,7 +295,8 @@
 
     def __init__(self):
         self.id = None
-        self.notes = ""
+        self.notes = None
+        self.description = None
         self.properties = None
 
     def load(self, id, model_json, processor, context):
@@ -377,11 +378,6 @@
         self.apis = [
             Api().load(j, processor, context) for j in api_json]
         models = api_decl_json.get('models').items() or []
-        self.is_events = False
-        for (k, j) in models:
-            if k == "Event":
-                self.is_events = True
-                break
         self.models = [
             Model().load(k, j, processor, context) for (k, j) in models]
 

Modified: team/kmoore/stasis-bridging-channel_events/rest-api/api-docs/events.json
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/rest-api/api-docs/events.json?view=diff&rev=387792&r1=387791&r2=387792
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/rest-api/api-docs/events.json (original)
+++ team/kmoore/stasis-bridging-channel_events/rest-api/api-docs/events.json Mon May  6 17:16:39 2013
@@ -127,12 +127,12 @@
 			"id": "ChannelDestroyed",
 			"description": "Notification that a channel has been destroyed.",
 			"properties": {
-				"Cause": {
+				"cause": {
 					"required": true,
 					"description": "Integer representation of the cause of the hangup",
 					"type": "integer"
 				},
-				"Cause-txt": {
+				"cause_txt": {
 					"required": true,
 					"description": "Text representation of the cause of the hangup",
 					"type": "string"
@@ -201,12 +201,12 @@
 			"id": "ChannelDialplan",
 			"description": "Channel changed location in the dialplan.",
 			"properties": {
-				"Application": {
+				"application": {
 					"required": true,
 					"type": "string",
 					"description": "The application that the channel is currently in."
 				},
-				"ApplicationData": {
+				"application_data": {
 					"required": true,
 					"type": "string",
 					"description": "The data that was passed to the application when it was invoked."
@@ -222,12 +222,12 @@
 			"id": "ChannelCallerId",
 			"description": "Channel changed Caller ID.",
 			"properties": {
-				"CallerPresentation": {
+				"caller_presentation": {
 					"required": true,
 					"type": "integer",
 					"description": "The integer representation of the Caller Presentation value."
 				},
-				"CallerPresentation-txt": {
+				"caller_presentation_txt": {
 					"required": true,
 					"type": "string",
 					"description": "The text representation of the Caller Presentation value."
@@ -248,7 +248,7 @@
 					"type": "string",
 					"description": "The name of the user event."
 				},
-				"Body": {
+				"body": {
 					"required": true,
 					"type": "string",
 					"description": "The additional body parameters for the user event."
@@ -269,7 +269,7 @@
 					"description": "Integer representation of the cause of the hangup."
 				},
 				"soft": {
-					"type": "integer",
+					"type": "boolean",
 					"description": "Whether the hangup request was a soft hangup request."
 				},
 				"channel": {




More information about the asterisk-commits mailing list