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

hub.exec.boto3.client.macie2.create_custom_data_identifier
hub.exec.boto3.client.macie2.delete_custom_data_identifier
hub.exec.boto3.client.macie2.get_custom_data_identifier
hub.exec.boto3.client.macie2.list_custom_data_identifiers
hub.exec.boto3.client.macie2.test_custom_data_identifier
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text = None, client_token: Text = None, description: Text = None, ignore_words: List = None, keywords: List = None, maximum_match_distance: int = None, regex: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates and defines the criteria and other settings for a custom data identifier.

    Args:
        name(Text, optional): A custom name for the custom data identifier. The name can contain as many as 128 characters. We
            strongly recommend that you avoid including any sensitive data in the name of a custom data
            identifier. Other users of your account might be able to see the identifier's name, depending on
            the actions that they're allowed to perform in Amazon Macie. Defaults to None.
        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 custom data identifier. The description can contain as many as 512
            characters. We strongly recommend that you avoid including any sensitive data in the description
            of a custom data identifier. Other users of your account might be able to see the identifier's
            description, depending on the actions that they're allowed to perform in Amazon Macie. Defaults to None.
        ignore_words(List, optional): An array that lists specific character sequences (ignore words) to exclude from the results. If
            the text matched by the regular expression is the same as any string in this array, Amazon Macie
            ignores it. The array can contain as many as 10 ignore words. Each ignore word can contain 4-90
            characters. Ignore words are case sensitive. Defaults to None.
        keywords(List, optional): An array that lists specific character sequences (keywords), one of which must be within
            proximity (maximumMatchDistance) of the regular expression to match. The array can contain as
            many as 50 keywords. Each keyword can contain 3-90 characters. Keywords aren't case sensitive. Defaults to None.
        maximum_match_distance(int, optional): The maximum number of characters that can exist between text that matches the regex pattern and
            the character sequences specified by the keywords array. Macie includes or excludes a result
            based on the proximity of a keyword to text that matches the regex pattern. The distance can be
            1-300 characters. The default value is 50. Defaults to None.
        regex(Text, optional): The regular expression (regex) that defines the pattern to match. The expression can contain as
            many as 512 characters. Defaults to None.
        tags(Dict, optional): A map of key-value pairs that specifies the tags to associate with the custom data identifier. A
            custom data identifier 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.custom_data_identifier.present:
                - 
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.macie2.custom_data_identifier.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_custom_data_identifier(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.macie2.create_custom_data_identifier(
                ctx,
                
                
                **{"Name": name, "clientToken": client_token, "description": description, "ignoreWords": ignore_words, "keywords": keywords, "maximumMatchDistance": maximum_match_distance, "regex": regex, "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_custom_data_identifier(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**
    
    Soft deletes a custom data identifier.

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

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

