<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2376/">https://reviewboard.asterisk.org/r/2376/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Not much yet; still looking through it.
As a general question - do we have an 'automatic' way of getting swagger and generating the documentation?</pre>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2376/diff/1/?file=34029#file34029line953" style="color: black; font-weight: bold; text-decoration: underline;">/team/dlee/stasis-app/Makefile</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">953</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        build_tools/make_stasis_http_stubs</pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">954</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Just for the sake of being nice to people, there's a dependency check for Python available:
ifeq ($(PYTHON),:)
@echo Complain
fi
</pre>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2376/diff/1/?file=34031#file34031line8" style="color: black; font-weight: bold; text-decoration: underline;">/team/dlee/stasis-app/cog/res_stasis_http.make.cog</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">8</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">#<span class="ew"> </span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Blob</pre>
</div>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2376/diff/1/?file=34032#file34032line276" style="color: black; font-weight: bold; text-decoration: underline;">/team/dlee/stasis-app/cog/stasis_cog.py</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">def __init__(self, parent_name, path_element):</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">276</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="bp">self</span><span class="o">.</span><span class="n">children</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">277</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="bp">self</span><span class="o">.</span><span class="n">operations</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">You're not going to enjoy this, but... we've tried not to use OrderedDict as it was new in Python 2.7. CentOS 6 is shipping with Python 2.6.x... so, it would be better if we didn't rely on it.</pre>
</div>
<br />
<p>- Matt</p>
<br />
<p>On March 7th, 2013, 11:03 a.m., David Lee wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By David Lee.</div>
<p style="color: grey;"><i>Updated March 7, 2013, 11:03 a.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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/
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Unit tests</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/team/dlee/stasis-app/Makefile <span style="color: grey">(382603)</span></li>
<li>/team/dlee/stasis-app/build_tools/make_stasis_http_stubs <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/cog/res_stasis_http.make.cog <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/cog/stasis_cog.py <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/cog/stasis_http_resource.c.cog <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/cog/stasis_http_resource.h.cog <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/cog/stasis_http_resources.c.cog <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/include/asterisk/http.h <span style="color: grey">(382603)</span></li>
<li>/team/dlee/stasis-app/include/asterisk/stasis_http.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/include/asterisk/strings.h <span style="color: grey">(382603)</span></li>
<li>/team/dlee/stasis-app/include/asterisk/utils.h <span style="color: grey">(382603)</span></li>
<li>/team/dlee/stasis-app/main/http.c <span style="color: grey">(382603)</span></li>
<li>/team/dlee/stasis-app/res/Makefile <span style="color: grey">(382603)</span></li>
<li>/team/dlee/stasis-app/res/res_stasis_http.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/res_stasis_http.exports.in <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/res_stasis_http.make <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_asterisk.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_asterisk.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_bridges.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_bridges.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_channels.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_channels.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_endpoints.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_endpoints.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_recordings.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resource_recordings.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/res/stasis_http/resources.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/rest-api/README.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/rest-api/asterisk.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/rest-api/bridges.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/rest-api/channels.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/rest-api/endpoints.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/rest-api/recordings.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/rest-api/resources.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/tests/test_stasis_http.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/stasis-app/tests/test_strings.c <span style="color: grey">(382603)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2376/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>