import { AbstractSession , Headers } from "@zowe/imperative" ; import { ZosmfRestClient , nozOSMFVersion } from "@zowe/core-for-zowe-sdk" ; import { WorkflowConstants , noWorkflowKey } from "./WorkflowConstants" ; import { WorkflowValidator } from "./WorkflowValidator" ; import { IStartWorkflow , startT } from "./doc/IStartWorkflow" ; import { isNullOrUndefined } from "util" ; /**
 * Class to handle starting of zOSMF workflow instance
 */ export class StartWorkflow { param { AbstractSession } session param { string } workflowKey param { string } resolveConflict param { string } step param { string } subsequent param { string } zOSMFVersion returns { Promise } public static async startWorkflow ( session , workflowKey , resolveConflict ? , step ? , subsequent ? , zOSMFVersion = WorkflowConstants . ZOSMF_VERSION ) { WorkflowValidator . validateSession ( session ) ; WorkflowValidator . validateNotEmptyString ( workflowKey , noWorkflowKey . message ) ; WorkflowValidator . validateNotEmptyString ( zOSMFVersion , nozOSMFVersion . message ) ; const data = { } ; if ( resolveConflict ) { data . resolveConflictByUsing = resolveConflict ; } if ( step ) { data . stepName = step ; } if ( ! isNullOrUndefined ( subsequent ) ) { data . performSubsequent = subsequent ; } let resourcesQuery = `${ WorkflowConstants . RESOURCE }/${ zOSMFVersion }/` ; resourcesQuery += `${ WorkflowConstants . WORKFLOW_RESOURCE }/${ workflowKey }/${ WorkflowConstants . START_WORKFLOW }` ; return ZosmfRestClient . putExpectString ( session , resourcesQuery , [ Headers . APPLICATION_JSON ] , data ) ; } }