�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d d
l Z d d
l
Z
d d l m Z d d l
m Z d d
l m Z d d l m Z d d l m Z d Z d Z d Z d d e e d � Z d d e e d � Z d � Z e d k re � n d
S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont stableinterfacet statust communityt supported_bys�
---
module: hipchat
version_added: "1.2"
short_description: Send a message to Hipchat.
description:
- Send a message to a Hipchat room, with options to control the formatting.
options:
token:
description:
- API token.
required: true
room:
description:
- ID or name of the room.
required: true
from:
description:
- Name the message will appear to be sent from. Max length is 15
characters - above this it will be truncated.
default: Ansible
msg:
description:
- The message body.
required: true
color:
description:
- Background color for the message.
default: yellow
choices: [ "yellow", "red", "green", "purple", "gray", "random" ]
msg_format:
description:
- Message format.
default: text
choices: [ "text", "html" ]
notify:
description:
- If true, a notification will be triggered for users in the room.
type: bool
default: 'yes'
validate_certs:
description:
- If C(no), SSL certificates will not be validated. This should only be used
on personally controlled sites using self-signed certificates.
type: bool
default: 'yes'
version_added: 1.5.1
api:
description:
- API url if using a self-hosted hipchat server. For Hipchat API version
2 use the default URI with C(/v2) instead of C(/v1).
default: 'https://api.hipchat.com/v1'
version_added: 1.6.0
author:
- Shirou Wakayama (@shirou)
- Paul Bourdel (@pb8226)
s�
- hipchat:
room: notif
msg: Ansible task finished
# Use Hipchat API version 2
- hipchat:
api: https://api.hipchat.com/v2/
token: OAUTH2_TOKEN
room: notify
msg: Ansible task finished
N( t
AnsibleModule( t urlencode( t pathname2url( t to_native( t fetch_urls https://api.hipchat.com/v1s /rooms/messages /room/{id_or_name}/notificationt textt yellowc C` s� i } | | d <| d | d <| | d <| | d <| | d <| | d <t | � | d <| t d | }
t | � } | j r� | j d
t � n t | |
d | �\ } }
|
d d
k r� | j � S| j d d t |
d � � d S( s$ sending message to hipchat v1 servert room_idi t fromt messaget message_formatt colort apit notifys ?auth_token=%st changedt dataR i� t msgs( failed to send message, return status=%sN(
t intt
MSG_URI_V1R t
check_modet exit_jsont FalseR t readt fail_jsont str( t modulet tokent roomt msg_fromR t
msg_formatR R R t paramst urlR t responset info( ( sH /usr/lib/python2.7/site-packages/ansible/modules/notification/hipchat.pyt send_msg_v1m s
c C` s� i d | d 6d d 6} t � }
| |
d <| |
d <| |
d <| |
d <| t } | j d t | � � } t j |
� }
| j r� | j d
t � n t | | d |
d | d
d �\ } } | d d k r� | j
� S| j d d t | d � � d S( s$ sending message to hipchat v2 servers Bearer %st
Authorizations application/jsons Content-TypeR R R R s {id_or_name}R R t headerst methodt POSTR i� i� R s( failed to send message, return status=%sN( i� i� (
t dictt
NOTIFY_URI_V2t replaceR
t jsont dumpsR R R R R R R ( R! R"