�
�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
m Z d d l m
Z
d d
l m Z m Z d Z d � Z d � Z e d k r� e � n d
S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys~
module: nexmo
short_description: Send a SMS via nexmo
description:
- Send a SMS message via nexmo
version_added: 1.6
author: "Matt Martz (@sivel)"
options:
api_key:
description:
- Nexmo API Key
required: true
api_secret:
description:
- Nexmo API Secret
required: true
src:
description:
- Nexmo Number to send from
required: true
dest:
description:
- Phone number(s) to send SMS message to
required: true
msg:
description:
- Message to text to send. Messages longer than 160 characters will be
split into multiple messages
required: true
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'
extends_documentation_fragment:
- url
s�
- name: Send notification message via Nexmo
nexmo:
api_key: 640c8a53
api_secret: 0ce239a6
src: 12345678901
dest:
- 10987654321
- 16789012345
msg: '{{ inventory_hostname }} completed'
delegate_to: localhost
N( t urlencode( t
AnsibleModule( t fetch_urlt url_argument_specs https://rest.nexmo.com/sms/jsonc
C` s� t � } t � } i | j j d � d 6| j j d � d 6| j j d � d 6| j j d � d 6} xx| j j d � D]d} | | d <d t t | � f } t d
d � } t | | d | �\ } } | d
d k r� | j | � t d t � | | <n y t j
| � | | <Wn1 t k
rD| j | � t d t � | | <nZ XxV | | d D]F } t | d
� d k rT| j | � t d t | | � | | <qTqTW| r�d } n d } | j
d t | � d | d t d | � qw Wd S( Nt api_keyt
api_secrett srct fromt msgt textt destt tos %s?%st Accepts application/jsont headersR i� t failedt messagesi s One or messages failed to sendt t changedt responses( t listt dictt paramst gett NEXMO_APIR R
t appendt Truet jsont loadt Exceptiont intt exit_jsont boolt False(
t moduleR R R t numbert urlR t responset infot message( ( sF /usr/lib/python2.7/site-packages/ansible/modules/notification/nexmo.pyt send_msgM s:
! !c C` s� t � } | j t d t d t d t � d t d t d t � d t d t d d � d t d t d d � d
t d t � � � t d | � } t | � d S( NR t requiredt no_logR
R t typeR% R R R t
argument_spec( R t updateR R! R R/ ( R3 R) ( ( sF /usr/lib/python2.7/site-packages/ansible/modules/notification/nexmo.pyt maint s t __main__( t
__future__R R R R2 t
__metaclass__t ANSIBLE_METADATAt
DOCUMENTATIONt EXAMPLESR"