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/pillar/__pycache__/http_json.cpython-310.pyc
o

�N�gm
�@sHdZddlZddlZddlZe�e�Zdd�Z						ddd�Z	dS)	a
A module that adds data to the Pillar structure retrieved by an http request


Configuring the HTTP_JSON ext_pillar
====================================

Set the following Salt config to setup http json result as external pillar source:

.. code-block:: yaml

  ext_pillar:
    - http_json:
        url: http://example.com/api/minion_id
        namespace: 'subkey'
        username: username
        password: password
        header_dict: None
        auth: None

You can pass additional parameters, they will be added to the http.query call
:py:func:`utils.http.query function <salt.utils.http.query>`:

.. versionchanged:: 3006.0
    If namespace is defined, the data will be added under the specified subkeys in the Pillar structure.

If the with_grains parameter is set, grain keys wrapped in can be provided (wrapped
in <> brackets) in the url in order to populate pillar data based on the grain value.

.. code-block:: yaml

  ext_pillar:
    - http_json:
        url: http://example.com/api/<nodename>
        with_grains: True

.. versionchanged:: 2018.3.0

    If %s is present in the url, it will be automatically replaced by the minion_id:

    .. code-block:: yaml

        ext_pillar:
          - http_json:
              url: http://example.com/api/%s

Module Documentation
====================
�NcCsdS)NT�rrr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/http_json.py�__virtual__:srFc		Cs�|�dtj�|��}d}	|rCt�|	|�D].}
|
�d�}td|d�}|s/t�	d||�iStj�t
|��}t�d|�d�||�}qt�d	|�td
|dd||||d
�}
d|
vrf|rb||
diS|
dSt�	d||�|
D]}t�	d||
|�qoiS)a
    Read pillar data from HTTP response.

    :param str url: Url to request.
    :param bool with_grains: Whether to substitute strings in the url with their grain values.
    :param dict header_dict: Extra headers to send
    :param auth: special auth if needed
    :param str username: username for auth
    :param str pasword: password for auth
    :param str namespace: (Optional) A pillar key to namespace the values under.
        .. versionadded:: 3006.0

    :return: A dictionary of the pillar data to add.
    :rtype: dict
    z%sz<(?P<grain_name>.*?)>�
grain_namez
grains.getNz#Unable to get minion '%s' grain: %s�<�>zGetting url: %sz
http.queryT�json)�url�decodeZdecode_type�header_dict�auth�username�password�dictz/Error on minion '%s' http query: %s
More Info:
z%s: %s)
�replace�urllib�parse�quote�re�finditer�groupZ__salt__�log�error�str�sub�debug)Z	minion_idZpillarr	Zwith_grainsrrr
r�	namespaceZ
grain_pattern�matchrZgrain_value�data�keyrrr�
ext_pillar>s:
�
r )FNNNNN)
�__doc__�loggingr�urllib.parser�	getLogger�__name__rrr rrrr�<module>s2
�