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/sdb/__pycache__/couchdb.cpython-310.pyc
o

�N�g_	�@s�dZddlZddlmZddlmZzddlZdZWney%dZYnwe�	e
�ZddiZd	d
�Z
edd��Zd
d�Zddd�Zddd�Zdd�ZdS)a�
CouchDB sdb Module

:maintainer:    SaltStack
:maturity:      New
:depends:       python2-couchdb
:platform:      all

This allow interaction between Salt and a CouchDB [couchdb.apache.org]
database. It uses salt's `sdb` system to allow for inserts and retrevals
using the `sdb://` prefix in salt configuration files.

To use the couchbase sdb module, it must first be configured in the salt
master or minion config. The following arguments are required:

.. code-block:: yaml

    couchdb_sdb:
      driver: couchdb
      host: localhost
      port: 5984
      database: salt_sdb

One could then query the CouchDB instance via an `sdb://` URI such as the
following:

.. code-block:: yaml

    password: sdb://couchdb_sdb/mykey

To use this interface, you must track IDs on your own or have another source
to do the map-reduce logic necessary to calculate the ID you wish to fetch.

Additional contributions to build true map-reduce functionality into this module
would be welcome.
�N)�uuid4)�memoizeTF�set_�setcCstS)z/
    Require the python2-couchdb libraries
    )�	HAS_COUCH�rr�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/sdb/couchdb.py�__virtual__;sr	cCsdjdi|��S)z�
    Examine configuration and return
    a uri for the couchdb server in the following format:

    .. code-block:: bash

        http://localhost:5984/
    zhttp://{host}:{port}Nr)�format)�profilerrr�_construct_uriBs
rcCs2t|�pd}t��}|d|vr|�|d�|S)z%
    Get a connection to CouchDB
    zhttp://localhost:5984Zdatabase)r�couchdbZServer�create)rZDEFAULT_BASE_URL�serverrrr�	_get_connOs
rcCst|�}|�dt�j||i�S)z)
    Set a key/value pair in couchdb
    Z_id)�_get_dbZsaver�hex)�key�valuer�dbrrrr[scCst|�}|�|�S)z(
    Get a value from couchdb by id
    )r�get)rrrrrrrcs
rcCst|�}t|�}|S)z*
    Wraps _get_conn() to return a db
    )rr)rrrrrrrksr)N)�__doc__�loggingZuuidrZsalt.utils.decoratorsrr
r�ImportError�	getLogger�__name__�logZ__func_alias__r	rrrrrrrrr�<module>s&&�