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/states/__pycache__/opsgenie.cpython-310.pyc
o

�N�gX�@s@dZddlZddlZddlZe�e�Zd
dd�Z	ddd	�Z	dS)a�
Create/Close an alert in OpsGenie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 2018.3.0

This state is useful for creating or closing alerts in OpsGenie
during state runs.

.. code-block:: yaml

    used_space:
      disk.status:
        - name: /
        - maximum: 79%
        - minimum: 20%

    opsgenie_create_action_sender:
      opsgenie.create_alert:
        - api_key: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
        - reason: 'Disk capacity is out of designated range.'
        - name: disk.status
        - onfail:
          - disk: used_space

    opsgenie_close_action_sender:
      opsgenie.close_alert:
        - api_key: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
        - name: disk.status
        - require:
          - disk: used_space

�N�Createc	Cs�t�t���\}}}}t�d|�ddddd�}|dus |dur&tj�d��tddur:d�	||�|d	<d|d
<|St
d||||d�\}}d
|krPdkrgnnt�d||�d�	||�|d	<d|d
<|St�d||�d|d
<|S)a�
    Create an alert in OpsGenie. Example usage with Salt's requisites and other
    global state arguments could be found above.

    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.

    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 above case.

    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.
    zArguments values: %s�)�result�nameZchanges�commentNz!API Key or Reason cannot be None.�testTz@Test: {} alert request will be processed using the API Key="{}".rrzopsgenie.post_data)�api_keyr�reason�action_type��i,z;POST Request has succeeded with message: %s status code: %sz6POST Request has failed with error: %s status code: %sF)�inspectZgetargvalues�currentframe�log�info�salt�
exceptions�SaltInvocationErrorZ__opts__�formatZ__salt__�error)	rrr	r
�_�values�retZresponse_status_codeZ
response_text�r�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/opsgenie.py�create_alert+sD��
����	��r�Conditions are met.�ClosecCs"|dur
tj�d��t||||�S)a"
    Close an alert in OpsGenie. It's a wrapper function for create_alert.
    Example usage with Salt's requisites and other global state arguments
    could be found above.

    Required 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 above case.

    Optional 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.
    NzName cannot be None.)rrrr)rrr	r
rrr�close_alerttsr)NNNr)NNrr)
�__doc__r�loggingZsalt.exceptionsr�	getLogger�__name__rrrrrrr�<module>s"

J�