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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 12 12:14:15 CDT 2013


Author: dlee
Date: Fri Apr 12 12:14:13 2013
New Revision: 385511

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385511
Log:
Break res_stasis_http into smaller modules; rewrote codegen for rest-api.

I wanted to break apart the res_stasis_http module into seperate resources,
but the cog templates were proving to be very difficult to modify and work
with.

After becoming more familiar with the Swagger Spec, I came up with a much
better code generator. It's actually very similar to how swagger-codegen
works, but written in Python to be Asterisk friendly.

Added:
    team/dlee/stasis-http/res/res_stasis_http_asterisk.c
      - copied, made public unchanged from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_asterisk.c
    team/dlee/stasis-http/res/res_stasis_http_bridges.c
      - copied, made public unchanged from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_bridges.c
    team/dlee/stasis-http/res/res_stasis_http_channels.c
      - copied, made public unchanged from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_channels.c
    team/dlee/stasis-http/res/res_stasis_http_endpoints.c
      - copied, made public unchanged from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_endpoints.c
    team/dlee/stasis-http/res/res_stasis_http_events.c
      - copied, made public unchanged from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_events.c
    team/dlee/stasis-http/res/res_stasis_http_recordings.c
      - copied, made public unchanged from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_recordings.c
    team/dlee/stasis-http/res/stasis_http.make
      - copied, made public unchanged from r385509, team/dlee/private/stasis-http-mustache/res/stasis_http.make
    team/dlee/stasis-http/rest-api-templates/   (props changed)
      - copied from r385509, team/dlee/private/stasis-http-mustache/rest-api-templates/
Removed:
    team/dlee/stasis-http/cog/
    team/dlee/stasis-http/res/stasis_http/resources.c
Modified:
    team/dlee/stasis-http/Makefile
    team/dlee/stasis-http/include/asterisk/stasis_http.h
    team/dlee/stasis-http/res/Makefile
    team/dlee/stasis-http/res/res_stasis_http.c
    team/dlee/stasis-http/res/stasis_http/resource_asterisk.h
    team/dlee/stasis-http/res/stasis_http/resource_bridges.h
    team/dlee/stasis-http/res/stasis_http/resource_channels.h
    team/dlee/stasis-http/res/stasis_http/resource_endpoints.h
    team/dlee/stasis-http/res/stasis_http/resource_events.h
    team/dlee/stasis-http/res/stasis_http/resource_recordings.h
    team/dlee/stasis-http/tests/test_stasis_http.c

Modified: team/dlee/stasis-http/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/Makefile?view=diff&rev=385511&r1=385510&r2=385511
==============================================================================
--- team/dlee/stasis-http/Makefile (original)
+++ team/dlee/stasis-http/Makefile Fri Apr 12 12:14:13 2013
@@ -970,7 +970,8 @@
 	@echo "--------------------------------------------------------------------------"
 	@false
 else
-	build_tools/make_stasis_http_stubs
+	$(PYTHON) rest-api-templates/make_stasis_http_stubs.py \
+		rest-api/resources.json res/
 endif
 
 .PHONY: menuselect

Modified: team/dlee/stasis-http/include/asterisk/stasis_http.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/include/asterisk/stasis_http.h?view=diff&rev=385511&r1=385510&r2=385511
==============================================================================
--- team/dlee/stasis-http/include/asterisk/stasis_http.h (original)
+++ team/dlee/stasis-http/include/asterisk/stasis_http.h Fri Apr 12 12:14:13 2013
@@ -82,21 +82,20 @@
 };
 
 /*!
- * \brief Handler for the default root RESTful resource.
+ * Add a resource for REST handling.
+ * \param handler Handler to add.
+ * \return 0 on success.
+ * \return non-zero on failure.
  */
-struct stasis_rest_handlers *stasis_default_root_handler(void);
+int stasis_http_add_handler(struct stasis_rest_handlers *handler);
 
 /*!
- * \internal
- * \brief Set a new handler for the root RESTful resource.
- *
- * Only call from res_stasis_http and test_stasis_http. Only public to allow
- * for unit testing.
- *
- * \param new_handler New root RESTful handler.
- * \param return The old handler.
+ * Remove a resource for REST handling.
+ * \param handler Handler to add.
+ * \return 0 on success.
+ * \return non-zero on failure.
  */
-struct stasis_rest_handlers *stasis_set_root_handler(struct stasis_rest_handlers *new_handler);
+int stasis_http_remove_handler(struct stasis_rest_handlers *handler);
 
 /*!
  * \internal

Modified: team/dlee/stasis-http/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/Makefile?view=diff&rev=385511&r1=385510&r2=385511
==============================================================================
--- team/dlee/stasis-http/res/Makefile (original)
+++ team/dlee/stasis-http/res/Makefile Fri Apr 12 12:14:13 2013
@@ -69,8 +69,5 @@
 clean::
 	rm -f snmp/*.[oi] ael/*.[oi] ais/*.[oi] stasis_http/*.[oi]
 
-# Dependencies for res_stasis_http.so are generated, so they're in this file
-include res_stasis_http.make
-
-# set CFLAGS for stasis_http/*.c to be the same as res_stasis_http.c
-$(subst .c,.o,$(wildcard stasis_http/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_stasis_http)
+# Dependencies for res_stasis_http_*.so are generated, so they're in this file
+include stasis_http.make

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=385511&r1=385510&r2=385511
==============================================================================
--- team/dlee/stasis-http/res/res_stasis_http.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http.c Fri Apr 12 12:14:13 2013
@@ -199,11 +199,89 @@
 	return cfg->global->enabled;
 }
 
+/*! Lock for \ref root_handler */
+static ast_mutex_t root_handler_lock;
+
 /*! Handler for root RESTful resource. */
 static struct stasis_rest_handlers *root_handler;
 
 /*! Pre-defined message for allocation failures. */
 static struct ast_json *alloc_failed_message;
+
+int stasis_http_add_handler(struct stasis_rest_handlers *handler)
+{
+	RAII_VAR(struct stasis_rest_handlers *, new_handler, NULL, ao2_cleanup);
+	size_t old_size, new_size;
+
+	SCOPED_MUTEX(lock, &root_handler_lock);
+
+	old_size = sizeof(*new_handler) +
+		root_handler->num_children * sizeof(handler);
+	new_size = old_size + sizeof(handler);
+
+	new_handler = ao2_alloc(new_size, NULL);
+	if (!new_handler) {
+		return -1;
+	}
+	memcpy(new_handler, root_handler, old_size);
+	new_handler->children[new_handler->num_children++] = handler;
+
+	ao2_cleanup(root_handler);
+	ao2_ref(new_handler, +1);
+	root_handler = new_handler;
+	return 0;
+}
+
+int stasis_http_remove_handler(struct stasis_rest_handlers *handler)
+{
+	RAII_VAR(struct stasis_rest_handlers *, new_handler, NULL, ao2_cleanup);
+	size_t old_size, new_size, i, j;
+
+	SCOPED_MUTEX(lock, &root_handler_lock);
+	old_size = sizeof(*new_handler) +
+		root_handler->num_children * sizeof(handler);
+	new_size = old_size - sizeof(handler);
+
+	new_handler = ao2_alloc(new_size, NULL);
+	if (!new_handler) {
+		return -1;
+	}
+	memcpy(new_handler, root_handler, sizeof(*new_handler));
+
+	for (i = 0, j = 0; i < root_handler->num_children; ++i) {
+		if (root_handler->children[i] == handler) {
+			continue;
+		}
+		new_handler->children[j++] = root_handler->children[i];
+	}
+	new_handler->num_children = j;
+
+	ao2_cleanup(root_handler);
+	ao2_ref(new_handler, +1);
+	root_handler = new_handler;
+	return 0;
+}
+
+static struct stasis_rest_handlers *get_root_handler(void)
+{
+	SCOPED_MUTEX(lock, &root_handler_lock);
+	ao2_ref(root_handler, +1);
+	return root_handler;
+}
+
+static struct stasis_rest_handlers *root_handler_create(void)
+{
+	RAII_VAR(struct stasis_rest_handlers *, handler, NULL, ao2_cleanup);
+
+	handler = ao2_alloc(sizeof(*handler), NULL);
+	if (!handler) {
+		return NULL;
+	}
+	handler->path_segment = "stasis";
+
+	ao2_ref(handler, +1);
+	return handler;
+}
 
 void stasis_http_response_error(struct stasis_http_response *response,
 				int response_code,
@@ -406,13 +484,15 @@
 			struct stasis_http_response *response)
 {
 	RAII_VAR(char *, response_text, NULL, ast_free);
-	struct stasis_rest_handlers *handler = root_handler;
+	RAII_VAR(struct stasis_rest_handlers *, root, NULL, ao2_cleanup);
+	struct stasis_rest_handlers *handler;
 	struct ast_variable *path_vars = NULL;
 	char *path = ast_strdupa(uri);
 	const char *path_segment;
 	stasis_rest_callback callback;
 
-	ast_assert(handler != NULL);
+	root = handler = get_root_handler();
+	ast_assert(root != NULL);
 
 	while ((path_segment = strsep(&path, "/")) && (strlen(path_segment) > 0)) {
 		struct stasis_rest_handlers *found_handler = NULL;
@@ -767,16 +847,14 @@
 	.key = __FILE__,
 };
 
-struct stasis_rest_handlers *stasis_set_root_handler(
-	struct stasis_rest_handlers *new_handler)
-{
-	struct stasis_rest_handlers *old_handler = root_handler;
-	root_handler = new_handler;
-	return old_handler;
-}
-
 static int load_module(void)
 {
+	ast_mutex_init(&root_handler_lock);
+	root_handler = root_handler_create();
+	if (!root_handler) {
+		return AST_MODULE_LOAD_FAILURE;
+	}
+
 	if (aco_info_init(&cfg_info)) {
 		aco_info_destroy(&cfg_info);
 		return AST_MODULE_LOAD_DECLINE;
@@ -792,10 +870,8 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	alloc_failed_message = ast_json_pack("{s: s}",
-					     "message", "Allocation failed");
-
-	stasis_set_root_handler(stasis_default_root_handler());
+	alloc_failed_message = ast_json_pack(
+		"{s: s}", "message", "Allocation failed");
 
 	if (is_enabled()) {
 		ast_http_uri_link(&http_uri);
@@ -815,6 +891,9 @@
 
 	aco_info_destroy(&cfg_info);
 	ao2_global_obj_release(confs);
+
+	ao2_cleanup(root_handler);
+	ast_mutex_destroy(&root_handler_lock);
 
 	return 0;
 }
@@ -836,10 +915,12 @@
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS,
-		"Stasis HTTP bindings",
-		.load = load_module,
-		.unload = unload_module,
-		.reload = reload_module,
-		.nonoptreq = "app_stasis"
+AST_MODULE_INFO(ASTERISK_GPL_KEY,
+	AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER,
+	"Stasis HTTP bindings",
+	.load = load_module,
+	.unload = unload_module,
+	.reload = reload_module,
+	.nonoptreq = "app_stasis",
+	.load_pri = AST_MODPRI_APP_DEPEND,
 	);

Copied: team/dlee/stasis-http/res/res_stasis_http_asterisk.c (from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_asterisk.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/res_stasis_http_asterisk.c?view=diff&rev=385511&p1=team/dlee/private/stasis-http-mustache/res/res_stasis_http_asterisk.c&r1=385509&p2=team/dlee/stasis-http/res/res_stasis_http_asterisk.c&r2=385511
==============================================================================
--- team/dlee/private/stasis-http-mustache/res/res_stasis_http_asterisk.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http_asterisk.c Fri Apr 12 12:14:13 2013
@@ -1,0 +1,95 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!!                               DO NOT EDIT                        !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a mustache template. Please see the original
+ * template in rest-api-templates/res_stasis_http_resource.c.mustache
+ */
+
+/*! \file
+ *
+ * \brief Asterisk resources
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+/*** MODULEINFO
+        <depend type="module">res_stasis_http</depend>
+        <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/module.h"
+#include "stasis_http/resource_asterisk.h"
+
+/*!
+ * \brief Parameter parsing callback for /asterisk/info.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_asterisk_info_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_get_asterisk_info_args args = {};
+	stasis_http_get_asterisk_info(headers, &args, response);
+}
+
+/*! \brief REST handler for /api-docs/asterisk.{format} */
+static struct stasis_rest_handlers asterisk_info = {
+	.path_segment = "info",
+	.callbacks = {
+		[AST_HTTP_GET] = stasis_http_get_asterisk_info_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/asterisk.{format} */
+static struct stasis_rest_handlers asterisk = {
+	.path_segment = "asterisk",
+	.callbacks = {
+	},
+	.num_children = 1,
+	.children = { &asterisk_info, }
+};
+
+static int load_module(void)
+{
+	return stasis_http_add_handler(&asterisk);
+}
+
+static int unload_module(void)
+{
+	stasis_http_remove_handler(&asterisk);
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
+	"RESTful API module - Asterisk resources",
+	.load = load_module,
+	.unload = unload_module,
+	.nonoptreq = "res_stasis_http",
+	);

Copied: team/dlee/stasis-http/res/res_stasis_http_bridges.c (from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_bridges.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/res_stasis_http_bridges.c?view=diff&rev=385511&p1=team/dlee/private/stasis-http-mustache/res/res_stasis_http_bridges.c&r1=385509&p2=team/dlee/stasis-http/res/res_stasis_http_bridges.c&r2=385511
==============================================================================
--- team/dlee/private/stasis-http-mustache/res/res_stasis_http_bridges.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http_bridges.c Fri Apr 12 12:14:13 2013
@@ -1,0 +1,210 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!!                               DO NOT EDIT                        !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a mustache template. Please see the original
+ * template in rest-api-templates/res_stasis_http_resource.c.mustache
+ */
+
+/*! \file
+ *
+ * \brief Bridge resources
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+/*** MODULEINFO
+        <depend type="module">res_stasis_http</depend>
+        <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/module.h"
+#include "stasis_http/resource_bridges.h"
+
+/*!
+ * \brief Parameter parsing callback for /bridges.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_bridges_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_get_bridges_args args = {};
+	stasis_http_get_bridges(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /bridges.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_new_bridge_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_new_bridge_args args = {};
+	stasis_http_new_bridge(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /bridges/{bridgeId}.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_bridge_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_get_bridge_args args = {};
+	stasis_http_get_bridge(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /bridges/{bridgeId}.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_delete_bridge_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_delete_bridge_args args = {};
+	stasis_http_delete_bridge(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /bridges/{bridgeId}/addChannel.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_add_channel_to_bridge_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_add_channel_to_bridge_args args = {};
+	stasis_http_add_channel_to_bridge(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /bridges/{bridgeId}/removeChannel.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_remove_channel_from_bridge_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_remove_channel_from_bridge_args args = {};
+	stasis_http_remove_channel_from_bridge(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /bridges/{bridgeId}/record.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_record_bridge_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_record_bridge_args args = {};
+	stasis_http_record_bridge(headers, &args, response);
+}
+
+/*! \brief REST handler for /api-docs/bridges.{format} */
+static struct stasis_rest_handlers bridges_bridgeId_addChannel = {
+	.path_segment = "addChannel",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_add_channel_to_bridge_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/bridges.{format} */
+static struct stasis_rest_handlers bridges_bridgeId_removeChannel = {
+	.path_segment = "removeChannel",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_remove_channel_from_bridge_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/bridges.{format} */
+static struct stasis_rest_handlers bridges_bridgeId_record = {
+	.path_segment = "record",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_record_bridge_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/bridges.{format} */
+static struct stasis_rest_handlers bridges_bridgeId = {
+	.path_segment = "bridgeId",
+	.is_wildcard = 1,
+	.callbacks = {
+		[AST_HTTP_GET] = stasis_http_get_bridge_cb,
+		[AST_HTTP_DELETE] = stasis_http_delete_bridge_cb,
+	},
+	.num_children = 3,
+	.children = { &bridges_bridgeId_addChannel,&bridges_bridgeId_removeChannel,&bridges_bridgeId_record, }
+};
+/*! \brief REST handler for /api-docs/bridges.{format} */
+static struct stasis_rest_handlers 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 = { &bridges_bridgeId, }
+};
+
+static int load_module(void)
+{
+	return stasis_http_add_handler(&bridges);
+}
+
+static int unload_module(void)
+{
+	stasis_http_remove_handler(&bridges);
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
+	"RESTful API module - Bridge resources",
+	.load = load_module,
+	.unload = unload_module,
+	.nonoptreq = "res_stasis_http",
+	);

Copied: team/dlee/stasis-http/res/res_stasis_http_channels.c (from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_channels.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/res_stasis_http_channels.c?view=diff&rev=385511&p1=team/dlee/private/stasis-http-mustache/res/res_stasis_http_channels.c&r1=385509&p2=team/dlee/stasis-http/res/res_stasis_http_channels.c&r2=385511
==============================================================================
--- team/dlee/private/stasis-http-mustache/res/res_stasis_http_channels.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http_channels.c Fri Apr 12 12:14:13 2013
@@ -1,0 +1,302 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!!                               DO NOT EDIT                        !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a mustache template. Please see the original
+ * template in rest-api-templates/res_stasis_http_resource.c.mustache
+ */
+
+/*! \file
+ *
+ * \brief Channel resources
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+/*** MODULEINFO
+        <depend type="module">res_stasis_http</depend>
+        <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/module.h"
+#include "stasis_http/resource_channels.h"
+
+/*!
+ * \brief Parameter parsing callback for /channels.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_channels_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_get_channels_args args = {};
+	stasis_http_get_channels(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_originate_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_originate_args args = {};
+	stasis_http_originate(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_channel_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_get_channel_args args = {};
+	stasis_http_get_channel(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_delete_channel_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_delete_channel_args args = {};
+	stasis_http_delete_channel(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/dial.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_dial_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_dial_args args = {};
+	stasis_http_dial(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/continue.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_continue_in_dialplan_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_continue_in_dialplan_args args = {};
+	stasis_http_continue_in_dialplan(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/reject.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_reject_channel_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_reject_channel_args args = {};
+	stasis_http_reject_channel(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/answer.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_answer_channel_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_answer_channel_args args = {};
+	stasis_http_answer_channel(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/mute.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_mute_channel_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_mute_channel_args args = {};
+	stasis_http_mute_channel(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/unmute.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_unmute_channel_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_unmute_channel_args args = {};
+	stasis_http_unmute_channel(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/record.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_record_channel_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_record_channel_args args = {};
+	stasis_http_record_channel(headers, &args, response);
+}
+
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_dial = {
+	.path_segment = "dial",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_dial_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_continue = {
+	.path_segment = "continue",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_continue_in_dialplan_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_reject = {
+	.path_segment = "reject",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_reject_channel_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_answer = {
+	.path_segment = "answer",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_answer_channel_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_mute = {
+	.path_segment = "mute",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_mute_channel_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_unmute = {
+	.path_segment = "unmute",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_unmute_channel_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId_record = {
+	.path_segment = "record",
+	.callbacks = {
+		[AST_HTTP_POST] = stasis_http_record_channel_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels_channelId = {
+	.path_segment = "channelId",
+	.is_wildcard = 1,
+	.callbacks = {
+		[AST_HTTP_GET] = stasis_http_get_channel_cb,
+		[AST_HTTP_DELETE] = stasis_http_delete_channel_cb,
+	},
+	.num_children = 7,
+	.children = { &channels_channelId_dial,&channels_channelId_continue,&channels_channelId_reject,&channels_channelId_answer,&channels_channelId_mute,&channels_channelId_unmute,&channels_channelId_record, }
+};
+/*! \brief REST handler for /api-docs/channels.{format} */
+static struct stasis_rest_handlers channels = {
+	.path_segment = "channels",
+	.callbacks = {
+		[AST_HTTP_GET] = stasis_http_get_channels_cb,
+		[AST_HTTP_POST] = stasis_http_originate_cb,
+	},
+	.num_children = 1,
+	.children = { &channels_channelId, }
+};
+
+static int load_module(void)
+{
+	return stasis_http_add_handler(&channels);
+}
+
+static int unload_module(void)
+{
+	stasis_http_remove_handler(&channels);
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
+	"RESTful API module - Channel resources",
+	.load = load_module,
+	.unload = unload_module,
+	.nonoptreq = "res_stasis_http",
+	);

Copied: team/dlee/stasis-http/res/res_stasis_http_endpoints.c (from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_endpoints.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/res_stasis_http_endpoints.c?view=diff&rev=385511&p1=team/dlee/private/stasis-http-mustache/res/res_stasis_http_endpoints.c&r1=385509&p2=team/dlee/stasis-http/res/res_stasis_http_endpoints.c&r2=385511
==============================================================================
--- team/dlee/private/stasis-http-mustache/res/res_stasis_http_endpoints.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http_endpoints.c Fri Apr 12 12:14:13 2013
@@ -1,0 +1,111 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!!                               DO NOT EDIT                        !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a mustache template. Please see the original
+ * template in rest-api-templates/res_stasis_http_resource.c.mustache
+ */
+
+/*! \file
+ *
+ * \brief Endpoint resources
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+/*** MODULEINFO
+        <depend type="module">res_stasis_http</depend>
+        <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/module.h"
+#include "stasis_http/resource_endpoints.h"
+
+/*!
+ * \brief Parameter parsing callback for /endpoints.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_endpoints_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_get_endpoints_args args = {};
+	stasis_http_get_endpoints(headers, &args, response);
+}
+/*!
+ * \brief Parameter parsing callback for /endpoints/{endpointId}.
+ * \param get_params GET parameters in the HTTP request.
+ * \param path_vars Path variables extracted from the request.
+ * \param headers HTTP headers.
+ * \param[out] response Response to the HTTP request.
+ */
+static void stasis_http_get_endpoint_cb(
+    struct ast_variable *get_params, struct ast_variable *path_vars,
+    struct ast_variable *headers, struct stasis_http_response *response)
+{
+        struct ast_get_endpoint_args args = {};
+	stasis_http_get_endpoint(headers, &args, response);
+}
+
+/*! \brief REST handler for /api-docs/endpoints.{format} */
+static struct stasis_rest_handlers endpoints_endpointId = {
+	.path_segment = "endpointId",
+	.is_wildcard = 1,
+	.callbacks = {
+		[AST_HTTP_GET] = stasis_http_get_endpoint_cb,
+	},
+	.num_children = 0,
+	.children = {  }
+};
+/*! \brief REST handler for /api-docs/endpoints.{format} */
+static struct stasis_rest_handlers endpoints = {
+	.path_segment = "endpoints",
+	.callbacks = {
+		[AST_HTTP_GET] = stasis_http_get_endpoints_cb,
+	},
+	.num_children = 1,
+	.children = { &endpoints_endpointId, }
+};
+
+static int load_module(void)
+{
+	return stasis_http_add_handler(&endpoints);
+}
+
+static int unload_module(void)
+{
+	stasis_http_remove_handler(&endpoints);
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
+	"RESTful API module - Endpoint resources",
+	.load = load_module,
+	.unload = unload_module,
+	.nonoptreq = "res_stasis_http",
+	);

Copied: team/dlee/stasis-http/res/res_stasis_http_events.c (from r385509, team/dlee/private/stasis-http-mustache/res/res_stasis_http_events.c)
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/res_stasis_http_events.c?view=diff&rev=385511&p1=team/dlee/private/stasis-http-mustache/res/res_stasis_http_events.c&r1=385509&p2=team/dlee/stasis-http/res/res_stasis_http_events.c&r2=385511
==============================================================================
--- team/dlee/private/stasis-http-mustache/res/res_stasis_http_events.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http_events.c Fri Apr 12 12:14:13 2013
@@ -1,0 +1,87 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012 - 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * !!!!!                               DO NOT EDIT                        !!!!!
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * This file is generated by a mustache template. Please see the original
+ * template in rest-api-templates/res_stasis_http_resource.c.mustache
+ */
+
+/*! \file
+ *
+ * \brief WebSocket resource
+ *
+ * \author David M. Lee, II <dlee at digium.com>
+ */
+
+/*** MODULEINFO
+        <depend type="module">res_stasis_http</depend>
+        <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/module.h"
+#include "stasis_http/resource_events.h"
+
+/*!
+ * \brief Parameter parsing callback for /events.
+ * \param get_params GET parameters in the HTTP request.

[... 1276 lines stripped ...]



More information about the asterisk-commits mailing list