%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/boto_sns.pyc

�
���^c@@skdZddlmZmZmZddlZd�Zdddddd�Zdddde	d�Z
dS(u�
Manage SNS Topics


Create and destroy SNS topics. Be aware that this interacts with Amazon's
services, and so may incur charges.

This module uses ``boto``, which can be installed via package, or pip.

This module accepts explicit AWS 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 `here
<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 file or
in the minion's config file:

.. code-block:: yaml

    sns.keyid: GKTADJGHEIQSXMKKRBJ08H
    sns.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

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

.. code-block:: yaml

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

.. code-block:: yaml

    mytopic:
        boto_sns.present:
            - region: us-east-1
            - keyid: GKTADJGHEIQSXMKKRBJ08H
            - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    # Using a profile from pillars
    mytopic:
        boto_sns.present:
            - region: us-east-1
            - profile: mysnsprofile

    # Passing in a profile
    mytopic:
        boto_sns.present:
            - region: us-east-1
            - profile:
                keyid: GKTADJGHEIQSXMKKRBJ08H
                key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
i(tabsolute_importtprint_functiontunicode_literalsNcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto_sns.existsuboto_sns(t__salt__tFalse(((s8/usr/lib/python2.7/site-packages/salt/states/boto_sns.pyt__virtual__?sc
C@sOi|d6d!d6dd6id6}td|d|d|d	|d
|�}|rpt|d<dj|�|d<n�tdr�d
j|�}||d<d!|d<|Std|d|d|d	|d
|�}	|	rdj|�}||d<d!|dd<i|d6gd6|dd<t|d<n!dj|�|d<t|d<|S|sJ|Std|d|d|d	|d
|�}
g|
D]"}i|dd6|dd6^qy}
x�|D]�}|d}
tjd|
�}|d!k	r�|
j|j	�dd�|d<n||
kr|
|d<tdrVdj|d|d|�}|dc|7<d!|d<q�ntd||d|dd|d|d	|d
|�}	|	r	dj|d|d|�}|dc|7<|dj
dd!�|dj
di�j
dg�j|�t|d<qGt|d<|Sq�d j|d|d|�}|dc|7<q�W|S("u�
    Ensure the SNS topic exists.

    name
        Name of the SNS topic.

    subscriptions
        List of SNS subscriptions.

        Each subscription is a dictionary with a protocol and endpoint key:

        .. code-block:: python

            [
            {'protocol': 'https', 'endpoint': 'https://www.example.com/sns-endpoint'},
            {'protocol': 'sqs', 'endpoint': 'arn:aws:sqs:us-west-2:123456789012:MyQueue'}
            ]

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.
    unameuresultuucommentuchangesuboto_sns.existstregiontkeytkeyidtprofileuAWS SNS topic {0} present.utestu'AWS SNS topic {0} is set to be created.uboto_sns.createuAWS SNS topic {0} created.uoldutopicu
subscriptionsunewu"Failed to create {0} AWS SNS topicu'boto_sns.get_all_subscriptions_by_topicuProtocoluprotocoluEndpointuendpointu$https://(?P<user>\w+):(?P<pass>\w+)@upassu****u5 AWS SNS subscription {0}:{1} to be set on topic {2}.uboto_sns.subscribeu/ AWS SNS subscription {0}:{1} set on topic {2}.u7 AWS SNS subscription {0}:{1} already set on topic {2}.N(tNoneRtTruetformatt__opts__Rtretsearchtreplacet	groupdictt
setdefaulttappend(tnamet
subscriptionsRRRR	trett
is_presenttmsgtcreatedt_subscriptionststsubscriptiont	_endpointtmatches((s8/usr/lib/python2.7/site-packages/salt/states/boto_sns.pytpresentFs�&"!



!


!,

	


	
	


	c
C@si|d6td6dd6id6}td|d|d|d	|d
|�}|r�|r~td|d|d|d	|d
|�ng}g}	tjd�r�d
j|t|��|d<d|d<|SxY|D]Q}
td||
dd|d|d	|d
|�}|tkr�|	j|
�q�q�Wtd|d|d|d	|d
|�}|r�dj|�|d<d|dd<|tkr�i|d6|dd<q�i|d6|d6|dd<|	r�i|	d6|dd<q�qt|d<dj|�|d<ndj|�|d<|S(u�
    Ensure the named sns topic is deleted.

    name
        Name of the SNS topic.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.

    unsubscribe
        If True, unsubscribe all subcriptions to the SNS topic before
        deleting the SNS topic

        .. versionadded:: 2016.11.0
    unameuresultuucommentuchangesuboto_sns.existsRRRR	u'boto_sns.get_all_subscriptions_by_topicutestuMAWS SNS topic {0} is set to be removed.  {1} subscription(s) will be removed.uboto_sns.unsubscribeuSubscriptionArnuboto_sns.deleteuAWS SNS topic {0} deleted.unewutopicuoldu
subscriptionsu#Failed to delete {0} AWS SNS topic.u!AWS SNS topic {0} does not exist.N(	RRR
tgetRtlenR
RR(
RRRRR	tunsubscribeRRRt failed_unsubscribe_subscriptionsRtunsubscribedtdeleted((s8/usr/lib/python2.7/site-packages/salt/states/boto_sns.pytabsent�s> "!4

!
(t__doc__t
__future__RRRRRR
RRR&(((s8/usr/lib/python2.7/site-packages/salt/states/boto_sns.pyt<module>8s		�

Zerion Mini Shell 1.0