[asterisk-dev] [Code Review] 2376: Adding RESTful API's to Asterisk
David Lee
reviewboard at asterisk.org
Mon Apr 8 11:01:19 CDT 2013
> On April 8, 2013, 10:03 a.m., Paul Belanger wrote:
> > It should also be noted that swagger's LICENSE is Apache License, 2.0. Which is not GPL compatible. I don't think his is an issue for us, but the only concern is the python script we've created to generate our documentation.
> >
> > Does anybody else see an issue?
Since the generator in Asterisk is not using any of the code from Swagger, even then licensing isn't an issue.
> On April 8, 2013, 10:03 a.m., Paul Belanger wrote:
> > /trunk/cog/odict.py, line 1
> > <https://reviewboard.asterisk.org/r/2376/diff/3/?file=35528#file35528line1>
> >
> > Please also include a reference to the MIT license. Looking at the URL, it appears to have that LICENSE.
So it is. Will do!
- David
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2376/#review8203
-----------------------------------------------------------
On April 8, 2013, 8:45 a.m., David Lee wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2376/
> -----------------------------------------------------------
>
> (Updated April 8, 2013, 8:45 a.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Repository: Asterisk
>
>
> Description
> -------
>
> This patch represents the first step toward adding a RESTful API to Asterisk.
>
> The following is the file doc from res_stasis_http.c:
>
> The API itself is documented using Swagger[1], a lightweight mechanism for
> documenting RESTful API's using JSON. This allows us to use swagger-ui[2] to
> provide executable documentation for the API, generate client bindings in
> different languages[3], 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
> Cog.py[4] templates. Cog.py is extemely lightweight (maybe too lightweight), and
> can be installed easily using pip. Template scripts live in the cog/ directory,
> and the generated code lives in the res/stasis-http/ directory.
>
> The structure of the generated code is:
>
> - A tree of 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 stasis_rest_callback functions, which glue the two
> together. They parse out path variables and request parameters to populate
> a specific *_args which is passed to the specific request handler.
>
> The use of the generated *_args allows for greater type safety and reduced
> boilerplate in the request handlers themselves.
>
> The basic flow of an HTTP request is:
>
> - stasis_http_callback()
> 1. Initial request validation
> 2. Routes as either a doc request (stasis_http_get_docs) or API
> request (stasis_http_invoke)
> - stasis_http_invoke()
> 1. Further request validation
> 2. Routes the request through the tree of generated
> stasis_rest_handlers.
> 3. Dispatch to the generated callback
> - stasis_http_*_cb
> 1. Populate *_args struct with path and get params
> 2. Invoke the request handler
> 3. Validates and sends response
>
> [1]: https://developers.helloreverb.com/swagger/
> [2]: https://github.com/wordnik/swagger-ui
> [3]: https://github.com/asterisk/asterisk_rest_libraries
> [4]: http://nedbatchelder.com/code/cog/
>
>
> Diffs
> -----
>
> /trunk/Makefile 384882
> /trunk/apps/app_stasis.c 384882
> /trunk/build_tools/make_stasis_http_stubs PRE-CREATION
> /trunk/cog/odict.py PRE-CREATION
> /trunk/cog/res_stasis_http.make.cog PRE-CREATION
> /trunk/cog/stasis_cog.py PRE-CREATION
> /trunk/cog/stasis_http_resource.c.cog PRE-CREATION
> /trunk/cog/stasis_http_resource.h.cog PRE-CREATION
> /trunk/cog/stasis_http_resources.c.cog PRE-CREATION
> /trunk/configs/stasis_http.conf.sample PRE-CREATION
> /trunk/include/asterisk/app_stasis.h 384882
> /trunk/include/asterisk/http.h 384882
> /trunk/include/asterisk/json.h 384882
> /trunk/include/asterisk/stasis_http.h PRE-CREATION
> /trunk/include/asterisk/strings.h 384882
> /trunk/include/asterisk/utils.h 384882
> /trunk/main/http.c 384882
> /trunk/main/json.c 384882
> /trunk/res/Makefile 384882
> /trunk/res/res_stasis_http.c PRE-CREATION
> /trunk/res/res_stasis_http.exports.in PRE-CREATION
> /trunk/res/res_stasis_http.make PRE-CREATION
> /trunk/res/stasis_http/resource_asterisk.h PRE-CREATION
> /trunk/res/stasis_http/resource_asterisk.c PRE-CREATION
> /trunk/res/stasis_http/resource_bridges.h PRE-CREATION
> /trunk/res/stasis_http/resource_bridges.c PRE-CREATION
> /trunk/res/stasis_http/resource_channels.h PRE-CREATION
> /trunk/res/stasis_http/resource_channels.c PRE-CREATION
> /trunk/res/stasis_http/resource_endpoints.h PRE-CREATION
> /trunk/res/stasis_http/resource_endpoints.c PRE-CREATION
> /trunk/res/stasis_http/resource_events.h PRE-CREATION
> /trunk/res/stasis_http/resource_events.c PRE-CREATION
> /trunk/res/stasis_http/resource_recordings.h PRE-CREATION
> /trunk/res/stasis_http/resource_recordings.c PRE-CREATION
> /trunk/res/stasis_http/resources.c PRE-CREATION
> /trunk/rest-api/README.txt PRE-CREATION
> /trunk/rest-api/api-docs/asterisk.json PRE-CREATION
> /trunk/rest-api/api-docs/bridges.json PRE-CREATION
> /trunk/rest-api/api-docs/channels.json PRE-CREATION
> /trunk/rest-api/api-docs/endpoints.json PRE-CREATION
> /trunk/rest-api/api-docs/events.json PRE-CREATION
> /trunk/rest-api/api-docs/recordings.json PRE-CREATION
> /trunk/rest-api/resources.json PRE-CREATION
> /trunk/tests/test_stasis.c 384882
> /trunk/tests/test_stasis_http.c PRE-CREATION
> /trunk/tests/test_strings.c 384882
>
> Diff: https://reviewboard.asterisk.org/r/2376/diff/
>
>
> Testing
> -------
>
> Unit tests
>
>
> Thanks,
>
> David Lee
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130408/119fa3d8/attachment.htm>
More information about the asterisk-dev
mailing list