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

�
���^c@@sqdZddlmZmZmZddlZyddlZeZWne	k
r]e
ZnXddlmZdZ
eje�ZdZdZdd	d
dgZeZidd
6dd6Zd�Zd�Zddddd�Zd�Zd�Zdddd�Zdddddd�Zdddddd�Zddddddd�Zddddddd�Z dS(uM
StatusPage
==========

Handle requests for the StatusPage_ API_.

.. _StatusPage: https://www.statuspage.io/
.. _API: http://doers.statuspage.io/api/v1/

In the minion configuration file, the following block is required:

.. code-block:: yaml

  statuspage:
    api_key: <API_KEY>
    page_id: <PAGE_ID>

.. versionadded:: 2017.7.0
i(tabsolute_importtunicode_literalstprint_functionN(tsixu
statuspageuhttps://api.statuspage.ioiuidu
created_atu
updated_atupage_idi�uPOSTi�uDELETEcC@sttkrtdfStS(u2
    Return the execution module virtualname.
    u,The requests python package is not installed(tHAS_REQUESTStFalset__virtualname__(((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyt__virtual__Bs
cC@sitd6dd6dd6S(u&
    Default dictionary returned.
    uresultuucommentuoutN(RtNone(((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyt_default_retKsc	C@s�tdd�}|si}ni|p:|jd�p:td6|pP|jd�d6|pf|jd�d6|p�|jd�p�td6S(u7
    Retrieve the API params from the config file.
    u
config.getu
statuspageuapi_urlupage_iduapi_page_iduapi_keyuapi_version(t__salt__tgettBASE_URLtDEFAULT_VERSION(tapi_urltpage_idtapi_keytapi_versiontstatuspage_cfg((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyt_get_api_paramsVs	cC@s<t|dtjtjf�o;t|dtjtjf�S(uB
    Validate the API params as specified in the config file.
    uapi_page_iduapi_key(t
isinstanceRtstring_typest	text_type(tparams((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyt_validate_api_paramshscC@sidjd|d�d6S(u'
    Return HTTP headers required.
    u
OAuth {oauth}toauthuapi_keyu
Authorization(tformat(R((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyt_get_headersqsuGETcC@s�tj||d|d|�}t�}tj|d�}|j|krr|ji|j�jdd�d6�|S|jitd6|dkr�|j�nd
d	6�|S(uE
    Make the HTTP request and return the body as python object.
    theaderstdatai�uerroruucommenturesultuDELETEuoutN(
trequeststrequestR	tMETHOD_OK_STATUSRtstatus_codetupdatetjsontTrueR(turltmethodRRtreqtrett	ok_status((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyt
_http_requestzs					#u	incidentsc	K@s0td|d|d|d|�}t|�sYtjd�tj|�itd6dd6S|d	 }t|�}d
jd|dd
|dd|dd|�}	i}
xltj|�D][\}}|dks�|j
d�s�|tkr�q�ndjd|d|�}
||
|
<q�Wt|	ddd|d|
�S(u8
    Insert a new entry under a specific endpoint.

    endpoint: incidents
        Insert under this specific endpoint.

    page_id
        Page ID. Can also be specified in the config file.

    api_key
        API key. Can also be specified in the config file.

    api_version: 1
        API version. Can also be specified in the config file.

    api_url
        Custom API URL in case the user has a StatusPage service running in a custom environment.

    CLI Example:

    .. code-block:: bash

        salt 'minion' statuspage.create endpoint='components' name='my component' group_id='993vgplshj12'

    Example output:

    .. code-block:: bash

        minion:
            ----------
            comment:
            out:
                ----------
                created_at:
                    2017-01-05T19:35:27.135Z
                description:
                    None
                group_id:
                    993vgplshj12
                id:
                    mjkmtt5lhdgc
                name:
                    my component
                page_id:
                    ksdhgfyiuhaa
                position:
                    7
                status:
                    operational
                updated_at:
                    2017-01-05T19:35:27.135Z
            result:
                True
    RRRRuInvalid API params.uresultu'Invalid API params. See log for detailsucommenti����u5{base_url}/v{version}/pages/{page_id}/{endpoint}.jsontbase_urluapi_urltversionuapi_versionuapi_page_idtendpointu__u{endpoint_sg}[{karg}]tendpoint_sgtkargR&uPOSTRRN(
RRtlogterrorRRRRt	iteritemsRt
startswithtINSERT_FORBIDDEN_FILEDSR*(R-RRRRtkwargsRR.Rt
create_urltchange_requestR/twargtchange_request_key((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pytcreate�s:<	


	


	'			c	C@s�td|d|d|d|�}t|�sYtjd�tj|�itd6dd6St|�}d	jd
|dd|d
d|dd|�}t|d|�S(u�
    Retrieve a specific endpoint from the Statuspage API.

    endpoint: incidents
        Request a specific endpoint.

    page_id
        Page ID. Can also be specified in the config file.

    api_key
        API key. Can also be specified in the config file.

    api_version: 1
        API version. Can also be specified in the config file.

    api_url
        Custom API URL in case the user has a StatusPage service running in a custom environment.

    CLI Example:

    .. code-block:: bash

        salt 'minion' statuspage.retrieve components

    Example output:

    .. code-block:: bash

        minion:
            ----------
            comment:
            out:
                |_
                  ----------
                  backfilled:
                      False
                  created_at:
                      2015-01-26T20:25:02.702Z
                  id:
                      kh2qwjbheqdc36
                  impact:
                      major
                  impact_override:
                      None
                  incident_updates:
                      |_
                        ----------
                        affected_components:
                            None
                        body:
                            We are currently investigating this issue.
                        created_at:
                            2015-01-26T20:25:02.849Z
                        display_at:
                            2015-01-26T20:25:02.849Z
                        id:
                            zvx7xz2z5skr
                        incident_id:
                            kh2qwjbheqdc36
                        status:
                            investigating
                        twitter_updated_at:
                            None
                        updated_at:
                            2015-01-26T20:25:02.849Z
                        wants_twitter_update:
                            False
                  monitoring_at:
                      None
                  name:
                      just testing some stuff
                  page_id:
                      ksdhgfyiuhaa
                  postmortem_body:
                      None
                  postmortem_body_last_updated_at:
                      None
                  postmortem_ignored:
                      False
                  postmortem_notified_subscribers:
                      False
                  postmortem_notified_twitter:
                      False
                  postmortem_published_at:
                      None
                  resolved_at:
                      None
                  scheduled_auto_completed:
                      False
                  scheduled_auto_in_progress:
                      False
                  scheduled_for:
                      None
                  scheduled_remind_prior:
                      False
                  scheduled_reminded_at:
                      None
                  scheduled_until:
                      None
                  shortlink:
                      http://stspg.io/voY
                  status:
                      investigating
                  updated_at:
                      2015-01-26T20:25:13.379Z
            result:
                True
    RRRRuInvalid API params.uresultu'Invalid API params. See log for detailsucommentu5{base_url}/v{version}/pages/{page_id}/{endpoint}.jsonR+uapi_urlR,uapi_versionuapi_page_idR-R(RRR0R1RRRR*(R-RRRRRRtretrieve_url((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pytretrieve�s$q	

	


		cK@sj|d }|s>tjd|�itd6djd|�d6Std|d|d	|d
|�}t|�s�tjd�tj|�itd6dd6St|�}	d
jd|dd|dd|dd|d|�}
i}xltj|�D][\}}
|
dks�|j
d�s�|tkr(q�ndjd|d|�}|
||<q�Wt|
ddd|	d|�S(u5
    Update attribute(s) of a specific endpoint.

    id
        The unique ID of the enpoint entry.

    endpoint: incidents
        Endpoint name.

    page_id
        Page ID. Can also be specified in the config file.

    api_key
        API key. Can also be specified in the config file.

    api_version: 1
        API version. Can also be specified in the config file.

    api_url
        Custom API URL in case the user has a StatusPage service running in a custom environment.

    CLI Example:

    .. code-block:: bash

        salt 'minion' statuspage.update id=dz959yz2nd4l status=resolved

    Example output:

    .. code-block:: bash

        minion:
            ----------
            comment:
            out:
                ----------
                created_at:
                    2017-01-03T15:25:30.718Z
                description:
                    None
                group_id:
                    993vgplshj12
                id:
                    dz959yz2nd4l
                name:
                    Management Portal
                page_id:
                    xzwjjdw87vpf
                position:
                    11
                status:
                    resolved
                updated_at:
                    2017-01-05T15:34:27.676Z
            result:
                True
    i����u
Invalid %s IDuresultu$Please specify a valid {endpoint} IDR-ucommentRRRRuInvalid API params.u'Invalid API params. See log for detailsu:{base_url}/v{version}/pages/{page_id}/{endpoint}/{id}.jsonR+uapi_urlR,uapi_versionuapi_page_idtidu__u{endpoint_sg}[{karg}]R.R/R&uPATCHRRN(
R0R1RRRRRRR2RR3tUPDATE_FORBIDDEN_FILEDSR*(R-R=RRRRR5R.RRt
update_urlR7R/R8R9((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyR"}sF@
	

	


	'			c
C@s�td|d|d|d|�}t|�sYtjd�tj|�itd6dd6S|d	 }|s�tjd
|�itd6djd|�d6St|�}d
jd|dd|dd|dd|d|�}	t|	ddd|�S(u�
    Remove an entry from an endpoint.

    endpoint: incidents
        Request a specific endpoint.

    page_id
        Page ID. Can also be specified in the config file.

    api_key
        API key. Can also be specified in the config file.

    api_version: 1
        API version. Can also be specified in the config file.

    api_url
        Custom API URL in case the user has a StatusPage service running in a custom environment.

    CLI Example:

    .. code-block:: bash

        salt 'minion' statuspage.delete endpoint='components' id='ftgks51sfs2d'

    Example output:

    .. code-block:: bash

        minion:
            ----------
            comment:
            out:
                None
            result:
                True
    RRRRuInvalid API params.uresultu'Invalid API params. See log for detailsucommenti����u
Invalid %s IDu$Please specify a valid {endpoint} IDR-u:{base_url}/v{version}/pages/{page_id}/{endpoint}/{id}.jsonR+uapi_urlR,uapi_versionuapi_page_idR=R&uDELETER(RRR0R1RRRR*(
R-R=RRRRRR.Rt
delete_url((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pytdelete�s4*	


	


		(!t__doc__t
__future__RRRtloggingRR$RtImportErrorRtsalt.extRRt	getLoggert__file__R0RR
R>R4R RR	RRRRR*R:R<R"RA(((s;/usr/lib/python2.7/site-packages/salt/modules/statuspage.pyt<module>sj


	
						
Z�d

Zerion Mini Shell 1.0