[asterisk-dev] [Code Review] 2641: ARI: Add support for getting/setting channel and global variables.

David Lee reviewboard at asterisk.org
Fri Jun 28 17:18:01 CDT 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2641/#review9021
-----------------------------------------------------------


I wonder if it would be beneficial to model variables as a first class resource.

  GET /channels/{channelId}/variables - returns all channel variables
  GET /channels/{channelId}/variables/{variableName} - returns a single variable
  POST /channels/{channelId}/variables/{variableName}?value=_ - sets a variable

And something similar for global variables. Functions become a little less intuitive, but this is probably more in the spirit of REST.


/trunk/res/stasis/control.c
<https://reviewboard.asterisk.org/r/2641/#comment17741>

    Why not just char *workspace = ast_alloc(1024)? Then you can get rid of the strdup.



/trunk/res/stasis/control.c
<https://reviewboard.asterisk.org/r/2641/#comment17742>

    You shouldn't have to cast variable to a char*. ast_func_read takes a const char *.
    
    Regarding mjordan's earlier comment, if ast_func_read() fails, you should return NULL here.



/trunk/res/stasis/control.c
<https://reviewboard.asterisk.org/r/2641/#comment17743>

    The doc for setvar_helper says "Will lock the channel." This lock isn't really needed.



/trunk/res/stasis_http/resource_asterisk.c
<https://reviewboard.asterisk.org/r/2641/#comment17744>

    Ideally, you would return a 400 error code if the failure is the user's fault (trying to set a function that does not exist), or 500 if it's an internal error (a function unexpectedly failed).
    
    setvar_helper really doesn't distinguish the two, so I would err on the side of the user making the mistake and always return a 400 error code here.



/trunk/res/stasis_http/resource_channels.c
<https://reviewboard.asterisk.org/r/2641/#comment17745>

    Same comment here.


- David Lee


On June 27, 2013, 11:19 a.m., Jason Parker wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2641/
> -----------------------------------------------------------
> 
> (Updated June 27, 2013, 11:19 a.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: ASTERISK-21868
>     https://issues.asterisk.org/jira/browse/ASTERISK-21868
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> Allows for reading channel variables (or functions), setting channel variables (or functions), getting global variables, setting global variables.
> 
> 
> Diffs
> -----
> 
>   /trunk/include/asterisk/stasis_app.h 393055 
>   /trunk/res/res_stasis_http_asterisk.c 393055 
>   /trunk/res/res_stasis_http_channels.c 393055 
>   /trunk/res/stasis/control.c 393055 
>   /trunk/res/stasis_http/resource_asterisk.h 393055 
>   /trunk/res/stasis_http/resource_asterisk.c 393055 
>   /trunk/res/stasis_http/resource_channels.h 393055 
>   /trunk/res/stasis_http/resource_channels.c 393055 
>   /trunk/res/stasis_json/resource_asterisk.h 393055 
>   /trunk/res/stasis_json/resource_channels.h 393055 
>   /trunk/rest-api/api-docs/asterisk.json 393055 
>   /trunk/rest-api/api-docs/channels.json 393055 
> 
> Diff: https://reviewboard.asterisk.org/r/2641/diff/
> 
> 
> Testing
> -------
> 
> All 4 things work.  Failures occur in the few places they would be expected (invalid function name, etc).
> 
> 
> Thanks,
> 
> Jason Parker
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130628/c589b46c/attachment.htm>


More information about the asterisk-dev mailing list