HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_sns.cpython-310.pyc
o

�N�g��@s�dZddlZddlZe�e�ZzddlZddlZe�d��	ej
�dZWney/dZYnwdd�Z
d dd	�Zd d
d�Zd dd
�Zd dd�Z	d dd�Z	d dd�Z	d dd�Zd dd�Zd!dd�Zdd�Zdd�Zdd�ZdS)"a�
Connection module for Amazon SNS

:configuration: This module accepts explicit sns credentials but can also
    utilize IAM roles assigned to the instance through Instance Profiles. Dynamic
    credentials are then automatically obtained from AWS API and no further
    configuration is necessary. More Information available at:

    .. code-block:: text

        http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

    If IAM roles are not used you need to specify them either in a pillar or
    in the minion's config file:

    .. code-block:: yaml

        sns.keyid: GKTADJGHEIQSXMKKRBJ08H
        sns.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    A region may also be specified in the configuration:

    .. code-block:: yaml

        sns.region: us-east-1

    If a region is not specified, the default is us-east-1.

    It's also possible to specify key, keyid and region via a profile, either
    as a passed in dict, or as a string to pull from pillars or minion config:

    .. code-block:: yaml

        myprofile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
            region: us-east-1

:depends: boto
�N�botoTFcCs.tjjjdd�}|durtdtdtd�|S)z,
    Only load if boto libraries exist.
    F)Zcheck_boto3Tzboto.assign_funcsZsns)�pack)�salt�utilsZversionsZcheck_boto_reqsZ	__utils__�__name__�__salt__)Z
has_boto_reqs�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_sns.py�__virtual__@sr
c	Cs�t�}zt|WStyYnwt||||d�}it|<|��}|dddD]}|d�d�d}|dt||<q*t|S)z�
    Returns a list of the all topics..

    CLI Example:

    .. code-block:: bash

        salt myminion boto_sns.get_all_topics
    ��region�key�keyid�profileZListTopicsResponseZListTopicsResultZTopicsZTopicArn�:���)�_cache_get_key�__context__�KeyError�	_get_conn�get_all_topics�split)	rr
rr�	cache_key�conn�topics�tZ
short_namerrr	rJs

�rcCs:t||||d�}|�d�r|t|���vS|t|���vS)z�
    Check to see if an SNS topic exists.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_sns.exists mytopic region=us-east-1
    r�arn:aws:sns:)r�
startswith�list�values�keys)�namerr
rrrrrr	�existsds

r"cCs0t||||d�}|�|�t�d|�t�dS)z�
    Create an SNS topic.

    CLI example to create a topic::

        salt myminion boto_sns.create mytopic region=us-east-1
    rzCreated SNS topic %sT)rZcreate_topic�log�info�_invalidate_cache�r!rr
rrrrrr	�createus

r'cCs<t||||d�}|�t|||||��t�d|�t�dS)z�
    Delete an SNS topic.

    CLI example to delete a topic::

        salt myminion boto_sns.delete mytopic region=us-east-1
    rzDeleted SNS topic %sT)rZdelete_topic�get_arnr#r$r%r&rrr	�delete�s
r)cCsht|�}zt|WStyYnwt||||d�}|�t|||||��}|dddt|<t|S)z�
    Get list of all subscriptions to a specific topic.

    CLI example to delete a topic::

        salt myminion boto_sns.get_all_subscriptions_by_topic mytopic region=us-east-1
    rZ ListSubscriptionsByTopicResponseZListSubscriptionsByTopicResultZ
Subscriptions)�_subscriptions_cache_keyrrr�get_all_subscriptions_by_topicr()r!rr
rrrr�retrrr	r+�s 

����r+cCs`t||||d�}|�t|||||�||�t�d|||�ztt|�=WdSty/YdSw)z�
    Subscribe to a Topic.

    CLI example to delete a topic::

        salt myminion boto_sns.subscribe mytopic https https://www.example.com/sns-endpoint region=us-east-1
    rzSubscribe %s %s to %s topicT)r�	subscriber(r#r$rr*r)�topic�protocolZendpointrr
rrrrrr	r-�s
��r-c
Cs�t||||d�}|�d�durdSz|�|�t�d||�Wnty9}ztjddd�WYd}~dSd}~wwt�t	|�d�dS)	z�
    Unsubscribe a specific SubscriptionArn of a topic.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_sns.unsubscribe my_topic my_subscription_arn region=us-east-1

    .. versionadded:: 2016.11.0
    rrFzUnsubscribe %s to %s topiczUnsubscribe ErrorT)�exc_infoN)
rr�unsubscriber#r$�	Exception�errorr�popr*)r.Zsubscription_arnrr
rrr�errr	r1�s
��r1cCs>|�d�r|Std||||d�}dt||��d|�d|��S)z�
    Returns the full ARN for a given topic name.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_sns.get_arn mytopic
    rzboto_iam.get_account_idrr)rr�_get_region)r!rr
rrZ
account_idrrr	r(�s

�r(cCsd|r
d|vr
|dS|std|�rtd|�}|�dd�}|s,tdd�r,tdd�}|s0d}|S)Nrz
config.optionz
sns.regionz	us-east-1)r�get)rrZ_profilerrr	r6�sr6cCst��d|�d�S)N�_Z_subscriptions)r)r!rrr	r*�sr*cCs$ztt�=WdStyYdSw)N)rrrrrrr	r%s
�r%cCsdS)Nzboto_sns.topics_cacherrrrr	r
sr)NNNN)NN)�__doc__�loggingZsalt.utils.versionsr�	getLoggerrr#rZboto.sns�setLevel�CRITICALZHAS_BOTO�ImportErrorr
rr"r'r)r+r-r1r(r6r*r%rrrrr	�<module>s8-
�





�
�
�