
    Vh                     p    d dl mZmZmZ eZdZ	 dZd dlm	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: offense_note
short_description: Create or update a QRadar Offense Note
description:
  - This module allows to create a QRadar Offense note
version_added: "1.0.0"
options:
  id:
    description:
      - Offense ID to operate on
    required: true
    type: int
  note_text:
    description: The note's text contents
    required: true
    type: str

author: Ansible Security Automation Team (@maxamillion) <https://github.com/ansible-security>
z
- name: Add a note to QRadar Offense ID 1
  ibm.qradar.offense_note:
    id: 1
    note_text: This an example note entry that should be made on offense id 1
)AnsibleModule)quote)QRadarRequestc           
         | j                   d   r|j                  dj                  t        dj                  | j                   d                           \  }}|r|d   d   | j                   d<   n-| j	                  dj                  | j                   d                | j                   d   r+| j                   d   j                         | j                   d<   y y )	Nclosing_reasonz,/api/siem/offense_closing_reasons?filter={0}z
text="{0}"r   idclosing_reason_idz'Unable to find closing_reason text: {0}status)paramsgetformatr   	fail_jsonupper)moduleqradar_requestcodefound_closing_reasons       k/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ibm/qradar/plugins/modules/offense_note.pyset_offense_valuesr   >   s    }}%&%3%7%7:AAl))&--8H*IJK&
""
  1Ea1H1NFMM-.9@@MM"23 }}X"(--"9"?"?"Ah     c                      t        t        dd      t        dd            } t        | d      }t        |ddg	      }|j                  d
j	                  |j
                  d   t        dj	                  |j
                  d                           \  }}|r|d   }|d   |j
                  d   k(  r|j                  dd       n5|j                  r|j                  dd       |j                  dj	                  |j
                  d   t        dj	                  |j
                  d                     d      }|j                  dj	                  |d         |d       n|j                  r|j                  dd       |j                  dj	                  |j
                  d   t        dj	                  |j
                  d                     d      }|j                  dj	                  |d         |d       |j                  dd       y )NTint)requiredtypestr)r   	note_text)argument_specsupports_check_modestater   )not_rest_data_keysz'/api/siem/offenses/{0}/notes?filter={1}znote_text="{0}"r   r   z$No changes necessary. Nothing to do.F)msgchangedz:A change would have occured but did not because Check Modez)api/siem/offenses/{0}/notes?note_text={1}z{0})dataz)Successfully created Offense Note ID: {0})r$   qradar_return_datar%   )
dictr   r   r   r   r   r   	exit_json
check_modepost_by_path)argspecr   r   r   found_notesnoter'   s          r   mainr/   R   s5   E*51G dKF"#T?N '**188MM$#**6==+EFG	
D+  1~k :::  
     T  ! 
 "0!<!<;BBMM$'%,,v}}['ABC  "= " ?FF&t, $6   P  
 ,887>>d#ell6==#=>?  9 
 	;BB"4(  2 	 	
 ?Or   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESansible.module_utils.basicr   +ansible.module_utils.six.moves.urllib.parser   :ansible_collections.ibm.qradar.plugins.module_utils.qradarr   r   r/   __name__ r   r   <module>r:      sU    A @ *  5 = TB(QPR zF r   