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

�
���^c@@sedZddlmZmZmZd�Zdd	d	d�Zdd	d	d�Zd�Z	d�Z
d	S(
uk

Manage PagerDuty escalation policies.

Schedules and users can be referenced by pagerduty ID, or by name, or by email address.

For example:

.. code-block:: yaml

    ensure test escalation policy:
        pagerduty_escalation_policy.present:
            - name: bruce test escalation policy
            - escalation_rules:
                - targets:
                    - type: schedule
                      id: 'bruce test schedule level1'
                    - type: user
                      id: 'Bruce Sherrod'
                  escalation_delay_in_minutes: 15
                - targets:
                    - type: schedule
                      id: 'bruce test schedule level2'
                  escalation_delay_in_minutes: 15
                - targets:
                    - type: user
                      id: 'Bruce TestUser1'
                    - type: user
                      id: 'Bruce TestUser2'
                    - type: user
                      id: 'Bruce TestUser3'
                    - type: user
                      id:  'bruce+test4@lyft.com'
                  escalation_delay_in_minutes: 15
i(tabsolute_importtprint_functiontunicode_literalscC@sdtkrdStS(uD
    Only load if the pygerduty module is available in __salt__
    upagerduty_util.get_resourceupagerduty_escalation_policy(t__salt__tFalse(((sK/usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyt__virtual__*su	pagerdutyc
K@sAx|dD]}x�|dD]�}d}|ddkr�tdd|ddd	dgd
|d|d|�}|r�|d}q�n\|dd
kr�tdd|dd	dgd
|d|d|�}|r�|d
d}q�n|dkrtdj|���n||d<qWqWtddd	dgt||||�}	|	S(u9
    Ensure that a pagerduty escalation policy exists.  Will create or update as needed.

    This method accepts as args everything defined in
    https://developer.pagerduty.com/documentation/rest/escalation_policies/create.
    In addition, user and schedule id's will be translated from name (or email address)
    into PagerDuty unique ids.  For example:

    .. code-block:: yaml

    pagerduty_escalation_policy.present:
        - name: bruce test escalation policy
        - escalation_rules:
            - targets:
                - type: schedule
                  id: 'bruce test schedule level1'
                - type: user
                  id: 'Bruce Sherrod'

    In this example, 'Bruce Sherrod' will be looked up and replaced with the
    PagerDuty id (usually a 7 digit all-caps string, e.g. PX6GQL7)

    uescalation_rulesutargetsutypeuuserupagerduty_util.get_resourceuusersuiduemailunametprofilet	subdomaintapi_keyuscheduleu	schedulesuunidentified target: {0}upagerduty_util.resource_presentuescalation_policiesN(tNoneRt	Exceptiontformatt_diff(
RRRtkwargstescalation_rulettargett	target_idtusertscheduletr((sK/usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pytpresent1s@
	
	
		cK@s)tddddg||||�}|S(u
    Ensure that a PagerDuty escalation policy does not exist.
    Accepts all the arguments that pagerduty_escalation_policy.present accepts;
    but ignores all arguments except the name.

    Name can be the escalation policy id or the escalation policy name.
    upagerduty_util.resource_absentuescalation_policiesunameuid(R(RRRR
R((sK/usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pytabsentns
		cC@s�d}x�|j�D]�\}}|dkrJt|�}t||�}n%||j�kret}n
||}||krdj|||�}PqqW|r�|SiSdS(u�helper method to compare salt state info with the PagerDuty API json structure,
    and determine if we need to update.

    returns the dict to pass to the PD API to perform the update, or empty dict if no update.
    uescalation_rulesu{0} {1} {2}N(R	titemst_escalation_rules_to_stringtkeystTrueR(t
state_datatresource_objecttobjects_differtktvtresource_value((sK/usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyRs	
cC@sed}xX|D]P}|dj|d�7}x0|dD]$}|dj|d|d�7}q5Wq
W|S(u8convert escalation_rules dict to a string for comparisonuu!escalation_delay_in_minutes: {0} uescalation_delay_in_minutesutargetsu{0}:{1} utypeuid(R(tescalation_rulestresulttruleR((sK/usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyR�s
&N(t__doc__t
__future__RRRRR	RRRR(((sK/usr/lib/python2.7/site-packages/salt/states/pagerduty_escalation_policy.pyt<module>$s	=	

Zerion Mini Shell 1.0