Implement functionality of the API method cloudapi/account/listTemplates

This commit is contained in:
2024-07-23 10:46:58 +03:00
parent 0c0fde8470
commit 7422464109
3 changed files with 180 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ class DecortAccountInfo(DecortController):
account_id=amodule.params['id'],
computes_args=self.mapped_computes_args,
disks_args=self.mapped_disks_args,
images_args=self.mapped_images_args,
resource_consumption=amodule.params['resource_consumption'],
resource_groups_args=self.mapped_rg_args,
vinses_args=self.mapped_vinses_args,
@@ -178,6 +179,58 @@ class DecortAccountInfo(DecortController):
id=dict(
type='int',
),
images=dict(
type='dict',
options=dict(
deleted=dict(
type='bool',
default=False,
),
filter=dict(
type='dict',
options=dict(
id=dict(
type='int',
),
name=dict(
type='str',
),
type=dict(
type='str',
choices=self.IMAGE_TYPES,
),
),
),
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_IMAGE_LIST,
required=True,
),
),
),
),
),
jwt=dict(
type='str',
fallback=(env_fallback, ['DECORT_JWT']),
@@ -387,6 +440,38 @@ class DecortAccountInfo(DecortController):
return mapped_args
@property
def mapped_images_args(self) -> None | dict:
"""
Map the module argument `images` to
arguments dictionary for the method
`DecortController.account_images`
(excluding for `account_id`).
"""
input_args = self.amodule.params['images']
if not input_args:
return input_args
mapped_args = {}
mapped_args['deleted'] = input_args['deleted']
if input_args['filter']:
mapped_args['image_id'] = input_args['filter']['id']
mapped_args['image_name'] = input_args['filter']['name']
mapped_args['image_type'] = input_args['filter']['type']
if input_args['pagination']:
mapped_args['page_number'] =\
input_args['pagination']['number']
mapped_args['page_size'] =\
input_args['pagination']['size']
if input_args['sorting']:
mapped_args['sort_by_asc'] =\
input_args['sorting']['asc']
mapped_args['sort_by_field'] =\
input_args['sorting']['field']
return mapped_args
@property
def mapped_rg_args(self) -> None | dict:
"""