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

hub.exec.boto3.client.personalize.create_event_tracker
hub.exec.boto3.client.personalize.delete_event_tracker
hub.exec.boto3.client.personalize.describe_event_tracker
hub.exec.boto3.client.personalize.list_event_trackers
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, dataset_group_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an event tracker that you use when adding event data to a specified dataset group using the PutEvents
    API.  Only one event tracker can be associated with a dataset group. You will get an error if you call
    CreateEventTracker using the same dataset group as an existing event tracker.  When you create an event tracker,
    the response includes a tracking ID, which you pass as a parameter when you use the PutEvents operation. Amazon
    Personalize then appends the event data to the Interactions dataset of the dataset group you specify in your
    event tracker.  The event tracker can be in one of the following states:   CREATE PENDING > CREATE IN_PROGRESS >
    ACTIVE -or- CREATE FAILED   DELETE PENDING > DELETE IN_PROGRESS   To get the status of the event tracker, call
    DescribeEventTracker.  The event tracker must be in the ACTIVE state before using the tracking ID.   Related
    APIs     ListEventTrackers     DescribeEventTracker     DeleteEventTracker

    Args:
        name(Text): The name for the event tracker.
        dataset_group_arn(Text): The Amazon Resource Name (ARN) of the dataset group that receives the event data.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.personalize.event_tracker.present:
                - name: value
                - dataset_group_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.personalize.event_tracker.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.personalize.describe_event_tracker(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.personalize.create_event_tracker(
                ctx,
                
                
                **{"Name": name, "datasetGroupArn": dataset_group_arn}
            )
            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.personalize.describe_event_tracker(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, event_tracker_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the event tracker. Does not delete the event-interactions dataset from the associated dataset group. For
    more information on event trackers, see CreateEventTracker.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        event_tracker_arn(Text): The Amazon Resource Name (ARN) of the event tracker to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.personalize.event_tracker.absent:
                - name: value
                - event_tracker_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.personalize.event_tracker.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.personalize.describe_event_tracker(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.personalize.delete_event_tracker(
                ctx,
                
                
                **{"eventTrackerArn": event_tracker_arn}
            )
            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.personalize.describe_event_tracker(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

