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

hub.exec.boto3.client.iot.create_audit_suppression
hub.exec.boto3.client.iot.delete_audit_suppression
hub.exec.boto3.client.iot.describe_audit_suppression
hub.exec.boto3.client.iot.list_audit_suppressions
hub.exec.boto3.client.iot.update_audit_suppression
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, check_name: Text, resource_identifier: Dict, client_request_token: Text, expiration_date: Text = None, suppress_indefinitely: bool = None, description: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates a Device Defender audit suppression.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        check_name(Text): An audit check name. Checks must be enabled for your account. (Use
            DescribeAccountAuditConfiguration to see the list of all checks, including those that are
            enabled or use UpdateAccountAuditConfiguration to select which checks are enabled.).
        resource_identifier(Dict): Information that identifies the noncompliant resource.
        expiration_date(Text, optional):  The epoch timestamp in seconds at which this suppression expires. Defaults to None.
        suppress_indefinitely(bool, optional):  Indicates whether a suppression should exist indefinitely or not. Defaults to None.
        description(Text, optional):  The description of the audit suppression. Defaults to None.
        client_request_token(Text):  The epoch timestamp in seconds at which this suppression expires.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.iot.audit_suppression.present:
                - name: value
                - check_name: value
                - resource_identifier: value
                - client_request_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.iot.audit_suppression.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.iot.describe_audit_suppression(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.iot.create_audit_suppression(
                ctx,
                
                
                **{"checkName": check_name, "resourceIdentifier": resource_identifier, "expirationDate": expiration_date, "suppressIndefinitely": suppress_indefinitely, "description": description, "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.iot.describe_audit_suppression(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, check_name: Text, resource_identifier: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Deletes a Device Defender audit suppression.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        check_name(Text): An audit check name. Checks must be enabled for your account. (Use
            DescribeAccountAuditConfiguration to see the list of all checks, including those that are
            enabled or use UpdateAccountAuditConfiguration to select which checks are enabled.).
        resource_identifier(Dict): Information that identifies the noncompliant resource.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.iot.delete_audit_suppression(
                ctx,
                
                
                **{"checkName": check_name, "resourceIdentifier": resource_identifier}
            )
            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.iot.describe_audit_suppression(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

