File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/http.cpython-310.pyc
o
�N�g � @ s@ d Z ddlZddlZddlmZ dd� Zddd�Zdd d
�ZdS )
z�
Module for making various web calls. Primarily designed for webhooks and the
like, but also useful for basic http testing.
.. versionadded:: 2015.5.0
� N)�CommandExecutionErrorc
K sf t �� }d|v r|�|d � |d= ztjjjd| |d�|��W S ty2 } ztt |���d}~ww )a�
.. versionadded:: 2015.5.0
Query a resource, and decode the return data
Passes through all the parameters described in the
:py:func:`utils.http.query function <salt.utils.http.query>`:
.. autofunction:: salt.utils.http.query
raise_error : True
If ``False``, and if a connection cannot be made, the error will be
suppressed and the body of the return will simply be ``None``.
CLI Example:
.. code-block:: bash
salt '*' http.query http://somelink.com/
salt '*' http.query http://somelink.com/ method=POST params='{"key1": "val1", "key2": "val2"}'
salt '*' http.query http://somelink.com/ method=POST data='<xml>somecontent</xml>'
�opts)�urlr N� )
�__opts__�copy�update�salt�utils�http�query� Exceptionr �str)r �kwargsr �excr r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/http.pyr s ��r �, c
K s� t � � } d}d}ztdd| i|��}|�d�s |�d�s |W S W n ty5 } z|}W Y d}~nd}~ww t � � || krF|sD|rD|�|S d|v rQt �|d � q)z�
Query a resource until a successful response, and decode the return data
CLI Example:
.. code-block:: bash
salt '*' http.wait_for_successful_query http://somelink.com/ wait_for=160 request_interval=1
TNr �Error�errorZrequest_intervalr )�timer �getr
�sleep)r �wait_forr Z starttimeZcaught_exception�resultr r r r �wait_for_successful_query2 s( ����r c C s@ | du rt d dd�} |du rt d dd�}tjj�| |t|�S )ab
Update the local CA bundle file from a URL
.. versionadded:: 2015.5.0
CLI Example:
.. code-block:: bash
salt '*' http.update_ca_bundle
salt '*' http.update_ca_bundle target=/path/to/cacerts.pem
salt '*' http.update_ca_bundle source=https://example.com/cacerts.pem
If the ``target`` is not specified, it will be pulled from the ``ca_cert``
configuration variable available to the minion. If it cannot be found there,
it will be placed at ``<<FILE_ROOTS>>/cacerts.pem``.
If the ``source`` is not specified, it will be pulled from the
``ca_cert_url`` configuration variable available to the minion. If it cannot
be found, it will be downloaded from the cURL website, using an http (not
https) URL. USING THE DEFAULT URL SHOULD BE AVOIDED!
``merge_files`` may also be specified, which includes a string or list of
strings representing a file or files to be appended to the end of the CA
bundle, once it is downloaded.
CLI Example:
.. code-block:: bash
salt '*' http.update_ca_bundle merge_files=/path/to/mycert.pem
Nz
config.getZ ca_bundleZ
ca_bundle_url)Z__salt__r r
r �update_ca_bundler )�target�sourceZmerge_filesr r r r T s
!r )r )NNN) �__doc__r Zsalt.utils.httpr Zsalt.exceptionsr r r r r r r r �<module> s
$"