diff options
author | Roberto Berto <roberto.berto@under.com.br> | 2024-03-10 13:56:37 -0300 |
---|---|---|
committer | Roberto Berto <roberto.berto@under.com.br> | 2024-03-10 13:56:37 -0300 |
commit | f3d382288980f4e49b6b9a1bd1b9f86e22f1f06c (patch) | |
tree | 98b10481c34a07f564245a6622325f3e6343ab58 /pyvyos/device.py | |
parent | bf3d1770decc1810fdb69d4d32b2a9e89f6073b7 (diff) | |
download | pyvyos-f3d382288980f4e49b6b9a1bd1b9f86e22f1f06c.tar.gz pyvyos-f3d382288980f4e49b6b9a1bd1b9f86e22f1f06c.zip |
improved configure_set to multiple paths
Diffstat (limited to 'pyvyos/device.py')
-rw-r--r-- | pyvyos/device.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/pyvyos/device.py b/pyvyos/device.py index cc87a32..5b54394 100644 --- a/pyvyos/device.py +++ b/pyvyos/device.py @@ -51,7 +51,9 @@ class VyDevice: image_delete(name, url=None, file=None, path=[]): Delete a specific image. show(path=[]): Show configuration information. generate(path=[]): Generate configuration based on specified path. - configure_set(path=[]): Set configuration based on specified path. + configure_set(path=[]): Sets configuration based on the specified path. This method is versatile, accepting + either a single configuration path or a list of configuration paths. This flexibility + allows for setting both individual and multiple configurations in a single operation. configure_delete(path=[]): Delete configuration based on specified path. config_file_save(file=None): Save the configuration to a file. config_file_load(file=None): Load the configuration from a file. @@ -269,13 +271,25 @@ class VyDevice: """ Set configuration based on the given path. + This method accepts both a single configuration path as a list and a list of configuration paths for setting multiple configurations in one go. + Args: - path (list, optional): The path elements for configuration setting (default is an empty list). + path (list): The path elements for configuration setting. This can be a list for a single configuration, + or a list of lists for multiple configurations. Returns: - ApiResponse: An ApiResponse object representing the API response. - """ - return self._api_request(command="configure", op='set', path=path, method="POST") + ApiResponse or list of ApiResponse: Returns a single ApiResponse object for a single configuration, or a list of ApiResponse objects for multiple configurations. + """ + # Check if the first element of the path is a list, indicating multiple configurations + if path and isinstance(path[0], list): + # Process each configuration path separately + responses = [self._api_request("configure", "set", [p], "POST") for p in path] + # Return a list of ApiResponse objects for multiple configurations + return responses + else: + # Handle a single configuration path + return self._api_request("configure", "set", path, "POST") + def configure_delete(self, path=[]): """ |