Implement functionality of /cloudapi/account/listRG API method in decort_account_info module
This commit is contained in:
@@ -32,6 +32,7 @@ class DecortAccountInfo(DecortController):
|
||||
account_name=amodule.params['name'],
|
||||
account_id=amodule.params['id'],
|
||||
resource_consumption=amodule.params['resource_consumption'],
|
||||
resource_groups_params=self.mapped_rg_params,
|
||||
fail_if_not_found=True
|
||||
)
|
||||
|
||||
@@ -72,6 +73,60 @@ class DecortAccountInfo(DecortController):
|
||||
type='str',
|
||||
fallback=(env_fallback, ['DECORT_OAUTH2_URL'])
|
||||
),
|
||||
resource_groups=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
filter=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
id=dict(
|
||||
type='int',
|
||||
),
|
||||
name=dict(
|
||||
type='str'
|
||||
),
|
||||
status=dict(
|
||||
type='str',
|
||||
choices=self.RESOURCE_GROUP_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_RG_LIST,
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
resource_consumption=dict(
|
||||
type='bool',
|
||||
default=False
|
||||
@@ -94,6 +149,37 @@ class DecortAccountInfo(DecortController):
|
||||
]
|
||||
)
|
||||
|
||||
@property
|
||||
def mapped_rg_params(self) -> None | dict:
|
||||
input_params = self.amodule.params['resource_groups']
|
||||
if not input_params:
|
||||
return input_params
|
||||
|
||||
mapped_params = {}
|
||||
if input_params['filter']:
|
||||
mapped_params['rg_id'] =\
|
||||
input_params['filter']['id']
|
||||
mapped_params['rg_name'] =\
|
||||
input_params['filter']['name']
|
||||
mapped_params['rg_status'] =\
|
||||
input_params['filter']['status']
|
||||
mapped_params['vins_id'] =\
|
||||
input_params['filter']['vins_id']
|
||||
mapped_params['vm_id'] =\
|
||||
input_params['filter']['vm_id']
|
||||
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
|
||||
|
||||
def exit(self):
|
||||
self.result['facts'] = self.facts
|
||||
self.amodule.exit_json(**self.result)
|
||||
|
||||
Reference in New Issue
Block a user