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

hub.exec.boto3.client.docdb.copy_db_cluster_snapshot
hub.exec.boto3.client.docdb.create_db_cluster_snapshot
hub.exec.boto3.client.docdb.delete_db_cluster_snapshot
hub.exec.boto3.client.docdb.describe_db_cluster_snapshots
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, db_cluster_snapshot_identifier: Text, db_cluster_identifier: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a snapshot of a cluster.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        db_cluster_snapshot_identifier(Text): The identifier of the cluster snapshot. This parameter is stored as a lowercase string.
            Constraints:   Must contain from 1 to 63 letters, numbers, or hyphens.   The first character
            must be a letter.   Cannot end with a hyphen or contain two consecutive hyphens.    Example: my-
            cluster-snapshot1.
        db_cluster_identifier(Text): The identifier of the cluster to create a snapshot for. This parameter is not case sensitive.
            Constraints:   Must match the identifier of an existing DBCluster.   Example: my-cluster.
        tags(List, optional): The tags to be assigned to the cluster snapshot. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.docdb.db_cluster_snapshot.present:
                - name: value
                - db_cluster_snapshot_identifier: value
                - db_cluster_identifier: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.docdb.db_cluster_snapshot.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.docdb.describe_db_cluster_snapshots(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.docdb.create_db_cluster_snapshot(
                ctx,
                
                
                **{"DBClusterSnapshotIdentifier": db_cluster_snapshot_identifier, "DBClusterIdentifier": db_cluster_identifier, "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.docdb.describe_db_cluster_snapshots(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, db_cluster_snapshot_identifier: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a cluster snapshot. If the snapshot is being copied, the copy operation is terminated.  The cluster
    snapshot must be in the available state to be deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        db_cluster_snapshot_identifier(Text): The identifier of the cluster snapshot to delete. Constraints: Must be the name of an existing
            cluster snapshot in the available state.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

