%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZeje	�Z
yGddlZddlZddl
Z
ejd�jej�eZWnek
r�eZnXd�Zddddd�Zddddd�Zddddd�Zddddd	�Zddddd
�Zddddd�Zddddd�Zddddd
�Zddddd�Zddddd�Zddddd�Z ddddd�Z!ddddd�Z"dS(u�
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: boto3
i(tabsolute_importtprint_functiontunicode_literalsNuboto3cC@s6tjjj�}|tkr2tdtd�n|S(u,
    Only load if boto libraries exist.
    uboto3.assign_funcsusns(tsalttutilstversionstcheck_boto_reqstTruet	__utils__t__name__(t
has_boto_reqs((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyt__virtual__Csc	C@s�td|d|d|d|�}i}d}xt|dk	r�|jd|�}|jdd�}tjd|�}x+|D]#}	|	jd	�d
}
|	||
<qyWq0W|S(ur
    Returns a list of the requester's topics

    CLI example::

        salt myminion boto3_sns.list_topics
    tregiontkeytkeyidtprofileut	NextTokenu	NextTokenuTopics[*].TopicArnu:i����N(t	_get_conntNonetlist_topicstgettjmespathtsearchtsplit(RR
RRtconntresRtrettarnsttt
short_name((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyRMs!
c	C@s�td|d|d|d|�}i}x�|j�D]~\}}|||fkr4i|d6}t|d|d|d|d|�|d<t|d|d|d|d|�|d<q4q4W|S(u�
    Returns details about a specific SNS topic, specified by name or ARN.

    CLI example::

        salt my_favorite_client boto3_sns.describe_topic a_sns_topic_of_my_choice
    RR
RRuTopicArnu
Subscriptionsu
Attributes(Rtitemstlist_subscriptions_by_topictget_topic_attributes(	tnameRR
RRttopicsRttopictarn((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pytdescribe_topicbs!
c	C@sAtd|d|d|d|�}|t|j�|j��kS(u�
    Check to see if an SNS topic exists.

    CLI example::

        salt myminion boto3_sns.topic_exists mytopic region=us-east-1
    RR
RR(Rtlisttvaluestkeys(R!RR
RRR"((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyttopic_existsvs!c	C@s�td|d|d|d|�}y5|jd|�}tjd||d�|dSWnNtjjk
r�}tjd||�d
St	k
r�tjd	|�d
SXd
S(ux
    Create an SNS topic.

    CLI example::

        salt myminion boto3_sns.create_topic mytopic region=us-east-1
    RR
RRtNameu SNS topic %s created with ARN %suTopicArnu!Failed to create SNS topic %s: %suFailed to create SNS topic %sN(
Rtcreate_topictlogtinfotbotocoret
exceptionstClientErrorterrorRtKeyError(R*RR
RRRRte((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR+�s!
c	C@s}td|d|d|d|�}y(|jd|�tjd|�tSWn-tjjk
rx}tjdt	|�t
SXdS(	ux
    Delete an SNS topic.

    CLI example::

        salt myminion boto3_sns.delete_topic mytopic region=us-east-1
    RR
RRtTopicArnuSNS topic %s deletedu!Failed to delete SNS topic %s: %sN(Rtdelete_topicR,R-RR.R/R0R1R!tFalse(R4RR
RRRR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR5�s!c	C@srtd|d|d|d|�}y|jd|�jd�SWn-tjjk
rm}tjd||�dSXdS(	u�
    Returns all of the properties of a topic.  Topic properties returned might differ based on the
    authorization of the user.

    CLI example::

        salt myminion boto3_sns.get_topic_attributes someTopic region=us-west-1
    RR
RRR4u
Attributesu0Failed to garner attributes for SNS topic %s: %sN(	RR RR.R/R0R,R1R(R4RR
RRRR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR �s	!c		C@s�td|d|d|d|�}y:|jd|d|d|�tjd|||�tSWn3tjjk
r�}tjd	||||�t	SXd
S(u�
    Set an attribute of a topic to a new value.

    CLI example::

        salt myminion boto3_sns.set_topic_attributes someTopic DisplayName myDisplayNameValue
    RR
RRR4t
AttributeNametAttributeValueu#Set attribute %s=%s on SNS topic %su2Failed to set attribute %s=%s for SNS topic %s: %sN(
Rtset_topic_attributesR,tdebugRR.R/R0R1R6(	R4R7R8RR
RRRR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR9�s	!	
	c	C@s�td|d|d|d|�}d}g}y]xV|dk	r�|jd|d|�}|jdd�}|jd	g�}	||	7}q3WWn-tjjk
r�}
tjd
||
�dSX|S(u�
    Returns a list of the subscriptions to a specific topic

    CLI example::

        salt myminion boto3_sns.list_subscriptions_by_topic mytopic region=us-east-1
    RR
RRuR4Ru	NextTokenu
Subscriptionsu1Failed to list subscriptions for SNS topic %s: %sN(	RRRRR.R/R0R,R1(R4RR
RRRRRRtsubsR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR�s!c
	C@s�td|d|d|d|�}d}g}yWxP|d
k	r�|jd|�}|jdd
�}|jdg�}||7}q3WWn*tjjk
r�}	tjd	|	�d
SX|S(u�
    Returns a list of the requester's topics

    CLI example::

        salt myminion boto3_sns.list_subscriptions region=us-east-1
    RR
RRuRu	NextTokenu
Subscriptionsu$Failed to list SNS subscriptions: %sN(	RRtlist_subscriptionsRR.R/R0R,R1(
RR
RRRRRRR;R3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR<�s!c	C@s�td|d|d|d|�}y|jd|�}|dSWnNtjjk
rn}tjd||�d	Stk
r�tjd|�d	SXd	S(
u�
    Returns all of the properties of a subscription.

    CLI example::

        salt myminion boto3_sns.get_subscription_attributes somesubscription region=us-west-1
    RR
RRtSubscriptionArnu
Attributesu5Failed to list attributes for SNS subscription %s: %su1Failed to list attributes for SNS subscription %sN(	Rtget_subscription_attributesR.R/R0R,R1RR2(R=RR
RRRRR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR>�s!	

	c		C@s�td|d|d|d|�}y:|jd|d|d|�tjd|||�tSWn3tjjk
r�}tjd	||||�t	SXd
S(u�
    Set an attribute of a subscription to a new value.

    CLI example::

        salt myminion boto3_sns.set_subscription_attributes someSubscription RawMessageDelivery jsonStringValue
    RR
RRR=R7R8u*Set attribute %s=%s on SNS subscription %su9Failed to set attribute %s=%s for SNS subscription %s: %sN(
Rtset_subscription_attributesR,R:RR.R/R0R1R6(	R=R7R8RR
RRRR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyR?s	!
	
	c
	C@s�td|d|d|d|�}yG|jd|d|d|�}tjd||||d	�|d	SWnNtjjk
r�}	tjd
||	�dSt	k
r�tjd|�dSXdS(
u�
    Subscribe to a Topic.

    CLI example::

        salt myminion boto3_sns.subscribe mytopic https https://www.example.com/sns-endpoint
    RR
RRR4tProtocoltEndpointu4Subscribed %s %s to topic %s with SubscriptionArn %suSubscriptionArnu1Failed to create subscription to SNS topic %s: %su-Failed to create subscription to SNS topic %sN(
Rt	subscribeR,R-R.R/R0R1RR2(
R4R@RARR
RRRRR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyRB*s!	
c	C@s�td|d|d|d|�}g|D]!}|jd�|kr(|^q(}|sitjd|�tS|dd}td|d|d|d|�}	y+|	jd	|�tjd
||�tSWn-t	j
jk
r�}
tjd||
�tSXdS(
u�
    Unsubscribe a specific SubscriptionArn of a topic.

    CLI Example:

    .. code-block:: bash

        salt myminion boto3_sns.unsubscribe my_subscription_arn region=us-east-1
    RR
RRuSubscriptionArnuSubscription ARN %s not foundiuTopicArnR=u)Deleted subscription %s from SNS topic %su$Failed to delete subscription %s: %sN(R<RR,R1R6RtunsubscribeR-RR.R/R0(R=RR
RRR;tstsubR4RR3((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyRC@s
!.!	
(#t__doc__t
__future__RRRtloggingtsalt.utils.versionsRt	getLoggerR	R,R.tboto3RtsetLeveltCRITICALRtHAS_BOTOtImportErrorR6RRRR%R)R+R5R R9RR<R>R?RBRC(((s:/usr/lib/python2.7/site-packages/salt/modules/boto3_sns.pyt<module>)s8


	
	

Zerion Mini Shell 1.0