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

hub.exec.boto3.client.s3outposts.create_endpoint
hub.exec.boto3.client.s3outposts.delete_endpoint
hub.exec.boto3.client.s3outposts.list_endpoints
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, outpost_id: Text, subnet_id: Text, security_group_id: Text, access_type: Text = None, customer_owned_ipv4_pool: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Amazon S3 on Outposts Access Points simplify managing data access at scale for shared datasets in S3 on
    Outposts. S3 on Outposts uses endpoints to connect to Outposts buckets so that you can perform actions within
    your virtual private cloud (VPC). For more information, see  Accessing S3 on Outposts using VPC only access
    points. This action creates an endpoint and associates it with the specified Outposts.  It can take up to 5
    minutes for this action to complete.   Related actions include:    DeleteEndpoint     ListEndpoints

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        outpost_id(Text): The ID of the AWS Outposts.
        subnet_id(Text): The ID of the subnet in the selected VPC. The endpoint subnet must belong to the Outpost that
            has the Amazon S3 on Outposts provisioned.
        security_group_id(Text): The ID of the security group to use with the endpoint.
        access_type(Text, optional): The type of access for the on-premise network connectivity for the Outpost endpoint. To access
            the endpoint from an on-premises network, you must specify the access type and provide the
            customer owned IPv4 pool. Defaults to None.
        customer_owned_ipv4_pool(Text, optional): The ID of the customer-owned IPv4 pool for the endpoint. IP addresses will be allocated from
            this pool for the endpoint. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.s3outposts.endpoint.present:
                - name: value
                - outpost_id: value
                - subnet_id: value
                - security_group_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.s3outposts.endpoint.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.s3outposts.list_endpoints(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.s3outposts.create_endpoint(
                ctx,
                
                
                **{"OutpostId": outpost_id, "SubnetId": subnet_id, "SecurityGroupId": security_group_id, "AccessType": access_type, "CustomerOwnedIpv4Pool": customer_owned_ipv4_pool}
            )
            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.s3outposts.list_endpoints(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, endpoint_id: Text, outpost_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Amazon S3 on Outposts Access Points simplify managing data access at scale for shared datasets in S3 on
    Outposts. S3 on Outposts uses endpoints to connect to Outposts buckets so that you can perform actions within
    your virtual private cloud (VPC). For more information, see  Accessing S3 on Outposts using VPC only access
    points. This action deletes an endpoint.  It can take up to 5 minutes for this action to complete.   Related
    actions include:    CreateEndpoint     ListEndpoints

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        endpoint_id(Text): The ID of the endpoint.
        outpost_id(Text): The ID of the AWS Outposts.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.s3outposts.endpoint.absent:
                - name: value
                - endpoint_id: value
                - outpost_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.s3outposts.endpoint.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.s3outposts.list_endpoints(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.s3outposts.delete_endpoint(
                ctx,
                
                
                **{"EndpointId": endpoint_id, "OutpostId": outpost_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.s3outposts.list_endpoints(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

