
    VhL                     f    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ d Zd Zed	k(  r e        y
y
)    )absolute_importdivisionprint_functiona  
module: cisco_webex
short_description: Send a message to a Cisco Webex Teams Room or Individual
description:
  - Send a message to a Cisco Webex Teams Room or Individual with options to control the formatting.
author: Drew Rusell (@drew-russell)
notes:
  - The O(recipient_type) must be valid for the supplied O(recipient_id).
  - Full API documentation can be found at U(https://developer.webex.com/docs/api/basics).
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none

options:

  recipient_type:
    description:
      - The request parameter you would like to send the message to.
      - Messages can be sent to either a room or individual (by ID or E-Mail).
    required: true
    choices: ['roomId', 'toPersonEmail', 'toPersonId']
    type: str

  recipient_id:
    description:
      - The unique identifier associated with the supplied O(recipient_type).
    required: true
    type: str

  msg_type:
    description:
      - Specifies how you would like the message formatted.
    default: text
    choices: ['text', 'markdown']
    type: str
    aliases: ['message_type']

  personal_token:
    description:
      - Your personal access token required to validate the Webex Teams API.
    required: true
    aliases: ['token']
    type: str

  msg:
    description:
      - The message you would like to send.
    required: true
    type: str
a  
# Note: The following examples assume a variable file has been imported
# that contains the appropriate information.

- name: Cisco Webex Teams - Markdown Message to a Room
  community.general.cisco_webex:
    recipient_type: roomId
    recipient_id: "{{ room_id }}"
    msg_type: markdown
    personal_token: "{{ token }}"
    msg: "**Cisco Webex Teams Ansible Module - Room Message in Markdown**"

- name: Cisco Webex Teams - Text Message to a Room
  community.general.cisco_webex:
    recipient_type: roomId
    recipient_id: "{{ room_id }}"
    msg_type: text
    personal_token: "{{ token }}"
    msg: "Cisco Webex Teams Ansible Module - Room Message in Text"

- name: Cisco Webex Teams - Text Message by an Individuals ID
  community.general.cisco_webex:
    recipient_type: toPersonId
    recipient_id: "{{ person_id}}"
    msg_type: text
    personal_token: "{{ token }}"
    msg: "Cisco Webex Teams Ansible Module - Text Message to Individual by ID"

- name: Cisco Webex Teams - Text Message by an Individuals E-Mail Address
  community.general.cisco_webex:
    recipient_type: toPersonEmail
    recipient_id: "{{ person_email }}"
    msg_type: text
    personal_token: "{{ token }}"
    msg: "Cisco Webex Teams Ansible Module - Text Message to Individual by E-Mail"
a  
status_code:
  description:
    - The Response Code returned by the Webex Teams API.
    - Full Response Code explanations can be found at U(https://developer.webex.com/docs/api/basics).
  returned: always
  type: int
  sample: 200

message:
  description:
    - The Response Message returned by the Webex Teams API.
    - Full Response Code explanations can be found at U(https://developer.webex.com/docs/api/basics).
  returned: always
  type: str
  sample: OK (585 bytes)
)AnsibleModule)	fetch_urlc                 d   i }| j                   }dj                  |d         dd}| j                  rd}d}n%d}|d   |d	   |d
   |d   i}| j                  |      }t	        | |||      \  }}|d   }|d   }	|dk7  rd|d<   ||d<   |	|d<   |S d|d<   ||d<   | j                  rd|d<   |S |	|d<   |S )zWhen check mode is specified, establish a read only connection, that does not return any user specific
    data, to validate connectivity. In regular mode, send a message to a Cisco Webex Teams Room or Individualz
Bearer {0}personal_tokenzapplication/json)Authorizationzcontent-typez"https://webexapis.com/v1/people/meNz!https://webexapis.com/v1/messagesrecipient_typerecipient_idmsg_typemsg)dataheadersstatus   Tfailedstatus_codemessageFzAuthentication Successful.)paramsformat
check_modejsonifyr   )
moduleresultsansibler   urlpayloadresponseinfor   r   s
             q/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/cisco_webex.py	webex_msgr"   }   s   
 GmmG &,,W5E-FG*G
 2 2 $%w~'>J

 ..)vs'JNHdx.K
u+C c !, 	 N "!,!=GI N "%GIN    c                      t        t        t        dg d      t        dd      t        dddgddg	      t        ddd
g      t        d            d      } t        |       } | j                  di | y)zAnsible main. T)roomIdtoPersonEmail
toPersonId)requiredchoices)r(   no_logFtextmessage_typemarkdown)r(   defaultaliasesr)   token)r(   r*   r/   )r(   )r   r   r   r	   r   )argument_specsupports_check_modeN )r   dictr"   	exit_json)r   r   s     r!   mainr6      s{    7`atD95&>BR]ceo\pqdWINd#
 !
F GFwr#   __main__N)
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   ansible.module_utils.urlsr   r"   r6   __name__r3   r#   r!   <module>rA      sQ    A @5n#J
" 5 /.b & zF r#   