%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/runners/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/runners/mattermost.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlm	Z	ddl
ZddlmZej
e�ZdZd�Zd�Zd	�Zd
�Zd�Zddddd�Zddddd
�ZdS(u�
Module for sending messages to Mattermost

.. versionadded:: 2017.7.0

:configuration: This module can be used by either passing an api_url and hook
    directly or by specifying both in a configuration profile in the salt
    master/minion config. For example:

    .. code-block:: yaml

        mattermost:
          hook: peWcBiMOS9HrZG15peWcBiMOS9HrZG15
          api_url: https://example.com
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tSaltInvocationErroru
mattermostcC@stS(uY
    Return virtual name of the module.
    :return: The virtual name of the module.
    (t__virtualname__(((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pyt__virtual__'scC@s9tdd�ptdd�}|s5td��n|S(uo
    Retrieves and return the Mattermost's configured hook
    :return:            String: the hook string
    u
config.getumattermost.hookumattermost:hookuNo Mattermost Hook found(t__salt__R(thook((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pyt	_get_hook/s
cC@s9tdd�ptdd�}|s5td��n|S(uu
    Retrieves and return the Mattermost's configured api url
    :return:            String: the api url string
    u
config.getumattermost.api_urlumattermost:api_urluNo Mattermost API URL found(RR(tapi_url((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pyt_get_api_url<s
cC@s$tdd�ptdd�}|S(uj
    Retrieves the Mattermost's configured channel
    :return:            String: the channel string
    u
config.getumattermost.channelumattermost:channel(R(tchannel((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pyt_get_channelIscC@s$tdd�ptdd�}|S(ul
    Retrieves the Mattermost's configured username
    :return:            String: the username string
    u
config.getumattermost.usernameumattermost:username(R(tusername((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pyt
_get_usernameTscC@s	|st�}n|s$t�}n|s6t�}n|sHt�}n|s^tjd�nt�}|rz||d<n|r�||d<nd|d|d<tjd|�tj	j
j|�}tj	jj
d|d|d	td
�j|��}|rtS|SdS(uC
    Send a message to a Mattermost channel.
    :param channel:     The channel name, either will work.
    :param username:    The username of the poster.
    :param message:     The message to send to the Mattermost channel.
    :param api_url:     The Mattermost api url, if not specified in the configuration.
    :param hook:        The Mattermost hook, if not specified in the configuration.
    :return:            Boolean if message was sent successfully.

    CLI Example:

    .. code-block:: bash

        salt-run mattermost.post_message message='Build is done'
    umessage is a required option.uchanneluusernameu```utextuParameters: %sR
Rtdataupayload={0}N(RR	RR
tlogterrortdicttdebugtsalttutilstjsontdumpst
mattermosttquerytstrtformattTrue(tmessageRRR
Rt
parametersRtresult((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pytpost_message_s2	

c	C@s�|st�}n|s$t�}n|s6t�}n|sHt�}n|s^tjd�ntjd|�tjd|d�dj|d�}x7tj	|d�D]"\}}|dj||�7}q�Wt
|||||�}t|�S(u�
    Send an event to a Mattermost channel.
    :param channel:     The channel name, either will work.
    :param username:    The username of the poster.
    :param event:       The event to send to the Mattermost channel.
    :param api_url:     The Mattermost api url, if not specified in the configuration.
    :param hook:        The Mattermost hook, if not specified in the configuration.
    :return:            Boolean if message was sent successfully.
    umessage is a required option.u	Event: %suEvent data: %sudatau
tag: {0}
utagu
{0}: {1}
(RR	RR
RRRRRt	iteritemsR!tbool(	teventRRR
RRtkeytvalueR ((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pyt
post_event�s* 	(t__doc__t
__future__RRRtloggingtsalt.utils.jsonRtsalt.extRtsalt.utils.mattermosttsalt.exceptionsRt	getLoggert__name__RRRR	RR
RtNoneR!R'(((s;/usr/lib/python2.7/site-packages/salt/runners/mattermost.pyt<module>s*		
	
		3

Zerion Mini Shell 1.0