From 970154e24d3e1558859aaccfa8482a8b06f13cef Mon Sep 17 00:00:00 2001 From: John Bowdre <61015723+jbowdre@users.noreply.github.com> Date: Tue, 14 Jun 2022 09:04:02 -0500 Subject: [PATCH] Create vcLogout.js --- .../Actions/com.virtuallypotato.utility/vcLogout.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Orchestrator/Actions/com.virtuallypotato.utility/vcLogout.js diff --git a/Orchestrator/Actions/com.virtuallypotato.utility/vcLogout.js b/Orchestrator/Actions/com.virtuallypotato.utility/vcLogout.js new file mode 100644 index 0000000..f1ad331 --- /dev/null +++ b/Orchestrator/Actions/com.virtuallypotato.utility/vcLogout.js @@ -0,0 +1,12 @@ +/* JavaScript: vcLogout action + Logs out of a connected vCenter REST endpoint. + Inputs: token (string), vCenterName (string) + Return type: string +*/ +var host = System.getModule("com.virtuallypotato.utility").getConfigValue("vPotato", "Endpoints", vCenterName).host; +System.debug("Closing vCenter API session: " + token); +var request = host.createRequest("DELETE", "/api/session"); +request.setHeader("Content-Type", "application/json"); +request.setHeader("vmware-api-session-id", token); +var result = request.execute().statusCode; +System.debug("Result status code: " + result);