diff options
author | xTITUSMAXIMUSX <chad@chadhigh.com> | 2024-03-01 17:36:34 -0600 |
---|---|---|
committer | xTITUSMAXIMUSX <chad@chadhigh.com> | 2024-03-01 17:36:34 -0600 |
commit | b58cf4db2f41df5a71b56fde5a0901d7a6a3835c (patch) | |
tree | ee0cd8415383d75866c4a622613a0b2e6bf663fb /pyvyos/device.py | |
parent | 3edba0df5b073ddfbce291a5cddcf67a5fb254fd (diff) | |
download | pyvyos-b58cf4db2f41df5a71b56fde5a0901d7a6a3835c.tar.gz pyvyos-b58cf4db2f41df5a71b56fde5a0901d7a6a3835c.zip |
Fix issue with functions without paths
Diffstat (limited to 'pyvyos/device.py')
-rw-r--r-- | pyvyos/device.py | 23 |
1 files changed, 22 insertions, 1 deletions
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]} |