From f26ef563bca94f04531b610ffd904baf1c14d36c Mon Sep 17 00:00:00 2001 From: John Bowdre <61015723+jbowdre@users.noreply.github.com> Date: Tue, 14 Jun 2022 08:49:12 -0500 Subject: [PATCH] Create vraLogout.js --- .../com.virtuallypotato.utility/vraLogout.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Orchestrator/Actions/com.virtuallypotato.utility/vraLogout.js diff --git a/Orchestrator/Actions/com.virtuallypotato.utility/vraLogout.js b/Orchestrator/Actions/com.virtuallypotato.utility/vraLogout.js new file mode 100644 index 0000000..b0e8903 --- /dev/null +++ b/Orchestrator/Actions/com.virtuallypotato.utility/vraLogout.js @@ -0,0 +1,14 @@ +/* JavaScript: vraLogout action + Logs out of a connected vRA REST endpoint. + Inputs: token (string) + Return type: string +*/ +var host = System.getModule("com.virtuallypotato.utility").getConfigValue("vPotato", "Endpoints", "vRAHost").host; +var logoutObj = { + idToken: token +}; +var logoutJson = JSON.stringify(logoutObj); +var request = host.createRequest("POST", "/csp/gateway/am/api/auth/logout", logoutJson); +request.setHeader("Content-Type", "application/json"); +request.execute().statusCode; +System.debug("Terminated vRA API session: " + token);