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

hub.exec.boto3.client.backup.delete_backup_vault_notifications
hub.exec.boto3.client.backup.get_backup_vault_notifications
hub.exec.boto3.client.backup.put_backup_vault_notifications
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, backup_vault_name: Text, sns_topic_arn: Text, backup_vault_events: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Turns on notifications on a backup vault for the specified topic and events.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        backup_vault_name(Text): The name of a logical container where backups are stored. Backup vaults are identified by names
            that are unique to the account used to create them and the AWS Region where they are created.
            They consist of lowercase letters, numbers, and hyphens.
        sns_topic_arn(Text): The Amazon Resource Name (ARN) that specifies the topic for a backup vault’s events; for
            example, arn:aws:sns:us-west-2:111122223333:MyVaultTopic.
        backup_vault_events(List): An array of events that indicate the status of jobs to back up resources to the backup vault.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.backup.backup_vault_notification.present:
                - name: value
                - backup_vault_name: value
                - sns_topic_arn: value
                - backup_vault_events: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.backup.backup_vault_notification.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.backup.get_backup_vault_notifications(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.backup.put_backup_vault_notifications(
                ctx,
                
                
                **{"BackupVaultName": backup_vault_name, "SNSTopicArn": sns_topic_arn, "BackupVaultEvents": backup_vault_events}
            )
            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.backup.get_backup_vault_notifications(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, backup_vault_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes event notifications for the specified backup vault.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        backup_vault_name(Text): The name of a logical container where backups are stored. Backup vaults are identified by names
            that are unique to the account used to create them and the Region where they are created. They
            consist of lowercase letters, numbers, and hyphens.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

