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

hub.exec.boto3.client.route53_recovery_control_config.create_routing_control
hub.exec.boto3.client.route53_recovery_control_config.delete_routing_control
hub.exec.boto3.client.route53_recovery_control_config.describe_routing_control
hub.exec.boto3.client.route53_recovery_control_config.list_routing_controls
hub.exec.boto3.client.route53_recovery_control_config.update_routing_control
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, cluster_arn: Text, routing_control_name: Text, control_panel_arn: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new routing control. A routing control has one of two states: ON and OFF. You can map the routing
    control state to the state of an Amazon Route 53 health check, which can be used to control traffic routing. To
    get or update the routing control state, see the Recovery Cluster (data plane) API actions for Amazon Route 53
    Application Recovery Controller.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cluster_arn(Text): The Amazon Resource Name (ARN) of the cluster that includes the routing control.
        control_panel_arn(Text, optional): The Amazon Resource Name (ARN) of the control panel that includes the routing control. Defaults to None.
        routing_control_name(Text): The name of the routing control.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.route53_recovery_control_config.routing_control.present:
                - name: value
                - cluster_arn: value
                - routing_control_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.route53_recovery_control_config.routing_control.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.route53_recovery_control_config.describe_routing_control(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.route53_recovery_control_config.create_routing_control(
                ctx,
                
                ClientToken=name,
                **{"ClusterArn": cluster_arn, "ControlPanelArn": control_panel_arn, "RoutingControlName": routing_control_name}
            )
            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.route53_recovery_control_config.describe_routing_control(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, routing_control_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a routing control.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        routing_control_arn(Text): The Amazon Resource Name (ARN) of the routing control that you're deleting.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

