cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1466
Views
0
Helpful
0
Comments
Alejandro Madurga Ainoza
Cisco Employee
Cisco Employee
Task NameGet User Rest API Key.
Description
  1. Gets the REST API Key from a given user name.
Prerequisites
  1. Tested on 5.3
CategoryCustom Task
Components
User Inputs
    • userName: The user name to get the Rest API KEY --> Generic Text Input
User Outputs
    • OUTPUT_REST_API_KEY: The rest api Key from the given user --> Generic Text Input

Instructions for Regular Workflow Use:

  1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
  2. Unzip the file on your computer. Should end up with a .WFDX file.
  3. Log in to UCS Director as a user that has "system-admin" privileges.
  4. Navigate to "Policies-->Orchestration" and click on "Import".
  5. Click "Browse" and navigate to the location on your computer where the .WFDX file resides. Choose the .WFDX file and click "Open".
  6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
  7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
  8. Click "Submit".
  9. A new task should appear in "Policies-->Orchestration--> Custom Workflow tasks" that contains the imported Custom Tasks.  Now you can drag and drop the new custom task on the Workflows.

The Custom Task:

Screen Shot 2015-06-29 at 9.40.09 AM.png

The task Input:

Screen Shot 2015-06-29 at 9.42.11 AM.png

The task Output:

Screen Shot 2015-06-29 at 9.42.16 AM.png

The Code:

/*

Name: getUserRestAPIKey.js

Author: Alex Madurga (almadurg@cisco.com)

Date: 26th July 2015

Version: 1

UCSD Version: 5.3

Description: Gets the REST API Key from a given user name.

  //INPUTS:

  userName: The user name to get the Rest API KEY --> Generic Text Input

  //OUTPUTS:

  OUTPUT_REST_API_KEY: The rest api Key from the given user --> Generic Text Input

*/

//IMPORTS

importPackage(com.cloupia.service.cIM.inframgr);

//FUNCTIONS

  //Function Name:

  //Inputs:

  //Outputs:

//MAIN CODE

//Input Clean UP - check the Inputs and adapt those to correct types to avoid errors.

var userName = String(input.userName);

output.OUTPUT_REST_API_KEY = "";

//Get the USER Profile and the REST API KEY

userMgr = UserAccessProfileManagerImpl();

try{

  var userProfiles = userMgr.getAllUserAccessProfile(userName);

}

catch(e){

  ctxt.setFailed("User " + userName + " not found.");

  ctxt.exit();

}

//REGISTER OUPUTS

//Seems that there is a user here...

output.OUTPUT_REST_API_KEY = userProfiles[0].getRestKey();

logger.addInfo("User " + userName + " found, REST API Key retrieved.");

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links

Review Cisco Networking for a $25 gift card