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

hub.exec.boto3.client.kendra.create_faq
hub.exec.boto3.client.kendra.delete_faq
hub.exec.boto3.client.kendra.describe_faq
hub.exec.boto3.client.kendra.list_faqs
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, index_id: Text, s3_path: Dict, role_arn: Text, description: Text = None, tags: List = None, file_format: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an new set of frequently asked question (FAQ) questions and answers.

    Args:
        name(Text): The name that should be associated with the FAQ.
        index_id(Text): The identifier of the index that contains the FAQ.
        description(Text, optional): A description of the FAQ. Defaults to None.
        s3_path(Dict): The S3 location of the FAQ input data.
        role_arn(Text): The Amazon Resource Name (ARN) of a role with permission to access the S3 bucket that contains
            the FAQs. For more information, see IAM Roles for Amazon Kendra.
        tags(List, optional): A list of key-value pairs that identify the FAQ. You can use the tags to identify and organize
            your resources and to control access to resources. Defaults to None.
        file_format(Text, optional): The format of the input file. You can choose between a basic CSV format, a CSV format that
            includes customs attributes in a header, and a JSON format that includes custom attributes. The
            format must match the format of the file stored in the S3 bucket identified in the S3Path
            parameter. For more information, see Adding questions and answers. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.kendra.faq.present:
                - name: value
                - index_id: value
                - s3_path: value
                - role_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.kendra.faq.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.kendra.describe_faq(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.kendra.create_faq(
                ctx,
                
                ClientToken=name,
                **{"Name": name, "IndexId": index_id, "Description": description, "S3Path": s3_path, "RoleArn": role_arn, "Tags": tags, "FileFormat": file_format}
            )
            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.kendra.describe_faq(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, id_: Text, index_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes an FAQ from an index.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        id_(Text): The identifier of the FAQ to remove.
        index_id(Text): The index to remove the FAQ from.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.kendra.faq.absent:
                - name: value
                - id_: value
                - index_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.kendra.faq.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.kendra.describe_faq(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.kendra.delete_faq(
                ctx,
                
                
                **{"Id": id_, "IndexId": index_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.kendra.describe_faq(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

