
    Vhr	                     b    d dl mZmZmZ eZdZdZdZd dl	Z	d dl
mZ d Zd Zed	k(  r e        yy)
    )absolute_importdivisionprint_functiona  
module: logentries_msg
short_description: Send a message to logentries
description:
  - Send a message to logentries.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  token:
    type: str
    description:
      - Log token.
    required: true
  msg:
    type: str
    description:
      - The message body.
    required: true
  api:
    type: str
    description:
      - API endpoint.
    default: data.logentries.com
  port:
    type: int
    description:
      - API endpoint port.
    default: 80
author: "Jimmy Tang (@jcftang) <jimmy_tang@rapid7.com>"
#z
- name: Send a message to logentries
  community.general.logentries_msg:
    token: 00000000-0000-0000-0000-000000000000
    msg: "{{ ansible_hostname }}"
N)AnsibleModulec                    dj                  ||      }t        j                  |      }t        j                  t        j                  t        j                        }|j                  ||f       	 | j                  s|j                  |       |j                          y # t        $ r}| j                  d|z         Y d }~4d }~ww xY w)Nz{0} {1}
zfailed to send message, msg=%smsg)formatsocketgethostbynameAF_INETSOCK_STREAMconnect
check_modesend	Exception	fail_jsonclose)	moduletokenr
   apiportmessageapi_ipses	            t/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/logentries_msg.pysend_msgr   >   s      ,G!!#&Ffnnf&8&89AIIvtnC  FF7O GGI  C=ABBCs   .B 	C%B??Cc                     t        t        t        ddd      t        dd      t        dd      t        dd      	      d
      } | j                  d   }| j                  d   }| j                  d   }| j                  d   }d}	 t        | ||||       d}| j                  ||       y # t        $ r}| j                  d|z         Y d }~7d }~ww xY w)NstrT)typerequiredno_log)r"   r#   zdata.logentries.com)r"   defaultintP   )r   r
   r   r   )argument_specsupports_check_moder   r
   r   r   Fzunable to send msg: %sr	   )changedr
   )r   dictparamsr   r   r   	exit_json)r   r   r
   r   r   r*   r   s          r   mainr.   N   s    ED>%$/%)>?5"-	/
 !F MM'"E
--
C
--
C== DG;S$/ W#.  ;59::;s   B, ,	C5CC__main__)
__future__r   r   r   r"   __metaclass__DOCUMENTATIONRETURNEXAMPLESr   ansible.module_utils.basicr   r   r.   __name__     r   <module>r9      sO    A @"H 
  4 /2 zF r8   