Generic REST API SDB Module
SaltStack
New
all
New in version 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:
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:
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:
github_urls: sdb://my-rest-api/keys?user=myuser
This will cause the following URL to actually be called:
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:
another-rest-api:
driver: rest
user_data:
url: https://api.example.com/users/
params:
user: myuser
salt.sdb.rest.
get
(key, service=None, profile=None)¶Get a value from the REST interface
salt.sdb.rest.
query
(key, value=None, service=None, profile=None)¶Get a value from the REST interface
salt.sdb.rest.
set_
(key, value, service=None, profile=None)¶Set a key/value pair in the REST interface