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

hub.exec.boto3.client.stepfunctions.create_activity
hub.exec.boto3.client.stepfunctions.delete_activity
hub.exec.boto3.client.stepfunctions.describe_activity
hub.exec.boto3.client.stepfunctions.list_activities
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an activity. An activity is a task that you write in any programming language and host on any machine
    that has access to AWS Step Functions. Activities must poll Step Functions using the GetActivityTask API action
    and respond using SendTask* API actions. This function lets Step Functions know the existence of your activity
    and returns an identifier for use in a state machine and when polling from the activity.  This operation is
    eventually consistent. The results are best effort and may not reflect very recent updates and changes.
    CreateActivity is an idempotent API. Subsequent requests won’t create a duplicate resource if it was already
    created. CreateActivity's idempotency check is based on the activity name. If a following request has different
    tags values, Step Functions will ignore these differences and treat it as an idempotent request of the previous.
    In this case, tags will not be updated, even if they are different.

    Args:
        name(Text): The name of the activity to create. This name must be unique for your AWS account and region for
            90 days. For more information, see  Limits Related to State Machine Executions in the AWS Step
            Functions Developer Guide. A name must not contain:   white space   brackets < > { } [ ]
            wildcard characters ? *    special characters " # % \ ^ | ~ ` $ & , ; : /    control characters
            (U+0000-001F, U+007F-009F)   To enable logging with CloudWatch Logs, the name should only
            contain 0-9, A-Z, a-z, - and _.
        tags(List, optional): The list of tags to add to a resource. An array of key-value pairs. For more information, see
            Using Cost Allocation Tags in the AWS Billing and Cost Management User Guide, and Controlling
            Access Using IAM Tags. Tags may only contain Unicode letters, digits, white space, or these
            symbols: _ . : / = + - @. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.stepfunctions.activity.present:
                - name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)

    
    before = await hub.exec.boto3.client.stepfunctions.describe_activity(name)

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

async def absent(hub, ctx, name: Text, activity_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an activity.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

