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

hub.exec.boto3.client.lexv2_models.create_intent
hub.exec.boto3.client.lexv2_models.delete_intent
hub.exec.boto3.client.lexv2_models.describe_intent
hub.exec.boto3.client.lexv2_models.list_intents
hub.exec.boto3.client.lexv2_models.update_intent
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, intent_name: Text, bot_id: Text, bot_version: Text, locale_id: Text, description: Text = None, parent_intent_signature: Text = None, sample_utterances: List = None, dialog_code_hook: Dict = None, fulfillment_code_hook: Dict = None, intent_confirmation_setting: Dict = None, intent_closing_setting: Dict = None, input_contexts: List = None, output_contexts: List = None, kendra_configuration: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an intent. To define the interaction between the user and your bot, you define one or more intents. For
    example, for a pizza ordering bot you would create an OrderPizza intent. When you create an intent, you must
    provide a name. You can optionally provide the following:   Sample utterances. For example, "I want to order a
    pizza" and "Can I order a pizza." You can't provide utterances for built-in intents.   Information to be
    gathered. You specify slots for the information that you bot requests from the user. You can specify standard
    slot types, such as date and time, or custom slot types for your application.   How the intent is fulfilled. You
    can provide a Lambda function or configure the intent to return the intent information to your client
    application. If you use a Lambda function, Amazon Lex invokes the function when all of the intent information is
    available.   A confirmation prompt to send to the user to confirm an intent. For example, "Shall I order your
    pizza?"   A conclusion statement to send to the user after the intent is fulfilled. For example, "I ordered your
    pizza."   A follow-up prompt that asks the user for additional activity. For example, "Do you want a drink with
    your pizza?"

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        intent_name(Text): The name of the intent. Intent names must be unique in the locale that contains the intent and
            cannot match the name of any built-in intent.
        description(Text, optional): A description of the intent. Use the description to help identify the intent in lists. Defaults to None.
        parent_intent_signature(Text, optional): A unique identifier for the built-in intent to base this intent on. Defaults to None.
        sample_utterances(List, optional): An array of strings that a user might say to signal the intent. For example, "I want a pizza",
            or "I want a {PizzaSize} pizza".  In an utterance, slot names are enclosed in curly braces ("{",
            "}") to indicate where they should be displayed in the utterance shown to the user.. Defaults to None.
        dialog_code_hook(Dict, optional): Specifies that Amazon Lex invokes the alias Lambda function for each user input. You can invoke
            this Lambda function to personalize user interaction. For example, suppose that your bot
            determines that the user's name is John. You Lambda function might retrieve John's information
            from a backend database and prepopulate some of the values. For example, if you find that John
            is gluten intolerant, you might set the corresponding intent slot, glutenIntolerant to true. You
            might find John's phone number and set the corresponding session attribute. Defaults to None.
        fulfillment_code_hook(Dict, optional): Specifies that Amazon Lex invokes the alias Lambda function when the intent is ready for
            fulfillment. You can invoke this function to complete the bot's transaction with the user. For
            example, in a pizza ordering bot, the Lambda function can look up the closest pizza restaurant
            to the customer's location and then place an order on the customer's behalf. Defaults to None.
        intent_confirmation_setting(Dict, optional): Provides prompts that Amazon Lex sends to the user to confirm the completion of an intent. If
            the user answers "no," the settings contain a statement that is sent to the user to end the
            intent. Defaults to None.
        intent_closing_setting(Dict, optional): Sets the response that Amazon Lex sends to the user when the intent is closed. Defaults to None.
        input_contexts(List, optional): A list of contexts that must be active for this intent to be considered by Amazon Lex. When an
            intent has an input context list, Amazon Lex only considers using the intent in an interaction
            with the user when the specified contexts are included in the active context list for the
            session. If the contexts are not active, then Amazon Lex will not use the intent. A context can
            be automatically activated using the outputContexts property or it can be set at runtime.  For
            example, if there are two intents with different input contexts that respond to the same
            utterances, only the intent with the active context will respond. An intent may have up to 5
            input contexts. If an intent has multiple input contexts, all of the contexts must be active to
            consider the intent. Defaults to None.
        output_contexts(List, optional): A lists of contexts that the intent activates when it is fulfilled. You can use an output
            context to indicate the intents that Amazon Lex should consider for the next turn of the
            conversation with a customer.  When you use the outputContextsList property, all of the contexts
            specified in the list are activated when the intent is fulfilled. You can set up to 10 output
            contexts. You can also set the number of conversation turns that the context should be active,
            or the length of time that the context should be active. Defaults to None.
        kendra_configuration(Dict, optional): Configuration information required to use the AMAZON.KendraSearchIntent intent to connect to an
            Amazon Kendra index. The AMAZON.KendraSearchIntent intent is called when Amazon Lex can't
            determine another intent to invoke. Defaults to None.
        bot_id(Text): The identifier of the bot associated with this intent.
        bot_version(Text): The identifier of the version of the bot associated with this intent.
        locale_id(Text): The identifier of the language and locale where this intent is used. All of the bots, slot
            types, and slots used by the intent 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.intent.present:
                - name: value
                - intent_name: 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.intent.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_intent(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.create_intent(
                ctx,
                
                
                **{"intentName": intent_name, "description": description, "parentIntentSignature": parent_intent_signature, "sampleUtterances": sample_utterances, "dialogCodeHook": dialog_code_hook, "fulfillmentCodeHook": fulfillment_code_hook, "intentConfirmationSetting": intent_confirmation_setting, "intentClosingSetting": intent_closing_setting, "inputContexts": input_contexts, "outputContexts": output_contexts, "kendraConfiguration": kendra_configuration, "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_intent(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, intent_id: Text, bot_id: Text, bot_version: Text, locale_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes the specified intent. Deleting an intent also deletes the slots associated with the intent.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        intent_id(Text): The unique identifier of the intent to delete.
        bot_id(Text): The identifier of the bot associated with the intent.
        bot_version(Text): The version of the bot associated with the intent.
        locale_id(Text): The identifier of the language and locale where the bot will be deleted. The string must match
            one of the supported locales. For more information, see Supported languages.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.lexv2_models.intent.absent:
                - name: value
                - intent_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.intent.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_intent(name)

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

