
    Vh                     ~    d dl mZmZmZ eZ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        yy)    )absolute_importdivisionprint_functionaA  
module: nexmo
short_description: Send a SMS using nexmo
description:
  - Send a SMS message using nexmo.
author: "Matt Martz (@sivel)"
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  api_key:
    type: str
    description:
      - Nexmo API Key.
    required: true
  api_secret:
    type: str
    description:
      - Nexmo API Secret.
    required: true
  src:
    type: int
    description:
      - Nexmo Number to send from.
    required: true
  dest:
    type: list
    elements: int
    description:
      - Phone number(s) to send SMS message to.
    required: true
  msg:
    type: str
    description:
      - Message to text to send. Messages longer than 160 characters will be split into multiple messages.
    required: true
  validate_certs:
    description:
      - If V(false), SSL certificates will not be validated. This should only be used on personally controlled sites using
        self-signed certificates.
    type: bool
    default: true
extends_documentation_fragment:
  - ansible.builtin.url
  - community.general.attributes
a  
- name: Send notification message via Nexmo
  community.general.nexmo:
    api_key: 640c8a53
    api_secret: 0ce239a6
    src: 12345678901
    dest:
      - 10987654321
      - 16789012345
    msg: '{{ inventory_hostname }} completed'
  delegate_to: localhost
N)	urlencode)AnsibleModule)	fetch_urlurl_argument_speczhttps://rest.nexmo.com/sms/jsonc                 `   t               }t               }| j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  d      d}| j                  j                  d      D ]  }||d<   t        dt        |      }t        d	
      }t        | ||      \  }}|d   dk7  r |j                  |       t        d      ||<   	 t        j                  |      ||<   ||   d   D ]8  }	t        |	d         dk7  s|j                  |       t        dddi||   ||<   : 	 |rd}nd}| j                  t        |      |d|        y # t        $ r# |j                  |       t        d      ||<   Y Sw xY w)Napi_key
api_secretsrcmsg)r   r   fromtextdestto?zapplication/json)Accept)headersstatus   T)failedmessagesr   r   zOne or messages failed to send F)r   r   changed	responses )listdictparamsget	NEXMO_APIr   r   appendjsonloadint	Exception	exit_jsonbool)
moduler   r   r   numberurlr   responseinfomessages
             k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/nexmo.pysend_msgr1   S   s   VFI==$$Y/mm''5!!%(!!%(	C --##F+ .D	"IcN301"63@$>S MM&! $D 1If		O $		( 3If
 %V,Z8 Owx()Q.MM&)(,(ND(NIf<M(NIf%O
 2CCV#u#, 	 	.5.  	2MM&! $D 1If	2s   =F)F-,F-c                      t               } | j                  t        t        dd      t        dd      t        dd      t        ddd      t        d                   t        | 	      }t	        |       y )
NT)requiredno_logr&   )r3   typer   )r3   r5   elements)r3   )r   r   r   r   r   )argument_spec)r	   updater   r   r1   )r7   r*   s     r0   mainr9   z   sk    %'M$t4T$7d/t&5Ad#	
 #F V    __main__)
__future__r   r   r   r5   __metaclass__DOCUMENTATIONEXAMPLESr$   +ansible.module_utils.six.moves.urllib.parser   ansible.module_utils.basicr   ansible.module_utils.urlsr   r	   r"   r1   r9   __name__r   r:   r0   <module>rD      sV    A @/b  A 4 B .	$.N& zF r:   