import { isNullOrUndefined } from "util" ; import { IHandlerParameters , TextUtils } from "@zowe/imperative" ; import { explainProvisionTemplateResponse , IProvisionOptionals , IProvisionTemplateResponse , ProvisioningConstants , ProvisioningService , ProvisionPublishedTemplate } from "@zowe/provisioning-for-zowe-sdk" ; import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk" ; export default class Handler extends ZosmfBaseHandler { public async processCmd ( commandParameters ) { let response ; let usedOptionalParms = false ; let arrayOfSystemNickNames ; if ( ! isNullOrUndefined ( commandParameters . arguments . systemNickNames ) ) { arrayOfSystemNickNames = commandParameters . arguments . systemNickNames . split ( "," ) . map ( ( systemName ) => { return systemName . trim ( ) ; } ) ; } const provisionOptionalParams = ProvisioningService . checkForPassedOptionalParms ( commandParameters . arguments . properties , commandParameters . arguments . propertiesFile , commandParameters . arguments . domainName , commandParameters . arguments . tenantName , commandParameters . arguments . userDataId , commandParameters . arguments . userData , commandParameters . arguments . accountInfo , arrayOfSystemNickNames ) ; for ( const property in provisionOptionalParams ) { if ( ! isNullOrUndefined ( provisionOptionalParams [ property as keyof IProvisionOptionals ] ) ) { usedOptionalParms = true ; } } if ( usedOptionalParms ) { response = await ProvisionPublishedTemplate . provisionTemplate ( this . mSession , ProvisioningConstants . ZOSMF_VERSION , commandParameters . arguments . name , provisionOptionalParams ) ; } else { response = await ProvisionPublishedTemplate . provisionTemplate ( this . mSession , ProvisioningConstants . ZOSMF_VERSION , commandParameters . arguments . name ) ; } let prettyResponse = TextUtils . explainObject ( response , explainProvisionTemplateResponse , false ) ; prettyResponse = TextUtils . prettyJson ( prettyResponse ) ; commandParameters . response . console . log ( prettyResponse ) ; commandParameters . response . data . setObj ( response ) ; } }