blob: bcce88ee3cfce301abebe9592bda7b10713284f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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']))
|