diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2023-08-23 13:37:06 +0200 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2023-08-24 09:14:36 +0200 |
commit | 563e30893de06b2cee744694788ea2da60cb01a3 (patch) | |
tree | dddb93c077e90262096db536f610e1969865b4e8 /cli/cli.py | |
parent | 82e8880841e31a37060b3d2e5b7dd25abd9b91cf (diff) |
cli: add delete http method
Add delete function to OgRest class. Enable ogCLI to send HTTP
requests using DELETE as request verb.
Encapsulates requests python module .delete() method.
Diffstat (limited to 'cli/cli.py')
-rw-r--r-- | cli/cli.py | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -48,6 +48,19 @@ class OgREST(): sys.exit(f"Cannot connect to ogServer: {e}") return r + def delete(self, path, payload): + try: + r = requests.delete(f'{self.URL}{path}', + headers=self.HEADERS, + json=payload) + print(r.text) + if r.status_code != 200: + sys.exit(f"Unsuccessful request to ogServer: " + f"{r.status_code} HTTP status code") + except IOError as e: + sys.exit(f"Cannot connect to ogServer: {e}") + return r + class OgCLI(): def __init__(self, cfg): |