This is a sample of how to create an enhanced workflow orchestrator workflow using the Build Tools.
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: WorflowGeneralSampleEnhanced.wf.ts
import { Logger } from "com.vmware.pscoe.library.ts.logging/Logger";
import { DefaultErrorHandler, In, Item, Out, RootItem, Workflow } from "vrotsc-annotations";
@Workflow({
name: "Sample - Enhanced",
path: "CompanyName/Workflows/General",
description: "",
restartMode: 1, // restartMode - 0: Do not resume workflow run, 1: Resume workflow run (default)
resumeFromFailedMode: 0, // resumeFromFailedMode - 0: System default (default), 1: Enabled, 2: Disabled
attributes: {
businessStatus: {
type: "string"
},
endMode: {
type: "number"
},
strErrorMessage: {
type: "string"
},
},
input: {
strProjectID: {
type: "string"
}
},
output: {
},
})
export class generalSampleEnhanced {
@DefaultErrorHandler({
target: "processError",
})
public defaultErrorHandler(@Out strErrorMessage: string): void {
// NO OP
}
@Item({
target: "end",
})
public processError(@In strErrorMessage: string, @In strProjectID: string): void {
System.log(`Sending Error Message with message '${strErrorMessage}'.`);
}
@RootItem({
target: "workflowValidate"
})
public workflowStart(@In inputProperties: Properties, @In strResourceActionType: string, @In strResourceActionName: string): void {
let strWorkflowName: string = `${strResourceActionType} - ${strResourceActionName}`;
let objLogger: Logger = Logger.getLogger(strWorkflowName);
Utilities.logExecutionContext(objLogger);
Utilities.logInputPropertiesForSubscription(objLogger, inputProperties, strWorkflowName);
}
@Item({
target: "workflowExecute"
})
public workflowValidate(@In inputProperties: Properties, @In strResourceActionType: string, @In strResourceActionName: string): void {
System.log(`Validating Workflow Inputs.`);
Utilities.validateFunctionInputs(inputProperties, strResourceActionType, strResourceActionName, workflow);
}
@Item({
target: "end"
})
public workflowExecute(@In strProjectID: string): void {
try {
let strResourceActionType: string = "General";
let strResourceActionName: string = "Sample - Enhanced";
let objLogger: Logger = Logger.getLogger(`${strResourceActionType} - ${strResourceActionName}`);
let objError: Error = objException as Error;
objLogger.error(`${strFunctionName} - Name: ${objError.name}`);
objLogger.error(`${strFunctionName} - Message: ${objError.message}`);
if (objError.stack) {
objLogger.error(`${strFunctionName} - Message: ${objError.message}`);
}
if (strCustomErrorMessage !== "") {
objLogger.error(`${strFunctionName} - Custom Error Message: ${strCustomErrorMessage}`);
}
} catch (e) {
throw e;
} finally {
}
}
}
Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
