import { IHandlerParameters , TextUtils } from "@zowe/imperative" ; import { explainActionResponse , PerformAction , ProvisioningConstants , IProvisionedInstance , ListRegistryInstances } from "@zowe/provisioning-for-zowe-sdk" ; import { isNullOrUndefined } from "util" ; import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk" ; export class implements ICommandHandler export default class ActionHandler extends ZosmfBaseHandler { public async processCmd ( commandParameters ) { const registry = await ListRegistryInstances . listFilteredRegistry ( this . mSession , ProvisioningConstants . ZOSMF_VERSION , null , commandParameters . arguments . name ) ; const instances = registry [ "scr-list" ] ; if ( isNullOrUndefined ( instances ) ) { commandParameters . response . console . error ( "No instance with name " + commandParameters . arguments . name + " was found" ) ; } else if ( instances . length === 1 ) { const id = instances . pop ( ) [ "object-id" ] ; const response = await PerformAction . doProvisioningActionCommon ( this . mSession , ProvisioningConstants . ZOSMF_VERSION , id , commandParameters . arguments . actionname ) ; const pretty = TextUtils . explainObject ( response , explainActionResponse , false ) ; commandParameters . response . console . log ( TextUtils . prettyJson ( pretty ) ) ; commandParameters . response . data . setObj ( response ) ; } else if ( instances . length > 1 ) { commandParameters . response . console . error ( "Multiple instances with name " + commandParameters . arguments . name + " were found" ) ; } } }