Added axapi_authenticate_v3 and axapi_call_v3 for new AXAPIv3 that is not backward compatible
This commit is contained in:
parent
147857d7ac
commit
b6c30e7985
1 changed files with 3 additions and 3 deletions
|
@ -97,15 +97,15 @@ def axapi_authenticate_v3(module, base_url, username, password):
|
||||||
signature = result['authresponse']['signature']
|
signature = result['authresponse']['signature']
|
||||||
return signature
|
return signature
|
||||||
|
|
||||||
def axapi_call_v3(module, url, post=None, signature=''):
|
def axapi_call_v3(module, url, method=None, body=None, signature=None):
|
||||||
'''
|
'''
|
||||||
Returns a datastructure based on the result of the API call
|
Returns a datastructure based on the result of the API call
|
||||||
'''
|
'''
|
||||||
if signature:
|
if signature:
|
||||||
headers = {'content-type': 'application/json', 'signature': signature}
|
headers = {'content-type': 'application/json', 'Authorization': 'A10 %s' % signature}
|
||||||
else:
|
else:
|
||||||
headers = {'content-type': 'application/json'}
|
headers = {'content-type': 'application/json'}
|
||||||
rsp, info = fetch_url(module, url, method='POST', data=json.dumps(post), headers=headers)
|
rsp, info = fetch_url(module, url, method=method, data=json.dumps(body), headers=headers)
|
||||||
if not rsp or info['status'] >= 400:
|
if not rsp or info['status'] >= 400:
|
||||||
module.fail_json(msg="failed to connect (status code %s), error was %s" % (info['status'], info.get('msg', 'no error given')))
|
module.fail_json(msg="failed to connect (status code %s), error was %s" % (info['status'], info.get('msg', 'no error given')))
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue