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

hub.exec.boto3.client.redshift.create_cluster
hub.exec.boto3.client.redshift.delete_cluster
hub.exec.boto3.client.redshift.describe_clusters
hub.exec.boto3.client.redshift.modify_cluster
hub.exec.boto3.client.redshift.pause_cluster
hub.exec.boto3.client.redshift.reboot_cluster
hub.exec.boto3.client.redshift.resize_cluster
hub.exec.boto3.client.redshift.resume_cluster
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, cluster_identifier: Text, node_type: Text, master_username: Text, master_user_password: Text, db_name: Text = None, cluster_type: Text = None, cluster_security_groups: List = None, vpc_security_group_ids: List = None, cluster_subnet_group_name: Text = None, availability_zone: Text = None, preferred_maintenance_window: Text = None, cluster_parameter_group_name: Text = None, automated_snapshot_retention_period: int = None, manual_snapshot_retention_period: int = None, port: int = None, cluster_version: Text = None, allow_version_upgrade: bool = None, number_of_nodes: int = None, publicly_accessible: bool = None, encrypted: bool = None, hsm_client_certificate_identifier: Text = None, hsm_configuration_identifier: Text = None, elastic_ip: Text = None, tags: List = None, kms_key_id: Text = None, enhanced_vpc_routing: bool = None, additional_info: Text = None, iam_roles: List = None, maintenance_track_name: Text = None, snapshot_schedule_identifier: Text = None, availability_zone_relocation: bool = None, aqua_configuration_status: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new cluster with the specified parameters. To create a cluster in Virtual Private Cloud (VPC), you
    must provide a cluster subnet group name. The cluster subnet group identifies the subnets of your VPC that
    Amazon Redshift uses when creating the cluster. For more information about managing clusters, go to Amazon
    Redshift Clusters in the Amazon Redshift Cluster Management Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        db_name(Text, optional): The name of the first database to be created when the cluster is created. To create additional
            databases after the cluster is created, connect to the cluster with a SQL client and use SQL
            commands to create a database. For more information, go to Create a Database in the Amazon
            Redshift Database Developer Guide.  Default: dev  Constraints:   Must contain 1 to 64
            alphanumeric characters.   Must contain only lowercase letters.   Cannot be a word that is
            reserved by the service. A list of reserved words can be found in Reserved Words in the Amazon
            Redshift Database Developer Guide. Defaults to None.
        cluster_identifier(Text): A unique identifier for the cluster. You use this identifier to refer to the cluster for any
            subsequent cluster operations such as deleting or modifying. The identifier also appears in the
            Amazon Redshift console. Constraints:   Must contain from 1 to 63 alphanumeric characters or
            hyphens.   Alphabetic characters must be lowercase.   First character must be a letter.   Cannot
            end with a hyphen or contain two consecutive hyphens.   Must be unique for all clusters within
            an Amazon Web Services account.   Example: myexamplecluster.
        cluster_type(Text, optional): The type of the cluster. When cluster type is specified as    single-node, the NumberOfNodes
            parameter is not required.    multi-node, the NumberOfNodes parameter is required.   Valid
            Values: multi-node | single-node  Default: multi-node. Defaults to None.
        node_type(Text): The node type to be provisioned for the cluster. For information about node types, go to
            Working with Clusters in the Amazon Redshift Cluster Management Guide.  Valid Values: ds2.xlarge
            | ds2.8xlarge | dc1.large | dc1.8xlarge | dc2.large | dc2.8xlarge | ra3.xlplus | ra3.4xlarge |
            ra3.16xlarge.
        master_username(Text): The user name associated with the admin user account for the cluster that is being created.
            Constraints:   Must be 1 - 128 alphanumeric characters. The user name can't be PUBLIC.   First
            character must be a letter.   Cannot be a reserved word. A list of reserved words can be found
            in Reserved Words in the Amazon Redshift Database Developer Guide.
        master_user_password(Text): The password associated with the admin user account for the cluster that is being created.
            Constraints:   Must be between 8 and 64 characters in length.   Must contain at least one
            uppercase letter.   Must contain at least one lowercase letter.   Must contain one number.   Can
            be any printable ASCII character (ASCII code 33 to 126) except ' (single quote), " (double
            quote), \, /, @, or space.
        cluster_security_groups(List, optional): A list of security groups to be associated with this cluster. Default: The default cluster
            security group for Amazon Redshift. Defaults to None.
        vpc_security_group_ids(List, optional): A list of Virtual Private Cloud (VPC) security groups to be associated with the cluster.
            Default: The default VPC security group is associated with the cluster. Defaults to None.
        cluster_subnet_group_name(Text, optional): The name of a cluster subnet group to be associated with this cluster. If this parameter is not
            provided the resulting cluster will be deployed outside virtual private cloud (VPC). Defaults to None.
        availability_zone(Text, optional): The EC2 Availability Zone (AZ) in which you want Amazon Redshift to provision the cluster. For
            example, if you have several EC2 instances running in a specific Availability Zone, then you
            might want the cluster to be provisioned in the same zone in order to decrease network latency.
            Default: A random, system-chosen Availability Zone in the region that is specified by the
            endpoint. Example: us-east-2d  Constraint: The specified Availability Zone must be in the same
            region as the current endpoint. Defaults to None.
        preferred_maintenance_window(Text, optional): The weekly time range (in UTC) during which automated cluster maintenance can occur.  Format:
            ddd:hh24:mi-ddd:hh24:mi   Default: A 30-minute window selected at random from an 8-hour block of
            time per region, occurring on a random day of the week. For more information about the time
            blocks for each region, see Maintenance Windows in Amazon Redshift Cluster Management Guide.
            Valid Days: Mon | Tue | Wed | Thu | Fri | Sat | Sun Constraints: Minimum 30-minute window. Defaults to None.
        cluster_parameter_group_name(Text, optional): The name of the parameter group to be associated with this cluster. Default: The default Amazon
            Redshift cluster parameter group. For information about the default parameter group, go to
            Working with Amazon Redshift Parameter Groups  Constraints:   Must be 1 to 255 alphanumeric
            characters or hyphens.   First character must be a letter.   Cannot end with a hyphen or contain
            two consecutive hyphens. Defaults to None.
        automated_snapshot_retention_period(int, optional): The number of days that automated snapshots are retained. If the value is 0, automated snapshots
            are disabled. Even if automated snapshots are disabled, you can still create manual snapshots
            when you want with CreateClusterSnapshot.  You can't disable automated snapshots for RA3 node
            types. Set the automated retention period from 1-35 days. Default: 1  Constraints: Must be a
            value from 0 to 35. Defaults to None.
        manual_snapshot_retention_period(int, optional): The default number of days to retain a manual snapshot. If the value is -1, the snapshot is
            retained indefinitely. This setting doesn't change the retention period of existing snapshots.
            The value must be either -1 or an integer between 1 and 3,653. Defaults to None.
        port(int, optional): The port number on which the cluster accepts incoming connections. The cluster is accessible
            only via the JDBC and ODBC connection strings. Part of the connection string requires the port
            on which the cluster will listen for incoming connections. Default: 5439  Valid Values:
            1150-65535. Defaults to None.
        cluster_version(Text, optional): The version of the Amazon Redshift engine software that you want to deploy on the cluster. The
            version selected runs on all the nodes in the cluster. Constraints: Only version 1.0 is
            currently available. Example: 1.0. Defaults to None.
        allow_version_upgrade(bool, optional): If true, major version upgrades can be applied during the maintenance window to the Amazon
            Redshift engine that is running on the cluster. When a new major version of the Amazon Redshift
            engine is released, you can request that the service automatically apply upgrades during the
            maintenance window to the Amazon Redshift engine that is running on your cluster. Default: true. Defaults to None.
        number_of_nodes(int, optional): The number of compute nodes in the cluster. This parameter is required when the ClusterType
            parameter is specified as multi-node.  For information about determining how many nodes you
            need, go to  Working with Clusters in the Amazon Redshift Cluster Management Guide.  If you
            don't specify this parameter, you get a single-node cluster. When requesting a multi-node
            cluster, you must specify the number of nodes that you want in the cluster. Default: 1
            Constraints: Value must be at least 1 and no more than 100. Defaults to None.
        publicly_accessible(bool, optional): If true, the cluster can be accessed from a public network. Defaults to None.
        encrypted(bool, optional): If true, the data in the cluster is encrypted at rest.  Default: false. Defaults to None.
        hsm_client_certificate_identifier(Text, optional): Specifies the name of the HSM client certificate the Amazon Redshift cluster uses to retrieve
            the data encryption keys stored in an HSM. Defaults to None.
        hsm_configuration_identifier(Text, optional): Specifies the name of the HSM configuration that contains the information the Amazon Redshift
            cluster can use to retrieve and store keys in an HSM. Defaults to None.
        elastic_ip(Text, optional): The Elastic IP (EIP) address for the cluster. Constraints: The cluster must be provisioned in
            EC2-VPC and publicly-accessible through an Internet gateway. For more information about
            provisioning clusters in EC2-VPC, go to Supported Platforms to Launch Your Cluster in the Amazon
            Redshift Cluster Management Guide. Defaults to None.
        tags(List, optional): A list of tag instances. Defaults to None.
        kms_key_id(Text, optional): The Key Management Service (KMS) key ID of the encryption key that you want to use to encrypt
            data in the cluster. Defaults to None.
        enhanced_vpc_routing(bool, optional): An option that specifies whether to create the cluster with enhanced VPC routing enabled. To
            create a cluster that uses enhanced VPC routing, the cluster must be in a VPC. For more
            information, see Enhanced VPC Routing in the Amazon Redshift Cluster Management Guide. If this
            option is true, enhanced VPC routing is enabled.  Default: false. Defaults to None.
        additional_info(Text, optional): Reserved. Defaults to None.
        iam_roles(List, optional): A list of Identity and Access Management (IAM) roles that can be used by the cluster to access
            other Amazon Web Services services. You must supply the IAM roles in their Amazon Resource Name
            (ARN) format. You can supply up to 10 IAM roles in a single request. A cluster can have up to 10
            IAM roles associated with it at any time. Defaults to None.
        maintenance_track_name(Text, optional): An optional parameter for the name of the maintenance track for the cluster. If you don't
            provide a maintenance track name, the cluster is assigned to the current track. Defaults to None.
        snapshot_schedule_identifier(Text, optional): A unique identifier for the snapshot schedule. Defaults to None.
        availability_zone_relocation(bool, optional): The option to enable relocation for an Amazon Redshift cluster between Availability Zones after
            the cluster is created. Defaults to None.
        aqua_configuration_status(Text, optional): The value represents how the cluster is configured to use AQUA (Advanced Query Accelerator) when
            it is created. Possible values include the following.   enabled - Use AQUA if it is available
            for the current Amazon Web Services Region and Amazon Redshift node type.   disabled - Don't use
            AQUA.    auto - Amazon Redshift determines whether to use AQUA. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.redshift.cluster.present:
                - name: value
                - cluster_identifier: value
                - node_type: value
                - master_username: value
                - master_user_password: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.redshift.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.redshift.describe_clusters(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.redshift.create_cluster(
                ctx,
                
                
                **{"DBName": db_name, "ClusterIdentifier": cluster_identifier, "ClusterType": cluster_type, "NodeType": node_type, "MasterUsername": master_username, "MasterUserPassword": master_user_password, "ClusterSecurityGroups": cluster_security_groups, "VpcSecurityGroupIds": vpc_security_group_ids, "ClusterSubnetGroupName": cluster_subnet_group_name, "AvailabilityZone": availability_zone, "PreferredMaintenanceWindow": preferred_maintenance_window, "ClusterParameterGroupName": cluster_parameter_group_name, "AutomatedSnapshotRetentionPeriod": automated_snapshot_retention_period, "ManualSnapshotRetentionPeriod": manual_snapshot_retention_period, "Port": port, "ClusterVersion": cluster_version, "AllowVersionUpgrade": allow_version_upgrade, "NumberOfNodes": number_of_nodes, "PubliclyAccessible": publicly_accessible, "Encrypted": encrypted, "HsmClientCertificateIdentifier": hsm_client_certificate_identifier, "HsmConfigurationIdentifier": hsm_configuration_identifier, "ElasticIp": elastic_ip, "Tags": tags, "KmsKeyId": kms_key_id, "EnhancedVpcRouting": enhanced_vpc_routing, "AdditionalInfo": additional_info, "IamRoles": iam_roles, "MaintenanceTrackName": maintenance_track_name, "SnapshotScheduleIdentifier": snapshot_schedule_identifier, "AvailabilityZoneRelocation": availability_zone_relocation, "AquaConfigurationStatus": aqua_configuration_status}
            )
            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.redshift.describe_clusters(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, cluster_identifier: Text, skip_final_cluster_snapshot: bool = None, final_cluster_snapshot_identifier: Text = None, final_cluster_snapshot_retention_period: int = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a previously provisioned cluster without its final snapshot being created. A successful response from
    the web service indicates that the request was received correctly. Use DescribeClusters to monitor the status of
    the deletion. The delete operation cannot be canceled or reverted once submitted. For more information about
    managing clusters, go to Amazon Redshift Clusters in the Amazon Redshift Cluster Management Guide. If you want
    to shut down the cluster and retain it for future use, set SkipFinalClusterSnapshot to false and specify a name
    for FinalClusterSnapshotIdentifier. You can later restore this snapshot to resume using the cluster. If a final
    cluster snapshot is requested, the status of the cluster will be "final-snapshot" while the snapshot is being
    taken, then it's "deleting" once Amazon Redshift begins deleting the cluster.   For more information about
    managing clusters, go to Amazon Redshift Clusters in the Amazon Redshift Cluster Management Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cluster_identifier(Text): The identifier of the cluster to be deleted. Constraints:   Must contain lowercase characters.
            Must contain from 1 to 63 alphanumeric characters or hyphens.   First character must be a
            letter.   Cannot end with a hyphen or contain two consecutive hyphens.
        skip_final_cluster_snapshot(bool, optional): Determines whether a final snapshot of the cluster is created before Amazon Redshift deletes the
            cluster. If true, a final cluster snapshot is not created. If false, a final cluster snapshot is
            created before the cluster is deleted.   The FinalClusterSnapshotIdentifier parameter must be
            specified if SkipFinalClusterSnapshot is false.  Default: false. Defaults to None.
        final_cluster_snapshot_identifier(Text, optional): The identifier of the final snapshot that is to be created immediately before deleting the
            cluster. If this parameter is provided, SkipFinalClusterSnapshot must be false.  Constraints:
            Must be 1 to 255 alphanumeric characters.   First character must be a letter.   Cannot end with
            a hyphen or contain two consecutive hyphens. Defaults to None.
        final_cluster_snapshot_retention_period(int, optional): The number of days that a manual snapshot is retained. If the value is -1, the manual snapshot
            is retained indefinitely. The value must be either -1 or an integer between 1 and 3,653. The
            default value is -1. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.redshift.delete_cluster(
                ctx,
                
                
                **{"ClusterIdentifier": cluster_identifier, "SkipFinalClusterSnapshot": skip_final_cluster_snapshot, "FinalClusterSnapshotIdentifier": final_cluster_snapshot_identifier, "FinalClusterSnapshotRetentionPeriod": final_cluster_snapshot_retention_period}
            )
            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.redshift.describe_clusters(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

