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

hub.exec.boto3.client.transcribe.create_vocabulary
hub.exec.boto3.client.transcribe.delete_vocabulary
hub.exec.boto3.client.transcribe.get_vocabulary
hub.exec.boto3.client.transcribe.list_vocabularies
hub.exec.boto3.client.transcribe.update_vocabulary
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, vocabulary_name: Text, language_code: Text, phrases: List = None, vocabulary_file_uri: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new custom vocabulary that you can use to change the way Amazon Transcribe handles transcription of an
    audio file.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        vocabulary_name(Text): The name of the vocabulary. The name must be unique within an Amazon Web Services account. The
            name is case sensitive. If you try to create a vocabulary with the same name as a previous
            vocabulary you will receive a ConflictException error.
        language_code(Text): The language code of the vocabulary entries. For a list of languages and their corresponding
            language codes, see what-is-transcribe.
        phrases(List, optional): An array of strings that contains the vocabulary entries. Defaults to None.
        vocabulary_file_uri(Text, optional): The S3 location of the text file that contains the definition of the custom vocabulary. The URI
            must be in the same region as the API endpoint that you are calling. The general form is  For
            more information about S3 object names, see Object Keys in the Amazon S3 Developer Guide. For
            more information about custom vocabularies, see Custom Vocabularies. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.transcribe.create_vocabulary(
                ctx,
                
                
                **{"VocabularyName": vocabulary_name, "LanguageCode": language_code, "Phrases": phrases, "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_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.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

