From b58cf4db2f41df5a71b56fde5a0901d7a6a3835c Mon Sep 17 00:00:00 2001 From: xTITUSMAXIMUSX Date: Fri, 1 Mar 2024 17:36:34 -0600 Subject: Fix issue with functions without paths --- pyvyos/device.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'pyvyos/device.py') diff --git a/pyvyos/device.py b/pyvyos/device.py index 2d14c53..0d1dad9 100644 --- a/pyvyos/device.py +++ b/pyvyos/device.py @@ -104,7 +104,28 @@ class VyDevice: Returns: dict: The payload for the API request. """ - + if not path: + data = { + 'op': op, + 'path': path + } + + if file is not None: + data['file'] = file + + if url is not None: + data['url'] = url + + if name is not None: + data['name'] = name + + payload = { + 'data': json.dumps(data), + 'key': self.apikey + } + + return payload + if isinstance(path, list) and len(path) == 1: # If path is a list and contains only one element, use it directly data = {'op': op, 'path': path[0]} -- cgit v1.2.3