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

hub.exec.boto3.client.rds.copy_db_cluster_snapshot
hub.exec.boto3.client.rds.create_db_cluster_snapshot
hub.exec.boto3.client.rds.delete_db_cluster_snapshot
hub.exec.boto3.client.rds.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 DB cluster. For more information on Amazon Aurora, see  What Is Amazon Aurora? in the
    Amazon Aurora User Guide.   This action only applies to Aurora DB clusters.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.rds.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.rds.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.rds.describe_db_cluster_snapshots(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.rds.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.rds.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 DB cluster snapshot. If the snapshot is being copied, the copy operation is terminated.  The DB
    cluster snapshot must be in the available state to be deleted.  For more information on Amazon Aurora, see  What
    Is Amazon Aurora? in the Amazon Aurora User Guide.   This action only applies to Aurora DB clusters.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.rds.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.rds.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.rds.describe_db_cluster_snapshots(name)

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

