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

hub.exec.boto3.client.mturk.accept_qualification_request
hub.exec.boto3.client.mturk.list_qualification_requests
hub.exec.boto3.client.mturk.reject_qualification_request
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, qualification_request_id: Text, integer_value: int = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     The AcceptQualificationRequest operation approves a Worker's request for a Qualification.   Only the owner of
    the Qualification type can grant a Qualification request for that type.   A successful request for the
    AcceptQualificationRequest operation returns with no errors and an empty body.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        qualification_request_id(Text): The ID of the Qualification request, as returned by the GetQualificationRequests operation.
        integer_value(int, optional):  The value of the Qualification. You can omit this value if you are using the presence or
            absence of the Qualification as the basis for a HIT requirement. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.mturk.accept_qualification_request(
                ctx,
                
                
                **{"QualificationRequestId": qualification_request_id, "IntegerValue": integer_value}
            )
            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.mturk.list_qualification_requests(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, qualification_request_id: Text, reason: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     The RejectQualificationRequest operation rejects a user's request for a Qualification.   You can provide a text
    message explaining why the request was rejected. The Worker who made the request can see this message.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        qualification_request_id(Text):  The ID of the Qualification request, as returned by the ListQualificationRequests operation.
        reason(Text, optional): A text message explaining why the request was rejected, to be shown to the Worker who made the
            request. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.mturk.reject_qualification_request(
                ctx,
                
                
                **{"QualificationRequestId": qualification_request_id, "Reason": reason}
            )
            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.mturk.list_qualification_requests(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

