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

hub.exec.boto3.client.lex_models.delete_slot_type
hub.exec.boto3.client.lex_models.get_slot_types
hub.exec.boto3.client.lex_models.put_slot_type
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, description: Text = None, enumeration_values: List = None, checksum: Text = None, value_selection_strategy: Text = None, create_version: bool = None, parent_slot_type_signature: Text = None, slot_type_configurations: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a custom slot type or replaces an existing custom slot type. To create a custom slot type, specify a
    name for the slot type and a set of enumeration values, which are the values that a slot of this type can
    assume. For more information, see how-it-works. If you specify the name of an existing slot type, the fields in
    the request replace the existing values in the $LATEST version of the slot type. Amazon Lex removes the fields
    that you don't provide in the request. If you don't specify required fields, Amazon Lex throws an exception.
    When you update the $LATEST version of a slot type, if a bot uses the $LATEST version of an intent that contains
    the slot type, the bot's status field is set to NOT_BUILT. This operation requires permissions for the
    lex:PutSlotType action.

    Args:
        name(Text): The name of the slot type. The name is not case sensitive.  The name can't match a built-in slot
            type name, or a built-in slot type name with "AMAZON." removed. For example, because there is a
            built-in slot type called AMAZON.DATE, you can't create a custom slot type called DATE. For a
            list of built-in slot types, see Slot Type Reference in the Alexa Skills Kit.
        description(Text, optional): A description of the slot type. Defaults to None.
        enumeration_values(List, optional): A list of EnumerationValue objects that defines the values that the slot type can take. Each
            value can have a list of synonyms, which are additional values that help train the machine
            learning model about the values that it resolves for a slot.  A regular expression slot type
            doesn't require enumeration values. All other slot types require a list of enumeration values.
            When Amazon Lex resolves a slot value, it generates a resolution list that contains up to five
            possible values for the slot. If you are using a Lambda function, this resolution list is passed
            to the function. If you are not using a Lambda function you can choose to return the value that
            the user entered or the first value in the resolution list as the slot value. The
            valueSelectionStrategy field indicates the option to use. Defaults to None.
        checksum(Text, optional): Identifies a specific revision of the $LATEST version. When you create a new slot type, leave
            the checksum field blank. If you specify a checksum you get a BadRequestException exception.
            When you want to update a slot type, set the checksum field to the checksum of the most recent
            revision of the $LATEST version. If you don't specify the  checksum field, or if the checksum
            does not match the $LATEST version, you get a PreconditionFailedException exception. Defaults to None.
        value_selection_strategy(Text, optional): Determines the slot resolution strategy that Amazon Lex uses to return slot type values. The
            field can be set to one of the following values:    ORIGINAL_VALUE - Returns the value entered
            by the user, if the user value is similar to the slot value.    TOP_RESOLUTION - If there is a
            resolution list for the slot, return the first value in the resolution list as the slot type
            value. If there is no resolution list, null is returned.   If you don't specify the
            valueSelectionStrategy, the default is ORIGINAL_VALUE. Defaults to None.
        create_version(bool, optional): When set to true a new numbered version of the slot type is created. This is the same as calling
            the CreateSlotTypeVersion operation. If you do not specify createVersion, the default is false. Defaults to None.
        parent_slot_type_signature(Text, optional): The built-in slot type used as the parent of the slot type. When you define a parent slot type,
            the new slot type has all of the same configuration as the parent. Only AMAZON.AlphaNumeric is
            supported. Defaults to None.
        slot_type_configurations(List, optional): Configuration information that extends the parent built-in slot type. The configuration is added
            to the settings for the parent slot type. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lex_models.put_slot_type(
                ctx,
                
                
                **{"Name": name, "description": description, "enumerationValues": enumeration_values, "checksum": checksum, "valueSelectionStrategy": value_selection_strategy, "createVersion": create_version, "parentSlotTypeSignature": parent_slot_type_signature, "slotTypeConfigurations": slot_type_configurations}
            )
            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.lex_models.get_slot_types(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes all versions of the slot type, including the $LATEST version. To delete a specific version of the slot
    type, use the DeleteSlotTypeVersion operation.  You can delete a version of a slot type only if it is not
    referenced. To delete a slot type that is referred to in one or more intents, you must remove those references
    first.    If you get the ResourceInUseException exception, the exception provides an example reference that
    shows the intent where the slot type is referenced. To remove the reference to the slot type, either update the
    intent or delete it. If you get the same exception when you attempt to delete the slot type again, repeat until
    the slot type has no references and the DeleteSlotType call is successful.   This operation requires permission
    for the lex:DeleteSlotType action.

    Args:
        name(Text): The name of the slot type. The name is case sensitive.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

