def _get_requested_items()

in gstack/controllers/__init__.py [0:0]


def _get_requested_items(authorization, args, type, to_cloudstack, **kwargs):
    name = None
    filter = helpers.get_filter(request.args)

    if 'name' in filter:
        name = filter['name']

    items = []

    if name:
        cloudstack_item = get_item_with_name(
            authorization=authorization,
            name=name,
            args=args,
            type=type
        )
        if cloudstack_item:
            items.append(
                to_cloudstack(
                    cloudstack_response=cloudstack_item, **kwargs
                )
            )
    else:
        cloudstack_items = _get_items(authorization=authorization, args=args)
        if cloudstack_items:
            for cloudstack_item in cloudstack_items[type]:
                items.append(
                    to_cloudstack(
                        cloudstack_response=cloudstack_item, **kwargs)
                )

    return items