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

hub.exec.boto3.client.route53_recovery_control_config.create_control_panel
hub.exec.boto3.client.route53_recovery_control_config.delete_control_panel
hub.exec.boto3.client.route53_recovery_control_config.describe_control_panel
hub.exec.boto3.client.route53_recovery_control_config.list_control_panels
hub.exec.boto3.client.route53_recovery_control_config.update_control_panel
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, cluster_arn: Text, control_panel_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new control panel. A control panel represents a group of routing controls that can be changed together
    in a single transaction. You can use a control panel to centrally view the operational status of applications
    across your organization, and trigger multi-app failovers in a single transaction, for example, to fail over an
    Availability Zone or AWS Region.

    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 for the control panel.
        control_panel_name(Text): The name of the control panel.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

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

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

