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

hub.exec.boto3.client.s3control.create_access_point_for_object_lambda
hub.exec.boto3.client.s3control.delete_access_point_for_object_lambda
hub.exec.boto3.client.s3control.get_access_point_for_object_lambda
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, account_id: Text, configuration: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an Object Lambda Access Point. For more information, see Transforming objects with Object Lambda Access
    Points in the Amazon S3 User Guide. The following actions are related to CreateAccessPointForObjectLambda:
    DeleteAccessPointForObjectLambda     GetAccessPointForObjectLambda     ListAccessPointsForObjectLambda

    Args:
        name(Text): The name you want to assign to this Object Lambda Access Point.
        account_id(Text): The account ID for owner of the specified Object Lambda Access Point.
        configuration(Dict): Object Lambda Access Point configuration as a JSON document.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.s3control.create_access_point_for_object_lambda(
                ctx,
                
                
                **{"Name": name, "AccountId": account_id, "Configuration": configuration}
            )
            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_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**
    
    Deletes the specified Object Lambda Access Point. The following actions are related to
    DeleteAccessPointForObjectLambda:    CreateAccessPointForObjectLambda     GetAccessPointForObjectLambda
    ListAccessPointsForObjectLambda

    Args:
        name(Text): The name of the access point you want to delete.
        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_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_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_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_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_for_object_lambda(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

