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

hub.exec.boto3.client.braket.cancel_quantum_task
hub.exec.boto3.client.braket.create_quantum_task
hub.exec.boto3.client.braket.get_quantum_task
hub.exec.boto3.client.braket.search_quantum_tasks
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, action: Text, client_token: Text, device_arn: Text, output_s3_bucket: Text, output_s3_key_prefix: Text, shots: int, device_parameters: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a quantum task.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        action(Text): The action associated with the task.
        client_token(Text): The client token associated with the request.
        device_arn(Text): The ARN of the device to run the task on.
        device_parameters(Text, optional): The parameters for the device to run the task on. Defaults to None.
        output_s3_bucket(Text): The S3 bucket to store task result files in.
        output_s3_key_prefix(Text): The key prefix for the location in the S3 bucket to store task results in.
        shots(int): The number of shots to use for the task.
        tags(Dict, optional): Tags to be added to the quantum task you're creating. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.braket.quantum_task.present:
                - name: value
                - action: value
                - client_token: value
                - device_arn: value
                - output_s3_bucket: value
                - output_s3_key_prefix: value
                - shots: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.braket.quantum_task.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.braket.get_quantum_task(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.braket.create_quantum_task(
                ctx,
                
                
                **{"action": action, "clientToken": client_token, "deviceArn": device_arn, "deviceParameters": device_parameters, "outputS3Bucket": output_s3_bucket, "outputS3KeyPrefix": output_s3_key_prefix, "shots": shots, "tags": tags}
            )
            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.braket.get_quantum_task(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, client_token: Text, quantum_task_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Cancels the specified task.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_token(Text): The client token associated with the request.
        quantum_task_arn(Text): The ARN of the task to cancel.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.braket.quantum_task.absent:
                - name: value
                - client_token: value
                - quantum_task_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.braket.quantum_task.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.braket.get_quantum_task(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.braket.cancel_quantum_task(
                ctx,
                
                
                **{"clientToken": client_token, "quantumTaskArn": quantum_task_arn}
            )
            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.braket.get_quantum_task(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

