mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-09-10 11:40:41 +08:00
Raise clear exception when a given private cloud does not support a given api
This commit is contained in:
@@ -25,10 +25,14 @@ def api_handler(arg, cloud, api, batch=False, auth=None, **kwargs):
|
|||||||
if not auth:
|
if not auth:
|
||||||
auth = config.AUTH
|
auth = config.AUTH
|
||||||
|
|
||||||
response = requests.post(url, data=json_data, headers=JSON_HEADERS, auth=auth).json()
|
response = requests.post(url, data=json_data, headers=JSON_HEADERS, auth=auth)
|
||||||
results = response.get('results', False)
|
if response.status_code == 503 and cloud != None:
|
||||||
|
raise Exception("Private cloud '%s' does not include api '%s'" % (cloud, api))
|
||||||
|
|
||||||
|
json_results = response.json()
|
||||||
|
results = json_results.get('results', False)
|
||||||
if results is False:
|
if results is False:
|
||||||
error = response.get('error')
|
error = json_results.get('error')
|
||||||
raise ValueError(error)
|
raise ValueError(error)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user