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

hub.exec.boto3.client.transcribe.create_medical_vocabulary
hub.exec.boto3.client.transcribe.delete_medical_vocabulary
hub.exec.boto3.client.transcribe.get_medical_vocabulary
hub.exec.boto3.client.transcribe.list_medical_vocabularies
hub.exec.boto3.client.transcribe.update_medical_vocabulary
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, vocabulary_name: Text, language_code: Text, vocabulary_file_uri: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new custom vocabulary that you can use to change how Amazon Transcribe Medical transcribes your audio
    file.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        vocabulary_name(Text): The name of the custom vocabulary. This case-sensitive name must be unique within an Amazon Web
            Services account. If you try to create a vocabulary with the same name as a previous vocabulary,
            you get a ConflictException error.
        language_code(Text): The language code for the language used for the entries in your custom vocabulary. The language
            code of your custom vocabulary must match the language code of your transcription job. US
            English (en-US) is the only language code available for Amazon Transcribe Medical.
        vocabulary_file_uri(Text): The location in Amazon S3 of the text file you use to define your custom vocabulary. The URI
            must be in the same Amazon Web Services Region as the resource that you're calling. Enter
            information about your VocabularyFileUri in the following format:   https://s3.<aws-
            region>.amazonaws.com/<bucket-name>/<keyprefix>/<objectkey>   The following is an example URI
            for a vocabulary file that is stored in Amazon S3:  https://s3.us-east-1.amazonaws.com/AWSDOC-
            EXAMPLE-BUCKET/vocab.txt  For more information about Amazon S3 object names, see Object Keys in
            the Amazon S3 Developer Guide. For more information about custom vocabularies, see Medical
            Custom Vocabularies.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.transcribe.medical_vocabulary.present:
                - name: value
                - vocabulary_name: value
                - language_code: value
                - vocabulary_file_uri: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.transcribe.medical_vocabulary.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.get_medical_vocabulary(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.transcribe.create_medical_vocabulary(
                ctx,
                
                
                **{"VocabularyName": vocabulary_name, "LanguageCode": language_code, "VocabularyFileUri": vocabulary_file_uri}
            )
            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.get_medical_vocabulary(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, vocabulary_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a vocabulary from Amazon Transcribe Medical.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        vocabulary_name(Text): The name of the vocabulary that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

