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

hub.exec.boto3.client.wafv2.delete_logging_configuration
hub.exec.boto3.client.wafv2.get_logging_configuration
hub.exec.boto3.client.wafv2.list_logging_configurations
hub.exec.boto3.client.wafv2.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**
    
    Enables the specified LoggingConfiguration, to start logging from a web ACL, according to the configuration
    provided. You can access information about all traffic that 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. If you are capturing logs for Amazon CloudFront, always create the firehose in US East (N. Virginia).
    Give the data firehose a name that starts with the prefix aws-waf-logs-. For example, aws-waf-logs-us-
    east-2-analytics.  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, 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
    WAF Developer Guide.  This operation completely replaces the mutable specifications that you already have for
    the logging configuration with the ones that you provide to this call. To modify the logging configuration,
    retrieve it by calling GetLoggingConfiguration, update the settings as needed, and then provide the complete
    logging configuration specification to this call.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        logging_configuration(Dict): .

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.wafv2.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.wafv2.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**
    
    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.wafv2.logging_configuration.absent:
                - name: value
                - resource_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.wafv2.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.wafv2.get_logging_configuration(name)

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

