summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/recipes
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/api/graphql/recipes')
-rw-r--r--src/services/api/graphql/recipes/session.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/services/api/graphql/recipes/session.py b/src/services/api/graphql/recipes/session.py
index c6c3209c0..f8c072b39 100644
--- a/src/services/api/graphql/recipes/session.py
+++ b/src/services/api/graphql/recipes/session.py
@@ -1,6 +1,10 @@
+import json
+
from ariadne import convert_camel_case_to_snake
+
import vyos.defaults
from vyos.config import Config
+from vyos.configtree import ConfigTree
from vyos.template import render
class Session(object):
@@ -43,6 +47,21 @@ class Session(object):
session.delete(path)
session.commit()
+ def show_config(self):
+ session = self._session
+ data = self._data
+ out = ''
+
+ try:
+ out = session.show_config(data['path'])
+ if data.get('config_format', '') == 'json':
+ config_tree = vyos.configtree.ConfigTree(out)
+ out = json.loads(config_tree.to_json())
+ except Exception as error:
+ raise error
+
+ return out
+
def save(self):
session = self._session
data = self._data