From 6e719622e8326e4fe90b8c241f1efc75f6d6aa2f Mon Sep 17 00:00:00 2001 From: David Kaufmann Date: Tue, 11 Dec 2018 15:10:09 +0100 Subject: [PATCH] delete default users --- camunda-overlay/camunda.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/camunda-overlay/camunda.py b/camunda-overlay/camunda.py index 65ad271..514b508 100755 --- a/camunda-overlay/camunda.py +++ b/camunda-overlay/camunda.py @@ -34,6 +34,26 @@ def cleanup_old_deployments(key='sentiment-analysis'): except: pprint(res.content) +def get_users(): + res = requests.get(CAMUNDA + "user") + return res.json() + +def cleanup_users(keep = ["demo"]): + for user in get_users(): + # keep user "demo" + if user['id'] in keep: + continue + + res = requests.delete(CAMUNDA + "user/" + user['id']) + if (res.status_code == 204): + print ("Cleaned up user {}".format(user['id'])) + else: + print ("Error cleaning user {}: Code: {}".format(user['id'], res.status_code)) + try: + pprint(res.json()) + except: + pprint(res.content) + def create_deployment(cleanup=False): parameters = [ ("deployment-name", "sentiment-analysis"), @@ -106,6 +126,8 @@ if __name__ == "__main__": if args.deploy: # initialize camunda process create_deployment(cleanup=args.cleanup) + if args.cleanup: + cleanup_users() if args.autoclick >= 1: # start clicking -- 2.43.0