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

hub.exec.boto3.client.fms.delete_notification_channel
hub.exec.boto3.client.fms.get_notification_channel
hub.exec.boto3.client.fms.put_notification_channel
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, sns_topic_arn: Text, sns_role_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Designates the IAM role and Amazon Simple Notification Service (SNS) topic that Firewall Manager uses to record
    SNS logs. To perform this action outside of the console, you must configure the SNS topic to allow the Firewall
    Manager role AWSServiceRoleForFMS to publish SNS logs. For more information, see Firewall Manager required
    permissions for API actions in the Firewall Manager Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        sns_topic_arn(Text): The Amazon Resource Name (ARN) of the SNS topic that collects notifications from Firewall
            Manager.
        sns_role_name(Text): The Amazon Resource Name (ARN) of the IAM role that allows Amazon SNS to record Firewall Manager
            activity.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.fms.notification_channel.present:
                - name: value
                - sns_topic_arn: value
                - sns_role_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.fms.notification_channel.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.fms.get_notification_channel(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.fms.put_notification_channel(
                ctx,
                
                
                **{"SnsTopicArn": sns_topic_arn, "SnsRoleName": sns_role_name}
            )
            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.fms.get_notification_channel(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an Firewall Manager association with the IAM role and the Amazon Simple Notification Service (SNS) topic
    that is used to record Firewall Manager SNS logs.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

