%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/boto_cloudwatch_event.pyc

�
���^c
@@s�dZddlmZmZmZddlZddlZddlZddl	Zej
e�ZyKddl
Z
ddlZddlmZej
d�jej�eZWnek
r�ZeZnXddlmZd�Zd�Zddddd	�Zdddddddddd
�	Zddddd�Zddddd�Z ddddd
�Z!ddddd�Z"ddddd�Z#ddddd�Z$dS(u
Connection module for Amazon CloudWatch Events

.. versionadded:: 2016.11.0

:configuration: This module accepts explicit 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

        cloudwatch_event.keyid: GKTADJGHEIQSXMKKRBJ08H
        cloudwatch_event.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

    A region may also be specified in the configuration:

    .. code-block:: yaml

        cloudwatch_event.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_literalsN(tClientErroruboto3(tsixcC@stjjj�S(u,
    Only load if boto libraries exist.
    (tsalttutilstversionstcheck_boto_reqs(((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pyt__virtual__LscC@s1tjjjt�tr-tdtd�ndS(Nuboto3.assign_funcsuevents(RRtcompattpack_dundert__name__tHAS_BOTOt	__utils__(topts((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pyt__init__Ssc
	C@s�td|d|d|d|�}y~|jd|�}t|�dkrSitd6Sx=|jdg�D])}|jd	d�|krfitd6SqfWitd6SWn+tk
r�}td
|�}	i|	d6SXdS(
u
    Given a rule name, check to see if the given rule exists.

    Returns True if the given rule exists and returns False if the given
    rule does not exist.

    CLI example::

        salt myminion boto_cloudwatch_event.exists myevent region=us-east-1
    tregiontkeytkeyidtprofilet
NamePrefixiuexistsuRulesuNameuboto3.get_erroruerrorN(	t	_get_connt
list_rulestlentFalsetgettNonetTrueRR(
tNameRRRRtconnteventstruleteterr((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pytexistsYs!c
	C@s�y�td|d|d|d|	�}
i}x5dD]-}t�|dk	r1t�|||<q1q1W|
jd
||�}
|
r�tjd|
jd��itd
6|
jd�d6Stjd�it	d
6SWn,t
k
r�}it	d
6td|�d6SXdS(u
    Given a valid config, create an event rule.

    Returns {created: true} if the rule was created and returns
    {created: False} if the rule was not created.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudwatch_event.create_or_update my_rule

    RRRRuScheduleExpressionuEventPatternuStateuDescriptionuRoleArnRu"The newly created event rule is %suRuleArnucreateduarnuEvent rule was not createduboto3.get_erroruerrorN(uScheduleExpressionuEventPatternuStateuDescriptionuRoleArn(RtlocalsRtput_ruletlogtinfoRRtwarningRRR(RtScheduleExpressiontEventPatterntDescriptiontRoleArntStateRRRRRtkwargstargR R!((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pytcreate_or_updatess !
	
c	C@ssy@td|d|d|d|�}|jd|�itd6SWn,tk
rn}itd6td|�d6SXd	S(
u
    Given a rule name, delete it.

    Returns {deleted: true} if the rule was deleted and returns
    {deleted: false} if the rule was not deleted.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudwatch_event.delete myrule

    RRRRRudeleteduboto3.get_erroruerrorN(Rtdelete_ruleRRRR(RRRRRRR!((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pytdelete�s!c	C@s�y�td|d|d|d|�}|jd|�}|rud}itg|D]}||j|�f^qO�d
6Sidd
6SWnmtk
r�}	td|	�}
|	jjdi�jd�dkr�idjt	�d6Sitd|	�d6SXdS(u�
    Given a rule name describe its properties.

    Returns a dictionary of interesting properties.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudwatch_event.describe myrule

    RRRRRuNameuArnuEventPatternuScheduleExpressionuStateuDescriptionuRoleArnuruleuboto3.get_erroruErroruCodeuRuleNotFoundExceptionuRule {0} not founduerrorN(uNameuArnuEventPatternuScheduleExpressionuStateuDescriptionuRoleArn(
Rt
describe_ruletdictRRRRtresponsetformattRule(RRRRRRR tkeystkR!R"((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pytdescribe�s!3$c
	C@s�td|d|d|d|�}ytg}d}x]|d
k	r�|rRi|d6ni}|j|�}||jdg�7}|jd�}q3W|SWn%tk
r�}	itd|	�d	6SXd
S(u�
    List, with details, all Cloudwatch Event rules visible in the current scope.

    CLI example::

        salt myminion boto_cloudwatch_event.list_rules region=us-east-1
    RRRRuu	NextTokenuRulesuboto3.get_erroruerrorN(RRRRRR(
RRRRRtrett	NextTokentargstrR!((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pyR�s!c
	C@s:y�td|d|d|d|�}|jd|�}g}|r�d|kr�d}xX|jd�D]G}	|jtg|D]'}
|
|	krz|
|	j|
�f^qz��qdWi|d6Sidd6SWnmtk
r5}td|�}|jjd
i�jd�dkr idj	|�d6Sitd|�d6SXdS(u�
    Given a rule name list the targets of that rule.

    Returns a dictionary of interesting properties.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudwatch_event.list_targets myrule

    RRRRR7uTargetsuIduArnuInputu	InputPathutargetsuboto3.get_erroruErroruCodeuRuleNotFoundExceptionuRule {0} not founduerrorN(uIduArnuInputu	InputPath(
Rtlist_targets_by_ruleRtappendR4RRRR5R6(
R7RRRRRttargetsR;R8ttargetR9R!R"((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pytlist_targets�s !E$c
	C@sy�td|d|d|d|�}t|tj�rNtjjj|�}n|jd|d|�}|r�|j	dd�dkr�i|j	d	�d
6Sidd
6SWnmtk
r}td|�}	|j
j	di�j	d
�dkr�idj|�d6Sitd|�d6SXdS(u�
    Add the given targets to the given rule

    Returns a dictionary describing any failures.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudwatch_event.put_targets myrule [{'Id': 'target1', 'Arn': 'arn:***'}]

    RRRRR7tTargetsuFailedEntryCountiu
FailedEntriesufailuresuboto3.get_erroruErroruCodeuRuleNotFoundExceptionuRule {0} not founduerrorN(Rt
isinstanceRtstring_typesRRtjsontloadstput_targetsRRRRR5R6(
R7RDRRRRRtfailuresR!R"((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pyRI
s!$c
	C@sy�td|d|d|d|�}t|tj�rNtjjj|�}n|jd|d|�}|r�|j	dd�dkr�i|j	d	d
�d6Sidd6SWnmtk
r}td|�}	|j
j	d
i�j	d�dkridj|�d6Sitd|�d6SXdS(u�
    Given a rule name remove the named targets from the target list

    Returns a dictionary describing any failures.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudwatch_event.remove_targets myrule ['Target1']

    RRRRR7tIdsuFailedEntryCountiu
FailedEntriesiufailuresuboto3.get_erroruErroruCodeuRuleNotFoundExceptionuRule {0} not founduerrorN(RRERRFRRRGRHtremove_targetsRRRRR5R6(
R7RKRRRRRRJR!R"((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pyRL+s!$(%t__doc__t
__future__RRRtloggingtsalt.utils.compatRtsalt.utils.jsontsalt.utils.versionst	getLoggerRR&tbototboto3tbotocore.exceptionsRtsetLeveltCRITICALRR
tImportErrorR!Rtsalt.extRR	RRR#R0R2R:RRCRIRL(((sF/usr/lib/python2.7/site-packages/salt/modules/boto_cloudwatch_event.pyt<module>+s<

		$ !

Zerion Mini Shell 1.0