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

hub.exec.boto3.client.ssm_incidents.create_replication_set
hub.exec.boto3.client.ssm_incidents.delete_replication_set
hub.exec.boto3.client.ssm_incidents.get_replication_set
hub.exec.boto3.client.ssm_incidents.list_replication_sets
hub.exec.boto3.client.ssm_incidents.update_replication_set
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, regions: Dict, client_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    A replication set replicates and encrypts your data to the provided Regions with the provided KMS key.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_token(Text, optional): A token ensuring that the action is called only once with the specified details. Defaults to None.
        regions(Dict): The Regions that Incident Manager replicates your data to. You can have up to three Regions in
            your replication set.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.ssm_incidents.replication_set.present:
                - name: value
                - regions: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.ssm_incidents.replication_set.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.ssm_incidents.get_replication_set(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ssm_incidents.create_replication_set(
                ctx,
                
                
                **{"clientToken": client_token, "regions": regions}
            )
            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.ssm_incidents.get_replication_set(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes all Regions in your replication set. Deleting the replication set deletes all Incident Manager data.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        arn(Text): The Amazon Resource Name (ARN) of the replication set you're deleting.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

