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

hub.exec.boto3.client.rds.create_db_proxy
hub.exec.boto3.client.rds.delete_db_proxy
hub.exec.boto3.client.rds.describe_db_proxies
hub.exec.boto3.client.rds.modify_db_proxy
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, db_proxy_name: Text, engine_family: Text, auth: List, role_arn: Text, vpc_subnet_ids: List, vpc_security_group_ids: List = None, require_tls: bool = None, idle_client_timeout: int = None, debug_logging: bool = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new DB proxy.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        db_proxy_name(Text): The identifier for the proxy. This name must be unique for all proxies owned by your Amazon Web
            Services account in the specified Amazon Web Services Region. An identifier must begin with a
            letter and must contain only ASCII letters, digits, and hyphens; it can't end with a hyphen or
            contain two consecutive hyphens.
        engine_family(Text): The kinds of databases that the proxy can connect to. This value determines which database
            network protocol the proxy recognizes when it interprets network traffic to and from the
            database. The engine family applies to MySQL and PostgreSQL for both RDS and Aurora.
        auth(List): The authorization mechanism that the proxy uses.
        role_arn(Text): The Amazon Resource Name (ARN) of the IAM role that the proxy uses to access secrets in Amazon
            Web Services Secrets Manager.
        vpc_subnet_ids(List): One or more VPC subnet IDs to associate with the new proxy.
        vpc_security_group_ids(List, optional): One or more VPC security group IDs to associate with the new proxy. Defaults to None.
        require_tls(bool, optional): A Boolean parameter that specifies whether Transport Layer Security (TLS) encryption is required
            for connections to the proxy. By enabling this setting, you can enforce encrypted TLS
            connections to the proxy. Defaults to None.
        idle_client_timeout(int, optional): The number of seconds that a connection to the proxy can be inactive before the proxy
            disconnects it. You can set this value higher or lower than the connection timeout limit for the
            associated database. Defaults to None.
        debug_logging(bool, optional): Whether the proxy includes detailed information about SQL statements in its logs. This
            information helps you to debug issues involving SQL behavior or the performance and scalability
            of the proxy connections. The debug information includes the text of SQL statements that you
            submit through the proxy. Thus, only enable this setting when needed for debugging, and only
            when you have security measures in place to safeguard any sensitive information that appears in
            the logs. Defaults to None.
        tags(List, optional): An optional set of key-value pairs to associate arbitrary data of your choosing with the proxy. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.rds.create_db_proxy(
                ctx,
                
                
                **{"DBProxyName": db_proxy_name, "EngineFamily": engine_family, "Auth": auth, "RoleArn": role_arn, "VpcSubnetIds": vpc_subnet_ids, "VpcSecurityGroupIds": vpc_security_group_ids, "RequireTLS": require_tls, "IdleClientTimeout": idle_client_timeout, "DebugLogging": debug_logging, "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_proxies(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, db_proxy_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an existing DB proxy.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

