Merge branch '58-reporting-add-health-endpoint-to-service' into 'master'
[pub/jan/aic18.git] / camunda-overlay / camunda.py
index b9fa022039145932a00a557df85dee8c32c4dea5..ae76619e5d7e2853bd6d4ba771c2eca0b4d5884b 100755 (executable)
@@ -54,6 +54,26 @@ def cleanup_users(keep = ["demo"]):
             except:
                 pprint(res.content)
 
+def get_filters():
+    res = requests.get(CAMUNDA + "filter")
+    return res.json()
+
+def cleanup_filters(keep = ["All Tasks"]):
+    for filter in get_filters():
+        # keep filter "All Tasks"
+        if filter['name'] in keep:
+            continue
+
+        res = requests.delete(CAMUNDA + "filter/" + filter['id'])
+        if (res.status_code == 204):
+            print ("Cleaned up filter {}".format(filter['name']))
+        else:
+            print ("Error cleaning filter {} ({}): Code: {}".format(filter['name'], filter['id'], res.status_code))
+            try:
+                pprint(res.json())
+            except:
+                pprint(res.content)
+
 def create_deployment(cleanup=False):
     parameters = [
             ("deployment-name", "sentiment-analysis"),
@@ -129,6 +149,7 @@ if __name__ == "__main__":
         create_deployment(cleanup=args.cleanup)
         if args.cleanup:
             cleanup_users()
+            cleanup_filters()
 
     if args.autoclick >= 1:
         # start clicking