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

hub.exec.boto3.client.kafka.create_configuration
hub.exec.boto3.client.kafka.delete_configuration
hub.exec.boto3.client.kafka.describe_configuration
hub.exec.boto3.client.kafka.list_configurations
hub.exec.boto3.client.kafka.update_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, server_properties: ByteString, description: Text = None, kafka_versions: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates a new MSK configuration.

    Args:
        name(Text):  The name of the configuration.
        description(Text, optional):  The description of the configuration. Defaults to None.
        kafka_versions(List, optional):  The versions of Apache Kafka with which you can use this MSK configuration. Defaults to None.
        server_properties(ByteString):  Contents of the server.properties file. When using the API, you must ensure that the contents
            of the file are base64 encoded.                 When using the AWS Management Console, the SDK,
            or the AWS CLI, the contents of server.properties can be in plaintext.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.kafka.create_configuration(
                ctx,
                
                
                **{"Name": name, "Description": description, "KafkaVersions": kafka_versions, "ServerProperties": server_properties}
            )
            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.kafka.describe_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Deletes an MSK Configuration.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        arn(Text):  The Amazon Resource Name (ARN) that uniquely identifies an MSK configuration.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

