import { AbstractSession , Headers } from "@zowe/imperative" ; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk" ; import { IStopTsoParms } from "./doc/input/IStopTsoParms" ; import { noServletKeyInput , TsoConstants } from "./TsoConstants" ; import { TsoValidator } from "./TsoValidator" ; import { IZosmfTsoResponse } from "./doc/zosmf/IZosmfTsoResponse" ; import { TsoResponseService } from "./TsoResponseService" ; import { IStartStopResponse } from "./doc/IStartStopResponse" ; export class export class StopTso { param { AbstractSession } session param { IStopTsoParms } commandParms see { IStopTsoParms } returns { Promise < IZosmfTsoResponse > } see { IZosmfTsoResponse } memberOf public static async stopCommon ( session , commandParms ) { TsoValidator . validateSession ( session ) ; TsoValidator . validateStopParams ( commandParms ) ; TsoValidator . validateNotEmptyString ( commandParms . servletKey , noServletKeyInput . message ) ; const resources = this . getResources ( commandParms . servletKey ) ; return ZosmfRestClient . deleteExpectJSON < IZosmfTsoResponse > ( session , resources , [ Headers . APPLICATION_JSON ] ) ; } param { AbstractSession } session param { string } servKey returns { Promise < IStartStopResponse > } see { IStartStopResponse } memberOf public static async stop ( session , servKey ) { TsoValidator . validateSession ( session ) ; TsoValidator . validateNotEmptyString ( servKey , noServletKeyInput . message ) ; const commandParms = { servletKey : servKey } ; const zosmfResponse = await this . stopCommon ( session , commandParms ) ; TsoValidator . validateErrorMessageFromZosmf ( zosmfResponse ) ; return TsoResponseService . populateStartAndStop ( zosmfResponse ) ; } param { string } servletKey returns { string } memberOf public static getResources ( servletKey ) { TsoValidator . validateNotEmptyString ( servletKey , noServletKeyInput . message ) ; return `${ TsoConstants . RESOURCE }/${ TsoConstants . RES_START_TSO }/${ servletKey }` ; } }