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

hub.exec.boto3.client.quicksight.cancel_ingestion
hub.exec.boto3.client.quicksight.create_ingestion
hub.exec.boto3.client.quicksight.describe_ingestion
hub.exec.boto3.client.quicksight.list_ingestions
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, data_set_id: Text, ingestion_id: Text, aws_account_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates and starts a new SPICE ingestion on a dataset Any ingestions operating on tagged datasets inherit the
    same tags automatically for use in access control. For an example, see How do I create an IAM policy to control
    access to Amazon EC2 resources using tags? in the Amazon Web Services Knowledge Center. Tags are visible on the
    tagged dataset, but not on the ingestion resource.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        data_set_id(Text): The ID of the dataset used in the ingestion.
        ingestion_id(Text): An ID for the ingestion.
        aws_account_id(Text): The Amazon Web Services account; ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.quicksight.ingestion.present:
                - name: value
                - data_set_id: value
                - ingestion_id: value
                - aws_account_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.quicksight.ingestion.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.quicksight.describe_ingestion(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.create_ingestion(
                ctx,
                
                
                **{"DataSetId": data_set_id, "IngestionId": ingestion_id, "AwsAccountId": aws_account_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.quicksight.describe_ingestion(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, aws_account_id: Text, data_set_id: Text, ingestion_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Cancels an ongoing ingestion of data into SPICE.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        aws_account_id(Text): The Amazon Web Services account; ID.
        data_set_id(Text): The ID of the dataset used in the ingestion.
        ingestion_id(Text): An ID for the ingestion.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.quicksight.ingestion.absent:
                - name: value
                - aws_account_id: value
                - data_set_id: value
                - ingestion_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.quicksight.ingestion.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.quicksight.describe_ingestion(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.cancel_ingestion(
                ctx,
                
                
                **{"AwsAccountId": aws_account_id, "DataSetId": data_set_id, "IngestionId": ingestion_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.quicksight.describe_ingestion(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

