
    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: silence
author:
  - Paul Arthur (@flowerysong)
  - Aljaz Kosir (@aljazkosir)
  - Manca Bizjak (@mancabizjak)
  - Tadej Borovsak (@tadeboro)
short_description: Manage Sensu silences
description:
  - Create, update or delete Sensu silence.
  - For more information, refer to the Sensu documentation at
    U(https://docs.sensu.io/sensu-go/latest/reference/silencing/).
version_added: 1.0.0
extends_documentation_fragment:
  - sensu.sensu_go.requirements
  - sensu.sensu_go.auth
  - sensu.sensu_go.namespace
  - sensu.sensu_go.state
  - sensu.sensu_go.labels
  - sensu.sensu_go.annotations
seealso:
  - module: sensu.sensu_go.silence_info
options:
  subscription:
    description:
      - The name of the subscription the entry should match.
      - If left empty a silencing entry will contain an asterisk in the
        subscription position. This indicates that any event with a matching
        check name will be marked as silenced, regardless of the originating
        entities subscriptions.
      - Specific entity can also be targeted by taking advantage of per-entity
        subscription (entity:<entity_name>).
      - This parameter is required if the I(check) parameter is absent.
    type: str
  check:
    description:
      - The name of the check the entry should match.
      - If left empty a silencing entry will contain an asterisk in the check
        position. This indicates that any event where the originating entities
        subscriptions match the subscription specified in the entry will be
        marked as silenced, regardless of the check name.
      - This parameter is required if the I(subscription) parameter is absent.
    type: str
  begin:
    description:
      - UNIX time at which silence entry goes into effect.
    type: int
  expire:
    description:
      - Number of seconds until the silence expires.
    type: int
  expire_on_resolve:
    description:
      - If the entry should be deleted when a check begins return OK status (resolves).
    type: bool
  reason:
    description:
      - Reason for silencing.
    type: str
a
  
- name: Silence a specific check
  sensu.sensu_go.silence:
    subscription: proxy
    check: check-disk

- name: Silence specific check regardless of the originating entities subscription
  sensu.sensu_go.silence:
    check: check-cpu

- name: Silence all checks on a specific entity
  sensu.sensu_go.silence:
    subscription: entity:important-entity
    expire: 120
    reason: rebooting the world

- name: Delete a silencing entry
  sensu.sensu_go.silence:
    subscription: entity:important-entity
    state: absent
an  
object:
  description: Object representing Sensu silence.
  returned: success
  type: dict
  sample:
    metadata:
      annotations: null
      labels: null
      name: entity:i-424242:*
      namespace: default
    begin: 1542671205
    check: null
    creator: admin
    expire: -1
    expire_on_resolve: false
    reason: null
    subscription: entity:i-424242
)AnsibleModule   )	argumentserrorsutilsc                  D   ddgg} t        d| t        t        j                  ddddd      t               t               t        d	
      t        d	
      t        d
      t                           }dj	                  |j
                  d   xs d|j
                  d   xs d      }t        j                  |j
                  d         }t        j                  |j
                  d   d|      }||j
                  d<   t        j                  |j
                  dd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subscriptioncheckTauthstatelabelsannotations	namespaceint)typebool)r   r   beginexpireexpire_on_resolvereason)supports_check_moderequired_one_ofargument_specz{0}:{1}*silencednamer   r   r   r   )changedobject)msg)r   dictr   get_specformatparamsget_sensu_clientr   build_core_v2_pathget_mutation_payloadsync
check_mode	exit_jsonr   Error	fail_jsonstr)	r    moduler$   clientpathpayloadr%   silencees	            j/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/sensu/sensu_go/plugins/modules/silence.pymainr<   }   s   	!O  '=+ &  # 6
F* FMM.9@S&--PWBXB_\_`D''f(=>F##k"JD
 !FMM&,,~wCVX`G% ::MM'"FD'6;L;L
 	9<< %SV$$%s    AE' 'F:FF__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>rI      sd    A @  ! ;z,
( 5 3 3+%\ zF rH   