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

hub.exec.boto3.client.iotwireless.create_destination
hub.exec.boto3.client.iotwireless.delete_destination
hub.exec.boto3.client.iotwireless.get_destination
hub.exec.boto3.client.iotwireless.list_destinations
hub.exec.boto3.client.iotwireless.update_destination
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, expression_type: Text, expression: Text, role_arn: Text, description: Text = None, tags: List = None, client_request_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new destination that maps a device message to an AWS IoT rule.

    Args:
        name(Text): The name of the new resource.
        expression_type(Text): The type of value in Expression.
        expression(Text): The rule name or topic rule to send messages to.
        description(Text, optional): The description of the new resource. Defaults to None.
        role_arn(Text): The ARN of the IAM Role that authorizes the destination.
        tags(List, optional): The tags to attach to the new destination. Tags are metadata that you can use to manage a
            resource. Defaults to None.
        client_request_token(Text, optional): Each resource must have a unique client request token. If you try to create a new resource with
            the same token as a resource that already exists, an exception occurs. If you omit this value,
            AWS SDKs will automatically generate a unique client request. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.iotwireless.destination.present:
                - name: value
                - expression_type: value
                - expression: value
                - role_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.iotwireless.destination.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.iotwireless.get_destination(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.iotwireless.create_destination(
                ctx,
                
                
                **{"Name": name, "ExpressionType": expression_type, "Expression": expression, "Description": description, "RoleArn": role_arn, "Tags": tags, "ClientRequestToken": client_request_token}
            )
            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.iotwireless.get_destination(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

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

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

