Implement functionality of cloudapi/account/listComputes API method in decort_account_info module
This commit is contained in:
@@ -31,6 +31,7 @@ class DecortAccountInfo(DecortController):
|
||||
self.id, self.facts = self.account_find(
|
||||
account_name=amodule.params['name'],
|
||||
account_id=amodule.params['id'],
|
||||
computes_params=self.mapped_computes_params,
|
||||
resource_consumption=amodule.params['resource_consumption'],
|
||||
resource_groups_params=self.mapped_rg_params,
|
||||
fail_if_not_found=True
|
||||
@@ -54,6 +55,75 @@ class DecortAccountInfo(DecortController):
|
||||
required=True,
|
||||
choices=['oauth2', 'jwt']
|
||||
),
|
||||
computes=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
ext_net_id=dict(
|
||||
type='int',
|
||||
),
|
||||
ext_net_name=dict(
|
||||
type='str'
|
||||
),
|
||||
id=dict(
|
||||
type='int',
|
||||
),
|
||||
ip=dict(
|
||||
type='str'
|
||||
),
|
||||
name=dict(
|
||||
type='str'
|
||||
),
|
||||
rg_id=dict(
|
||||
type='int',
|
||||
),
|
||||
rg_name=dict(
|
||||
type='str'
|
||||
),
|
||||
tech_status=dict(
|
||||
type='str',
|
||||
choices=self.COMPUTE_TECH_STATUSES,
|
||||
),
|
||||
vins_id=dict(
|
||||
type='int'
|
||||
),
|
||||
vm_id=dict(
|
||||
type='int'
|
||||
),
|
||||
),
|
||||
),
|
||||
pagination=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
number=dict(
|
||||
type='int',
|
||||
default=1,
|
||||
),
|
||||
size=dict(
|
||||
type='int',
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
sorting=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
asc=dict(
|
||||
type='bool',
|
||||
default=True,
|
||||
),
|
||||
field=dict(
|
||||
type='str',
|
||||
choices=\
|
||||
self.FIELDS_FOR_SORTING_ACCOUNT_COMPUTE_LIST,
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
controller_url=dict(
|
||||
type='str',
|
||||
required=True
|
||||
@@ -149,6 +219,37 @@ class DecortAccountInfo(DecortController):
|
||||
]
|
||||
)
|
||||
|
||||
@property
|
||||
def mapped_computes_params(self) -> None | dict:
|
||||
input_params = self.amodule.params['computes']
|
||||
if not input_params:
|
||||
return input_params
|
||||
|
||||
mapped_params = {}
|
||||
if input_params['filter']:
|
||||
mapped_params['compute_id'] = input_params['filter']['id']
|
||||
mapped_params['compute_ip'] = input_params['filter']['ip']
|
||||
mapped_params['compute_name'] = input_params['filter']['name']
|
||||
mapped_params['compute_tech_status'] =\
|
||||
input_params['filter']['tech_status']
|
||||
mapped_params['ext_net_id'] = input_params['filter']['ext_net_id']
|
||||
mapped_params['ext_net_name'] =\
|
||||
input_params['filter']['ext_net_name']
|
||||
mapped_params['rg_id'] = input_params['filter']['rg_id']
|
||||
mapped_params['rg_name'] = input_params['filter']['rg_name']
|
||||
if input_params['pagination']:
|
||||
mapped_params['page_number'] =\
|
||||
input_params['pagination']['number']
|
||||
mapped_params['page_size'] =\
|
||||
input_params['pagination']['size']
|
||||
if input_params['sorting']:
|
||||
mapped_params['sort_by_asc'] =\
|
||||
input_params['sorting']['asc']
|
||||
mapped_params['sort_by_field'] =\
|
||||
input_params['sorting']['field']
|
||||
|
||||
return mapped_params
|
||||
|
||||
@property
|
||||
def mapped_rg_params(self) -> None | dict:
|
||||
input_params = self.amodule.params['resource_groups']
|
||||
|
||||
Reference in New Issue
Block a user