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

hub.exec.boto3.client.docdb.create_db_cluster
hub.exec.boto3.client.docdb.delete_db_cluster
hub.exec.boto3.client.docdb.describe_db_clusters
hub.exec.boto3.client.docdb.failover_db_cluster
hub.exec.boto3.client.docdb.modify_db_cluster
hub.exec.boto3.client.docdb.start_db_cluster
hub.exec.boto3.client.docdb.stop_db_cluster
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, db_cluster_identifier: Text, engine: Text, availability_zones: List = None, backup_retention_period: int = None, db_cluster_parameter_group_name: Text = None, vpc_security_group_ids: List = None, db_subnet_group_name: Text = None, engine_version: Text = None, port: int = None, master_username: Text = None, master_user_password: Text = None, preferred_backup_window: Text = None, preferred_maintenance_window: Text = None, tags: List = None, storage_encrypted: bool = None, kms_key_id: Text = None, pre_signed_url: Text = None, enable_cloudwatch_logs_exports: List = None, deletion_protection: bool = None, global_cluster_identifier: Text = None, source_region: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new Amazon DocumentDB cluster.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        availability_zones(List, optional): A list of Amazon EC2 Availability Zones that instances in the cluster can be created in. Defaults to None.
        backup_retention_period(int, optional): The number of days for which automated backups are retained. You must specify a minimum value of
            1. Default: 1 Constraints:   Must be a value from 1 to 35. Defaults to None.
        db_cluster_identifier(Text): The cluster identifier. 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.
        db_cluster_parameter_group_name(Text, optional): The name of the cluster parameter group to associate with this cluster. Defaults to None.
        vpc_security_group_ids(List, optional): A list of EC2 VPC security groups to associate with this cluster. Defaults to None.
        db_subnet_group_name(Text, optional): A subnet group to associate with this cluster. Constraints: Must match the name of an existing
            DBSubnetGroup. Must not be default. Example: mySubnetgroup. Defaults to None.
        engine(Text): The name of the database engine to be used for this cluster. Valid values: docdb.
        engine_version(Text, optional): The version number of the database engine to use. The --engine-version will default to the
            latest major engine version. For production workloads, we recommend explicitly declaring this
            parameter with the intended major engine version. Defaults to None.
        port(int, optional): The port number on which the instances in the cluster accept connections. Defaults to None.
        master_username(Text, optional): The name of the master user for the cluster. Constraints:   Must be from 1 to 63 letters or
            numbers.   The first character must be a letter.   Cannot be a reserved word for the chosen
            database engine. Defaults to None.
        master_user_password(Text, optional): The password for the master database user. This password can contain any printable ASCII
            character except forward slash (/), double quote ("), or the "at" symbol (@). Constraints: Must
            contain from 8 to 100 characters. Defaults to None.
        preferred_backup_window(Text, optional): The daily time range during which automated backups are created if automated backups are enabled
            using the BackupRetentionPeriod parameter.  The default is a 30-minute window selected at random
            from an 8-hour block of time for each Region.  Constraints:   Must be in the format hh24:mi-
            hh24:mi.   Must be in Universal Coordinated Time (UTC).   Must not conflict with the preferred
            maintenance window.    Must be at least 30 minutes. Defaults to None.
        preferred_maintenance_window(Text, optional): The weekly time range during which system maintenance can occur, in Universal Coordinated Time
            (UTC). Format: ddd:hh24:mi-ddd:hh24:mi  The default is a 30-minute window selected at random
            from an 8-hour block of time for each Region, occurring on a random day of the week. Valid days:
            Mon, Tue, Wed, Thu, Fri, Sat, Sun Constraints: Minimum 30-minute window. Defaults to None.
        tags(List, optional): The tags to be assigned to the cluster. Defaults to None.
        storage_encrypted(bool, optional): Specifies whether the cluster is encrypted. Defaults to None.
        kms_key_id(Text, optional): The KMS key identifier for an encrypted cluster. The KMS key identifier is the Amazon Resource
            Name (ARN) for the KMS encryption key. If you are creating a cluster using the same account that
            owns the KMS encryption key that is used to encrypt the new cluster, you can use the KMS key
            alias instead of the ARN for the KMS encryption key. If an encryption key is not specified in
            KmsKeyId:    If the StorageEncrypted parameter is true, Amazon DocumentDB uses your default
            encryption key.    KMS creates the default encryption key for your account. Your account has a
            different default encryption key for each Regions. Defaults to None.
        pre_signed_url(Text, optional): Not currently supported. Defaults to None.
        enable_cloudwatch_logs_exports(List, optional): A list of log types that need to be enabled for exporting to Amazon CloudWatch Logs. You can
            enable audit logs or profiler logs. For more information, see  Auditing Amazon DocumentDB Events
            and  Profiling Amazon DocumentDB Operations. Defaults to None.
        deletion_protection(bool, optional): Specifies whether this cluster can be deleted. If DeletionProtection is enabled, the cluster
            cannot be deleted unless it is modified and DeletionProtection is disabled. DeletionProtection
            protects clusters from being accidentally deleted. Defaults to None.
        global_cluster_identifier(Text, optional): The cluster identifier of the new global cluster. Defaults to None.
        source_region(Text, optional): The ID of the region that contains the source for the db cluster. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.docdb.create_db_cluster(
                ctx,
                
                
                **{"AvailabilityZones": availability_zones, "BackupRetentionPeriod": backup_retention_period, "DBClusterIdentifier": db_cluster_identifier, "DBClusterParameterGroupName": db_cluster_parameter_group_name, "VpcSecurityGroupIds": vpc_security_group_ids, "DBSubnetGroupName": db_subnet_group_name, "Engine": engine, "EngineVersion": engine_version, "Port": port, "MasterUsername": master_username, "MasterUserPassword": master_user_password, "PreferredBackupWindow": preferred_backup_window, "PreferredMaintenanceWindow": preferred_maintenance_window, "Tags": tags, "StorageEncrypted": storage_encrypted, "KmsKeyId": kms_key_id, "PreSignedUrl": pre_signed_url, "EnableCloudwatchLogsExports": enable_cloudwatch_logs_exports, "DeletionProtection": deletion_protection, "GlobalClusterIdentifier": global_cluster_identifier, "SourceRegion": source_region}
            )
            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_clusters(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, db_cluster_identifier: Text, skip_final_snapshot: bool = None, final_db_snapshot_identifier: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a previously provisioned cluster. When you delete a cluster, all automated backups for that cluster are
    deleted and can't be recovered. Manual DB cluster snapshots of the specified cluster are not deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        db_cluster_identifier(Text): The cluster identifier for the cluster to be deleted. This parameter isn't case sensitive.
            Constraints:   Must match an existing DBClusterIdentifier.
        skip_final_snapshot(bool, optional):  Determines whether a final cluster snapshot is created before the cluster is deleted. If true
            is specified, no cluster snapshot is created. If false is specified, a cluster snapshot is
            created before the DB cluster is deleted.   If SkipFinalSnapshot is false, you must specify a
            FinalDBSnapshotIdentifier parameter.  Default: false. Defaults to None.
        final_db_snapshot_identifier(Text, optional):  The cluster snapshot identifier of the new cluster snapshot created when SkipFinalSnapshot is
            set to false.    Specifying this parameter and also setting the SkipFinalShapshot parameter to
            true results in an error.   Constraints:   Must be from 1 to 255 letters, numbers, or hyphens.
            The first character must be a letter.   Cannot end with a hyphen or contain two consecutive
            hyphens. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.docdb.delete_db_cluster(
                ctx,
                
                
                **{"DBClusterIdentifier": db_cluster_identifier, "SkipFinalSnapshot": skip_final_snapshot, "FinalDBSnapshotIdentifier": final_db_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_clusters(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

