New in version 2014.7.0.
depends: |
|
---|---|
optdepends: |
|
client_libraries: | |
configuration: | All authentication is done through Salt's external auth system which requires additional configuration not described here. Example production-ready configuration; add to the Salt master config file
and restart the rest_cherrypy:
port: 8000
ssl_crt: /etc/pki/tls/certs/localhost.crt
ssl_key: /etc/pki/tls/certs/localhost.key
Using only a secure HTTPS connection is strongly recommended since Salt authentication credentials will be sent over the wire. A self-signed certificate can be generated using the
salt-call --local tls.create_self_signed_cert
All available configuration options are detailed below. These settings configure the CherryPy HTTP server and do not apply when using an external server such as Apache or Nginx.
|
Authentication is performed by passing a session token with each request.
Tokens are generated via the Login
URL.
The token may be sent in one of two ways:
Include a custom header named X-Auth-Token.
For example, using curl:
curl -sSk https://localhost:8000/login \ -H 'Accept: application/x-yaml' \ -d username=saltdev \ -d password=saltdev \ -d eauth=auto
Copy the token
value from the output and include it in subsequent requests:
curl -sSk https://localhost:8000 \ -H 'Accept: application/x-yaml' \ -H 'X-Auth-Token: 697adbdc8fe971d09ae4c2a3add7248859c87079'\ -d client=local \ -d tgt='*' \ -d fun=test.ping
Sent via a cookie. This option is a convenience for HTTP clients that automatically handle cookie support (such as browsers).
For example, using curl:
# Write the cookie file:
curl -sSk https://localhost:8000/login \
-c ~/cookies.txt \
-H 'Accept: application/x-yaml' \
-d username=saltdev \
-d password=saltdev \
-d eauth=auto
# Read the cookie file:
curl -sSk https://localhost:8000 \
-b ~/cookies.txt \
-H 'Accept: application/x-yaml' \
-d client=local \
-d tgt='*' \
-d fun=test.ping
See also
You can bypass the session handling via the Run
URL.
Commands are sent to a running Salt master via this module by sending HTTP requests to the URLs detailed below.
Content negotiation
This REST interface is flexible in what data formats it will accept as well as what formats it will return (e.g., JSON, YAML, x-www-form-urlencoded).
Data sent in POST and PUT requests must be in the format of a list of lowstate dictionaries. This allows multiple commands to be executed in a single HTTP request. The order of commands in the request corresponds to the return for each command in the response.
Lowstate, broadly, is a dictionary of values that are mapped to a function call. This pattern is used pervasively throughout Salt. The functions called from netapi modules are described in Client Interfaces.
The following example (in JSON format) causes Salt to execute two commands, a command sent to minions as well as a runner function on the master:
[{
"client": "local",
"tgt": "*",
"fun": "test.fib",
"arg": ["10"]
},
{
"client": "runner",
"fun": "jobs.lookup_jid",
"jid": "20130603122505459265"
}]
x-www-form-urlencoded
Sending JSON or YAML in the request body is simple and most flexible, however sending data in urlencoded format is also supported with the caveats below. It is the default format for HTML forms, many JavaScript libraries, and the curl command.
For example, the equivalent to running salt '*' test.ping
is sending
fun=test.ping&arg&client=local&tgt=*
in the HTTP request body.
Caveats:
Only a single command may be sent per HTTP request.
Repeating the arg
parameter multiple times will cause those
parameters to be combined into a single list.
Note, some popular frameworks and languages (notably jQuery, PHP, and
Ruby on Rails) will automatically append empty brackets onto repeated
parameters. E.g., arg=one
, arg=two
will be sent as arg[]=one
,
arg[]=two
. This is not supported; send JSON or YAML instead.
salt.netapi.rest_cherrypy.app.
API
¶Collect configuration and URL map for building the CherryPy app
get_conf
()¶Combine the CherryPy configuration with the rest_cherrypy config values pulled from the master config and return the CherryPy configuration
url_map
= {'index': <class 'salt.netapi.rest_cherrypy.app.LowDataAdapter'>, 'stats': <class 'salt.netapi.rest_cherrypy.app.Stats'>, 'logout': <class 'salt.netapi.rest_cherrypy.app.Logout'>, 'keys': <class 'salt.netapi.rest_cherrypy.app.Keys'>, 'jobs': <class 'salt.netapi.rest_cherrypy.app.Jobs'>, 'run': <class 'salt.netapi.rest_cherrypy.app.Run'>, 'login': <class 'salt.netapi.rest_cherrypy.app.Login'>, 'events': <class 'salt.netapi.rest_cherrypy.app.Events'>, 'minions': <class 'salt.netapi.rest_cherrypy.app.Minions'>}¶salt.netapi.rest_cherrypy.app.
App
¶Class to serve HTML5 apps
GET
(*args)¶Serve a single static file ignoring the remaining path
This is useful in combination with a browser-based app using the HTML5 history API.
exposed
= True¶salt.netapi.rest_cherrypy.app.
Events
¶Expose the Salt event bus
The event bus on the Salt master exposes a large variety of things, notably when executions are started on the master and also when minions ultimately return their results. This URL provides a real-time window into a running Salt infrastructure.
See also
events
GET
(token=None, salt_token=None)¶An HTTP stream of the Salt master event bus
This stream is formatted per the Server Sent Events (SSE) spec. Each event is formatted as JSON.
GET
/events
¶Status Codes: |
|
---|---|
Query Parameters: | |
|
Example request:
curl -NsS localhost:8000/events
GET /events HTTP/1.1
Host: localhost:8000
Example response:
Note, the tag
field is not part of the spec. SSE compliant clients
should ignore unknown fields. This addition allows non-compliant
clients to only watch for certain tags without having to deserialze the
JSON object each time.
HTTP/1.1 200 OK
Connection: keep-alive
Cache-Control: no-cache
Content-Type: text/event-stream;charset=utf-8
retry: 400
tag: salt/job/20130802115730568475/new
data: {'tag': 'salt/job/20130802115730568475/new', 'data': {'minions': ['ms-4', 'ms-3', 'ms-2', 'ms-1', 'ms-0']}}
tag: salt/job/20130802115730568475/ret/jerry
data: {'tag': 'salt/job/20130802115730568475/ret/jerry', 'data': {'jid': '20130802115730568475', 'return': True, 'retcode': 0, 'success': True, 'cmd': '_return', 'fun': 'test.ping', 'id': 'ms-1'}}
The event stream can be easily consumed via JavaScript:
var source = new EventSource('/events');
source.onopen = function() { console.debug('opening') };
source.onerror = function(e) { console.debug('error!', e) };
source.onmessage = function(e) {
console.debug('Tag: ', e.data.tag)
console.debug('Data: ', e.data.data)
};
Or using CORS:
var source = new EventSource('/events?token=ecd589e4e01912cf3c4035afad73426dbb8dba75', {withCredentials: true});
It is also possible to consume the stream via the shell.
Records are separated by blank lines; the data:
and tag:
prefixes will need to be removed manually before attempting to
unserialize the JSON.
curl's -N
flag turns off input buffering which is required to
process the stream incrementally.
Here is a basic example of printing each event as it comes in:
curl -NsS localhost:8000/events |\
while IFS= read -r line ; do
echo $line
done
Here is an example of using awk to filter events based on tag:
curl -NsS localhost:8000/events |\
awk '
BEGIN { RS=""; FS="\\n" }
$1 ~ /^tag: salt\/job\/[0-9]+\/new$/ { print $0 }
'
tag: salt/job/20140112010149808995/new
data: {"tag": "salt/job/20140112010149808995/new", "data": {"tgt_type": "glob", "jid": "20140112010149808995", "tgt": "jerry", "_stamp": "2014-01-12_01:01:49.809617", "user": "shouse", "arg": [], "fun": "test.ping", "minions": ["jerry"]}}
tag: 20140112010149808995
data: {"tag": "20140112010149808995", "data": {"fun_args": [], "jid": "20140112010149808995", "return": true, "retcode": 0, "success": true, "cmd": "_return", "_stamp": "2014-01-12_01:01:49.819316", "fun": "test.ping", "id": "jerry"}}
exposed
= True¶salt.netapi.rest_cherrypy.app.
Jobs
¶GET
(jid=None, timeout='')¶A convenience URL for getting lists of previously run jobs or getting the return from a single job
GET
/jobs/
(jid)¶List jobs or show a single job from the job cache.
Request Headers: | |
---|---|
|
|
Status Codes: |
|
Example request:
curl -i localhost:8000/jobs
GET /jobs HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Example response:
HTTP/1.1 200 OK
Content-Length: 165
Content-Type: application/x-yaml
return:
- '20121130104633606931':
Arguments:
- '3'
Function: test.fib
Start Time: 2012, Nov 30 10:46:33.606931
Target: jerry
Target-type: glob
Example request:
curl -i localhost:8000/jobs/20121130104633606931
GET /jobs/20121130104633606931 HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Example response:
HTTP/1.1 200 OK
Content-Length: 73
Content-Type: application/x-yaml
info:
- Arguments:
- '3'
Function: test.fib
Minions:
- jerry
Start Time: 2012, Nov 30 10:46:33.606931
Target: '*'
Target-type: glob
User: saltdev
jid: '20121130104633606931'
return:
- jerry:
- - 0
- 1
- 1
- 2
- 6.9141387939453125e-06
salt.netapi.rest_cherrypy.app.
Keys
¶Convenience URLs for working with minion keys
New in version 2014.7.0.
These URLs wrap the functionality provided by the key wheel
module
functions.
GET
(mid=None)¶Show the list of minion keys or detail on a specific key
New in version 2014.7.0.
GET
/keys/
(mid)¶List all keys or show a specific key
Status Codes: |
|
---|
Example request:
curl -i localhost:8000/keys
GET /keys HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Example response:
HTTP/1.1 200 OK
Content-Length: 165
Content-Type: application/x-yaml
return:
local:
- master.pem
- master.pub
minions:
- jerry
minions_pre: []
minions_rejected: []
Example request:
curl -i localhost:8000/keys/jerry
GET /keys/jerry HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Example response:
HTTP/1.1 200 OK
Content-Length: 73
Content-Type: application/x-yaml
return:
minions:
jerry: 51:93:b3:d0:9f:3a:6d:e5:28:67:c2:4b:27:d6:cd:2b
POST
(mid, keysize=None, force=None, **kwargs)¶Easily generate keys for a minion and auto-accept the new key
New in version 2014.7.0.
Example partial kickstart script to bootstrap a new minion:
%post
mkdir -p /etc/salt/pki/minion
curl -sSk https://localhost:8000/keys \
-d mid=jerry \
-d username=kickstart \
-d password=kickstart \
-d eauth=pam \
| tar -C /etc/salt/pki/minion -xf -
mkdir -p /etc/salt/minion.d
printf 'master: 10.0.0.5\nid: jerry' > /etc/salt/minion.d/id.conf
%end
POST
/keys
¶Generate a public and private key and return both as a tarball
Authentication credentials must be passed in the request.
Status Codes: |
|
---|
Example request:
curl -sSk https://localhost:8000/keys \
-d mid=jerry \
-d username=kickstart \
-d password=kickstart \
-d eauth=pam \
-o jerry-salt-keys.tar
POST /keys HTTP/1.1
Host: localhost:8000
Example response:
HTTP/1.1 200 OK
Content-Length: 10240
Content-Disposition: attachment; filename="saltkeys-jerry.tar"
Content-Type: application/x-tar
jerry.pub0000644000000000000000000000070300000000000010730 0ustar 00000000000000
salt.netapi.rest_cherrypy.app.
Login
(*args, **kwargs)¶Log in to receive a session token
GET
()¶Present the login interface
GET
/login
¶An explanation of how to log in.
Status Codes: |
|
---|
Example request:
curl -i localhost:8000/login
GET /login HTTP/1.1
Host: localhost:8000
Accept: text/html
Example response:
HTTP/1.1 200 OK
Content-Type: text/html
POST
(**kwargs)¶Authenticate against Salt's eauth system
POST
/login
¶Request Headers: | |
---|---|
|
|
Form Parameters: | |
|
|
Status Codes: |
|
Example request:
curl -si localhost:8000/login \
-H "Accept: application/json" \
-d username='saltuser' \
-d password='saltpass' \
-d eauth='pam'
POST / HTTP/1.1
Host: localhost:8000
Content-Length: 42
Content-Type: application/x-www-form-urlencoded
Accept: application/json
username=saltuser&password=saltpass&eauth=pam
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 206
X-Auth-Token: 6d1b722e
Set-Cookie: session_id=6d1b722e; expires=Sat, 17 Nov 2012 03:23:52 GMT; Path=/
{"return": {
"token": "6d1b722e",
"start": 1363805943.776223,
"expire": 1363849143.776224,
"user": "saltuser",
"eauth": "pam",
"perms": [
"grains.*",
"status.*",
"sys.*",
"test.*"
]
}}
salt.netapi.rest_cherrypy.app.
Logout
¶Class to remove or invalidate sessions
POST
()¶Destroy the currently active session and expire the session cookie
salt.netapi.rest_cherrypy.app.
LowDataAdapter
¶The primary entry point to Salt's REST API
GET
()¶An explanation of the API with links of where to go next
GET
/
¶Request Headers: | |
---|---|
|
|
Status Codes: |
|
Example request:
curl -i localhost:8000
GET / HTTP/1.1
Host: localhost:8000
Accept: application/json
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
POST
¶Mock out specified imports
This allows autodoc to do its thing without having oodles of req'd
installed libs. This doesn't work with import *
imports.
exec_lowstate
(client=None, token=None)¶Pull a Low State data structure from request and execute the low-data chunks through Salt. The low-data chunks will be updated to include the authorization token for the current session.
exposed
= True¶salt.netapi.rest_cherrypy.app.
Minions
¶Convenience URLs for working with minions
GET
(mid=None)¶A convenience URL for getting lists of minions or getting minion details
GET
/minions/
(mid)¶Request Headers: | |
---|---|
|
|
Status Codes: |
|
Example request:
curl -i localhost:8000/minions/ms-3
GET /minions/ms-3 HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Example response:
HTTP/1.1 200 OK
Content-Length: 129005
Content-Type: application/x-yaml
return:
- ms-3:
grains.items:
...
POST
(**kwargs)¶Start an execution command and immediately return the job id
POST
/minions
¶Request Headers: | |
---|---|
|
|
Response Headers: | |
|
|
Status Codes: |
|
lowstate data describing Salt commands must be sent in the
request body. The client
option will be set to
local_async()
.
Example request:
curl -sSi localhost:8000/minions \
-H "Accept: application/x-yaml" \
-d tgt='*' \
-d fun='status.diskusage'
POST /minions HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Content-Length: 26
Content-Type: application/x-www-form-urlencoded
tgt=*&fun=status.diskusage
Example response:
HTTP/1.1 202 Accepted
Content-Length: 86
Content-Type: application/x-yaml
return:
- jid: '20130603122505459265'
minions: [ms-4, ms-3, ms-2, ms-1, ms-0]
_links:
jobs:
- href: /jobs/20130603122505459265
salt.netapi.rest_cherrypy.app.
Run
¶Class to run commands without normal session handling
POST
(**kwargs)¶Run commands bypassing the normal session handling
POST
/run
¶This entry point is primarily for "one-off" commands. Each request
must pass full Salt authentication credentials. Otherwise this URL
is identical to the root URL (/)
.
lowstate data describing Salt commands must be sent in the request body.
Status Codes: |
|
---|
Example request:
curl -sS localhost:8000/run \
-H 'Accept: application/x-yaml' \
-d client='local' \
-d tgt='*' \
-d fun='test.ping' \
-d username='saltdev' \
-d password='saltdev' \
-d eauth='pam'
POST /run HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Content-Length: 75
Content-Type: application/x-www-form-urlencoded
client=local&tgt=*&fun=test.ping&username=saltdev&password=saltdev&eauth=pam
Example response:
HTTP/1.1 200 OK
Content-Length: 73
Content-Type: application/x-yaml
return:
- ms-0: true
ms-1: true
ms-2: true
ms-3: true
ms-4: true
The /run enpoint can also be used to issue commands using the salt-ssh subsystem.
When using salt-ssh, eauth credentials should not be supplied. Instad, authentication should be handled by the SSH layer itself. The use of the salt-ssh client does not require a salt master to be running. Instead, only a roster file must be present in the salt configuration directory.
All SSH client requests are synchronous.
** Example SSH client request:**
curl -sS localhost:8000/run \
-H 'Accept: application/x-yaml' \
-d client='ssh' \
-d tgt='*' \
-d fun='test.ping'
POST /run HTTP/1.1
Host: localhost:8000
Accept: application/x-yaml
Content-Length: 75
Content-Type: application/x-www-form-urlencoded
client=ssh&tgt=*&fun=test.ping
Example SSH response:
return:
- silver:
fun: test.ping
fun_args: []
id: silver
jid: '20141203103525666185'
retcode: 0
return: true
success: true
salt.netapi.rest_cherrypy.app.
Stats
¶Expose statistics on the running CherryPy server
GET
()¶Return a dump of statistics collected from the CherryPy server
GET
/stats
¶Request Headers: | |
---|---|
|
|
Response Headers: | |
|
|
Status Codes: |
|
exposed
= True¶salt.netapi.rest_cherrypy.app.
Webhook
¶A generic web hook entry point that fires an event on Salt's event bus
External services can POST data to this URL to trigger an event in Salt. For example, Amazon SNS, Jenkins-CI or Travis-CI, or GitHub web hooks.
Note
Be mindful of security
Salt's Reactor can run any code. A Reactor SLS that responds to a hook event is responsible for validating that the event came from a trusted source and contains valid data.
This is a generic interface and securing it is up to you!
This URL requires authentication however not all external services can be configured to authenticate. For this reason authentication can be selectively disabled for this URL. Follow best practices -- always use SSL, pass a secret key, configure the firewall to only allow traffic from a known source, etc.
The event data is taken from the request body. The Content-Type header is respected for the payload.
The event tag is prefixed with salt/netapi/hook
and the URL path is
appended to the end. For example, a POST
request sent to
/hook/mycompany/myapp/mydata
will produce a Salt event with the tag
salt/netapi/hook/mycompany/myapp/mydata
.
The following is an example .travis.yml
file to send notifications to
Salt of successful test runs:
language: python
script: python -m unittest tests
after_success:
- |
curl -sSk https://saltapi-url.example.com:8000/hook/travis/build/success -d branch="${TRAVIS_BRANCH}" -d commit="${TRAVIS_COMMIT}"
See also
events, reactor
POST
(*args, **kwargs)¶Fire an event in Salt with a custom event tag and data
POST
/hook
¶Status Codes: |
|
---|
Example request:
curl -sS localhost:8000/hook -d foo='Foo!' -d bar='Bar!'
POST /hook HTTP/1.1
Host: localhost:8000
Content-Length: 16
Content-Type: application/x-www-form-urlencoded
foo=Foo&bar=Bar!
Example response:
HTTP/1.1 200 OK
Content-Length: 14
Content-Type: application/json
{"success": true}
As a practical example, an internal continuous-integration build
server could send an HTTP POST request to the URL
https://localhost:8000/hook/mycompany/build/success
which contains
the result of a build and the SHA of the version that was built as
JSON. That would then produce the following event in Salt that could be
used to kick off a deployment via Salt's Reactor:
Event fired at Fri Feb 14 17:40:11 2014
*************************
Tag: salt/netapi/hook/mycompany/build/success
Data:
{'_stamp': '2014-02-14_17:40:11.440996',
'headers': {
'X-My-Secret-Key': 'F0fAgoQjIT@W',
'Content-Length': '37',
'Content-Type': 'application/json',
'Host': 'localhost:8000',
'Remote-Addr': '127.0.0.1'},
'post': {'revision': 'aa22a3c4b2e7', 'result': True}}
Salt's Reactor could listen for the event:
reactor:
- 'salt/netapi/hook/mycompany/build/*':
- /srv/reactor/react_ci_builds.sls
And finally deploy the new build:
{% set secret_key = data.get('headers', {}).get('X-My-Secret-Key') %}
{% set build = data.get('post', {}) %}
{% if secret_key == 'F0fAgoQjIT@W' and build.result == True %}
deploy_my_app:
cmd.state.sls:
- tgt: 'application*'
- arg:
- myapp.deploy
- kwarg:
pillar:
revision: {{ revision }}
{% endif %}
exposed
= True¶tag_base
= ['salt', 'netapi', 'hook']¶salt.netapi.rest_cherrypy.app.
WebsocketEndpoint
¶Open a WebSocket connection to Salt's event bus
The event bus on the Salt master exposes a large variety of things, notably when executions are started on the master and also when minions ultimately return their results. This URL provides a real-time window into a running Salt infrastructure. Uses websocket as the transport mechanism.
See also
events
GET
(token=None, **kwargs)¶Return a websocket connection of Salt's event stream
GET
/ws/
(token)¶Query format_events: | |
---|---|
The event stream will undergo server-side
formatting if the curl -NsS <...snip...> localhost:8000/ws?format_events
|
|
Reqheader X-Auth-Token: | |
an authentication token from
|
|
Status 101: | switching to the websockets protocol |
Status 401: | authentication required |
Status 406: | requested Content-Type not available |
Example request:
- curl -NsSk
- -H 'X-Auth-Token: ffedf49d' -H 'Host: localhost:8000' -H 'Connection: Upgrade' -H 'Upgrade: websocket' -H 'Origin: https://localhost:8000' -H 'Sec-WebSocket-Version: 13' -H 'Sec-WebSocket-Key: '"$(echo -n $RANDOM | base64)" localhost:8000/ws
GET /ws HTTP/1.1
Connection: Upgrade
Upgrade: websocket
Host: localhost:8000
Origin: https://localhost:8000
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: s65VsgHigh7v/Jcf4nXHnA==
X-Auth-Token: ffedf49d
Example response:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: mWZjBV9FCglzn1rIKJAxrTFlnJE=
Sec-WebSocket-Version: 13
An authentication token may optionally be passed as part of the URL for browsers that cannot be configured to send the authentication header or cookie:
curl -NsS <...snip...> localhost:8000/ws/ffedf49d
The event stream can be easily consumed via JavaScript:
// Note, you must be authenticated!
var source = new Websocket('ws://localhost:8000/ws/d0ce6c1a');
source.onerror = function(e) { console.debug('error!', e); };
source.onmessage = function(e) { console.debug(e.data); };
source.send('websocket client ready')
source.close();
Or via Python, using the Python module websocket-client for example.
# Note, you must be authenticated!
from websocket import create_connection
ws = create_connection('ws://localhost:8000/ws/d0ce6c1a')
ws.send('websocket client ready')
# Look at https://pypi.python.org/pypi/websocket-client/ for more
# examples.
while listening_to_events:
print ws.recv()
ws.close()
Above examples show how to establish a websocket connection to Salt and
activating real time updates from Salt's event stream by signaling
websocket client ready
.
exposed
= True¶salt.netapi.rest_cherrypy.app.
cors_handler
(*args, **kwargs)¶Check a CORS preflight request and return a valid response
salt.netapi.rest_cherrypy.app.
cors_tool
()¶Handle both simple and complex CORS requests
Add CORS headers to each response. If the request is a CORS preflight request swap out the default handler with a simple, single-purpose handler that verifies the request and provides a valid CORS response.
salt.netapi.rest_cherrypy.app.
get_app
(opts)¶Returns a WSGI app and a configuration dictionary
salt.netapi.rest_cherrypy.app.
html_override_tool
()¶Bypass the normal handler and serve HTML for all URLs
The app_path
setting must be non-empty and the request must ask for
text/html
in the Accept
header.
salt.netapi.rest_cherrypy.app.
hypermedia_handler
(*args, **kwargs)¶Determine the best output format based on the Accept header, execute the regular handler, and transform the output to the request content type (even if it's an error).
Parameters: |
|
---|
salt.netapi.rest_cherrypy.app.
hypermedia_in
()¶Unserialize POST/PUT data of a specified Content-Type.
The following custom processors all are intended to format Low State data and will place that data structure into the request object.
Raises HTTPError: | |
---|---|
if the request contains a Content-Type that we do not have a processor for |
salt.netapi.rest_cherrypy.app.
hypermedia_out
()¶Determine the best handler for the requested content type
Wrap the normal handler and transform the output from that handler into the requested content type
salt.netapi.rest_cherrypy.app.
json_processor
(entity)¶A decorator to skip a processor function if process_request_body is False
salt.netapi.rest_cherrypy.app.
lowdata_fmt
()¶Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run.
salt.netapi.rest_cherrypy.app.
salt_api_acl_tool
(username, request)¶..versionadded:: Boron
Verifies user requests against the API whitelist. (User/IP pair) in order to provide whitelisting for the API similar to the master, but over the API.
..code-block:: yaml
- rest_cherrypy:
- api_acl:
- users:
- '*':
- 1.1.1.1
- 1.1.1.2
- foo:
- 8.8.4.4
- bar:
- '*'
Parameters: |
|
---|
salt.netapi.rest_cherrypy.app.
salt_auth_tool
()¶Redirect all unauthenticated requests to the login page
salt.netapi.rest_cherrypy.app.
salt_ip_verify_tool
()¶If there is a list of restricted IPs, verify current client is coming from one of those IPs.
salt.netapi.rest_cherrypy.app.
salt_token_tool
()¶If the custom authentication header is supplied, put it in the cookie dict so the rest of the session-based auth works as intended
salt.netapi.rest_cherrypy.app.
text_processor
(entity)¶A decorator to skip a processor function if process_request_body is False
salt.netapi.rest_cherrypy.app.
urlencoded_processor
(entity)¶Accept x-www-form-urlencoded data (run through CherryPy's formatter) and reformat it into a Low State data structure.
Since we can't easily represent complicated data structures with key-value pairs, any more complicated requirements (e.g. compound commands) must instead be delivered via JSON or YAML.
For example:
.. code-block:: bash
- curl -si localhost:8000 -d client=local -d tgt='*'
- -d fun='test.kwarg' -d arg='one=1' -d arg='two=2'
Parameters: | entity -- raw POST data |
---|
salt.netapi.rest_cherrypy.app.
yaml_processor
(entity)¶A decorator to skip a processor function if process_request_body is False
Docs for previous releases are available on readthedocs.org.
Latest Salt release: 2015.8.0