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__/uptime.cpython-310.pyc
o

�N�g��@s~dZddlZddlmZzddlZdZWneydZYnwe�e�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�ZdS)z5
Wrapper around uptime API
=========================
�N)�CommandExecutionErrorTFcCstrdSdS)zJ
    Only load this module if the requests python module is available
    Zuptime)Fz6uptime module needs the python requests module to work)�ENABLED�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/uptime.py�__virtual__srcKs�t|�rd|��}t�|�t|��t�}t�d�|j|d�tj|�d�|dd�}|j	s6td|j
����t�d�|��d	S)
aPCreate a check on a given URL.

    Additional parameters can be used and are passed to API (for
    example interval, maxTime, etc). See the documentation
    https://github.com/fzaninotto/uptime for a full list of the
    parameters.

    CLI Example:

    .. code-block:: bash

        salt '*' uptime.create http://example.org

    z-Trying to create check that already exists : zptime] trying PUT request��url�/api/checks�x)�data�timeout�request to uptime failed : z[uptime] PUT request successful�_id)�check_exists�log�errorr�_get_application_url�debug�update�requests�put�ok�reason�json)�name�params�msg�application_url�reqrrr�creates



rcs�t��sd���}t�|�t|��t�}t�d�tj|�d�dd���}�fdd�|D�d}tj	|�d	|��dd�}|j
sHtd
|j����t�d�dS)
z�
    Delete a check on a given URL

    CLI Example:

    .. code-block:: bash

        salt '*' uptime.delete http://example.org
    z-Trying to delete check that doesn't exists : z[uptime] trying DELETE requestr	r
�rcs g|]}|d�kr|d�qS)rrr��.0�x�rrr�
<listcomp>Ks zdelete.<locals>.<listcomp>rz/api/checks/r
z"[uptime] DELETE request successfulT)rrrrrrr�getr�deleterr)rrr�jcontentZurl_idrrr$rr':s




r'cCs*tdd�}|durt�d�td��|S)z<
    Helper function to get application url from pillar
    z
pillar.getzuptime:application_urlNz,Could not load uptime:application_url pillarz<uptime:application_url pillar is required for authentication)Z__salt__rrr)rrrrrSs
�rcCs6t�}t�d�tj|�d�dd���}dd�|D�S)zu
    List URL checked by uptime

    CLI Example:

    .. code-block:: bash

        salt '*' uptime.checks_list
    z[uptime] get checksr	r
r cSsg|]}|d�qSrrr!rrrr%mszchecks_list.<locals>.<listcomp>)rrrrr&r)rr(rrr�checks_list`s

r)cCs|t�vr
t�d|�dSdS)z�
    Check if a given URL is in being monitored by uptime

    CLI Example:

    .. code-block:: bash

        salt '*' uptime.check_exists http://example.org
    zptime] found %s in checksTF)r)rrr$rrrrps

r)�__doc__�loggingZsalt.exceptionsrrr�ImportError�	getLogger�__name__rrrr'rr)rrrrr�<module>s �