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

hub.exec.boto3.client.dms.create_replication_instance
hub.exec.boto3.client.dms.delete_replication_instance
hub.exec.boto3.client.dms.describe_replication_instances
hub.exec.boto3.client.dms.modify_replication_instance
hub.exec.boto3.client.dms.reboot_replication_instance
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, replication_instance_identifier: Text, replication_instance_class: Text, allocated_storage: int = None, vpc_security_group_ids: List = None, availability_zone: Text = None, replication_subnet_group_identifier: Text = None, preferred_maintenance_window: Text = None, multi_az: bool = None, engine_version: Text = None, auto_minor_version_upgrade: bool = None, tags: List = None, kms_key_id: Text = None, publicly_accessible: bool = None, dns_name_servers: Text = None, resource_identifier: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates the replication instance using the specified parameters. DMS requires that your account have certain
    roles with appropriate permissions before you can create a replication instance. For information on the required
    roles, see Creating the IAM Roles to Use With the CLI and DMS API. For information on the required permissions,
    see IAM Permissions Needed to Use DMS.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        replication_instance_identifier(Text): The replication instance identifier. This parameter is stored as a lowercase string.
            Constraints:   Must contain 1-63 alphanumeric characters or hyphens.   First character must be a
            letter.   Can't end with a hyphen or contain two consecutive hyphens.   Example: myrepinstance.
        allocated_storage(int, optional): The amount of storage (in gigabytes) to be initially allocated for the replication instance. Defaults to None.
        replication_instance_class(Text): The compute and memory capacity of the replication instance as defined for the specified
            replication instance class. For example to specify the instance class dms.c4.large, set this
            parameter to "dms.c4.large". For more information on the settings and capacities for the
            available replication instance classes, see  Selecting the right DMS replication instance for
            your migration.
        vpc_security_group_ids(List, optional):  Specifies the VPC security group to be used with the replication instance. The VPC security
            group must work with the VPC containing the replication instance. Defaults to None.
        availability_zone(Text, optional): The Availability Zone where the replication instance will be created. The default value is a
            random, system-chosen Availability Zone in the endpoint's Region, for example: us-east-1d. Defaults to None.
        replication_subnet_group_identifier(Text, optional): A subnet group to associate with the replication instance. 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  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. Valid Days: Mon, Tue,
            Wed, Thu, Fri, Sat, Sun Constraints: Minimum 30-minute window. Defaults to None.
        multi_az(bool, optional):  Specifies whether the replication instance is a Multi-AZ deployment. You can't set the
            AvailabilityZone parameter if the Multi-AZ parameter is set to true. Defaults to None.
        engine_version(Text, optional): The engine version number of the replication instance. If an engine version number is not
            specified when a replication instance is created, the default is the latest engine version
            available. Defaults to None.
        auto_minor_version_upgrade(bool, optional): A value that indicates whether minor engine upgrades are applied automatically to the
            replication instance during the maintenance window. This parameter defaults to true. Default:
            true. Defaults to None.
        tags(List, optional): One or more tags to be assigned to the replication instance. Defaults to None.
        kms_key_id(Text, optional): An KMS key identifier that is used to encrypt the data on the replication instance. If you don't
            specify a value for the KmsKeyId parameter, then DMS uses your default encryption key. KMS
            creates the default encryption key for your account. Your account has a different default
            encryption key for each Region. Defaults to None.
        publicly_accessible(bool, optional):  Specifies the accessibility options for the replication instance. A value of true represents an
            instance with a public IP address. A value of false represents an instance with a private IP
            address. The default value is true. Defaults to None.
        dns_name_servers(Text, optional): A list of custom DNS name servers supported for the replication instance to access your on-
            premise source or target database. This list overrides the default name servers supported by the
            replication instance. You can specify a comma-separated list of internet addresses for up to
            four on-premise DNS name servers. For example: "1.1.1.1,2.2.2.2,3.3.3.3,4.4.4.4". Defaults to None.
        resource_identifier(Text, optional): A friendly name for the resource identifier at the end of the EndpointArn response parameter
            that is returned in the created Endpoint object. The value for this parameter can have up to 31
            characters. It can contain only ASCII letters, digits, and hyphen ('-'). Also, it can't end with
            a hyphen or contain two consecutive hyphens, and can only begin with a letter, such as Example-
            App-ARN1. For example, this value might result in the EndpointArn value arn:aws:dms:eu-
            west-1:012345678901:rep:Example-App-ARN1. If you don't specify a ResourceIdentifier value, DMS
            generates a default identifier value for the end of EndpointArn. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.dms.replication_instance.present:
                - name: value
                - replication_instance_identifier: value
                - replication_instance_class: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.dms.replication_instance.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.dms.describe_replication_instances(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.dms.create_replication_instance(
                ctx,
                
                
                **{"ReplicationInstanceIdentifier": replication_instance_identifier, "AllocatedStorage": allocated_storage, "ReplicationInstanceClass": replication_instance_class, "VpcSecurityGroupIds": vpc_security_group_ids, "AvailabilityZone": availability_zone, "ReplicationSubnetGroupIdentifier": replication_subnet_group_identifier, "PreferredMaintenanceWindow": preferred_maintenance_window, "MultiAZ": multi_az, "EngineVersion": engine_version, "AutoMinorVersionUpgrade": auto_minor_version_upgrade, "Tags": tags, "KmsKeyId": kms_key_id, "PubliclyAccessible": publicly_accessible, "DnsNameServers": dns_name_servers, "ResourceIdentifier": resource_identifier}
            )
            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.dms.describe_replication_instances(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, replication_instance_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified replication instance.  You must delete any migration tasks that are associated with the
    replication instance before you can delete it.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        replication_instance_arn(Text): The Amazon Resource Name (ARN) of the replication instance to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

