Before you can run the following "bookmark scripts" you will need to save your X-Authorization
header
as a global variable. It is easier than it sounds ;)
In Chrome, go to the Workflows Manager page and open the Admin Console, then go to the Network tab and
click the XHR
button at the top.
Find a request that look like metaworkflow?page=1&pageSize=15&sortColumn=name&sortDir=ASC
or
https://x-holding.devbettercloud.com/workflowBuilder/v2/metaworkflow?page=1&pageSize=15&sortColumn=name&sortDir=ASC
.
If you click on that request and go to the Request Headers section, you will see an entry that looks like
X-Authorization:[{"identity":"eyJhbGciOiJSUzI1N
...
ByRg","provider":"google"}]
Copy everything between (and including) the [{...]}
. Then in the console tab type var auth =
and paste your
header value. Hit enter to save it. It should look like:
var auth = [{"identity":"eyJhbGciOi...NVJzeByRg","provider":"google"}]
That's it... Now you can run the bookmark scripts below.
Copy the text below and save it as a bookmark. When you are on the BetterCloud workflow manager page, you can click on the bookmark to suspend ALL of you Workflows.
javascript:(function(){function fetchAll(a){var b=arguments.length<=1||void 0===arguments[1]?0:arguments[1];$.ajax({url:"/workflowBuilder/v2/metaworkflow?page="+b+"&pageSize=100&sortColumn=name&sortDir=ASC",headers:{"X-Authorization":JSON.stringify(auth)},success:function(d){a(d.items),b+1<d.totalPages?fetchAll(a,b+1):alert("Done suspending all workflows")}})}function suspendAll(){fetchAll(function(a){a.filter(function(a){return"ACTIVE"===a.state}).map(function(a){return a.workflowId}).forEach(suspend)})}function suspend(a){var b="/workflowBuilder/v2/metaworkflow/"+a+"/published/suspend";$.ajax({url:b,type:"PUT",headers:{"X-Authorization":JSON.stringify(auth)}})}auth?suspendThisPage():(console.error("Please define your authentication header"),console.log("var auth = [{...}]"),console.log("try again after you set the auth variable"));})();
Copy the text below and save it as a bookmark. When you are on the BetterCloud workflow manager page, you can click on the bookmark to suspend ALL of you Workflows on the current page.
javascript:(function(){function suspendThisPage(){var a=parseInt($("#input_1")[0].value)-1,b=$("#select_value_label_0 > span:nth-child(1) > div")[0].innerText,c="/workflowBuilder/v2/metaworkflow?page="+a+"&pageSize="+b+"&sortColumn=name&sortDir=ASC";$.ajax({url:c,headers:{"X-Authorization":JSON.stringify(auth)},success:function(b){var c=b.items.filter(function(a){return"ACTIVE"===a.state}).map(function(a){return a.workflowId}),d=c.length;c.forEach(suspend),alert("Done suspending "+d+" workflows")}})}function suspend(a){var b="/workflowBuilder/v2/metaworkflow/"+a+"/published/suspend";$.ajax({url:b,type:"PUT",headers:{"X-Authorization":JSON.stringify(auth)}})}auth?suspendThisPage():(console.error("Please define your authentication header"),console.log("var auth = [{...}]"),console.log("try again after you set the auth variable"));})();