summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/recipes/session.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2021-12-01 13:14:07 -0600
committerJohn Estabrook <jestabro@vyos.io>2021-12-01 15:38:26 -0600
commit358831c18fcf2937f4bf85a55fa0c8bdc802d817 (patch)
treef17361f7a66a0bda293a4e9f26cdcf3aadeee5b2 /src/services/api/graphql/recipes/session.py
parentf2bdd26c36e7074d093e001656bc649b7c7426d3 (diff)
downloadvyos-1x-358831c18fcf2937f4bf85a55fa0c8bdc802d817.tar.gz
vyos-1x-358831c18fcf2937f4bf85a55fa0c8bdc802d817.zip
graphql: T3993: define add/delete system image request
Diffstat (limited to 'src/services/api/graphql/recipes/session.py')
-rw-r--r--src/services/api/graphql/recipes/session.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/services/api/graphql/recipes/session.py b/src/services/api/graphql/recipes/session.py
index f8c072b39..5ece78ee6 100644
--- a/src/services/api/graphql/recipes/session.py
+++ b/src/services/api/graphql/recipes/session.py
@@ -7,7 +7,12 @@ from vyos.config import Config
from vyos.configtree import ConfigTree
from vyos.template import render
-class Session(object):
+class Session:
+ """
+ Wrapper for calling configsession functions based on GraphQL requests.
+ Non-nullable fields in the respective schema allow avoiding a key check
+ in 'data'.
+ """
def __init__(self, session, data):
self._session = session
self._data = data
@@ -94,3 +99,25 @@ class Session(object):
raise error
return out
+
+ def add(self):
+ session = self._session
+ data = self._data
+
+ try:
+ res = session.install_image(data['location'])
+ except Exception as error:
+ raise error
+
+ return res
+
+ def delete(self):
+ session = self._session
+ data = self._data
+
+ try:
+ res = session.remove_image(data['name'])
+ except Exception as error:
+ raise error
+
+ return res