
    Vh                     v    d dl mZmZmZ eZddgddZdZdZdZ	d d	l
mZ d
dlmZmZmZ d Zedk(  r e        yy)    )absolute_importdivisionprint_functionz1.1stableinterface	certified)metadata_versionstatussupported_bya  
module: hook
author:
  - Paul Arthur (@flowerysong)
  - Aljaz Kosir (@aljazkosir)
  - Miha Plesko (@miha-plesko)
  - Tadej Borovsak (@tadeboro)
short_description: Manage Sensu hooks
description:
  - Create, update or delete Sensu hook.
  - For more information, refer to the Sensu documentation at
    U(https://docs.sensu.io/sensu-go/latest/reference/hooks/).
version_added: 1.0.0
extends_documentation_fragment:
  - sensu.sensu_go.requirements
  - sensu.sensu_go.auth
  - sensu.sensu_go.name
  - sensu.sensu_go.namespace
  - sensu.sensu_go.state
  - sensu.sensu_go.labels
  - sensu.sensu_go.annotations
seealso:
  - module: sensu.sensu_go.hook_info
options:
  command:
    description:
      - Command to run when the hook is triggered.
      - Required if I(state) is C(present).
    type: str
  timeout:
    description:
      - The hook execution duration timeout in seconds (hard stop).
      - Required if I(state) is C(present).
    type: int
  stdin:
    description:
      - Controls whether Sensu writes serialized JSON data to the process's stdin.
    type: bool
  runtime_assets:
    description:
      - List of runtime assets required to run the check.
    type: list
    elements: str
a  
- name: Rudimentary auto-remediation hook
  sensu.sensu_go.hook:
    auth:
      url: http://localhost:8080
    name: restart_nginx
    command: sudo systemctl start nginx
    timeout: 60
    stdin: false

- name: Capture the process tree
  sensu.sensu_go.hook:
    auth:
      url: http://localhost:8080
    name: process_tree
    command: ps aux
    timeout: 60
    stdin: false

- name: Delete a hook
  sensu.sensu_go.hook:
    name: process_tree
    state: absent
a  
object:
  description: Object representing Sensu hook.
  returned: success
  type: dict
  sample:
    metadata:
      annotations: null
      labels: null
      name: restart_nginx
      namespace: default
    command: sudo systemctl start nginx
    stdin: false
    timeout: 60
)AnsibleModule   )	argumentserrorsutilsc                     ddddgfg} t        | dt        t        j                  ddddd	d
      t               t        d      t        d      t        dd                  }t        j                  |j
                  d         }t        j                  |j
                  d
   d|j
                  d         }t        j                  |j
                  dddd      }	 t        j                  |j
                  d   ||||j                        \  }}|j                  ||       y # t        j                  $ r%}|j                  t        |             Y d }~y d }~ww xY w)NstatepresentcommandtimeoutTauthnamelabelsannotations	namespaceint)typeboolliststr)r   elements)r   r   stdinruntime_assets)required_ifsupports_check_modeargument_spechooksr    r!   )changedobject)msg)r   dictr   get_specget_sensu_clientparamsr   build_core_v2_pathget_mutation_payloadsync
check_mode	exit_jsonr   Error	fail_jsonr   )r"   moduleclientpathpayloadr&   hookes           g/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/sensu/sensu_go/plugins/modules/hook.pymainr;   l   sS   	)i34K  =+ F   e
F( ''f(=>F##k"GV]]6-BD ,,y)W6FG%

MM'"FD'6;L;L
 	6<< %SV$$%s   AD" "E5EE__main__N)
__future__r   r   r   r   __metaclass__ANSIBLE_METADATADOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   module_utilsr   r   r   r;   __name__     r:   <module>rH      sd    A @  ! +Z2
  5 3 3%%P zF rG   