[asterisk-bugs] [JIRA] (ASTERISK-24273) ARI deviceStates inconsistency

litnimax (JIRA) noreply at issues.asterisk.org
Wed Aug 27 16:53:29 CDT 2014


    [ https://issues.asterisk.org/jira/browse/ASTERISK-24273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=222433#comment-222433 ] 

litnimax commented on ASTERISK-24273:
-------------------------------------

Thanks Matt :-)
But it'a a newest version available on github and pip also - 0.1.2.
Creating an issue at ari-py, sorry.
Thanks again.

> ARI deviceStates inconsistency
> ------------------------------
>
>                 Key: ASTERISK-24273
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-24273
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_ari
>    Affects Versions: 12.3.0
>            Reporter: litnimax
>
> This works:
> {noformat}
> import ari
> client = ari.connect('http://localhost:8088', 'dialer', 'test')
>  e = client.endpoints.get(tech='SIP', resource='1061')
> print e.json
> {noformat}
> Result:
> {noformat}
> {u'resource': u'1061', u'state': u'online', u'technology': u'SIP', u'channel_ids': []}
> {noformat}
> This does not work:
> {noformat}
> d = client.deviceStates.get(deviceName='SIP%2F1061')
> {noformat}
> Give exception:
> {noformat}
> Traceback (most recent call last):
>   File "test_ari.py", line 9, in <module>
>     d = client.deviceStates.get(deviceName='SIP%2F1061')
>   File "/opt/ast/env/local/lib/python2.7/site-packages/ari/model.py", line 62, in <lambda>
>     return lambda **kwargs: promote(self.client, oper(**kwargs), oper.json)
>   File "/opt/ast/env/local/lib/python2.7/site-packages/ari/model.py", line 365, in promote
>     return factory(client, resp_json)
>   File "/opt/odoo/env/local/lib/python2.7/site-packages/ari/model.py", line 306, in __init__
>     client, client.swagger.devicestates, device_state_json,
>   File "/opt/ast/env/local/lib/python2.7/site-packages/swaggerpy/client.py", line 199, in __getattr__
>     raise AttributeError("API has no resource '%s'" % item)
> AttributeError: API has no resource 'devicestates'
> {noformat}
> But this works:
> {noformat}
> d = client.repositories['deviceStates'].api.get(deviceName='SIP%2F1061').json()
> {noformat}
> Result:
> {noformat}
> {u'resource': u'1061', u'state': u'online', u'technology': u'SIP', u'channel_ids': []}
> {noformat}
> P.S. Also it was a very tense way to understand that parameter deviceName should be url escaped.. 
> May be when called by URL (http://localhost:8088/ari/deviceStates/SIP%2F1061) it's ok.
> But why use the same from python?? URL must be escaped in code!



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list