import { AbstractSession , Headers } from "@zowe/imperative" ; import { ZosmfRestClient , nozOSMFVersion } from "@zowe/core-for-zowe-sdk" ; import { WorkflowConstants , noWorkflowKey } from "./WorkflowConstants" ; import { WorkflowValidator } from "./WorkflowValidator" ; /**
 * Class to handle canceling of zOSMF workflow instance
 */ export class CancelWorkflow { param { AbstractSession } session param { string } workflowKey param { string } zOSMFVersion returns { Promise < string > } memberof public static async cancelWorkflow ( session , workflowKey , zOSMFVersion = WorkflowConstants . ZOSMF_VERSION ) { WorkflowValidator . validateSession ( session ) ; WorkflowValidator . validateNotEmptyString ( zOSMFVersion , nozOSMFVersion . message ) ; WorkflowValidator . validateNotEmptyString ( workflowKey , noWorkflowKey . message ) ; let resourcesQuery = `${ WorkflowConstants . RESOURCE }/${ zOSMFVersion }/` ; resourcesQuery += `${ WorkflowConstants . WORKFLOW_RESOURCE }/${ workflowKey }/${ WorkflowConstants . CANCEL_WORKFLOW }` ; return ZosmfRestClient . putExpectString ( session , resourcesQuery , [ Headers . APPLICATION_JSON ] , { } ) ; } }