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

hub.exec.boto3.client.lexv2_models.create_slot_type
hub.exec.boto3.client.lexv2_models.delete_slot_type
hub.exec.boto3.client.lexv2_models.describe_slot_type
hub.exec.boto3.client.lexv2_models.list_slot_types
hub.exec.boto3.client.lexv2_models.update_slot_type
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, slot_type_name: Text, value_selection_setting: Dict, bot_id: Text, bot_version: Text, locale_id: Text, description: Text = None, slot_type_values: List = None, parent_slot_type_signature: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a custom slot type  To create a custom slot type, specify a name for the slot type and a set of
    enumeration values, the values that a slot of this type can assume.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        slot_type_name(Text): The name for the slot. A slot type name must be unique within the account.
        description(Text, optional): A description of the slot type. Use the description to help identify the slot type in lists. Defaults to None.
        slot_type_values(List, optional): A list of SlotTypeValue objects that defines the values that the slot type can take. Each value
            can have a list of synonyms, additional values that help train the machine learning model about
            the values that it resolves for a slot. Defaults to None.
        value_selection_setting(Dict): Determines the strategy that Amazon Lex uses to select a value from the list of possible values.
            The field can be set to one of the following values:    OriginalValue - Returns the value
            entered by the user, if the user value is similar to the slot value.    TopResolution - If there
            is a resolution list for the slot, return the first value in the resolution list. If there is no
            resolution list, return null.   If you don't specify the valueSelectionSetting parameter, the
            default is OriginalValue.
        parent_slot_type_signature(Text, optional): The built-in slot type used as a parent of this slot type. When you define a parent slot type,
            the new slot type has the configuration of the parent slot type. Only AMAZON.AlphaNumeric is
            supported. Defaults to None.
        bot_id(Text): The identifier of the bot associated with this slot type.
        bot_version(Text): The identifier of the bot version associated with this slot type.
        locale_id(Text): The identifier of the language and locale that the slot type will be used in. The string must
            match one of the supported locales. All of the bots, intents, and slots used by the slot type
            must have the same locale. For more information, see Supported languages.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.lexv2_models.slot_type.present:
                - name: value
                - slot_type_name: value
                - value_selection_setting: value
                - bot_id: value
                - bot_version: value
                - locale_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lexv2_models.slot_type.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_slot_type(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.create_slot_type(
                ctx,
                
                
                **{"slotTypeName": slot_type_name, "description": description, "slotTypeValues": slot_type_values, "valueSelectionSetting": value_selection_setting, "parentSlotTypeSignature": parent_slot_type_signature, "botId": bot_id, "botVersion": bot_version, "localeId": locale_id}
            )
            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_slot_type(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, slot_type_id: Text, bot_id: Text, bot_version: Text, locale_id: Text, skip_resource_in_use_check: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a slot type from a bot locale. If a slot is using the slot type, Amazon Lex throws a
    ResourceInUseException exception. To avoid the exception, set the skipResourceInUseCheck parameter to true.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        slot_type_id(Text): The identifier of the slot type to delete.
        bot_id(Text): The identifier of the bot associated with the slot type.
        bot_version(Text): The version of the bot associated with the slot type.
        locale_id(Text): The identifier of the language and locale that the slot type will be deleted from. The string
            must match one of the supported locales. For more information, see Supported languages.
        skip_resource_in_use_check(bool, optional): By default, the DeleteSlotType operations throws a ResourceInUseException exception if you try
            to delete a slot type used by a slot. Set the skipResourceInUseCheck parameter to true to skip
            this check and remove the slot type even if a slot uses it. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.lexv2_models.slot_type.absent:
                - name: value
                - slot_type_id: value
                - bot_id: value
                - bot_version: value
                - locale_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lexv2_models.slot_type.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_slot_type(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.delete_slot_type(
                ctx,
                
                
                **{"slotTypeId": slot_type_id, "botId": bot_id, "botVersion": bot_version, "localeId": locale_id, "skipResourceInUseCheck": skip_resource_in_use_check}
            )
            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_slot_type(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

