7.1
Table Of Contents
- Developing a Web Services Client for VMware vRealize Orchestrator
- Contents
- Developing a Web Services Client for VMware vRealize Orchestrator
- Updated Information
- Developing a Web Services Client
- Using the vRealize Orchestrator REST API
- Authenticating Against Orchestrator and Third-Party Systems
- Accessing the Reference Documentation for the Orchestrator REST API
- Using the Java REST SDK
- Operations with Workflows
- Working with Tasks
- Finding Objects in the Orchestrator Inventory
- Importing and Exporting Orchestrator Objects
- Deleting Orchestrator Objects
- Setting Permissions on Orchestrator Objects
- REST API Permissions
- Retrieve the Permissions of a Workflow
- Delete the Permissions of a Workflow
- Set the Permissions for a Workflow
- Retrieve the Permissions of an Action
- Delete the Permissions of an Action
- Set the Permissions for an Action
- Retrieve the Permissions of a Package
- Delete the Permissions of a Package
- Set the Permissions for a Package
- Retrieve the Permissions of a Resource
- Delete the Permissions of a Resource
- Set the Permissions for a Resource
- Retrieve the Permissions of a Configuration Element
- Delete the Permissions of a Configuration Element
- Set the Permissions for a Configuration Element
- Performing Operations with Plug-Ins
- Performing Server Configuration Operations
- Performing Tagging Operations
- Index
The Java REST SDK is installed together with Orchestrator. The Java REST SDK artifacts are available at the
following locations.
Note You can only access the artifacts if you have deployed the Orchestrator Appliance.
n
hps://orchestrator_host:port/vco-repo/com/vmware/o11n/o11n-rest-client/
n
hps://orchestrator_host:port/vco-repo/com/vmware/o11n/o11n-rest-client-examples/
n
hps://orchestrator_host:port/vco-repo/com/vmware/o11n/o11n-rest-client-services/
n
hps://orchestrator_host:port/vco-repo/com/vmware/o11n/o11n-rest-client-stubs/
Example: Run a Workflow and Wait for Its Completion
The following example code runs a workow and waits for it to complete.
//start a new session to Orchestrator by using specified credentials
VcoSession session = DefaultVcoSessionFactory.newLdapSession(new URI("https://orchestrator-
server:8281/vco/api/"), "username", "password");
//create the services
WorkflowService workflowService = new WorkflowService(session);
ExecutionService executionService = new ExecutionService(session);
//find a workflow by ID
Workflow workflow = workflowService.getWorkflow("1231235");
//create an ExecutionContext from the user's input
ExecutionContext context = new ExecutionContextBuilder().addParam("name",
"Jerry").addParam("age", 18).build();
//run the workflow
WorkflowExecution execution = executionService.execute(workflow, context);
//wait for the workflow to reach the user interaction state, checking every 500 milliseconds
execution = executionService.awaitState(execution, 500, 10, WorkflowExecutionState.CANCELED,
WorkflowExecutionState.FAILED, WorkflowExecutionState.COMPLETED);
String nameParamValue = new
ParameterExtractor().fromTheOutputOf(execution).extractString("name");
System.out.println("workflow was executed with 'name' input set to" + nameParamValue);
Chapter 3 Using the vRealize Orchestrator REST API
VMware, Inc. 15