import { AbstractSession } from "@zowe/imperative" ; import { ZosmfRestClient , ZosmfHeaders } from "@zowe/core-for-zowe-sdk" ; import { IZosLogType } from "./doc/IZosLogType" ; import { IZosLogParms } from "./doc/IZosLogParms" ; import { GetZosLogValidator } from "./GetZosLogValidator" ; import { ZosLogConstants } from "./ZosLogConstants" ; import { isNullOrUndefined } from "util" ; export class export class GetZosLog { static param { AbstractSession } session param { IZosLogParms } commandParms see { IZosLogParms } return { Promise < IZosLogType > } see { IZosLogType } memberof public static async getZosLog ( session , commandParms ) { GetZosLogValidator . validateSession ( session ) ; let resp = await ZosmfRestClient . getExpectJSON < IZosLogType > ( session , GetZosLog . getResourcePath ( commandParms ) , [ ZosmfHeaders . X_CSRF_ZOSMF_HEADER ] ) ; if ( isNullOrUndefined ( commandParms . processResponses ) || commandParms . processResponses !== false ) { resp = JSON . parse ( JSON . stringify ( resp ) . replace ( /\\r\\n/g , "\\n" ) . replace ( /\\r/g , "\\n" ) ) ; } return resp ; } static param { IZosLogParms } commandParms return { string } memberof public static getResourcePath ( commandParms ) { let path = ZosLogConstants . RESOURCE ; if ( commandParms . startTime !== undefined ) { let startTime = commandParms . startTime ; if ( ! isNaN ( commandParms . startTime ) ) { startTime = new Date ( + startTime ) . toISOString ( ) ; } path += "time=" + startTime + "&" ; } if ( commandParms . direction !== undefined ) { path += "direction=" + commandParms . direction + "&" ; } if ( commandParms . range !== undefined ) { path += "timeRange=" + commandParms . range + "&" ; } return path ; } }