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

hub.exec.boto3.client.lexv2_models.create_export
hub.exec.boto3.client.lexv2_models.delete_export
hub.exec.boto3.client.lexv2_models.describe_export
hub.exec.boto3.client.lexv2_models.list_exports
hub.exec.boto3.client.lexv2_models.update_export
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, resource_specification: Dict, file_format: Text, file_password: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a zip archive containing the contents of a bot or a bot locale. The archive contains a directory
    structure that contains JSON files that define the bot. You can create an archive that contains the complete
    definition of a bot, or you can specify that the archive contain only the definition of a single bot locale. For
    more information about exporting bots, and about the structure of the export archive, see  Importing and
    exporting bots

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        resource_specification(Dict): Specifies the type of resource to export, either a bot or a bot locale. You can only specify one
            type of resource to export.
        file_format(Text): The file format of the bot or bot locale definition files.
        file_password(Text, optional): An password to use to encrypt the exported archive. Using a password is optional, but you should
            encrypt the archive to protect the data in transit between Amazon Lex and your local computer. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.create_export(
                ctx,
                
                
                **{"resourceSpecification": resource_specification, "fileFormat": file_format, "filePassword": file_password}
            )
            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_export(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, export_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes a previous export and the associated files stored in an S3 bucket.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        export_id(Text): The unique identifier of the export to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

