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

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


litnimax created ASTERISK-24273:
-----------------------------------

             Summary: 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:

import ari
client = ari.connect('http://localhost:8088', 'dialer', 'test')
 e = client.endpoints.get(tech='SIP', resource='1061')
print e.json

Result:

{u'resource': u'1061', u'state': u'online', u'technology': u'SIP', u'channel_ids': []}

This does not work:

d = client.deviceStates.get(deviceName='SIP%2F1061')

Give exception:

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'

But this works:
d = client.repositories['deviceStates'].api.get(deviceName='SIP%2F1061').json()

Result:
{u'resource': u'1061', u'state': u'online', u'technology': u'SIP', u'channel_ids': []}


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