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

hub.exec.boto3.client.s3control.delete_access_point_policy_for_object_lambda
hub.exec.boto3.client.s3control.get_access_point_policy_for_object_lambda
hub.exec.boto3.client.s3control.put_access_point_policy_for_object_lambda
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, account_id: Text, policy: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates or replaces resource policy for an Object Lambda Access Point. For an example policy, see Creating
    Object Lambda Access Points in the Amazon S3 User Guide. The following actions are related to
    PutAccessPointPolicyForObjectLambda:    DeleteAccessPointPolicyForObjectLambda
    GetAccessPointPolicyForObjectLambda

    Args:
        name(Text): The name of the Object Lambda Access Point.
        account_id(Text): The account ID for the account that owns the specified Object Lambda Access Point.
        policy(Text): Object Lambda Access Point resource policy document.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.s3control.access_point_policy_for_object_lambda.present:
                - name: value
                - account_id: value
                - policy: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.s3control.access_point_policy_for_object_lambda.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.s3control.get_access_point_policy_for_object_lambda(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.s3control.put_access_point_policy_for_object_lambda(
                ctx,
                
                
                **{"Name": name, "AccountId": account_id, "Policy": policy}
            )
            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.s3control.get_access_point_policy_for_object_lambda(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, account_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes the resource policy for an Object Lambda Access Point. The following actions are related to
    DeleteAccessPointPolicyForObjectLambda:    GetAccessPointPolicyForObjectLambda
    PutAccessPointPolicyForObjectLambda

    Args:
        name(Text): The name of the Object Lambda Access Point you want to delete the policy for.
        account_id(Text): The account ID for the account that owns the specified Object Lambda Access Point.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.s3control.delete_access_point_policy_for_object_lambda(
                ctx,
                
                
                **{"Name": name, "AccountId": account_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.s3control.get_access_point_policy_for_object_lambda(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

