summaryrefslogtreecommitdiffstats
path: root/client/bug_delete.py
diff options
context:
space:
mode:
Diffstat (limited to 'client/bug_delete.py')
-rwxr-xr-xclient/bug_delete.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/client/bug_delete.py b/client/bug_delete.py
new file mode 100755
index 0000000..bcce88e
--- /dev/null
+++ b/client/bug_delete.py
@@ -0,0 +1,33 @@
+#!../flask/bin/python
+"""
+usage: bug delete [options] <ticket_id>
+
+If no arguments are given it will open your $EDITOR where the first line is
+the summary following a newline and then the body of the report. Both are
+required.
+
+ -h, --help Print this help text
+ -i, --ticket-id ID of the ticket to delete
+"""
+from docopt import docopt
+import json, requests
+
+if __name__ == '__main__':
+ print(docopt(__doc__))
+
+def call(args):
+ print(args)
+ api_endpoint = args['--uri'] + '/api/1.0/ticket/'
+
+ req = requests.delete(api_endpoint + args['<ticket_id>'])
+
+ res = json.loads(req.text)
+
+ if req.status_code == 404:
+ print("Ticket with ID '{}' could not be deleted: {}".format(args['<ticket_id>'], res['error']))
+ elif req.status_code == 200:
+ print("Ticket with ID '{}' deleted successfully.".format(args['<ticket_id>']))
+ else:
+ exit("ALERT ALERT ALERT")
+
+ #print("{} {}\n {}".format(t['id'], t['title'], t['uri']))