summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreduardormorais <eduardoromorais@gmail.com>2025-08-27 17:55:43 -0300
committereduardormorais <eduardoromorais@gmail.com>2025-08-27 17:55:43 -0300
commite770412a93d2bbbc95bbb5a5edcdbb23036fd7dd (patch)
treeae4d11db51eb4cba1c75a0f6b31dc65a7eab8898
parent0c9cf41304670516171a8cdc13712af875912805 (diff)
parentac03cf884fade1c6945763b6d399e758d706a02b (diff)
downloadpyvyos-e770412a93d2bbbc95bbb5a5edcdbb23036fd7dd.tar.gz
pyvyos-e770412a93d2bbbc95bbb5a5edcdbb23036fd7dd.zip
Merge remote-tracking branch 'anusajith/update_get_payload' into release/0.3.0
-rw-r--r--pyvyos/device.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/pyvyos/device.py b/pyvyos/device.py
index cb8f642..6579587 100644
--- a/pyvyos/device.py
+++ b/pyvyos/device.py
@@ -107,11 +107,16 @@ class VyDevice:
Returns:
dict: The payload for the API request.
"""
- # Adjusting the data structure based on whether path is single or multiple
- if isinstance(path[0], list): # Handling multiple paths
- data = [{'op': op, 'path': p} for p in path]
- else: # Handling a single path
- data = {'op': op, 'path': path}
+ # Adding option to pass multiple operation (eg:delete and set) commands
+ if op:
+ # Adjusting the data structure based on whether path is single or multiple
+ if path and isinstance(path, list) and isinstance(path[0], list): # Handling multiple paths
+ data = [{'op': op, 'path': p} for p in path]
+ else: # Handling a single path
+ data = {'op': op, 'path': path}
+ else:
+ if path and isinstance(path[0], dict):
+ data = path
# Including the optional parameters if provided
if file:
@@ -299,6 +304,19 @@ class VyDevice:
"""
return self._api_request(command="configure", op='delete', path=path, method="POST")
+ def configure_multiple_op(self, op_path=[]):
+ """
+ Set configuration based on the given {operation : path} for multiple operation.
+
+ Args:
+ op_path (list): The path elements for configuration deletion or/and setting.
+ eg: [{'op': 'delete', 'path': [...]}, {'op': 'set', 'path': [...]}]
+
+ Returns:
+ ApiResponse: An ApiResponse object representing the API response.
+ """
+ return self._api_request(command="configure", op="", path=op_path)
+
def config_file_save(self, file=None):
"""
Save the configuration to a file.