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

hub.exec.boto3.client.waf.create_sql_injection_match_set
hub.exec.boto3.client.waf.delete_sql_injection_match_set
hub.exec.boto3.client.waf.get_sql_injection_match_set
hub.exec.boto3.client.waf.list_sql_injection_match_sets
hub.exec.boto3.client.waf.update_sql_injection_match_set
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, change_token: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.  For
    the latest version of AWS WAF, use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the latest
    version, AWS WAF has a single set of endpoints for regional and global use.   Creates a SqlInjectionMatchSet,
    which you use to allow, block, or count requests that contain snippets of SQL code in a specified part of web
    requests. AWS WAF searches for character sequences that are likely to be malicious strings. To create and
    configure a SqlInjectionMatchSet, perform the following steps:   Use GetChangeToken to get the change token that
    you provide in the ChangeToken parameter of a CreateSqlInjectionMatchSet request.   Submit a
    CreateSqlInjectionMatchSet request.   Use GetChangeToken to get the change token that you provide in the
    ChangeToken parameter of an UpdateSqlInjectionMatchSet request.   Submit an UpdateSqlInjectionMatchSet request
    to specify the parts of web requests in which you want to allow, block, or count malicious SQL code.   For more
    information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

    Args:
        name(Text): A friendly name or description for the SqlInjectionMatchSet that you're creating. You can't
            change Name after you create the SqlInjectionMatchSet.
        change_token(Text): The value returned by the most recent call to GetChangeToken.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.waf.sql_injection_match_set.present:
                - name: value
                - change_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.waf.sql_injection_match_set.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.waf.get_sql_injection_match_set(name)

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

async def absent(hub, ctx, name: Text, sql_injection_match_set_id: Text, change_token: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.  For
    the latest version of AWS WAF, use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the latest
    version, AWS WAF has a single set of endpoints for regional and global use.   Permanently deletes a
    SqlInjectionMatchSet. You can't delete a SqlInjectionMatchSet if it's still used in any Rules or if it still
    contains any SqlInjectionMatchTuple objects. If you just want to remove a SqlInjectionMatchSet from a Rule, use
    UpdateRule. To permanently delete a SqlInjectionMatchSet from AWS WAF, perform the following steps:   Update the
    SqlInjectionMatchSet to remove filters, if any. For more information, see UpdateSqlInjectionMatchSet.   Use
    GetChangeToken to get the change token that you provide in the ChangeToken parameter of a
    DeleteSqlInjectionMatchSet request.   Submit a DeleteSqlInjectionMatchSet request.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        sql_injection_match_set_id(Text): The SqlInjectionMatchSetId of the SqlInjectionMatchSet that you want to delete.
            SqlInjectionMatchSetId is returned by CreateSqlInjectionMatchSet and by
            ListSqlInjectionMatchSets.
        change_token(Text): The value returned by the most recent call to GetChangeToken.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.waf.delete_sql_injection_match_set(
                ctx,
                
                
                **{"SqlInjectionMatchSetId": sql_injection_match_set_id, "ChangeToken": change_token}
            )
            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.waf.get_sql_injection_match_set(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

