#!../flask/bin/python """ usage: bug delete [options] 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, sys import configparser if __name__ == '__main__': print(docopt(__doc__)) def entrypoint(args): print(args) c = configparser.ConfigParser() c.read('config') config = c[args['--uri']] access_token = config['access_token'] uri = args['--uri'] + '/api/1.0/ticket/' + args[''] headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Access-Token': access_token, } req = requests.delete(uri, headers=headers, verify=False) res = json.loads(req.text) if req.status_code == (401 or 404): sys.exit("Ticket with ID '{}' could not be deleted: {}".format(args[''], res['error'])) elif req.status_code == 200: sys.exit("Ticket with ID '{}' deleted successfully.".format(args[''])) else: sys.exit("ALERT ALERT ALERT") #print("{} {}\n {}".format(t['id'], t['title'], t['uri']))