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

hub.exec.boto3.client.macie2.create_findings_filter
hub.exec.boto3.client.macie2.delete_findings_filter
hub.exec.boto3.client.macie2.get_findings_filter
hub.exec.boto3.client.macie2.list_findings_filters
hub.exec.boto3.client.macie2.update_findings_filter
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, action: Text, finding_criteria: Dict, client_token: Text = None, description: Text = None, position: int = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates and defines the criteria and other settings for a findings filter.

    Args:
        name(Text): A custom name for the filter. The name must contain at least 3 characters and can contain as
            many as 64 characters. We strongly recommend that you avoid including any sensitive data in the
            name of a filter. Other users of your account might be able to see the filter's name, depending
            on the actions that they're allowed to perform in Amazon Macie.
        action(Text): The action to perform on findings that meet the filter criteria (findingCriteria). Valid values
            are: ARCHIVE, suppress (automatically archive) the findings; and, NOOP, don't perform any action
            on the findings.
        client_token(Text, optional): A unique, case-sensitive token that you provide to ensure the idempotency of the request. Defaults to None.
        description(Text, optional): A custom description of the filter. The description can contain as many as 512 characters. We
            strongly recommend that you avoid including any sensitive data in the description of a filter.
            Other users of your account might be able to see the filter's description, depending on the
            actions that they're allowed to perform in Amazon Macie. Defaults to None.
        finding_criteria(Dict): The criteria to use to filter findings.
        position(int, optional): The position of the filter in the list of saved filters on the Amazon Macie console. This value
            also determines the order in which the filter is applied to findings, relative to other filters
            that are also applied to the findings. Defaults to None.
        tags(Dict, optional): A map of key-value pairs that specifies the tags to associate with the filter. A findings filter
            can have a maximum of 50 tags. Each tag consists of a tag key and an associated tag value. The
            maximum length of a tag key is 128 characters. The maximum length of a tag value is 256
            characters. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.macie2.findings_filter.present:
                - name: value
                - action: value
                - finding_criteria: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.macie2.findings_filter.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.macie2.get_findings_filter(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.macie2.create_findings_filter(
                ctx,
                
                
                **{"Name": name, "action": action, "clientToken": client_token, "description": description, "findingCriteria": finding_criteria, "position": position, "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.macie2.get_findings_filter(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

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

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        id_(Text): The unique identifier for the Amazon Macie resource or account that the request applies to.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

