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

hub.exec.boto3.client.lexv2_models.create_bot_version
hub.exec.boto3.client.lexv2_models.delete_bot_version
hub.exec.boto3.client.lexv2_models.describe_bot_version
hub.exec.boto3.client.lexv2_models.list_bot_versions
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, bot_id: Text, bot_version_locale_specification: Dict, description: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new version of the bot based on the DRAFT version. If the DRAFT version of this resource hasn't
    changed since you created the last version, Amazon Lex doesn't create a new version, it returns the last created
    version. When you create the first version of a bot, Amazon Lex sets the version to 1. Subsequent versions
    increment by 1.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_id(Text): The identifier of the bot to create the version for.
        description(Text, optional): A description of the version. Use the description to help identify the version in lists. Defaults to None.
        bot_version_locale_specification(Dict): Specifies the locales that Amazon Lex adds to this version. You can choose the Draft version or
            any other previously published version for each locale. When you specify a source version, the
            locale data is copied from the source version to the new version.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.create_bot_version(
                ctx,
                
                
                **{"botId": bot_id, "description": description, "botVersionLocaleSpecification": bot_version_locale_specification}
            )
            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.lexv2_models.describe_bot_version(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, bot_id: Text, bot_version: Text, skip_resource_in_use_check: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a specific version of a bot. To delete all version of a bot, use the DeleteBot operation.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_id(Text): The identifier of the bot that contains the version.
        bot_version(Text): The version of the bot to delete.
        skip_resource_in_use_check(bool, optional): By default, the DeleteBotVersion operations throws a ResourceInUseException exception if you try
            to delete a bot version that has an alias pointing at it. Set the skipResourceInUseCheck
            parameter to true to skip this check and remove the version even if an alias points to it. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.delete_bot_version(
                ctx,
                
                
                **{"botId": bot_id, "botVersion": bot_version, "skipResourceInUseCheck": skip_resource_in_use_check}
            )
            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.lexv2_models.describe_bot_version(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

