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

hub.exec.boto3.client.emr_containers.create_virtual_cluster
hub.exec.boto3.client.emr_containers.delete_virtual_cluster
hub.exec.boto3.client.emr_containers.describe_virtual_cluster
hub.exec.boto3.client.emr_containers.list_virtual_clusters
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, container_provider: Dict, client_token: Text, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a virtual cluster. Virtual cluster is a managed entity on Amazon EMR on EKS. You can create, describe,
    list and delete virtual clusters. They do not consume any additional resource in your system. A single virtual
    cluster maps to a single Kubernetes namespace. Given this relationship, you can model virtual clusters the same
    way you model Kubernetes namespaces to meet your requirements.

    Args:
        name(Text): The specified name of the virtual cluster.
        container_provider(Dict): The container provider of the virtual cluster.
        client_token(Text): The client token of the virtual cluster.
        tags(Dict, optional): The tags assigned to the virtual cluster. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.emr_containers.virtual_cluster.present:
                - name: value
                - container_provider: value
                - client_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.emr_containers.virtual_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.emr_containers.describe_virtual_cluster(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.emr_containers.create_virtual_cluster(
                ctx,
                
                
                **{"Name": name, "containerProvider": container_provider, "clientToken": client_token, "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.emr_containers.describe_virtual_cluster(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, id_: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a virtual cluster. Virtual cluster is a managed entity on Amazon EMR on EKS. You can create, describe,
    list and delete virtual clusters. They do not consume any additional resource in your system. A single virtual
    cluster maps to a single Kubernetes namespace. Given this relationship, you can model virtual clusters the same
    way you model Kubernetes namespaces to meet your requirements.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        id_(Text): The ID of the virtual cluster that will be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.emr_containers.virtual_cluster.absent:
                - name: value
                - id_: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.emr_containers.virtual_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.emr_containers.describe_virtual_cluster(name)

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

