
    Vh                     n    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mZ d Zedk(  r e        y	y	)
    )absolute_importdivisionprint_functionan  
---
module: offense_action
short_description: Take action on a QRadar Offense
description:
  - This module allows to assign, protect, follow up, set status, and assign closing reason to QRadar Offenses
version_added: "1.0.0"
options:
  id:
    description:
     - ID of Offense
    required: true
    type: int
  status:
    description:
      - One of "open", "hidden" or "closed". (Either all lower case or all caps)
    required: false
    choices: [ "open", "OPEN", "hidden", "HIDDEN", "closed", "CLOSED" ]
    type: str
  assigned_to:
    description:
      - Assign to an user, the QRadar username should be provided
    required: false
    type: str
  closing_reason:
    description:
      - Assign a predefined closing reason here, by name.
    required: false
    type: str
  closing_reason_id:
    description:
      - Assign a predefined closing reason here, by id.
    required: false
    type: int
  follow_up:
    description:
      - Set or unset the flag to follow up on a QRadar Offense
    required: false
    type: bool
  protected:
    description:
      - Set or unset the flag to protect a QRadar Offense
    required: false
    type: bool

notes:
  - Requires one of C(name) or C(id) be provided
  - Only one of C(closing_reason) or C(closing_reason_id) can be provided

author: Ansible Security Automation Team (@maxamillion) <https://github.com/ansible-security>

)to_text)AnsibleModule)QRadarRequestset_offense_valuesc                     t        t        dd      t        dd      t        dd      t        dd      t        dd      t        dd      t        dg dd      	      } t        | d
gd      }t        |g d      }|j                  dj	                  |j
                  d               \  }}|rst        ||       g }|j
                  d   r]t        |d         t        |j
                  d         k7  r6|j                  dj	                  t        |j
                  d                      |j
                  d   rTt        |d         t        |j
                  d         k7  r-|j                  dj	                  |j
                  d                |j
                  d   rB|d   |j
                  d   k7  r-|j                  dj	                  |j
                  d                |j
                  d   rB|d   |j
                  d   k7  r-|j                  dj	                  |j
                  d                |j
                  d   rB|d   |j
                  d   k7  r-|j                  dj	                  |j
                  d                |r|j                  r|j                  dd       |j                  dj	                  |j
                  d   dj                  |                  }|j                  dj	                  |j
                  d         |d       y |j                  d d       y |j                  d!j	                  |j
                  d         "       y )#NTint)requiredtypeFstrbool)openOPENhiddenHIDDENclosedCLOSED)r   choicesr   )idassigned_toclosing_reasonclosing_reason_id	follow_up	protectedstatus)r   r   )argument_specmutually_exclusivesupports_check_mode)namer   r   r   )not_rest_data_keysz/api/siem/offenses/{0}r   r   z
status={0}r   zassigned_to={0}r   zclosing_reason_id={0}r   zfollow_up={0}r   zprotected={0}z@A change would have been made but was not because of Check Mode.)msgchangedzapi/siem/offenses/{0}?{1}&z$Successfully updated Offense ID: {0})r$   qradar_return_datar%   z$No changes necessary. Nothing to do.zUnable to find Offense ID: {0})r$   )dictr   r	   getformatparamsr
   r   append
check_mode	exit_jsonpost_by_pathjoin	fail_json)argspecmoduleqradar_requestcodefound_offense	post_strsr'   s          m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ibm/qradar/plugins/modules/offense_action.pymainr9   U   s3    E*%e4U7E:F3F3L
G   DD F #JN ),, ''d(;<D- 6>2	=="M(+,h8O0PP##GFMM(,C$DE =='M-01WV]]==Y5ZZ!((})EF ==,--.&--@S2TT'..MM"56 ==%+&&--*DD&&v}}['AB ==%+&&--*DD&&v}}['AB     Z  ! 
 "0!<!<+22MM$'HHY'" :AAMM$' $6   :   	077d8KL 	 	
    __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESansible.module_utils._textr   ansible.module_utils.basicr   :ansible_collections.ibm.qradar.plugins.module_utils.qradarr	   r
   r9   __name__ r:   r8   <module>rE      sQ    A @ 2h / 4o
d zF r:   