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

hub.exec.boto3.client.mgn.create_replication_configuration_template
hub.exec.boto3.client.mgn.delete_replication_configuration_template
hub.exec.boto3.client.mgn.describe_replication_configuration_templates
hub.exec.boto3.client.mgn.update_replication_configuration_template
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, associate_default_security_group: bool, bandwidth_throttling: int, create_public_ip: bool, data_plane_routing: Text, default_large_staging_disk_type: Text, ebs_encryption: Text, replication_server_instance_type: Text, replication_servers_security_groups_i_ds: List, staging_area_subnet_id: Text, staging_area_tags: Dict, use_dedicated_replication_server: bool, ebs_encryption_key_arn: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new ReplicationConfigurationTemplate.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        associate_default_security_group(bool): Request to associate the default Application Migration Service Security group with the
            Replication Settings template.
        bandwidth_throttling(int): Request to configure bandwidth throttling during Replication Settings template creation.
        create_public_ip(bool): Request to create Public IP during Replication Settings template creation.
        data_plane_routing(Text): Request to configure data plane routing during Replication Settings template creation.
        default_large_staging_disk_type(Text): Request to configure the Staging Disk EBS volume type to "gp2" during Replication Settings
            template creation.
        ebs_encryption(Text): Request to configure EBS enryption during Replication Settings template creation.
        ebs_encryption_key_arn(Text, optional): Request to configure an EBS enryption key during Replication Settings template creation. Defaults to None.
        replication_server_instance_type(Text): Request to configure the Replication Server instance type during Replication Settings template
            creation.
        replication_servers_security_groups_i_ds(List): Request to configure the Replication Server Secuirity group ID during Replication Settings
            template creation.
        staging_area_subnet_id(Text): Request to configure the Staging Area subnet ID during Replication Settings template creation.
        staging_area_tags(Dict): Request to configure Staiging Area tags during Replication Settings template creation.
        tags(Dict, optional): Request to configure tags during Replication Settings template creation. Defaults to None.
        use_dedicated_replication_server(bool): Request to use Dedicated Replication Servers during Replication Settings template creation.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.mgn.replication_configuration_template.present:
                - name: value
                - associate_default_security_group: value
                - bandwidth_throttling: value
                - create_public_ip: value
                - data_plane_routing: value
                - default_large_staging_disk_type: value
                - ebs_encryption: value
                - replication_server_instance_type: value
                - replication_servers_security_groups_i_ds: value
                - staging_area_subnet_id: value
                - staging_area_tags: value
                - use_dedicated_replication_server: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.mgn.replication_configuration_template.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.mgn.describe_replication_configuration_templates(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.mgn.create_replication_configuration_template(
                ctx,
                
                
                **{"associateDefaultSecurityGroup": associate_default_security_group, "bandwidthThrottling": bandwidth_throttling, "createPublicIP": create_public_ip, "dataPlaneRouting": data_plane_routing, "defaultLargeStagingDiskType": default_large_staging_disk_type, "ebsEncryption": ebs_encryption, "ebsEncryptionKeyArn": ebs_encryption_key_arn, "replicationServerInstanceType": replication_server_instance_type, "replicationServersSecurityGroupsIDs": replication_servers_security_groups_i_ds, "stagingAreaSubnetId": staging_area_subnet_id, "stagingAreaTags": staging_area_tags, "tags": tags, "useDedicatedReplicationServer": use_dedicated_replication_server}
            )
            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.mgn.describe_replication_configuration_templates(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, replication_configuration_template_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a single Replication Configuration Template by ID

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        replication_configuration_template_id(Text): Request to delete Replication Configuration Template from service by Replication Configuration
            Template ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

