"""
Autogenerated state module using `pop-create-idem <https://gitlab.com/saltstack/pop/pop-create-idem>`__

hub.exec.boto3.client.frauddetector.delete_event_type
hub.exec.boto3.client.frauddetector.get_event_types
hub.exec.boto3.client.frauddetector.put_event_type
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, event_variables: List, entity_types: List, description: Text = None, labels: List = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates or updates an event type. An event is a business activity that is evaluated for fraud risk. With Amazon
    Fraud Detector, you generate fraud predictions for events. An event type defines the structure for an event sent
    to Amazon Fraud Detector. This includes the variables sent as part of the event, the entity performing the event
    (such as a customer), and the labels that classify the event. Example event types include online payment
    transactions, account registrations, and authentications.

    Args:
        name(Text): The name.
        description(Text, optional): The description of the event type. Defaults to None.
        event_variables(List): The event type variables.
        labels(List, optional): The event type labels. Defaults to None.
        entity_types(List): The entity type for the event type. Example entity types: customer, merchant, account.
        tags(List, optional): A collection of key and value pairs. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.frauddetector.event_type.present:
                - name: value
                - event_variables: value
                - entity_types: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.frauddetector.event_type.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    
    before = await hub.exec.boto3.client.frauddetector.get_event_types(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.frauddetector.put_event_type(
                ctx,
                
                
                **{"Name": name, "description": description, "eventVariables": event_variables, "labels": labels, "entityTypes": entity_types, "tags": tags}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            ret["comment"] = f"Created '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    
    # TODO perform other modifications as needed here
    ...

    after = await hub.exec.boto3.client.frauddetector.get_event_types(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an event type. You cannot delete an event type that is used in a detector or a model. When you delete an
    entity type, Amazon Fraud Detector permanently deletes that entity type and the data is no longer stored in
    Amazon Fraud Detector.

    Args:
        name(Text): The name of the event type to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.frauddetector.event_type.absent:
                - name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.frauddetector.event_type.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    

    before = await hub.exec.boto3.client.frauddetector.get_event_types(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.frauddetector.delete_event_type(
                ctx,
                
                
                **{"Name": name}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            result["comment"] = f"Deleted '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    

    after = await hub.exec.boto3.client.frauddetector.get_event_types(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

