Implement functionality of the API method /cloudapi/account/listFlipGroups

This commit is contained in:
2024-07-23 17:53:45 +03:00
parent ce54341a64
commit 0ca3399026
3 changed files with 131 additions and 1 deletions

View File

@@ -2079,6 +2079,7 @@ class DecortController(object):
computes_args: None | dict = None,
disks_args: None | dict = None,
fail_if_not_found=False,
flip_groups_args: None | dict = None,
images_args: None | dict = None,
resource_consumption=False,
resource_groups_args: None | dict = None,
@@ -2108,6 +2109,12 @@ class DecortController(object):
the method `self.amodule.fail_json(**self.result)` will be
called if account is not found.
@param (None | dict) flip_groups_args: If dict is
specified, then the method `self.account_flip_groups`
will be called passing founded account ID
and `**flip_groups_args`. Result of the call will
be added to account info dict (key `flip_groups`).
@param (None | dict) images_args: If dict is
specified, then the method `self.account_images`
will be called passing founded account ID
@@ -2242,6 +2249,13 @@ class DecortController(object):
**images_args
)
if flip_groups_args is not None:
account_details['flip_groups'] =\
self.account_flip_groups(
account_id=account_details['id'],
**flip_groups_args
)
return account_details['id'], account_details
@waypoint
@@ -2586,6 +2600,51 @@ class DecortController(object):
return images
@waypoint
def account_flip_groups(
self,
account_id: int,
ext_net_id: None | int = None,
flig_group_id: None | int = None,
flig_group_ip: None | str = None,
flig_group_name: None | str = None,
page_number: int = 1,
page_size: None | int = None,
vins_id: None | int = None,
vins_name: None | str = None,
) -> list[dict]:
"""
Implementation of functionality of the API method
`/cloudapi/account/listFlipGroups`.
"""
api_params = {
'accountId': account_id,
'byIp': flig_group_ip,
'extnetId': ext_net_id,
'flipGroupId': flig_group_id,
'name': flig_group_name,
'page': page_number if page_size else None,
'size': page_size,
'vinsId': vins_id,
'vinsName': vins_name,
}
api_resp = self.decort_api_call(
arg_req_function=requests.post,
arg_api_name='/restmachine/cloudapi/account/listFlipGroups',
arg_params=api_params,
)
flip_groups = api_resp.json()['data']
for fg in flip_groups:
fg['createdTime_readable'] = self.sec_to_dt_str(fg['createdTime'])
fg['deletedTime_readable'] = self.sec_to_dt_str(fg['deletedTime'])
fg['updatedTime_readable'] = self.sec_to_dt_str(fg['updatedTime'])
return flip_groups
###################################
# GPU resource manipulation methods
###################################