summaryrefslogtreecommitdiff
path: root/src/services/vyos-http-api-server
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-08-05 21:20:54 +0200
committerDaniil Baturin <daniil@baturin.org>2019-08-05 21:20:54 +0200
commit9ac783472872329fe1a1683585b679a7afcc78f0 (patch)
tree9e04b2d799d81a34bffedcaa1e5e487e07a80191 /src/services/vyos-http-api-server
parentb4ed7280179e814b9837a0fbfa05ff8065dd8b50 (diff)
downloadvyos-1x-9ac783472872329fe1a1683585b679a7afcc78f0.tar.gz
vyos-1x-9ac783472872329fe1a1683585b679a7afcc78f0.zip
T1431: add showConfig operation to the HTTP API.
Diffstat (limited to 'src/services/vyos-http-api-server')
-rwxr-xr-xsrc/services/vyos-http-api-server14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server
index e11eb6d52..afab9be70 100755
--- a/src/services/vyos-http-api-server
+++ b/src/services/vyos-http-api-server
@@ -179,6 +179,7 @@ def configure():
@app.route('/retrieve', method='POST')
def get_value():
config = app.config['vyos_config']
+ session = app.config['vyos_session']
api_keys = app.config['vyos_keys']
@@ -190,8 +191,11 @@ def get_value():
command = bottle.request.forms.get("data")
command = json.loads(command)
- op = command['op']
- path = " ".join(command['path'])
+ try:
+ op = command['op']
+ path = " ".join(command['path'])
+ except KeyError:
+ return error(400, "Missing required field. \"op\" and \"path\" fields are required")
try:
if op == 'returnValue':
@@ -200,6 +204,12 @@ def get_value():
res = config.return_values(path)
elif op == 'exists':
res = config.exists(path)
+ elif op == 'showConfig':
+ config_format = 'raw'
+ if 'configFormat' in command:
+ config_format = command['configFormat']
+
+ res = session.show_config(command['path'], format=config_format)
else:
return error(400, "\"{0}\" is not a valid operation".format(op))
except VyOSError as e: