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

hub.exec.boto3.client.transcribe.create_language_model
hub.exec.boto3.client.transcribe.delete_language_model
hub.exec.boto3.client.transcribe.describe_language_model
hub.exec.boto3.client.transcribe.list_language_models
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, language_code: Text, base_model_name: Text, model_name: Text, input_data_config: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new custom language model. Use Amazon S3 prefixes to provide the location of your input files. The
    time it takes to create your model depends on the size of your training data.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        language_code(Text): The language of the input text you're using to train your custom language model.
        base_model_name(Text): The Amazon Transcribe standard language model, or base model used to create your custom language
            model. If you want to use your custom language model to transcribe audio with a sample rate of
            16 kHz or greater, choose Wideband. If you want to use your custom language model to transcribe
            audio with a sample rate that is less than 16 kHz, choose Narrowband.
        model_name(Text): The name you choose for your custom language model when you create it.
        input_data_config(Dict): Contains the data access role and the Amazon S3 prefixes to read the required input files to
            create a custom language model.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.transcribe.language_model.present:
                - name: value
                - language_code: value
                - base_model_name: value
                - model_name: value
                - input_data_config: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.transcribe.language_model.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.transcribe.describe_language_model(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.transcribe.create_language_model(
                ctx,
                
                
                **{"LanguageCode": language_code, "BaseModelName": base_model_name, "ModelName": model_name, "InputDataConfig": input_data_config}
            )
            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.transcribe.describe_language_model(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, model_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a custom language model using its name.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_name(Text): The name of the model you're choosing to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

