Refactor DecortController.account_find method

This commit is contained in:
2024-07-16 15:11:33 +03:00
parent 37de8afbc1
commit f00055e009

View File

@@ -1981,7 +1981,14 @@ class DecortController(object):
if api_resp.status_code == 200:
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']
)
@@ -2006,14 +2013,6 @@ class DecortController(object):
resource_consumption['Reserved']
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,
fail_if_not_found=False) -> None | dict: