[asterisk-commits] dlee: branch dlee/stasis-http r385519 - in /team/dlee/stasis-http: ./ build_t...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 12 13:26:40 CDT 2013
Author: dlee
Date: Fri Apr 12 13:26:36 2013
New Revision: 385519
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385519
Log:
Decogged. Minor Pystache template cleanup.
Removed:
team/dlee/stasis-http/build_tools/make_stasis_http_stubs
team/dlee/stasis-http/res/res_stasis_http.make
Modified:
team/dlee/stasis-http/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/rest-api-templates/make_stasis_http_stubs.py
team/dlee/stasis-http/rest-api-templates/stasis_http_resource.h.mustache
team/dlee/stasis-http/rest-api/README.txt
Modified: team/dlee/stasis-http/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/Makefile?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/Makefile (original)
+++ team/dlee/stasis-http/Makefile Fri Apr 12 13:26:36 2013
@@ -962,7 +962,8 @@
@cat sounds/sounds.xml >> $@
@echo "</menu>" >> $@
-# We don't want to require Python or Cog for every build, so this is its own target.
+# We don't want to require Python or Pystache for every build, so this is its
+# own target.
stasis-stubs:
ifeq ($(PYTHON),:)
@echo "--------------------------------------------------------------------------"
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=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/res/res_stasis_http.c (original)
+++ team/dlee/stasis-http/res/res_stasis_http.c Fri Apr 12 13:26:36 2013
@@ -31,22 +31,28 @@
* bindings. The API docs live in the \c rest-api/ directory.
*
* The RESTful bindings are generated from the Swagger API docs using a set of
- * <a href="http://nedbatchelder.com/code/cog/">Cog.py</a> templates. Cog.py is
- * extemely lightweight (maybe too lightweight), and can be installed easily
- * using \c pip. Template scripts live in the \c cog/ directory, and the
- * generated code lives in the \c res/stasis-http/ directory.
+ * <a href="http://mustache.github.io/mustache.5.html">Mustache</a> templates.
+ * The code generator is written in Python, and uses the Python implementation
+ * <a href="https://github.com/defunkt/pystache">pystache</a>. Pystache has no
+ * dependencies, and be installed easily using \c pip. Code generation code
+ * lives in \c rest-api-templates/.
+ *
+ * The generated code reduces a lot of boilerplate when it comes to handling
+ * HTTP requests. It also helps us have greater consistency in the REST API.
*
* The structure of the generated code is:
*
- * - A tree of \ref stasis_rest_handlers which are used for request routing.
- * - Prototypes for request handlers, and structures for passing arguments in
- * the request handler.
- * - A set of \ref stasis_rest_callback functions, which glue the two
- * together. They parse out path variables and request parameters to populate
- * a specific \c *_args which is passed to the specific request handler.
- *
- * The use of the generated \c *_args allows for greater type safety and reduced
- * boilerplate in the request handlers themselves.
+ * - res/stasis_http/resource_{resource}.h
+ * - For each operation in the resouce, a generated argument structure
+ * (holding the parsed arguments from the request) and function
+ * declarations (to implement in res/stasis_http/resource_{resource}.c)
+ * - res_stasis_http_{resource}.c
+ * - A set of \ref stasis_rest_callback functions, which glue the two
+ * together. They parse out path variables and request parameters to
+ * populate a specific \c *_args which is passed to the specific request
+ * handler (in res/stasis_http/resource_{resource}.c)
+ * - A tree of \ref stasis_rest_handlers for routing requests to its
+ * \ref stasis_rest_callback
*
* The basic flow of an HTTP request is:
*
Modified: team/dlee/stasis-http/res/stasis_http/resource_asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_asterisk.h?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_asterisk.h (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_asterisk.h Fri Apr 12 13:26:36 2013
@@ -39,6 +39,7 @@
#include "asterisk/stasis_http.h"
+/*! \brief Argument struct for stasis_http_get_asterisk_info() */
struct ast_get_asterisk_info_args {
/*! \brief Filter information returned */
const char *only;
Modified: team/dlee/stasis-http/res/stasis_http/resource_bridges.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_bridges.h?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_bridges.h (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_bridges.h Fri Apr 12 13:26:36 2013
@@ -39,9 +39,8 @@
#include "asterisk/stasis_http.h"
+/*! \brief Argument struct for stasis_http_get_bridges() */
struct ast_get_bridges_args {
-};
-struct ast_new_bridge_args {
};
/*!
* \brief List active bridges
@@ -50,6 +49,9 @@
* \param[out] response HTTP response
*/
void stasis_http_get_bridges(struct ast_variable *headers, struct ast_get_bridges_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_new_bridge() */
+struct ast_new_bridge_args {
+};
/*!
* \brief Create a new bridge
* \param headers HTTP headers
@@ -57,11 +59,8 @@
* \param[out] response HTTP response
*/
void stasis_http_new_bridge(struct ast_variable *headers, struct ast_new_bridge_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_get_bridge() */
struct ast_get_bridge_args {
- /*! \brief Bridge's id */
- const char *bridge_id;
-};
-struct ast_delete_bridge_args {
/*! \brief Bridge's id */
const char *bridge_id;
};
@@ -72,6 +71,11 @@
* \param[out] response HTTP response
*/
void stasis_http_get_bridge(struct ast_variable *headers, struct ast_get_bridge_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_delete_bridge() */
+struct ast_delete_bridge_args {
+ /*! \brief Bridge's id */
+ const char *bridge_id;
+};
/*!
* \brief Delete bridge
* \param headers HTTP headers
@@ -79,6 +83,7 @@
* \param[out] response HTTP response
*/
void stasis_http_delete_bridge(struct ast_variable *headers, struct ast_delete_bridge_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_add_channel_to_bridge() */
struct ast_add_channel_to_bridge_args {
/*! \brief Bridge's id */
const char *bridge_id;
@@ -92,6 +97,7 @@
* \param[out] response HTTP response
*/
void stasis_http_add_channel_to_bridge(struct ast_variable *headers, struct ast_add_channel_to_bridge_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_remove_channel_from_bridge() */
struct ast_remove_channel_from_bridge_args {
/*! \brief Bridge's id */
const char *bridge_id;
@@ -105,6 +111,7 @@
* \param[out] response HTTP response
*/
void stasis_http_remove_channel_from_bridge(struct ast_variable *headers, struct ast_remove_channel_from_bridge_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_record_bridge() */
struct ast_record_bridge_args {
/*! \brief Bridge's id */
const char *bridge_id;
Modified: team/dlee/stasis-http/res/stasis_http/resource_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_channels.h?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_channels.h (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_channels.h Fri Apr 12 13:26:36 2013
@@ -39,8 +39,17 @@
#include "asterisk/stasis_http.h"
+/*! \brief Argument struct for stasis_http_get_channels() */
struct ast_get_channels_args {
};
+/*!
+ * \brief List active channels
+ * \param headers HTTP headers
+ * \param args Swagger parameters
+ * \param[out] response HTTP response
+ */
+void stasis_http_get_channels(struct ast_variable *headers, struct ast_get_channels_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_originate() */
struct ast_originate_args {
/*! \brief Endpoint to call. If not specified, originate is routed via dialplan */
const char *endpoint;
@@ -50,24 +59,14 @@
const char *context;
};
/*!
- * \brief List active channels
- * \param headers HTTP headers
- * \param args Swagger parameters
- * \param[out] response HTTP response
- */
-void stasis_http_get_channels(struct ast_variable *headers, struct ast_get_channels_args *args, struct stasis_http_response *response);
-/*!
* \brief Create a new channel (originate)
* \param headers HTTP headers
* \param args Swagger parameters
* \param[out] response HTTP response
*/
void stasis_http_originate(struct ast_variable *headers, struct ast_originate_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_get_channel() */
struct ast_get_channel_args {
- /*! \brief Channel's id */
- const char *channel_id;
-};
-struct ast_delete_channel_args {
/*! \brief Channel's id */
const char *channel_id;
};
@@ -78,6 +77,11 @@
* \param[out] response HTTP response
*/
void stasis_http_get_channel(struct ast_variable *headers, struct ast_get_channel_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_delete_channel() */
+struct ast_delete_channel_args {
+ /*! \brief Channel's id */
+ const char *channel_id;
+};
/*!
* \brief Delete (i.e. hangup) a channel
* \param headers HTTP headers
@@ -85,6 +89,7 @@
* \param[out] response HTTP response
*/
void stasis_http_delete_channel(struct ast_variable *headers, struct ast_delete_channel_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_dial() */
struct ast_dial_args {
/*! \brief Channel's id */
const char *channel_id;
@@ -102,6 +107,7 @@
* \param[out] response HTTP response
*/
void stasis_http_dial(struct ast_variable *headers, struct ast_dial_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_continue_in_dialplan() */
struct ast_continue_in_dialplan_args {
/*! \brief Channel's id */
const char *channel_id;
@@ -113,6 +119,7 @@
* \param[out] response HTTP response
*/
void stasis_http_continue_in_dialplan(struct ast_variable *headers, struct ast_continue_in_dialplan_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_reject_channel() */
struct ast_reject_channel_args {
/*! \brief Channel's id */
const char *channel_id;
@@ -124,6 +131,7 @@
* \param[out] response HTTP response
*/
void stasis_http_reject_channel(struct ast_variable *headers, struct ast_reject_channel_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_answer_channel() */
struct ast_answer_channel_args {
/*! \brief Channel's id */
const char *channel_id;
@@ -135,6 +143,7 @@
* \param[out] response HTTP response
*/
void stasis_http_answer_channel(struct ast_variable *headers, struct ast_answer_channel_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_mute_channel() */
struct ast_mute_channel_args {
/*! \brief Channel's id */
const char *channel_id;
@@ -148,6 +157,7 @@
* \param[out] response HTTP response
*/
void stasis_http_mute_channel(struct ast_variable *headers, struct ast_mute_channel_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_unmute_channel() */
struct ast_unmute_channel_args {
/*! \brief Channel's id */
const char *channel_id;
@@ -161,6 +171,7 @@
* \param[out] response HTTP response
*/
void stasis_http_unmute_channel(struct ast_variable *headers, struct ast_unmute_channel_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_record_channel() */
struct ast_record_channel_args {
/*! \brief Channel's id */
const char *channel_id;
Modified: team/dlee/stasis-http/res/stasis_http/resource_endpoints.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_endpoints.h?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_endpoints.h (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_endpoints.h Fri Apr 12 13:26:36 2013
@@ -39,6 +39,7 @@
#include "asterisk/stasis_http.h"
+/*! \brief Argument struct for stasis_http_get_endpoints() */
struct ast_get_endpoints_args {
/*! \brief Filter endpoints by type (sip,iax2,dhadi,...) */
const char *with_type;
@@ -50,6 +51,7 @@
* \param[out] response HTTP response
*/
void stasis_http_get_endpoints(struct ast_variable *headers, struct ast_get_endpoints_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_get_endpoint() */
struct ast_get_endpoint_args {
/*! \brief ID of the endpoint */
const char *endpoint_id;
Modified: team/dlee/stasis-http/res/stasis_http/resource_events.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_events.h?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_events.h (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_events.h Fri Apr 12 13:26:36 2013
@@ -39,6 +39,7 @@
#include "asterisk/stasis_http.h"
+/*! \brief Argument struct for stasis_http_event_websocket() */
struct ast_event_websocket_args {
/*! \brief Comma seperated list of applications to subscribe to. */
const char *app;
Modified: team/dlee/stasis-http/res/stasis_http/resource_recordings.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_recordings.h?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_recordings.h (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_recordings.h Fri Apr 12 13:26:36 2013
@@ -39,6 +39,7 @@
#include "asterisk/stasis_http.h"
+/*! \brief Argument struct for stasis_http_get_recordings() */
struct ast_get_recordings_args {
};
/*!
@@ -48,11 +49,8 @@
* \param[out] response HTTP response
*/
void stasis_http_get_recordings(struct ast_variable *headers, struct ast_get_recordings_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_get_recording() */
struct ast_get_recording_args {
- /*! \brief Recording's id */
- const char *recording_id;
-};
-struct ast_delete_recording_args {
/*! \brief Recording's id */
const char *recording_id;
};
@@ -63,6 +61,11 @@
* \param[out] response HTTP response
*/
void stasis_http_get_recording(struct ast_variable *headers, struct ast_get_recording_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_delete_recording() */
+struct ast_delete_recording_args {
+ /*! \brief Recording's id */
+ const char *recording_id;
+};
/*!
* \brief Delete recording
* \param headers HTTP headers
@@ -70,6 +73,7 @@
* \param[out] response HTTP response
*/
void stasis_http_delete_recording(struct ast_variable *headers, struct ast_delete_recording_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_stop_recording() */
struct ast_stop_recording_args {
/*! \brief Recording's id */
const char *recording_id;
@@ -81,6 +85,7 @@
* \param[out] response HTTP response
*/
void stasis_http_stop_recording(struct ast_variable *headers, struct ast_stop_recording_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_pause_recording() */
struct ast_pause_recording_args {
/*! \brief Recording's id */
const char *recording_id;
@@ -92,6 +97,7 @@
* \param[out] response HTTP response
*/
void stasis_http_pause_recording(struct ast_variable *headers, struct ast_pause_recording_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_unpause_recording() */
struct ast_unpause_recording_args {
/*! \brief Recording's id */
const char *recording_id;
@@ -103,6 +109,7 @@
* \param[out] response HTTP response
*/
void stasis_http_unpause_recording(struct ast_variable *headers, struct ast_unpause_recording_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_mute_recording() */
struct ast_mute_recording_args {
/*! \brief Recording's id */
const char *recording_id;
@@ -114,6 +121,7 @@
* \param[out] response HTTP response
*/
void stasis_http_mute_recording(struct ast_variable *headers, struct ast_mute_recording_args *args, struct stasis_http_response *response);
+/*! \brief Argument struct for stasis_http_unmute_recording() */
struct ast_unmute_recording_args {
/*! \brief Recording's id */
const char *recording_id;
Modified: team/dlee/stasis-http/rest-api-templates/make_stasis_http_stubs.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api-templates/make_stasis_http_stubs.py?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/rest-api-templates/make_stasis_http_stubs.py (original)
+++ team/dlee/stasis-http/rest-api-templates/make_stasis_http_stubs.py Fri Apr 12 13:26:36 2013
@@ -15,6 +15,11 @@
# the GNU General Public License Version 2. See the LICENSE file
# at the top of the source tree.
#
+
+try:
+ import pystache
+except ImportError:
+ print >> sys.stderr, "Pystache required. Please sudo pip install pystache."
import os.path
import pystache
Modified: team/dlee/stasis-http/rest-api-templates/stasis_http_resource.h.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api-templates/stasis_http_resource.h.mustache?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/rest-api-templates/stasis_http_resource.h.mustache (original)
+++ team/dlee/stasis-http/rest-api-templates/stasis_http_resource.h.mustache Fri Apr 12 13:26:36 2013
@@ -41,6 +41,7 @@
{{#apis}}
{{#operations}}
+/*! \brief Argument struct for stasis_http_{{c_nickname}}() */
struct ast_{{c_nickname}}_args {
{{#parameters}}
{{#description}}
@@ -49,8 +50,6 @@
{{c_data_type}}{{c_space}}{{c_name}};
{{/parameters}}
};
-{{/operations}}
-{{#operations}}
/*!
* \brief {{summary}}
{{#notes}}
Modified: team/dlee/stasis-http/rest-api/README.txt
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api/README.txt?view=diff&rev=385519&r1=385518&r2=385519
==============================================================================
--- team/dlee/stasis-http/rest-api/README.txt (original)
+++ team/dlee/stasis-http/rest-api/README.txt Fri Apr 12 13:26:36 2013
@@ -6,8 +6,4 @@
generate a lot of the boilerplate necessary for implementing the API
with Asterisk's HTTP server.
-In this directory, the *.cog files are (Cog templates)[2] for
-generating implementation stubs from the API spec.
-
[1]: http://swagger.wordnik.com/
- [2]: http://nedbatchelder.com/code/cog/
More information about the asterisk-commits
mailing list