import { AbstractSession , Headers } from "@zowe/imperative" ; import { ZosmfRestClient , nozOSMFVersion } from "@zowe/core-for-zowe-sdk" ; import { WorkflowConstants , noWorkflowDefinitionFile } from "./WorkflowConstants" ; import { WorkflowValidator } from "./WorkflowValidator" ; import { IWorkflowDefinition } from "./doc/IWorkflowDefinition" ; export class DefinitionWorkflow { param { AbstractSession } session param { string } filePath param { string } zOSMFVersion param { boolean } steps param { boolean } variables returns { Promise < IWorkflowDefinition > } memberof public static async getWorkflowDefinition ( session , zOSMFVersion = WorkflowConstants . ZOSMF_VERSION , filePath , steps , variables ) { WorkflowValidator . validateSession ( session ) ; WorkflowValidator . validateNotEmptyString ( zOSMFVersion , nozOSMFVersion . message ) ; WorkflowValidator . validateNotEmptyString ( filePath , noWorkflowDefinitionFile . message ) ; const wfPath = filePath ; let resourcesQuery = `${ WorkflowConstants . RESOURCE }/${ zOSMFVersion }/` ; resourcesQuery += `${ WorkflowConstants . WORKFLOW_DEFINITION }?${ WorkflowConstants . filePath }=${ wfPath }` ; if ( steps && variables ) { resourcesQuery += `&${ WorkflowConstants . returnData }=${ WorkflowConstants . steps },${ WorkflowConstants . variables }` ; } else if ( steps ) { resourcesQuery += `&${ WorkflowConstants . returnData }=${ WorkflowConstants . steps }` ; } else if ( variables ) { resourcesQuery += `&${ WorkflowConstants . returnData }=${ WorkflowConstants . variables }` ; } return ZosmfRestClient . getExpectJSON < IWorkflowDefinition > ( session , resourcesQuery , [ Headers . APPLICATION_JSON ] ) ; } }