Refactor DecortController.account_find method
This commit is contained in:
@@ -1981,7 +1981,14 @@ class DecortController(object):
|
|||||||
if api_resp.status_code == 200:
|
if api_resp.status_code == 200:
|
||||||
account_details = api_resp.json()
|
account_details = api_resp.json()
|
||||||
|
|
||||||
if account_details:
|
if not account_details:
|
||||||
|
if fail_if_not_found:
|
||||||
|
self.result['msg'] = ("Current user does not have access to"
|
||||||
|
" the requested account or non-existent"
|
||||||
|
" account specified.")
|
||||||
|
self.amodule.fail_json(**self.result)
|
||||||
|
return 0, None
|
||||||
|
|
||||||
account_details['createdTime_readable'] = self.sec_to_dt_str(
|
account_details['createdTime_readable'] = self.sec_to_dt_str(
|
||||||
account_details['createdTime']
|
account_details['createdTime']
|
||||||
)
|
)
|
||||||
@@ -2006,14 +2013,6 @@ class DecortController(object):
|
|||||||
resource_consumption['Reserved']
|
resource_consumption['Reserved']
|
||||||
|
|
||||||
return account_details['id'], account_details
|
return account_details['id'], account_details
|
||||||
else:
|
|
||||||
if fail_if_not_found:
|
|
||||||
self.result['msg'] = ("Current user does not have access to"
|
|
||||||
" the requested account or non-existent"
|
|
||||||
" account specified.")
|
|
||||||
self.amodule.fail_json(**self.result)
|
|
||||||
else:
|
|
||||||
return 0, None
|
|
||||||
|
|
||||||
def account_resource_consumption(self, account_id: int,
|
def account_resource_consumption(self, account_id: int,
|
||||||
fail_if_not_found=False) -> None | dict:
|
fail_if_not_found=False) -> None | dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user