5.5.1
Table Of Contents
- Developing a Web Services Client for VMware vCenter Orchestrator
- Contents
- Developing Web Services Client for VMware vCenter Orchestrator
- Developing a Web Services Client
- Using the vCenter 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
- Writing a Client Application for the Orchestrator SOAP Service
- Process for Creating an Orchestrator Web Service Client Application
- Web Service Endpoint
- Generating the Orchestrator Web Service Stubs
- Accessing the Server from Web Service Clients
- Create a Web Service Client
- Connect to the Orchestrator Web Service
- Find Objects in the Orchestrator Server
- Find Objects by Using the find Operation
- Find Objects by Using the findForId Operation
- Find Objects by Using the findRelation Operation
- Find Workflows in the Orchestrator Server
- Find Workflows by Using the getAllWorkflows Operation
- Retrieve the ID of a Workflow
- Find Workflows by Using the getWorkflowsWithName Operation
- Find Workflows by Using the getWorkflowForID Operation
- Run Workflows from a Web Service Client
- Interact with a Workflow While it Runs
- Obtain Workflow Results
- Time Zones and Running Workflows Through Web Services
- Web Service Application Examples
- Web Service API Object Reference
- Web Service API Operation Reference
- answerWorkflowInput Operation
- cancelWorkflow Operation
- echo Operation
- echoWorkflow Operation
- executeWorkflow Operation
- find Operation
- findForId Operation
- findRelation Operation
- getAllPlugins Operation
- getAllWorkflows Operation
- getWorkflowForId Operation
- getWorkflowInputForId Operation
- getWorkflowInputForWorkflowTokenId Operation
- getWorkflowsWithName Operation
- getWorkflowTokenBusinessState Operation
- getWorkflowTokenForId Operation
- getWorkflowTokenResult Operation
- getWorkflowTokenStatus Operation
- hasChildrenInRelation Operation
- hasRights Operation
- sendCustomEvent Operation
- simpleExecuteWorkflow Operation
- Index
//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);
Operations with Workflows
The Orchestrator REST API provides Web services that you can use to perform various operations with
workflows.
Find a Workflow and Retrieve Its Definition
To be able to perform any kind of operation with a workflow, you must find that workflow in the
Orchestrator inventory and retrieve its definition. The definition lists the workflow input and output
parameters, and contains links to the available workflow runs, the workflow presentation, and other objects.
Prerequisites
Verify that you have imported the sample workflows package in Orchestrator. The package is included in
the Orchestrator sample applications ZIP file that you can download from the Orchestrator documentation
page.
Procedure
1 Find the inventory item of the workflow.
n
If you have the full name of the workflow or a key word from the name, make a GET request at the
URL of the Workflow service by applying a filter:
GET https://{vcoHost}:{port}/vco/api/workflows?conditions=name={workflowFullName}
GET https://{vcoHost}:{port}/vco/api/workflows?conditions=name~{keyWord}
n
Search for the workflow through the Catalog or the Inventory service by making a GET request at
the URL that is an entry point for the workflow inventory items:
GET https://{vcoHost}:{port}/vco/api/catalog/System/Workflow/
GET https://{vcoHost}:{port}/vco/api/inventory/System/Workflows/
2 Retrieve the inventory item of the workflow by making a GET request at its URL:
GET https://{vcoHost}:{port}/vco/api/catalog/System/Workflow/{workflowID}/
Chapter 2 Using the vCenter Orchestrator REST API
VMware, Inc. 15