# Copyright (c) 2022 CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to legal@cloudzero.com

from typing import Dict

from aws_lambda_powertools.utilities.parser import parse


def parsed_event(model):
    def parsed_event_handler(handler):
        def handler_wrapper(event: Dict, context, **kwargs):
            parsed_event = parse(event, model=model)
            return handler(event, context, parsed_event=parsed_event, **kwargs)
        return handler_wrapper
    return parsed_event_handler
