def deletef(key_name,file_sign): """Delete a cloud hjws with a _hjws.json file """ url=vars.eHost+'/htsp/hjws' conf_data = common.parse(vars.fileConf) if not conf_data: print("Bad config file") return if (not key_name in conf_data["branch"]): print("Bad key name") return for i in file_sign: data = common.parse(i.name) if not data: print("Bad config file") return if (not "id_hjws" in data): print("Bad id_hjws") return message = {"api_key": conf_data["branch"][key_name], "id_hjws": data["id_hjws"]} response=common.sendingDel(url,message) if response["status_code"] != 200: print('\n'+i.name) print(json.dumps(response["content"],indent=2)) return print('\n'+i.name) print(json.dumps(response["content"],indent=2)) os.remove(i.name)
def deletef(key_name,file_sign): """Delete a snippet """ url=vars.eHost+'/snippets/id' conf_data = common.parse(vars.fileConf) if not conf_data: print("Bad config file") return if (not key_name in conf_data["branch"]): print("Bad key name") return for i in file_sign: print('\n'+i.name) message = common.parse(i.name) if not message: print("Bad json file: ", i.name) return if (not"id_data" in message): print("Bad snpt file: ", i.name) return url=vars.eHost+'/snippets' message["api_key"] = conf_data["branch"][key_name] response=common.sendingDel(url, message) print('\n'+i.name) if response["status_code"] != 200: print(json.dumps(response["content"],indent=2)) return print(json.dumps(response["content"],indent=2)) os.remove(i.name)
def subject(subject): """Delete a subject """ url = vars.eHost + '/htsp/subject' conf_data = common.parse(vars.fileConf) if not conf_data: print("Bad config file") return if (not "jwt" in conf_data): print("You need to login first") return if (not subject in conf_data["subject"]): print("Bad subject name") return message = {"id_sec": conf_data["subject"][subject]} headers = {"Authorization": conf_data["jwt"]} click.confirm('Do you want to continue?', abort=True) response = common.sendingDel(url, message, headers) if response["status_code"] != 200: print(json.dumps(response["content"], indent=2)) return print(json.dumps(response["content"], indent=2)) if (isinstance(conf_data[subject], list)): for i in conf_data[subject]: del conf_data["branch"][i] del conf_data["subject"][subject] del conf_data[subject] with open(vars.fileConf, 'w') as outfile: json.dump(conf_data, outfile, indent=2)
def delete(key_name,id_hjws): """Delete a cloud hjws with a id_hjws """ url=vars.eHost+'/htsp/hjws' conf_data = common.parse(vars.fileConf) if not conf_data: print("Bad config file") return if (not key_name in conf_data["branch"]): print("Bad key name") return for i in id_hjws: message = {"api_key": conf_data["branch"][key_name], "id_hjws": i} response=common.sendingDel(url,message) print('\n'+i) print(json.dumps(response["content"],indent=2))
def account(): """Delete a account """ url = vars.eHost + '/htsp/account' conf_data = common.parse(vars.fileConf) if not conf_data: print("Bad config file") return if (not "jwt" in conf_data): print("You need to login first") return message = {} headers = {"Authorization": conf_data["jwt"]} click.confirm('Do you want to continue?', abort=True) response = common.sendingDel(url, message, headers) if response["status_code"] != 200: print(json.dumps(response["content"], indent=2)) return print(json.dumps(response["content"], indent=2)) os.remove(vars.fileConf)
def branch(subject, key_name): """Delete a key """ url = vars.eHost + '/htsp/branch' conf_data = common.parse(vars.fileConf) if not conf_data: print("Bad config file") return if (not "jwt" in conf_data): print("You need to login first") return if (not isinstance(conf_data[subject], list)): print("Bad file config subject/branch") return if (conf_data[subject].count(key_name) == 0): print("Bad subject") return if (not "branch" in conf_data): print("You need to init first") return if (not isinstance(conf_data["branch"], dict)): print("Bad branches") return if (not key_name in conf_data["branch"]): print("Bad key name") return message = {"kid": conf_data["branch"][key_name].split('.')[0]} headers = {"Authorization": conf_data["jwt"]} click.confirm('Do you want to continue?', abort=True) response = common.sendingDel(url, message, headers) if response["status_code"] != 200: print(json.dumps(response["content"], indent=2)) return print(json.dumps(response["content"], indent=2)) del conf_data["branch"][key_name] conf_data[subject].remove(key_name) with open(vars.fileConf, 'w') as outfile: json.dump(conf_data, outfile, indent=2)