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

hub.exec.boto3.client.rds.create_db_proxy_endpoint
hub.exec.boto3.client.rds.delete_db_proxy_endpoint
hub.exec.boto3.client.rds.describe_db_proxy_endpoints
hub.exec.boto3.client.rds.modify_db_proxy_endpoint
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, db_proxy_name: Text, db_proxy_endpoint_name: Text, vpc_subnet_ids: List, vpc_security_group_ids: List = None, target_role: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates a DBProxyEndpoint. Only applies to proxies that are associated with Aurora DB clusters. You can use DB
    proxy endpoints to specify read/write or read-only access to the DB cluster. You can also use DB proxy endpoints
    to access a DB proxy through a different VPC than the proxy's default VPC.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        db_proxy_name(Text): The name of the DB proxy associated with the DB proxy endpoint that you create.
        db_proxy_endpoint_name(Text): The name of the DB proxy endpoint to create.
        vpc_subnet_ids(List): The VPC subnet IDs for the DB proxy endpoint that you create. You can specify a different set of
            subnet IDs than for the original DB proxy.
        vpc_security_group_ids(List, optional): The VPC security group IDs for the DB proxy endpoint that you create. You can specify a
            different set of security group IDs than for the original DB proxy. The default is the default
            security group for the VPC. Defaults to None.
        target_role(Text, optional): A value that indicates whether the DB proxy endpoint can be used for read/write or read-only
            operations. The default is READ_WRITE. Defaults to None.
        tags(List, optional): A list of tags. For more information, see Tagging Amazon RDS Resources in the Amazon RDS User
            Guide. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.rds.db_proxy_endpoint.present:
                - name: value
                - db_proxy_name: value
                - db_proxy_endpoint_name: value
                - vpc_subnet_ids: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.rds.db_proxy_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.rds.describe_db_proxy_endpoints(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.rds.create_db_proxy_endpoint(
                ctx,
                
                
                **{"DBProxyName": db_proxy_name, "DBProxyEndpointName": db_proxy_endpoint_name, "VpcSubnetIds": vpc_subnet_ids, "VpcSecurityGroupIds": vpc_security_group_ids, "TargetRole": target_role, "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.rds.describe_db_proxy_endpoints(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, db_proxy_endpoint_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a DBProxyEndpoint. Doing so removes the ability to access the DB proxy using the endpoint that you
    defined. The endpoint that you delete might have provided capabilities such as read/write or read-only
    operations, or using a different VPC than the DB proxy's default VPC.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        db_proxy_endpoint_name(Text): The name of the DB proxy endpoint to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.rds.db_proxy_endpoint.absent:
                - name: value
                - db_proxy_endpoint_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.rds.db_proxy_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.rds.describe_db_proxy_endpoints(name)

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

