B
    `                 @   sl   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d Zedkrhe  dS )    )absolute_importdivisionprint_functionz1.1ZstableinterfaceZ	certified)metadata_versionstatusZ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              C   s   ddddgfg} t | dttddddd	d
t tddtddtddddd}t|jd }t|jd
 d|jd }t|jdddd}y0t	|jd ||||j
\}}|j||d W n4 tjk
r } z|jt|d W d d }~X Y nX d S )NstateZpresentcommandtimeoutTauthnamelabelsannotations	namespaceint)typeboolliststr)r   elements)r   r   stdinruntime_assets)required_ifZsupports_check_modeZargument_spechooksr   r   )changedobject)msg)r   dictr	   Zget_specZget_sensu_clientparamsr   Zbuild_core_v2_pathZget_mutation_payloadsyncZ
check_modeZ	exit_jsonr
   ErrorZ	fail_jsonr   )r   moduleclientpathpayloadr   hooke r+   f/home/dcms/DCMS/lib/python3.7/site-packages/ansible_collections/sensu/sensu_go/plugins/modules/hook.pymainl   s2    r-   __main__N)
__future__r   r   r   r   __metaclass__ZANSIBLE_METADATAZDOCUMENTATIONZEXAMPLESZRETURNZansible.module_utils.basicr   Zmodule_utilsr	   r
   r   r-   __name__r+   r+   r+   r,   <module>   s   .(