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

hub.exec.boto3.client.translate.create_parallel_data
hub.exec.boto3.client.translate.delete_parallel_data
hub.exec.boto3.client.translate.get_parallel_data
hub.exec.boto3.client.translate.list_parallel_data
hub.exec.boto3.client.translate.update_parallel_data
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, parallel_data_config: Dict, description: Text = None, encryption_key: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a parallel data resource in Amazon Translate by importing an input file from Amazon S3. Parallel data
    files contain examples of source phrases and their translations from your translation memory. By adding parallel
    data, you can influence the style, tone, and word choice in your translation output.

    Args:
        name(Text): A custom name for the parallel data resource in Amazon Translate. You must assign a name that is
            unique in the account and region.
        description(Text, optional): A custom description for the parallel data resource in Amazon Translate. Defaults to None.
        parallel_data_config(Dict): Specifies the format and S3 location of the parallel data input file.
        encryption_key(Dict, optional): The encryption key used to encrypt this object. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.translate.create_parallel_data(
                ctx,
                
                ClientToken=name,
                **{"Name": name, "Description": description, "ParallelDataConfig": parallel_data_config, "EncryptionKey": encryption_key}
            )
            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.translate.get_parallel_data(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a parallel data resource in Amazon Translate.

    Args:
        name(Text): The name of the parallel data resource that is being deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

