HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/buyercall/lib/__pycache__/util_boto3_sns.cpython-310.pyc
o

we^�@s,ddlZddlZe�e�ZGdd�d�ZdS)�Nc@s4eZdZdZdd�Zddd�Zddd�Zd	d
�ZdS)
�AmazonSimpleNotificationServiceNcCs6tjd|j�dd�|j�dd�|j�dd�d�|_dS)N�sns�SES_REGION_NAME��AMAZON_ACCESS_KEY�AMAZON_SECRET_KEY)�region_name�aws_access_key_id�aws_secret_access_key)�boto3�client�config�get�
sns_client)�self�app�r�>/home/arjun/projects/buyercall/buyercall/lib/util_boto3_sns.py�init_apps�z(AmazonSimpleNotificationService.init_appc
Cs�|duri}|durg}ddid�}z|r%|jj|||d�}||d<W|Sd|d<d	|d
<W|StyS}zt�t|��d|d<t|�|d
<WYd}~|Sd}~ww)a�Creates a topic to which notifications can be published.

        Args:
            name (str): The name of the topic you want to create.
            tags (list, optional): list of tags to add to a new topic.
            attributes (dict, optional): A map of attributes with their corresponding values. Defaults to {}. 
        Returns:
            dict: Contains the Amazon Resource Name (ARN) assigned to the created topic.
        NT�Success��status�message�data)�Name�
Attributes�TagsrFrzInvalid inputsr)r�create_topic�	Exception�log�error�str)r�name�tags�
attributes�response�topic_response�exrrrrs0
�

�
���z,AmazonSimpleNotificationService.create_topic�httpsc
Cs�|duri}ddid�}z|r!|jj||||dd�}||d<W|Sd|d<d	|d
<W|StyO}zt�t|��d|d<t|�|d
<WYd}~|Sd}~ww)aSubscribes an endpoint to an Amazon SNS topic.

        Args:
            topic_arn (str): The ARN of the topic you want to subscribe to.
            endpoint (str): The endpoint that you want to receive notifications. 
            protocol (str, optional): The protocol that you want to use. Defaults to 'https'.
            attributes (dict, optional): A map of attributes with their corresponding values. Defaults to {}.
        Returns:
            dict: Contains the Amazon Resource Name (ARN) assigned to the subscription.
        NTrr)�TopicArn�Protocol�Endpointr�ReturnSubscriptionArnrFr�Invalid topic arnr)r�	subscriberrr r!)r�	topic_arn�endpoint�protocolr$r%�topic_subscribe_responser'rrrr.5s0�

�
���z)AmazonSimpleNotificationService.subscribec
Cs�ddid�}z|r|jj||dd�}||d<W|Sd|d<d	|d
<W|StyG}zt�t|��d|d<t|�|d
<WYd}~|Sd}~ww)a� Verifies an endpoint owner's intent to receive messages by validating the token sent
        to the endpoint by an earlier Subscribe action.

        Args:
            topic_arn (str): The ARN of the topic for which you wish to confirm a subscription.
            token (str): Short-lived token sent to an endpoint during the Subscribe action.

        Returns:
            dict: Contains the Amazon Resource Name (ARN) assigned to the subscription.
        Trr�true)r)�Token�AuthenticateOnUnsubscriberFrr-rN)r�confirm_subscriptionrrr r!)rr/�tokenr%r2r'rrrr6Xs(�

�
���z4AmazonSimpleNotificationService.confirm_subscription)NN)r(N)�__name__�
__module__�__qualname__rrrr.r6rrrrrs

"#r)�loggingr�	getLoggerr8rrrrrr�<module>s