%PDF- %PDF-
| Direktori : /proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/sdb/ |
| Current File : //proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/sdb/rest.pyo |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l j j
Z
d d l m Z e j
e � Z i d d 6Z d d d � Z d d d � Z d d d d � Z d S(
uG
Generic REST API SDB Module
:maintainer: SaltStack
:maturity: New
:platform: all
.. versionadded:: 2015.8.0
This module allows access to a REST interface using an ``sdb://`` URI.
Like all REST modules, the REST module requires a configuration profile to
be configured in either the minion or master configuration file. This profile
requires very little. In the example:
.. code-block:: yaml
my-rest-api:
driver: rest
urls:
url: https://api.github.com/
keys:
url: https://api.github.com/users/{{user}}/keys
backend: requests
The ``driver`` refers to the REST module, and must be set to ``rest`` in order
to use this driver. Each of the other items inside this block refers to a
separate set of HTTP items, including a URL and any options associated with it.
The options used here should match the options available in
``salt.utils.http.query()``.
In order to call the ``urls`` item in the example, the following reference can
be made inside a configuration file:
.. code-block:: yaml
github_urls: sdb://my-rest-api/urls
Key/Value pairs may also be used with this driver, and merged into the URL using
the configured renderer (``jinja``, by default). For instance, in order to use
the ``keys`` item in the example, the following reference can be made:
.. code-block:: yaml
github_urls: sdb://my-rest-api/keys?user=myuser
This will cause the following URL to actually be called:
.. code-block:: yaml
https://api.github.com/users/myuser/keys
Key/Value pairs will NOT be passed through as GET data. If GET data needs to be
sent to the URL, then it should be configured in the SDB configuration block.
For instance:
.. code-block:: yaml
another-rest-api:
driver: rest
user_data:
url: https://api.example.com/users/
params:
user: myuser
i ( t absolute_importt print_functiont unicode_literalsN( t compile_templateu setu set_c C@ s t | | | | � S( u4
Set a key/value pair in the REST interface
( t query( t keyt valuet servicet profile( ( s1 /usr/lib/python2.7/site-packages/salt/sdb/rest.pyt set_S s c C@ s t | d | | � S( u-
Get a value from the REST interface
N( R t None( R R R ( ( s1 /usr/lib/python2.7/site-packages/salt/sdb/rest.pyt getZ s c C@ s& | j d � } | d } i } x: | d j d � D]% } | j d � \ } } | | | <q3 Wt j d d � } t j j t i � }
t j d � } t j d � } t d
|
| | | d | | d | �}
i } x3 | | D]'