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

hub.exec.boto3.client.waf.delete_logging_configuration
hub.exec.boto3.client.waf.get_logging_configuration
hub.exec.boto3.client.waf.list_logging_configurations
hub.exec.boto3.client.waf.put_logging_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, logging_configuration: Dict)  -> 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.   Associates a LoggingConfiguration
    with a specified web ACL. You can access information about all traffic that AWS WAF inspects using the following
    steps:   Create an Amazon Kinesis Data Firehose.  Create the data firehose with a PUT source and in the region
    that you are operating. However, if you are capturing logs for Amazon CloudFront, always create the firehose in
    US East (N. Virginia).   Do not create the data firehose using a Kinesis stream as your source.    Associate
    that firehose to your web ACL using a PutLoggingConfiguration request.   When you successfully enable logging
    using a PutLoggingConfiguration request, AWS WAF will create a service linked role with the necessary
    permissions to write logs to the Amazon Kinesis Data Firehose. For more information, see Logging Web ACL Traffic
    Information in the AWS WAF Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        logging_configuration(Dict): The Amazon Kinesis Data Firehose that contains the inspected traffic information, the redacted
            fields details, and the Amazon Resource Name (ARN) of the web ACL to monitor.  When specifying
            Type in RedactedFields, you must use one of the following values: URI, QUERY_STRING, HEADER, or
            METHOD.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, resource_arn: 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 the
    LoggingConfiguration from the specified web ACL.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        resource_arn(Text): The Amazon Resource Name (ARN) of the web ACL from which you want to delete the
            LoggingConfiguration.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

