UNPKG

@broadcom/ops-for-zowe-cli

Version:

OPS/MVS® Plug-in for Zowe CLI

100 lines 6.48 kB
"use strict"; /* * Copyright (c) 2024 Broadcom. All Rights Reserved. The term * "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This software and all information contained therein is * confidential and proprietary and shall not be duplicated, * used, disclosed, or disseminated in any way except as * authorized by the applicable license agreement, without the * express written permission of Broadcom. All authorized * reproductions must be marked with this language. * * EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO * THE EXTENT PERMITTED BY APPLICABLE LAW, BROADCOM PROVIDES THIS * SOFTWARE WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT * LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL BROADCOM * BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR * DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE, * INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS * INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF BROADCOM IS * EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.StatusListUtils = void 0; const constants_1 = require("../constants"); const OpsTextUtils_1 = require("./OpsTextUtils"); class StatusListUtils { static printShowStatusResponse(statusList, params) { let output; // Response from REST API server if (params.arguments.format.toUpperCase() === constants_1.OpsConstants.CSV) { output = `${StatusListUtils.formatCsvHeaderResponse()}`; output = `${output}\n${StatusListUtils.formatCsvDataResponse(statusList, params)}`; } else if (params.arguments.format.toUpperCase() === constants_1.OpsConstants.JSON) { output = `[${StatusListUtils.formatJsonDataResponse(statusList, params)}]`; } else if (params.arguments.format.toUpperCase() === constants_1.OpsConstants.NAMEVALUECOLOR) { output = StatusListUtils.formatNameValueColorDataResponse(statusList, params); } else { output = StatusListUtils.formatNameValueDataResponse(statusList, params); } return output; } static formatNameValueDataResponse(statusList, params) { return `name: OPS/MVS REST-API/${params.arguments.host}/${params.arguments.port}\n` + ` userId: ${statusList.userId}\n jobNumber: ${statusList.jobNumber}\n jobName: ${statusList.jobName}\n` + ` stepName: ${statusList.stepName}\n lpar: ${statusList.lpar}\n security: ${statusList.security}\n` + ` javaVM: ${statusList.javaVM}\n version: ${statusList.version}\n rexxProgramsLaunched: ${statusList.rexxProgramsLaunched}\n` + ` rexxProgramsCanceled: ${statusList.rexxProgramsCanceled}\n rexxProgramsRejected: ${statusList.rexxProgramsRejected}\n`; } static formatNameValueColorDataResponse(statusList, params) { const nameText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("name: "); const userIDText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("userID: "); const jobNumberText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("jobNumber: "); const jobNameText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("jobName: "); const stepNameText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("stepName: "); const lparText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("lpar: "); const securityText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("security: "); const javaVMText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("javaVM: "); const versionText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("version: "); const rexxProgramsLaunchedText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("rexxProgramsLaunched: "); const rexxProgramsCanceledText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("rexxProgramsCanceled: "); const rexxProgramsRejectedText = OpsTextUtils_1.OpsTextUtils.colorizeAttention("rexxProgramsRejected: "); return `${nameText}OPS/MVS REST-API/${params.arguments.host}/${params.arguments.port}\n` + ` ${userIDText}${statusList.userId}\n ${jobNumberText}${statusList.jobNumber}\n ${jobNameText}${statusList.jobName}\n` + ` ${stepNameText}${statusList.stepName}\n ${lparText}${statusList.lpar}\n ${securityText}${statusList.security}\n` + ` ${javaVMText}${statusList.javaVM}\n ${versionText}${statusList.version}\n ${rexxProgramsLaunchedText}` + `${statusList.rexxProgramsLaunched}\n ${rexxProgramsCanceledText}${statusList.rexxProgramsCanceled}\n` + ` ${rexxProgramsRejectedText}${statusList.rexxProgramsRejected}`; } static formatJsonDataResponse(statusList, params) { let output = `{`; output += `"name": "OPS/MVS REST-API/${params.arguments.host}/${params.arguments.port}", "userId": "${statusList.userId}",`; output += ` "jobNumber": "${statusList.jobNumber}", "jobName": "${statusList.jobName}",`; output += ` "stepName": "${statusList.stepName}", "lpar": "${statusList.lpar}",`; output += ` "security": "${statusList.security}", "javaVM": "${statusList.javaVM}",`; output += ` "version": "${statusList.version}", "rexxProgramsLaunched": "${statusList.rexxProgramsLaunched}",`; output += ` "rexxProgramsCanceled": "${statusList.rexxProgramsCanceled}",`; output += ` "rexxProgramsRejected": "${statusList.rexxProgramsRejected}"`; output += `}`; return output; } static formatCsvHeaderResponse() { return `name,userId,jobNumber,jobName,stepName,lpar,security,javaVM,version,rexxProgramsLaunched,rexxProgramsCanceled,rexxProgramsRejected`; } static formatCsvDataResponse(statusList, params) { let output = `"OPS/MVS REST-API/${params.arguments.host}/${params.arguments.port}","${statusList.userId}",`; output += `"${statusList.jobNumber}","${statusList.jobName}",`; output += `"${statusList.stepName}","${statusList.lpar}",`; output += `"${statusList.security}","${statusList.javaVM}",`; output += `"${statusList.version}","${statusList.rexxProgramsLaunched}",`; output += `"${statusList.rexxProgramsCanceled}","${statusList.rexxProgramsRejected}"`; return output; } } exports.StatusListUtils = StatusListUtils; //# sourceMappingURL=StatusListUtils.js.map