diff options
author | John Estabrook <jestabro@vyos.io> | 2023-06-10 16:45:47 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-06-10 22:39:28 -0500 |
commit | 1c0d91fab1c430fcfd44cf5af80f5170b9a23156 (patch) | |
tree | 666dc4440ff44a22268b5852609a4e9749fd92be | |
parent | efc168bc702f6ff0b2b54918ff226d04ed493c5e (diff) | |
download | vyos-1x-1c0d91fab1c430fcfd44cf5af80f5170b9a23156.tar.gz vyos-1x-1c0d91fab1c430fcfd44cf5af80f5170b9a23156.zip |
http-api: T5263: factor out function _configure_op for generalization
-rwxr-xr-x | src/services/vyos-http-api-server | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server index 567564cc0..51dafe922 100755 --- a/src/services/vyos-http-api-server +++ b/src/services/vyos-http-api-server @@ -402,12 +402,14 @@ app.router.route_class = MultipartRoute async def validation_exception_handler(request, exc): return error(400, str(exc.errors()[0])) -@app.post('/configure') -async def configure_op(data: Union[ConfigureModel, ConfigureListModel]): +def _configure_op(data: Union[ConfigureModel, ConfigureListModel], + request: Request): session = app.state.vyos_session env = session.get_session_env() config = vyos.config.Config(session_env=env) + endpoint = request.url.path + # Allow users to pass just one command if not isinstance(data, ConfigureListModel): data = [data] @@ -420,6 +422,7 @@ async def configure_op(data: Union[ConfigureModel, ConfigureListModel]): lock.acquire() status = 200 + msg = None error_msg = None try: for c in data: @@ -469,7 +472,13 @@ async def configure_op(data: Union[ConfigureModel, ConfigureListModel]): if status != 200: return error(status, error_msg) - return success(None) + return success(msg) + +@app.post('/configure') +async def configure_op(data: Union[ConfigureModel, + ConfigureListModel], + request: Request): + return _configure_op(data, request) @app.post("/retrieve") async def retrieve_op(data: RetrieveModel): |