<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/2639/">https://reviewboard.asterisk.org/r/2639/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/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 and opticron.</div>
<div>By David Lee.</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-21885">ASTERISK-21885</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<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 started with the simple idea of changing the /events data
model to be more sane. The original model would send out events like:
{ "stasis_start": { "args": [], "channel": { ... } } }
The event discriminator was the field name instead of being a value in
the object, due to limitations in how Swagger 1.1 could model objects.
While technically sufficient in communicating event information, it was
really difficult to deal with in terms of client side JSON handling.
This patch takes advantage of a proposed extension[1] to Swagger which
allows type variance through the use of a discriminator field. This had
a domino effect that made this a surprisingly large patch.
[1]: https://groups.google.com/d/msg/wordnik-api/EC3rGajE0os/ey_5dBI_jWcJ
In changing the models, I also had to change the swagger_model.py
processor so it can handle the type discriminator and subtyping. I took
that a big step forward, and using that information to generate an
ari_model module, which can validate a JSON object against the Swagger
model.
The REST and WebSocket generators were changed to take advantage of the
validators. If compiled with AST_DEVMODE enabled, JSON objects that
don't match their corresponding models will not be sent out. For REST
API calls, a 500 Internal Server response is sent. For WebSockets, the
invalid JSON message is replaced with an error message.
Since this took over about half of the job of the existing JSON
generators, and the .to_json virtual function on messages took over the
other half, I reluctantly removed the generators.
The validators turned up all sorts of errors and inconsistencies in our
data models, and the code. These were cleaned up, with checks in the
code generator avoid some of the consistency problems in the future.
* The model for a channel snapshot was trimmed down to match the
information sent via AMI. Many of the field being sent were not
useful in the general case.
* The model for a bridge snapshot was updated to be more consistent
with the other ARI models.
Another impact of introducing subtyping was that the swagger-codegen
documentation generator was insufficient (at least until it catches up
with Swagger 1.2). I wanted it to be easier to generate docs for the API
anyways, so I ported the wiki pages to use the Asterisk Swagger
generator. In the process, I was able to clean up many of the model
links, which would occasionally give inconsistent results on the wiki. I
also added error responses to the wiki docs, making the wiki
documentation more complete.
Finally, since Stasis-HTTP will now be named Asterisk REST Interface
(ARI), any new functions and files I created carry the ari_ prefix. I
changed a few stasis_http references to ari where it was non-intrusive
and made sense.
This patch relies on the work in /team/dlee/ari-url-shuffle[2].
[2]: https://reviewboard.asterisk.org/r/2621/</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 for validator.
Created some channels, put them in Stasis(), using the ARI /bridges API to bridge them together. And it worked.</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/ari-url-shuffle/Makefile <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/include/asterisk/json.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/include/asterisk/stasis_http.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/main/json.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/main/stasis_bridging.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/main/stasis_channels.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/main/stasis_endpoints.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/Makefile <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_ari_model.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_ari_model.exports.in <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_asterisk.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_bridges.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_channels.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_endpoints.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_events.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_playback.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_recordings.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_http_sounds.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_asterisk.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_asterisk.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_bridges.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_bridges.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_channels.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_channels.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_endpoints.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_endpoints.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_events.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_events.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_playback.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_playback.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_recordings.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_recordings.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_sounds.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/res_stasis_json_sounds.exports.in <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_http/ari_model.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_http/ari_model.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_http/ari_websockets.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_http/resource_recordings.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_http/resource_recordings.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_asterisk.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_bridges.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_channels.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_endpoints.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_events.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_playback.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_recordings.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/res/stasis_json/resource_sounds.h <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/api.wiki.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/ari_model.c.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/ari_model.h.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/asterisk_processor.py <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/make_ari_stubs.py <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/make_stasis_http_stubs.py <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/models.wiki.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/res_stasis_http_resource.c.mustache <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/res_stasis_json_resource.c.mustache <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/res_stasis_json_resource.exports.mustache <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/stasis_json_resource.h.mustache <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/swagger_model.py <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api-templates/transform.py <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/asterisk.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/bridges.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/channels.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/endpoints.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/events.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/playback.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/recordings.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/rest-api/api-docs/sounds.json <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/tests/test_ari_model.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/team/dlee/ari-url-shuffle/tests/test_res_stasis.c <span style="color: grey">(392488)</span></li>
<li>/team/dlee/ari-url-shuffle/tests/test_stasis_channels.c <span style="color: grey">(392488)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2639/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>