HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/opsgenie.cpython-310.pyc
o

�N�g[
�@sBdZddlZddlZddlZddlZdZe�e�Z		ddd�Z
dS)a
Module for sending data to OpsGenie

.. versionadded:: 2018.3.0

:configuration: This module can be used in Reactor System for
    posting data to OpsGenie as a remote-execution function.

    For example:

    .. code-block:: yaml

        opsgenie_event_poster:
          local.opsgenie.post_data:
            - tgt: 'salt-minion'
            - kwarg:
                name: event.reactor
                api_key: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
                reason: {{ data['data']['reason'] }}
                action_type: Create
�Nz"https://api.opsgenie.com/v2/alerts�OpsGenie Execution ModulecCsV|dus|durtj�d��t�}||d<||d<td|d<td|d<td	|d	<td
|d
<td|d<td|d<td
|d<td|d<td|d<td|d<td|d<td|d<td|d<t�d|�t�d|t�|dkr�tj	ttj
j�|�dd|d�dd�}ntj	td|d tj
j�|�dd|d�dd�}|j
|jfS)!a�
    Post data to OpsGenie. It's designed for Salt's Event Reactor.

    After configuring the sls reaction file as shown above, you can trigger the
    module with your designated tag (og-tag in this case).

    CLI Example:

    .. code-block:: bash

        salt-call event.send 'og-tag' '{"reason" : "Overheating CPU!"}'

    Required parameters:

    api_key
        It's the API Key you've copied while adding integration in OpsGenie.

    reason
        It will be used as alert's default message in OpsGenie.

    action_type
        OpsGenie supports the default values Create/Close for action_type. You
        can customize this field with OpsGenie's custom actions for other
        purposes like adding notes or acknowledging alerts.

    Optional parameters:

    name
        It will be used as alert's alias. If you want to use the close
        functionality you must provide name field for both states like in
        this case.
    Nz!API Key or Reason cannot be None.�alias�messageZ	cpu_modelZcpuModelZcpuarchZcpuArchZfqdn�host�idZkernelZ
kernelreleaseZ
kernelReleaseZmaster�osZsaltpathZsaltPathZsaltversionZsaltVersion�usernameZuuidzBelow data will be posted:
%szAPI Key: %s 	 API Endpoint: %sZCreatezapplication/jsonz	GenieKey )zContent-TypeZ
Authorization�x)�url�data�headers�timeout�/z/close?identifierType=alias)�salt�
exceptionsZSaltInvocationError�dictZ
__grains__�log�debug�API_ENDPOINT�requestsZpost�utils�json�dumpsZstatus_code�text)Zapi_key�name�reasonZaction_typer�response�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/opsgenie.py�	post_data#sL#��
��
r)NrNN)�__doc__�loggingrZsalt.exceptionsrZsalt.utils.jsonr�	getLogger�__name__rrrrrr�<module>s
�