From 97e3d47f4372befae5d7ecba4f4ed8cf4cdabae6 Mon Sep 17 00:00:00 2001 From: John Bowdre <61015723+jbowdre@users.noreply.github.com> Date: Tue, 14 Jun 2022 09:02:11 -0500 Subject: [PATCH] Create vcLogin.js --- .../Actions/com.virtuallypotato.utility/vcLogin.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Orchestrator/Actions/com.virtuallypotato.utility/vcLogin.js diff --git a/Orchestrator/Actions/com.virtuallypotato.utility/vcLogin.js b/Orchestrator/Actions/com.virtuallypotato.utility/vcLogin.js new file mode 100644 index 0000000..a249446 --- /dev/null +++ b/Orchestrator/Actions/com.virtuallypotato.utility/vcLogin.js @@ -0,0 +1,13 @@ +/* JavaScript: vcLogin action + Retrieves a login token to a vCenter REST endpoint. + Inputs: vCenterName (string) + Return type: string +*/ +var host = System.getModule("com.virtuallypotato.utility").getConfigValue("vPotato", "Endpoints", vCenterName).host; +var request = host.createRequest("POST", "/api/session"); +request.setHeader("Content-Type", "application/json"); +var response = request.execute(); +var token = JSON.parse(response.contentAsString); +System.debug("Created vCenter API session: " + token); + +return token;