[asterisk-commits] dlee: branch dlee/stasis-http r380427 - in /team/dlee/stasis-http: cog/ inclu...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 29 15:36:36 CST 2013


Author: dlee
Date: Tue Jan 29 15:36:33 2013
New Revision: 380427

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380427
Log:
API updates

Modified:
    team/dlee/stasis-http/cog/stasis_cog.py
    team/dlee/stasis-http/include/asterisk/stasis_http_channels.h
    team/dlee/stasis-http/res/res_stasis_http.c
    team/dlee/stasis-http/res/stasis_http_resources.c
    team/dlee/stasis-http/rest-api/channels.json

Modified: team/dlee/stasis-http/cog/stasis_cog.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/cog/stasis_cog.py?view=diff&rev=380427&r1=380426&r2=380427
==============================================================================
--- team/dlee/stasis-http/cog/stasis_cog.py (original)
+++ team/dlee/stasis-http/cog/stasis_cog.py Tue Jan 29 15:36:33 2013
@@ -270,7 +270,7 @@
 
 	for api in resource_listing['apis']:
 	    # Path in json is URI relative, so we need to drop the initial /api/
-	    path = api['path'].replace('/api/', '', 1)
+	    path = api['path'].replace('/', '', 1)
 	    api_declaration_file = os.path.abspath(os.path.join(resource_listing_dir, path)).format(format = 'json')
 	    (basename, ext) = os.path.splitext(os.path.basename(api_declaration_file))
 	    self.includes.append('asterisk/stasis_http_%s.h' % basename)

Modified: team/dlee/stasis-http/include/asterisk/stasis_http_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/include/asterisk/stasis_http_channels.h?view=diff&rev=380427&r1=380426&r2=380427
==============================================================================
--- team/dlee/stasis-http/include/asterisk/stasis_http_channels.h (original)
+++ team/dlee/stasis-http/include/asterisk/stasis_http_channels.h Tue Jan 29 15:36:33 2013
@@ -37,8 +37,8 @@
 struct ast_dial_args {
 	/*! Endpoint to call. If not specified, dial is routed via dialplan */
 	const char *endpoint;
-	/*! Number to dial */
-	const char *number;
+	/*! Extension to dial */
+	const char *extension;
 	/*! When routing via dialplan, the context use. If omitted, uses 'default' */
 	const char *context;
 };
@@ -99,8 +99,8 @@
 struct ast_originate_args {
 	/*! Endpoint to call. If not specified, originate is routed via dialplan */
 	const char *endpoint;
-	/*! Number to dial */
-	const char *number;
+	/*! Extension to dial */
+	const char *extension;
 	/*! When routing via dialplan, the context use. If omitted, uses 'default' */
 	const char *context;
 };

Modified: team/dlee/stasis-http/res/res_stasis_http.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/res_stasis_http.c?view=diff&rev=380427&r1=380426&r2=380427
==============================================================================
--- team/dlee/stasis-http/res/res_stasis_http.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http.c Tue Jan 29 15:36:33 2013
@@ -106,11 +106,11 @@
 	while ((path_segment = strsep(&path, "/")) && (strlen(path_segment) > 0)) {
 		struct stasis_rest_handlers *found_handler = NULL;
 		int i;
-		ast_log(LOG_DEBUG, "stasis_http: Finding handler for %s\n", path_segment);
+		ast_debug(3, "Finding handler for %s\n", path_segment);
 		for (i = 0; found_handler == NULL && i < handler->num_children; ++i) {
 			struct stasis_rest_handlers *child = handler->children[i];
 
-			ast_log(LOG_DEBUG, "stasis_http:   Checking %s\n", child->path_segment);
+			ast_debug(3, "  Checking %s\n", child->path_segment);
 			if (child->is_wildcard) {
 				/* Record the path variable */
 				struct ast_variable *path_var = ast_variable_new(child->path_segment, path_segment, __FILE__);
@@ -124,11 +124,11 @@
 
 		if (found_handler == NULL) {
 			/* resource not found */
-			ast_log(LOG_DEBUG, "stasis_http:   Handler not found\n");
+			ast_debug(3, "  Handler not found\n");
 			response_error(response, "Resource not found", 404, "Not Found");
 			return;
 		} else {
-			ast_log(LOG_DEBUG, "stasis_http:   Got it!\n");
+			ast_debug(3, "  Got it!\n");
 			handler = found_handler;
 		}
 	}
@@ -157,7 +157,7 @@
 	struct ast_json_error error = {};
 	struct stat file_stat;
 
-	ast_log(LOG_DEBUG, "%s(%s)\n", __func__, uri);
+	ast_debug(3, "%s(%s)\n", __func__, uri);
 
 	if (absolute_path_builder == NULL) {
 		ast_log(LOG_ERROR, "Allocation failed\n");
@@ -282,7 +282,7 @@
 		response.response_text = "Found";
 	} else if (ast_begins_with(uri, "api/")) {
 		/* Other RESTful resources */
-		stasis_http_invoke(uri + 4, method, get_params, headers, &response);
+		stasis_http_invoke(uri, method, get_params, headers, &response);
 	} else {
 		/* Serving up API docs */
 		if (method != AST_HTTP_GET) {
@@ -356,7 +356,7 @@
 {
 	int res;
 
-	ast_log(LOG_DEBUG, "Stasis web socket connection\n");
+	ast_debug(3, "Stasis web socket connection\n");
 
 	if (ast_websocket_set_nonblock(session) != 0) {
 		ast_log(LOG_ERROR, "Stasis web socket failed to set nonblock; closing\n");

Modified: team/dlee/stasis-http/res/stasis_http_resources.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http_resources.c?view=diff&rev=380427&r1=380426&r2=380427
==============================================================================
--- team/dlee/stasis-http/res/stasis_http_resources.c (original)
+++ team/dlee/stasis-http/res/stasis_http_resources.c Tue Jan 29 15:36:33 2013
@@ -93,8 +93,8 @@
 		if (strcmp(i->name, "endpoint") == 0) {
 			args.endpoint = i->value;
 		}
-		if (strcmp(i->name, "number") == 0) {
-			args.number = i->value;
+		if (strcmp(i->name, "extension") == 0) {
+			args.extension = i->value;
 		}
 		if (strcmp(i->name, "context") == 0) {
 			args.context = i->value;
@@ -255,8 +255,8 @@
 		if (strcmp(i->name, "endpoint") == 0) {
 			args.endpoint = i->value;
 		}
-		if (strcmp(i->name, "number") == 0) {
-			args.number = i->value;
+		if (strcmp(i->name, "extension") == 0) {
+			args.extension = i->value;
 		}
 		if (strcmp(i->name, "context") == 0) {
 			args.context = i->value;
@@ -457,7 +457,7 @@
 	stasis_http_get_recordings(headers, &args, response);
 }
 
-static struct stasis_rest_handlers stasis_asterisk_info = {
+static struct stasis_rest_handlers stasis_api_asterisk_info = {
 	.path_segment = "info",
 	.callbacks = {
 		[AST_HTTP_GET] = stasis_http_get_asterisk_info_cb,
@@ -466,15 +466,15 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_asterisk = {
+static struct stasis_rest_handlers stasis_api_asterisk = {
 	.path_segment = "asterisk",
 	.callbacks = {
 	},
 	.num_children = 1,
-	.children = { &stasis_asterisk_info, },
-};
-
-static struct stasis_rest_handlers stasis_endpoints_endpointId = {
+	.children = { &stasis_api_asterisk_info, },
+};
+
+static struct stasis_rest_handlers stasis_api_endpoints_endpointId = {
 	.path_segment = "endpointId",
 	.is_wildcard = 1,
 	.callbacks = {
@@ -484,16 +484,16 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_endpoints = {
+static struct stasis_rest_handlers stasis_api_endpoints = {
 	.path_segment = "endpoints",
 	.callbacks = {
 		[AST_HTTP_GET] = stasis_http_get_endpoints_cb,
 	},
 	.num_children = 1,
-	.children = { &stasis_endpoints_endpointId, },
-};
-
-static struct stasis_rest_handlers stasis_channels_channelId_dial = {
+	.children = { &stasis_api_endpoints_endpointId, },
+};
+
+static struct stasis_rest_handlers stasis_api_channels_channelId_dial = {
 	.path_segment = "dial",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_dial_cb,
@@ -502,7 +502,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId_continue = {
+static struct stasis_rest_handlers stasis_api_channels_channelId_continue = {
 	.path_segment = "continue",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_continue_in_dialplan_cb,
@@ -511,7 +511,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId_reject = {
+static struct stasis_rest_handlers stasis_api_channels_channelId_reject = {
 	.path_segment = "reject",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_reject_channel_cb,
@@ -520,7 +520,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId_answer = {
+static struct stasis_rest_handlers stasis_api_channels_channelId_answer = {
 	.path_segment = "answer",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_answer_channel_cb,
@@ -529,7 +529,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId_hangup = {
+static struct stasis_rest_handlers stasis_api_channels_channelId_hangup = {
 	.path_segment = "hangup",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_hangup_channel_cb,
@@ -538,7 +538,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId_mute = {
+static struct stasis_rest_handlers stasis_api_channels_channelId_mute = {
 	.path_segment = "mute",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_mute_channel_cb,
@@ -547,7 +547,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId_unmute = {
+static struct stasis_rest_handlers stasis_api_channels_channelId_unmute = {
 	.path_segment = "unmute",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_unmute_channel_cb,
@@ -556,7 +556,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId_record = {
+static struct stasis_rest_handlers stasis_api_channels_channelId_record = {
 	.path_segment = "record",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_record_channel_cb,
@@ -565,7 +565,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_channels_channelId = {
+static struct stasis_rest_handlers stasis_api_channels_channelId = {
 	.path_segment = "channelId",
 	.is_wildcard = 1,
 	.callbacks = {
@@ -573,20 +573,20 @@
 		[AST_HTTP_DELETE] = stasis_http_delete_channel_cb,
 	},
 	.num_children = 8,
-	.children = { &stasis_channels_channelId_dial, &stasis_channels_channelId_continue, &stasis_channels_channelId_reject, &stasis_channels_channelId_answer, &stasis_channels_channelId_hangup, &stasis_channels_channelId_mute, &stasis_channels_channelId_unmute, &stasis_channels_channelId_record, },
-};
-
-static struct stasis_rest_handlers stasis_channels = {
+	.children = { &stasis_api_channels_channelId_dial, &stasis_api_channels_channelId_continue, &stasis_api_channels_channelId_reject, &stasis_api_channels_channelId_answer, &stasis_api_channels_channelId_hangup, &stasis_api_channels_channelId_mute, &stasis_api_channels_channelId_unmute, &stasis_api_channels_channelId_record, },
+};
+
+static struct stasis_rest_handlers stasis_api_channels = {
 	.path_segment = "channels",
 	.callbacks = {
 		[AST_HTTP_GET] = stasis_http_get_channels_cb,
 		[AST_HTTP_POST] = stasis_http_originate_cb,
 	},
 	.num_children = 1,
-	.children = { &stasis_channels_channelId, },
-};
-
-static struct stasis_rest_handlers stasis_bridges_bridgeId_addChannel = {
+	.children = { &stasis_api_channels_channelId, },
+};
+
+static struct stasis_rest_handlers stasis_api_bridges_bridgeId_addChannel = {
 	.path_segment = "addChannel",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_add_channel_to_bridge_cb,
@@ -595,7 +595,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_bridges_bridgeId_removeChannel = {
+static struct stasis_rest_handlers stasis_api_bridges_bridgeId_removeChannel = {
 	.path_segment = "removeChannel",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_remove_channel_from_bridge_cb,
@@ -604,7 +604,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_bridges_bridgeId_record = {
+static struct stasis_rest_handlers stasis_api_bridges_bridgeId_record = {
 	.path_segment = "record",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_record_bridge_cb,
@@ -613,7 +613,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_bridges_bridgeId = {
+static struct stasis_rest_handlers stasis_api_bridges_bridgeId = {
 	.path_segment = "bridgeId",
 	.is_wildcard = 1,
 	.callbacks = {
@@ -621,20 +621,20 @@
 		[AST_HTTP_DELETE] = stasis_http_delete_bridge_cb,
 	},
 	.num_children = 3,
-	.children = { &stasis_bridges_bridgeId_addChannel, &stasis_bridges_bridgeId_removeChannel, &stasis_bridges_bridgeId_record, },
-};
-
-static struct stasis_rest_handlers stasis_bridges = {
+	.children = { &stasis_api_bridges_bridgeId_addChannel, &stasis_api_bridges_bridgeId_removeChannel, &stasis_api_bridges_bridgeId_record, },
+};
+
+static struct stasis_rest_handlers stasis_api_bridges = {
 	.path_segment = "bridges",
 	.callbacks = {
 		[AST_HTTP_GET] = stasis_http_get_bridges_cb,
 		[AST_HTTP_POST] = stasis_http_new_bridge_cb,
 	},
 	.num_children = 1,
-	.children = { &stasis_bridges_bridgeId, },
-};
-
-static struct stasis_rest_handlers stasis_recordings_recordingId_stop = {
+	.children = { &stasis_api_bridges_bridgeId, },
+};
+
+static struct stasis_rest_handlers stasis_api_recordings_recordingId_stop = {
 	.path_segment = "stop",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_stop_recording_cb,
@@ -643,7 +643,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_recordings_recordingId_pause = {
+static struct stasis_rest_handlers stasis_api_recordings_recordingId_pause = {
 	.path_segment = "pause",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_pause_recording_cb,
@@ -652,7 +652,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_recordings_recordingId_unpause = {
+static struct stasis_rest_handlers stasis_api_recordings_recordingId_unpause = {
 	.path_segment = "unpause",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_unpause_recording_cb,
@@ -661,7 +661,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_recordings_recordingId_mute = {
+static struct stasis_rest_handlers stasis_api_recordings_recordingId_mute = {
 	.path_segment = "mute",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_mute_recording_cb,
@@ -670,7 +670,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_recordings_recordingId_unmute = {
+static struct stasis_rest_handlers stasis_api_recordings_recordingId_unmute = {
 	.path_segment = "unmute",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_unmute_recording_cb,
@@ -679,7 +679,7 @@
 	.children = { },
 };
 
-static struct stasis_rest_handlers stasis_recordings_recordingId = {
+static struct stasis_rest_handlers stasis_api_recordings_recordingId = {
 	.path_segment = "recordingId",
 	.is_wildcard = 1,
 	.callbacks = {
@@ -687,24 +687,32 @@
 		[AST_HTTP_DELETE] = stasis_http_delete_recording_cb,
 	},
 	.num_children = 5,
-	.children = { &stasis_recordings_recordingId_stop, &stasis_recordings_recordingId_pause, &stasis_recordings_recordingId_unpause, &stasis_recordings_recordingId_mute, &stasis_recordings_recordingId_unmute, },
-};
-
-static struct stasis_rest_handlers stasis_recordings = {
+	.children = { &stasis_api_recordings_recordingId_stop, &stasis_api_recordings_recordingId_pause, &stasis_api_recordings_recordingId_unpause, &stasis_api_recordings_recordingId_mute, &stasis_api_recordings_recordingId_unmute, },
+};
+
+static struct stasis_rest_handlers stasis_api_recordings = {
 	.path_segment = "recordings",
 	.callbacks = {
 		[AST_HTTP_GET] = stasis_http_get_recordings_cb,
 	},
 	.num_children = 1,
-	.children = { &stasis_recordings_recordingId, },
+	.children = { &stasis_api_recordings_recordingId, },
+};
+
+static struct stasis_rest_handlers stasis_api = {
+	.path_segment = "api",
+	.callbacks = {
+	},
+	.num_children = 5,
+	.children = { &stasis_api_asterisk, &stasis_api_endpoints, &stasis_api_channels, &stasis_api_bridges, &stasis_api_recordings, },
 };
 
 static struct stasis_rest_handlers stasis = {
 	.path_segment = "stasis",
 	.callbacks = {
 	},
-	.num_children = 5,
-	.children = { &stasis_asterisk, &stasis_endpoints, &stasis_channels, &stasis_bridges, &stasis_recordings, },
+	.num_children = 1,
+	.children = { &stasis_api, },
 };
 
 

Modified: team/dlee/stasis-http/rest-api/channels.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api/channels.json?view=diff&rev=380427&r1=380426&r2=380427
==============================================================================
--- team/dlee/stasis-http/rest-api/channels.json (original)
+++ team/dlee/stasis-http/rest-api/channels.json Tue Jan 29 15:36:33 2013
@@ -32,8 +32,8 @@
                             "dataType": "string"
                         },
                         {
-                            "name": "number",
-                            "description": "Number to dial",
+                            "name": "extension",
+                            "description": "Extension to dial",
                             "paramType": "query",
                             "required": false,
                             "allowMultiple": false,
@@ -108,8 +108,8 @@
                             "dataType": "string"
                         },
                         {
-                            "name": "number",
-                            "description": "Number to dial",
+                            "name": "extension",
+                            "description": "Extension to dial",
                             "paramType": "query",
                             "required": false,
                             "allowMultiple": false,




More information about the asterisk-commits mailing list