[Home]

Summary:ASTERISK-24273: ARI deviceStates inconsistency
Reporter:litnimax (maxgurubot)Labels:
Date Opened:2014-08-27 14:00:29Date Closed:2014-08-27 16:15:44
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_ari
Versions:12.3.0 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description: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!
Comments:By: Matt Jordan (mjordan) 2014-08-27 16:15:44.186-0500

So... this isn't actually a bug in Asterisk or ARI :-)

Please file issues that you may have with the Python library on github, which is where that project is maintained.

https://github.com/asterisk/ari-py

By: Matt Jordan (mjordan) 2014-08-27 16:16:47.456-0500

And, by the way, the reason why you got that Python exception is because you were using an out of date version of ARI. If you update ARI (pip install -U ), that should (I think) go away.

By: litnimax (maxgurubot) 2014-08-27 16:53:05.613-0500

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.