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

�
���^c@@s�dZddlmZmZmZddlmZddlZeZ	yddl
Z
Wnek
rmeZ	nXdZ
d�Zd�Zdddddddded�	Zddddd	�Zdddddddddddd
�ZdS(u%
An execution module that interacts with the Datadog API

The following parameters are required for all functions.

api_key
    The datadog API key

app_key
    The datadog application key

Full argument reference is available on the Datadog API reference page
https://docs.datadoghq.com/api/
i(tabsolute_importtprint_functiontunicode_literals(tSaltInvocationErrorNudatadogcC@str
dSd}t|fSdS(Nudatadogu<Unable to import the python datadog module. Is it installed?(tHAS_DATADOGtFalse(tmessage((s</usr/lib/python2.7/site-packages/salt/modules/datadog_api.pyt__virtual__!scC@s[|dkrtd��n|dkr6td��ni|d6|d6}tj|�dS(u'
    Initialize Datadog connection
    uapi_key must be specifieduapp_key must be specifieduapi_keyuapp_keyN(tNoneRtdatadogt
initialize(tapi_keytapp_keytoptions((s</usr/lib/python2.7/site-packages/salt/modules/datadog_api.pyt_initialize_connection)s
c

C@sitd6dd6dd6}
|dkr6td��n|dkrQtd��n|	tkrut|
d<d|
d<|
St||�y@tjjjd|d	|d
|d|d|d
|d|�}Wn"t	k
r�d}||
d<|
SX||
d<d|j
�krt|
d<d|
d<n|
S(u
    Schedule downtime for a scope of monitors.

    CLI Example:

    .. code-block:: bash

        salt-call datadog.schedule_downtime 'host:app2' \
                                            stop=$(date --date='30 minutes' +%s) \
                                            app_key='0123456789' \
                                            api_key='9876543210'

    Optional arguments

    :param monitor_id:      The ID of the monitor
    :param start:           Start time in seconds since the epoch
    :param end:             End time in seconds since the epoch
    :param message:         A message to send in a notification for this downtime
    :param recurrence:      Repeat this downtime periodically
    :param timezone:        Specify the timezone
    uresulturesponseuucommentuapi_key must be specifieduapp_key must be specifiedu2A schedule downtime API call would have been made.tscopet
monitor_idtstarttendRt
recurrencettimezoneuRUnexpected exception in Datadog Schedule Downtime API call. Are your keys correct?uactiveuSuccessfully scheduled downtimeN(RRRtTrueRR	tapitDowntimetcreatet
ValueErrortkeys(
RRRRRRRRRttesttrettresponsetcomment((s</usr/lib/python2.7/site-packages/salt/modules/datadog_api.pytschedule_downtime8s:










cC@sG|dkrtd��n|dkr6td��nt||�itd6dd6dd6}|r�tjjj|�}||d<|s�t|d<d|d<n|S|r7i|d6|d	6|d
6}t	j
dd|�}|jd
krt|d<|j�|d<d|d<n#|j
|d<dj|j�|d<|Std��|S(u�
    Cancel a downtime by id or by scope.

    CLI Example:

    .. code-block:: bash

        salt-call datadog.cancel_downtime scope='host:app01' \
                                          api_key='0123456789' \
                                          app_key='9876543210'`

    Arguments - Either scope or id is required.

    :param id:      The downtime ID
    :param scope:   The downtime scope
    uapi_key must be specifieduapp_key must be specifieduresulturesponseuucommentuSuccessfully cancelled downtimeuapi_keyuapplication_keyuscopeu9https://app.datadoghq.com/api/v1/downtime/cancel/by_scopetparamsi�uStatus Code: {}u$One of id or scope must be specifiedN(RRRRR	RRtdeleteRtrequeststposttstatus_codetjsonttexttformat(RRRtidRRR ((s</usr/lib/python2.7/site-packages/salt/modules/datadog_api.pytcancel_downtime{s@






	


cC@s1t||�|dkr(td��n|dkrCtd��n|dkrdd}t|��nitd6dd	6d
d6}yLtjjjd|d
|d|d|d|d|d|d|	d|
�	}
Wn"tk
r�d}||d<|SX|
|d	<d|
j	�kr#t
|d<d|d<n
d|d<|S(u�
    Post an event to the Datadog stream.

    CLI Example

    .. code-block:: bash

        salt-call datadog.post_event api_key='0123456789' \
                                     app_key='9876543210' \
                                     title='Salt Highstate' \
                                     text="Salt highstate was run on $(salt-call grains.get id)" \
                                     tags='["service:salt", "event:highstate"]'

    Required arguments

    :param title:   The event title. Limited to 100 characters.
    :param text:    The body of the event. Limited to 4000 characters. The text
                    supports markdown.

    Optional arguments

    :param date_happened:       POSIX timestamp of the event.
    :param priority:            The priority of the event ('normal' or 'low').
    :param host:                Host name to associate with the event.
    :param tags:                A list of tags to apply to the event.
    :param alert_type:          "error", "warning", "info" or "success".
    :param aggregation_key:     An arbitrary string to use for aggregation,
                                max length of 100 characters.
    :param source_type_name:    The type of event being posted.
    utitle must be specifiedutext must be specifieduerroruwarninguinfousuccessuBalert_type must be one of "error", "warning", "info", or "success"uresulturesponseuucommentttitleR&t
date_happenedtprioritythostttagst
alert_typetaggregation_keytsource_type_nameuKUnexpected exception in Datadog Post Event API call. Are your keys correct?ustatusuSuccessfully sent eventuError in posting event.N(Nuerroruwarninguinfousuccess(RRRRR	RtEventRRRR(RRR*R&R+R,R-R.R/R0R1RRRR((s</usr/lib/python2.7/site-packages/salt/modules/datadog_api.pyt
post_event�s>)









(t__doc__t
__future__RRRtsalt.exceptionsRR"RRR	tImportErrorRt__virtualname__RRRRR)R3(((s</usr/lib/python2.7/site-packages/salt/modules/datadog_api.pyt<module>sF

		:9

Zerion Mini Shell 1.0