
    Vh                     ~    d Z ddlmZmZmZ eZdZdZddl	m
Z
mZ ddlmZmZmZ d Zd Zd	 Zd
 Zedk(  r e        yy)z&This module sends events to Infinibox.    )absolute_importdivisionprint_functiona  
---
module: infini_event
version_added: 2.16.0
short_description:  Create custom events on Infinibox
description:
    - This module creates events on Infinibox.
author: David Ohlemacher (@ohlemacher)
options:
  description_template:
    description:
      - The content of the custom event
    type: str
    required: true
  visibility:
    description:
      - The event's visibility
    type: str
    required: false
    choices:
      - CUSTOMER
      - INFINIDAT
    default: CUSTOMER
  level:
    description:
      - The level of the custom event
    type: str
    required: true
    choices:
      - INFO
      - WARNING
      - ERROR
      - CRITICAL
  state:
    description:
      - Creates a custom event when present. Stat is not yet implemented. There is no way to remove events once posted, so abent is also not implemented.
    type: str
    required: false
    default: present
    choices: [ "present" ]

extends_documentation_fragment:
    - infinibox
z
- name: Create custom info event
  infini_event:
    description_template: Message content
    level: INFO
    state: present
    user: admin
    password: secret
    system: ibox001
)AnsibleModulemissing_required_lib)HAS_INFINISDKinfinibox_argument_spec
get_systemc                 ,    d}| j                  |       y)zHandle stat statez handle_stat() is not implementedmsgN)	exit_json)moduler   s     t/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/infinidat/infinibox/plugins/modules/infini_event.pyhandle_statr   R   s    
,C
    c                     t        |       }| j                  d   }| j                  d   }| j                  d   }d}|||d}|j                  j                  ||       | j	                  dd	       y
)zHandle present statedescription_templatelevel
visibilityzevents/custom)r   r   r   )pathdataTzEvent posted)changedr   N)r
   paramsapipostr   )r   systemr   r   r   r   	json_datas          r   handle_presentr   X   sv    F!==)?@MM'"E|,JD 4 I
 JJOOIO.
T~6r   c                    | j                   d   }	 |dk(  rt        |        n&|dk(  rt        |        n| j                  d|        t	        |       }|j                          y# t	        |       }|j                          w xY w)zHandle statesstatestatpresentz'Internal handler error. Invalid state: r   N)r   r   r   r   r
   logout)r   r!   r   s      r   execute_stater%   i   sw    MM'"E	F?i6"#J5'!RSF# F#s   7A$ $Bc                  *   t               } | j                  t        t        d      t        dg d      t        dddg      t        dddd	g
                   t        | d      }t        s|j                  t        d             t        |       y)z Main T)required)INFOWARNINGERRORCRITICAL)r'   choicesFr#   )r'   defaultr,   CUSTOMER	INFINIDAT)r-   r'   r,   )r   r   r!   r   )supports_check_mode	infinisdkr   N)r	   updatedictr   r   r   r   r%   )argument_specr   s     r   mainr5   x   s    +-M!%t!4.VWy9+NJU`Hab		
 =dCF1+>?&r   __main__N)__doc__
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESansible.module_utils.basicr   r   Fansible_collections.infinidat.infinibox.plugins.module_utils.infiniboxr   r	   r
   r   r   r%   r5   __name__ r   r   <module>rA      s_    -
 A @+Z	 K 7"( zF r   