This patch adds a RESTful HTTP interface to Asterisk.

The API itself is documented using Swagger, a lightweight mechanism for
documenting RESTful API's using JSON. This allows us to use swagger-ui
to provide executable documentation for the API, generate client
bindings in different languages, and generate a lot of the boilerplate
code for implementing the RESTful bindings. The API docs live in the
rest-api/ directory.

The RESTful bindings are generated from the Swagger API docs using a set
of Mustache templates.  The code generator is written in Python, and
uses Pystache. Pystache has no dependencies, and be installed easily
using pip. Code generation code lives in 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.

(closes issue ASTERISK-20891)
Review: https://reviewboard.asterisk.org/r/2376/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386232 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2013-04-22 14:58:53 +00:00
parent 1871017cc6
commit 1c21b8575b
63 changed files with 8605 additions and 59 deletions

View File

@@ -66,7 +66,7 @@ struct ast_channel_snapshot;
* \param argv Arguments for the application.
*/
int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc,
char *argv[]);
char *argv[]);
/*! @} */
@@ -126,22 +126,50 @@ int stasis_app_send(const char *app_name, struct ast_json *message);
struct stasis_app_control;
/*!
* \brief Returns the handler for the given channel
* \brief Returns the handler for the given channel.
* \param chan Channel to handle.
* \return NULL channel not in Stasis application
* \return Pointer to stasis handler.
* \return NULL channel not in Stasis application.
* \return Pointer to \c res_stasis handler.
*/
struct stasis_app_control *stasis_app_control_find_by_channel(
const struct ast_channel *chan);
/*!
* \brief Exit \c app_stasis and continue execution in the dialplan.
*
* If the channel is no longer in \c app_stasis, this function does nothing.
*
* \param handler Handler for \c app_stasis
* \brief Returns the handler for the channel with the given id.
* \param channel_id Uniqueid of the channel.
* \return NULL channel not in Stasis application, or channel does not exist.
* \return Pointer to \c res_stasis handler.
*/
void stasis_app_control_continue(struct stasis_app_control *handler);
struct stasis_app_control *stasis_app_control_find_by_channel_id(
const char *channel_id);
/*!
* \brief Exit \c res_stasis and continue execution in the dialplan.
*
* If the channel is no longer in \c res_stasis, this function does nothing.
*
* \param control Control for \c res_stasis
*/
void stasis_app_control_continue(struct stasis_app_control *control);
/*!
* \brief Answer the channel associated with this control.
* \param control Control for \c res_stasis.
* \return 0 for success.
* \return -1 for error.
*/
int stasis_app_control_answer(struct stasis_app_control *control);
/*! @} */
/*! @{ */
/*!
* \brief Build a JSON object from a \ref ast_channel_snapshot.
* \return JSON object representing channel snapshot.
* \return \c NULL on error
*/
struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot);
/*! @} */