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

hub.exec.boto3.client.route53_recovery_control_config.create_cluster
hub.exec.boto3.client.route53_recovery_control_config.delete_cluster
hub.exec.boto3.client.route53_recovery_control_config.describe_cluster
hub.exec.boto3.client.route53_recovery_control_config.list_clusters
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, cluster_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a new cluster. A cluster is a set of redundant Regional endpoints against which you can run API calls to
    update or get the state of one or more routing controls. Each cluster has a name, status, Amazon Resource Name
    (ARN), and an array of the five cluster endpoints (one for each supported Amazon Web Services Region) that you
    can use with API calls to the Amazon Route 53 Application Recovery Controller cluster data plane.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cluster_name(Text): The name of the cluster.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, cluster_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete a cluster.

    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 you're deleting.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

