summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/libs/op_mode.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2022-11-02 14:28:51 -0500
committerGitHub <noreply@github.com>2022-11-02 14:28:51 -0500
commitf11b76ec56f9a94c4cfb435081c7b9a5986c060c (patch)
tree643871c3f5585f3c2437caeb7eb7beaf3b5a3390 /src/services/api/graphql/libs/op_mode.py
parentf2ec92a78c4ee2a35e7d071387460fc6ce360740 (diff)
parentdb0791238c9cccaf73aac61844a6c0293c513a54 (diff)
downloadvyos-1x-f11b76ec56f9a94c4cfb435081c7b9a5986c060c.tar.gz
vyos-1x-f11b76ec56f9a94c4cfb435081c7b9a5986c060c.zip
Merge pull request #1636 from jestabro/standardize-op-mode-output
op-mode: T4791: consistent normalization of 'raw' output of op-mode scripts for CLI and API
Diffstat (limited to 'src/services/api/graphql/libs/op_mode.py')
-rw-r--r--src/services/api/graphql/libs/op_mode.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/services/api/graphql/libs/op_mode.py b/src/services/api/graphql/libs/op_mode.py
index da2bcdb5b..97a26520e 100644
--- a/src/services/api/graphql/libs/op_mode.py
+++ b/src/services/api/graphql/libs/op_mode.py
@@ -17,8 +17,11 @@ import os
import re
import typing
import importlib.util
+from typing import Union
+from humps import decamelize
from vyos.defaults import directories
+from vyos.opmode import _normalize_field_names
def load_as_module(name: str, path: str):
spec = importlib.util.spec_from_file_location(name, path)
@@ -98,3 +101,6 @@ def map_type_name(type_name: type, optional: bool = False) -> str:
# scalar 'Generic' is defined in schema.graphql
return 'Generic'
+
+def normalize_output(result: Union[dict, list]) -> Union[dict, list]:
+ return _normalize_field_names(decamelize(result))