From 358831c18fcf2937f4bf85a55fa0c8bdc802d817 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 1 Dec 2021 13:14:07 -0600 Subject: graphql: T3993: define add/delete system image request --- src/services/api/graphql/recipes/session.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/services/api/graphql/recipes') 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 -- cgit v1.2.3