%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/boto3_sns.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
mZeje
�Zd�Zddddddd�Zeddddd�Zd�ZdS(	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:
        boto3_sns.topic_present:
            - region: us-east-1
            - keyid: GKTADJGHEIQSXMKKRBJ08H
            - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    # Using a profile from pillars
    mytopic:
        boto3_sns.topic_present:
            - region: us-east-1
            - profile: mysnsprofile

    # Passing in a profile
    mytopic:
        boto3_sns.topic_present:
            - region: us-east-1
            - profile:
                keyid: GKTADJGHEIQSXMKKRBJ08H
                key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
i(tabsolute_importtprint_functiontunicode_literalsN(tsixcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto3_sns.topic_existsu	boto3_sns(t__salt__tFalse(((s9/usr/lib/python2.7/site-packages/salt/states/boto3_sns.pyt__virtual__Esc 
C@s�i|d6td6dd6id6}t}td|||||�}	|	rjdj|�|d<|	d}
n�td	r�d
j|�|d<d,|d<|Std|d|d
|d|d|�}
|
r�dj||
�|d<t}n2dj|�|d<tj|d�t|d<|S|r |ni}td|
d|d
|d|d|�}x?dddgD].}
|j|
�}|j|
�}|d,kr�q^nt	||�r�q^ntd	r�|dcdj|
|
�7<d,|d<q^nt
|tj�r�|nt
jjj|�}td|
|
|d|d
|d|d|�rb|dcdj|
||
�7<t}q^|dcdj|
|
�7<t|d<|Sq^W|r�|ng}g}|	jdg�}g|D]"}i|dd6|dd6^q�}g}g}x�|D]�}|d}tjd|�}|d,k	rQ|jd|j�dd �|d<n|tj|�g7}||kr�||d<||g7}q�q�WxJ|D]B}i|dd6|dd6}||kr�||d!g7}q�q�Wx�|D]�}|d}|d}td	r>d"j|||
�}|dc|7<d,|d<q�ntd#|
||d|d
|d|d|�}|r�d$j|||
�}|dc|7<t}q�d%j|||
�}|dc|7<t|d<|Sq�Wx�|D]�}td	r d&j||
�}|dc|7<d,|d<q�ntd'|d|d
|d|d|�}|rs|dcd(j||
�7<t}q�d)j||
�}|dc|7<t|d<|Sq�W|r�|	|dd*<td|||||�|dd+<n|S(-uj
    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:: yaml

            subscriptions:
            - Protocol: https
              Endpoint: https://www.example.com/sns-endpoint
            - Protocol: sqs
              Endpoint: arn:aws:sqs:us-west-2:123456789012:MyQueue

    attributes
        Dictionary of attributes to set on the SNS topic
        Valid attribute keys are:
          - Policy:  the JSON serialization of the topic's access control policy
          - DisplayName:  the human-readable name used in the "From" field for notifications
                to email and email-json endpoints
          - DeliveryPolicy:  the JSON serialization of the topic's delivery policy

    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.
    unameuresultuucommentuchangesuboto3_sns.describe_topicuAWS SNS topic {0} present.uTopicArnutestu#AWS SNS topic {0} would be created.uboto3_sns.create_topictregiontkeytkeyidtprofileu'AWS SNS topic {0} created with ARN {1}.u"Failed to create AWS SNS topic {0}uboto3_sns.get_topic_attributesuDisplayNameuPolicyuDeliveryPolicyu.  Attribute {0} would be updated on topic {1}.uboto3_sns.set_topic_attributesu(  Attribute {0} set to {1} on topic {2}.u$  Failed to update {0} on topic {1}.u
SubscriptionsuProtocoluEndpointu$https://(?P<user>\w+):(?P<pass>\w+)@u:upassu:****uSubscriptionArnu0 Subscription {0}:{1} would be set on topic {2}.uboto3_sns.subscribeu' Subscription {0}:{1} set on topic {2}.u1 Failed to set subscription {0}:{1} on topic {2}.u3  Subscription {0} would be removed from topic {1}.uboto3_sns.unsubscribeu*  Subscription {0} removed from topic {1}.u3  Failed to remove subscription {0} from topic {1}.uoldunewN(tTrueRRtformatt__opts__tNonetlogterrortgett_json_objs_equalt
isinstanceRtstring_typestsalttutilstjsontdumpstretsearchtreplacet	groupdicttcopytdeepcopy( tnamet
subscriptionst
attributesRRR	R
trettsomething_changedtcurrenttTopicArnt
want_attrst
current_attrstattrtcurr_valtwant_valt	want_substobfuscated_substcurrent_subststcurrent_slimt	subscribetunsubscribetsubtendpointtmatchestminimaltprottendptmsgtsubbedtunsubbed((s9/usr/lib/python2.7/site-packages/salt/states/boto3_sns.pyt
topic_presentLs�*"


	


-		
/

'






	



		
'cC@svi|d6td6dd6id6}t}td|||||�}|s`dj|�|d<n�|d}	td	r�d
j|	�|d<|r�|dcdjt|d��7<nd |d<|S|r�x�|dD]�}
|
d
dkrtjd|
d|
d|
d�q�ntd|
d
d|d|d|d|�rXtj	d|
|	�t}q�dj|
|	�|d<t|d<|Sq�Wntd|	d|d|d|d|�s�dj|	�|d<tj
|d�t|d<n[dj|	�|d<|r1|dcdjg|dD]}dj|�^q�7<nt}|rr||dd<td|||||�|dd<n|S(!u�
    Ensure the named sns topic is deleted.

    name
        Name of the SNS topic.

    unsubscribe
        If True, unsubscribe all subcriptions to the SNS topic before
        deleting 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.
    unameuresultuucommentuchangesuboto3_sns.describe_topicuAWS SNS topic {0} absent.uTopicArnutestu#AWS SNS topic {0} would be removed.u'  {0} subscription(s) would be removed.u
SubscriptionsuSubscriptionArnuPendingConfirmationu;Ignoring PendingConfirmation subscription %s %s on topic %suProtocoluEndpointuboto3_sns.unsubscribeRRR	R
u(Deleted subscription %s for SNS topic %su3Failed to delete subscription {0} for SNS topic {1}uboto3_sns.delete_topicuFailed to delete SNS topic {0}uAWS SNS topic {0} deleted.u  uSubscription {0} deleteduoldunewN(RRRRR
tlenRRtwarningtdebugRtjoin(RR1RRR	R
R"R#R$R%R2R.((s9/usr/lib/python2.7/site-packages/salt/states/boto3_sns.pyttopic_absent�sT"


	
	
)'cC@sxtdt|tj�r.tjjj|�n|�}tdt|tj�retjjj|�n|�}||kS(Nu
boto3.ordered(t	__utils__RRRRRRtloads(tlefttright((s9/usr/lib/python2.7/site-packages/salt/states/boto3_sns.pyR8s'	'	(t__doc__t
__future__RRRRtloggingRtsalt.utils.jsonRtsalt.extRt	getLoggert__name__RRRR;RR@R(((s9/usr/lib/python2.7/site-packages/salt/states/boto3_sns.pyt<module>8s	�K

Zerion Mini Shell 1.0