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

hub.exec.boto3.client.rds.create_custom_availability_zone
hub.exec.boto3.client.rds.delete_custom_availability_zone
hub.exec.boto3.client.rds.describe_custom_availability_zones
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, custom_availability_zone_name: Text, existing_vpn_id: Text = None, new_vpn_tunnel_name: Text = None, vpn_tunnel_originator_ip: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a custom Availability Zone (AZ). A custom AZ is an on-premises AZ that is integrated with a VMware
    vSphere cluster. For more information about RDS on VMware, see the  RDS on VMware User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        custom_availability_zone_name(Text): The name of the custom Availability Zone (AZ).
        existing_vpn_id(Text, optional): The ID of an existing virtual private network (VPN) between the Amazon RDS website and the
            VMware vSphere cluster. Defaults to None.
        new_vpn_tunnel_name(Text, optional): The name of a new VPN tunnel between the Amazon RDS website and the VMware vSphere cluster.
            Specify this parameter only if ExistingVpnId isn't specified. Defaults to None.
        vpn_tunnel_originator_ip(Text, optional): The IP address of network traffic from your on-premises data center. A custom AZ receives the
            network traffic. Specify this parameter only if ExistingVpnId isn't specified. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.rds.custom_availability_zone.present:
                - name: value
                - custom_availability_zone_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.rds.custom_availability_zone.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_custom_availability_zones(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.rds.create_custom_availability_zone(
                ctx,
                
                
                **{"CustomAvailabilityZoneName": custom_availability_zone_name, "ExistingVpnId": existing_vpn_id, "NewVpnTunnelName": new_vpn_tunnel_name, "VpnTunnelOriginatorIP": vpn_tunnel_originator_ip}
            )
            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_custom_availability_zones(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, custom_availability_zone_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a custom Availability Zone (AZ). A custom AZ is an on-premises AZ that is integrated with a VMware
    vSphere cluster. For more information about RDS on VMware, see the  RDS on VMware User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        custom_availability_zone_id(Text): The custom AZ identifier.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

