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

�
���^c@@sdZddlmZmZmZddlZddlZddlZddl	m
Zddl	mZ
ddlmZddlZeje�ZdZd�Zddddd	dd
�Zdddd�Zdddd�Zdddd
�Zdddd�Zdddded�ZdS(u�
Module for sending messages to hipchat.

.. versionadded:: 2015.5.0

:configuration: This module can be used by either passing an api key and version
    directly or by specifying both in a configuration profile in the salt
    master/minion config.

    It is possible to use a different API than http://api.hipchat.com,
    by specifying the API URL in config as api_url, or by passing the value directly.

    For example:

    .. code-block:: yaml

        hipchat:
          api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15
          api_version: v1

    Custom API Example:

    .. code-block:: yaml

        hipchat:
          api_url: http://api.hipchat.myteam.com
          api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15
          api_version: v2
i(tabsolute_importtprint_functiontunicode_literalsN(turljoin(t	urlencode(trangeuhipchatcC@stS(uZ
    Return virtual name of the module.

    :return: The virtual name of the module.
    (t__virtualname__(((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pyt__virtual__5suGETcC@s�i}i}|sUy#tdd�}	|	jd�}WqUtttfk
rQqUXn|sc|r�yDtdd�}	|s�|	jd�}n|s�|	jd�}nWq�tttfk
r�tjd�tSXn|r�dj|�}nd}iiid	d
6dd6d6id
d
6dd6d6idd
6dd6d6d6iidd
6dd6d6idd
6dd6d6i|d
6d-d6d6d6}
d}|r�|}nt
||d�}|
j|�j|�jd
�}
t
||
t�}|dkrPd|d<||d<|dkrd|d<n|r�|jdd-�r>d |d<nt|�}q�nj|dkr�d!j|�|d"<|r�tj
jj|�}n|dkr�d#|d<q�ntjd$�tStj
jj||d%|d&|d'td(td)|d*t�}|jdd-�tjjjjjkrZ|
j|�j|�jd�}|jd+i�j|d-�S|jdd-�tjjjjjkr�|dkr�tStj|�tj|�tj|�tj|�|jd,�r�tj|�ntSd-S(.u�
    HipChat object method function to construct and execute on the API URL.

    :param api_url:     The HipChat API URL.
    :param api_key:     The HipChat api key.
    :param function:    The HipChat api function to perform.
    :param api_version: The HipChat api version (v1 or v2).
    :param method:      The HTTP method, e.g. GET or POST.
    :param data:        The data to be sent for POST method.
    :return:            The json response from the API call or False.
    u
config.optionuhipchatuapi_urluapi_keyuapi_versionu$No HipChat api key or version found.uroom/{0}/notificationuroom/0/notificationu
rooms/listurequesturoomsuresponseu
users/listuusersu
rooms/messageustatusumessageuv1uroomuitemsuuseruv2uhttps://api.hipchat.comu/ujsonuformatu
auth_tokenuPOSTu!application/x-www-form-urlencodeduContent-Typeunotifyiu
Bearer {0}u
Authorizationuapplication/jsonuUnsupported HipChat API versiontparamstdatatdecodetstatustheader_dicttoptsudictuerrorN(t__salt__tgett	NameErrortKeyErrortAttributeErrortlogterrortFalsetformattNonet_urljoint
_urlencodetsalttutilstjsontdumpsthttptquerytTruet__opts__texttsixtmovesthttp_clienttOKt
NO_CONTENTtdebug(tfunctiontapi_urltapi_keytapi_versiontroom_idtmethodR	theaderstquery_paramstoptionsthipchat_functionstuse_api_urltbase_urltpathturltresulttresponse((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pyt_query>s�
	!




	'!'



c	C@s5tddd|d|d|�}tjd|�|S(u�
    List all HipChat rooms.

    :param api_url: The HipChat API URL, if not specified in the configuration.
    :param api_key: The HipChat admin api key.
    :param api_version: The HipChat api version, if not specified in the configuration.
    :return: The room list.

    CLI Example:

    .. code-block:: bash

        salt '*' hipchat.list_rooms

        salt '*' hipchat.list_rooms api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1
    R)uroomsR*R+R,ufoo %s(R9RR((R*R+R,tfoo((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pyt
list_rooms�s	c	C@stddd|d|d|�S(u�
    List all HipChat users.

    :param api_url: The HipChat API URL, if not specified in the configuration.
    :param api_key: The HipChat admin api key.
    :param api_version: The HipChat api version, if not specified in the configuration.
    :return: The user list.

    CLI Example:

    .. code-block:: bash

        salt '*' hipchat.list_users

        salt '*' hipchat.list_users api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1
    R)uusersR*R+R,(R9(R*R+R,((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pyt
list_users�scC@sdtd|d|d|�}|r`x<tdt|��D]"}||d|kr7||Sq7WntS(u(
    Find a room by name and return it.

    :param name:    The room name.
    :param api_url: The HipChat API URL, if not specified in the configuration.
    :param api_key: The HipChat admin api key.
    :param api_version: The HipChat api version, if not specified in the configuration.
    :return:        The room object.

    CLI Example:

    .. code-block:: bash

        salt '*' hipchat.find_room name="Development Room"

        salt '*' hipchat.find_room name="Development Room" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1
    R*R+R,iuname(R;RtlenR(tnameR*R+R,troomstx((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pyt	find_room�s	cC@sdtd|d|d|�}|r`x<tdt|��D]"}||d|kr7||Sq7WntS(u0
    Find a user by name and return it.

    :param name:        The user name.
    :param api_url:     The HipChat API URL, if not specified in the configuration.
    :param api_key:     The HipChat admin api key.
    :param api_version: The HipChat api version, if not specified in the configuration.
    :return:            The user object.

    CLI Example:

    .. code-block:: bash

        salt '*' hipchat.find_user name="Thomas Hatch"

        salt '*' hipchat.find_user name="Thomas Hatch" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15 api_version=v1
    R*R+R,iuname(R<RR=R(R>R*R+R,tusersR@((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pyt	find_users	uyellowc
C@s�t�}||d<|d |d<|d |d<d|d<||d<||d	<td
dd|d|d
|d|ddd|�}	|	r�tStSdS(u�
    Send a message to a HipChat room.

    :param room_id:     The room id or room name, either will work.
    :param message:     The message to send to the HipChat room.
    :param from_name:   Specify who the message is from.
    :param api_url:     The HipChat api URL, if not specified in the configuration.
    :param api_key:     The HipChat api key, if not specified in the configuration.
    :param api_version: The HipChat api version, if not specified in the configuration.
    :param color:       The color for the message, default: yellow.
    :param notify:      Whether to notify the room, default: False.
    :return:            Boolean if message was sent successfully.

    CLI Example:

    .. code-block:: bash

        salt '*' hipchat.send_message room_id="Development Room" message="Build is done" from_name="Build Server"

        salt '*' hipchat.send_message room_id="Development Room" message="Build failed" from_name="Build Server" color="red" notify=True
    uroom_idiufromi'umessageutextumessage_formatucolorunotifyR)R*R+R,R-R.uPOSTR	N(tdictR9R R(
R-tmessaget	from_nameR*R+R,tcolortnotifyt
parametersR7((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pytsend_message3s"	



	(t__doc__t
__future__RRRtloggingtsalt.utils.httpRtsalt.utils.jsontsalt.ext.six.moves.urllib.parseRRRRtsalt.ext.six.movesRtsalt.ext.six.moves.http_clientt	getLoggert__name__RRRRR9R;R<RARCRRJ(((s8/usr/lib/python2.7/site-packages/salt/modules/hipchat.pyt<module>sD	
}

Zerion Mini Shell 1.0