@zowe/cics-for-zowe-sdk
Version:
Zowe SDK for IBM CICS Transaction Server
116 lines • 6.58 kB
JavaScript
;
/**
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.disableLocalFile = exports.enableLocalFile = exports.openLocalFile = exports.closeLocalFile = void 0;
const imperative_1 = require("@zowe/imperative");
const constants_1 = require("../constants");
const ResourceActions_1 = require("../utils/ResourceActions");
/**
* Close a local file in CICS
* @param {AbstractSession} session - the session to connect to CMCI with
* @param {ILocalFileParms} parms - parameters for closing the local file
* @param {string} parms.name - the name of the local file to close (1-8 characters)
* @param {string} parms.regionName - the CICS region name
* @param {string} [parms.cicsPlex] - the CICSPlex name (optional)
* @param {string} [parms.busy] - busy condition option: "WAIT", "NOWAIT", or "FORCE" (case-insensitive, optional, default: "WAIT")
* @returns {Promise<ICMCIApiResponse>} promise that resolves to the response
* @throws {ImperativeError} CICS local file name not defined, blank, or exceeds maximum length
* @throws {ImperativeError} CICS region name not defined or blank
* @throws {ImperativeError} Invalid BUSY parameter value
* @throws {ImperativeError} CicsCmciRestClient request fails
*/
async function closeLocalFile(session, parms) {
// Validate required parameters
imperative_1.ImperativeExpect.toBeDefinedAndNonBlank(parms.name, "CICS Local File name", "CICS local file name is required");
imperative_1.ImperativeExpect.toBeDefinedAndNonBlank(parms.regionName, "CICS Region name", "CICS region name is required");
// Validate file name length (CICS resource names are limited to 8 characters)
if (parms.name.length > constants_1.CicsCmciConstants.CICS_LOCAL_FILE_MAX_LENGTH) {
throw new imperative_1.ImperativeError({
msg: `CICS local file name "${parms.name}" exceeds maximum length of ${constants_1.CicsCmciConstants.CICS_LOCAL_FILE_MAX_LENGTH} characters`,
});
}
imperative_1.Logger.getAppLogger().debug(`Attempting to close a local file with the following parameters:\n%s`, JSON.stringify(parms));
// Get busy parameter value
const busyValue = parms.busy ? parms.busy.trim().toUpperCase() : "WAIT";
// Validate busy parameter
if (!constants_1.CicsCmciConstants.CICS_LOCAL_FILE_BUSY_VALUES.includes(busyValue)) {
const allowedValuesStr = constants_1.CicsCmciConstants.CICS_LOCAL_FILE_BUSY_VALUES.join(", ");
throw new imperative_1.ImperativeError({
msg: `Invalid BUSY parameter value: "${busyValue}". Must be one of: ${allowedValuesStr}`,
});
}
// Use generic performAction utility
return (0, ResourceActions_1.performAction)(session, constants_1.CicsCmciConstants.CICS_CMCI_LOCAL_FILE, "CLOSE", {
name: parms.name,
regionName: parms.regionName,
cicsPlex: parms.cicsPlex,
}, constants_1.CicsCmciConstants.CICS_LOCAL_FILE_CRITERIA_FIELD, { name: "BUSY", value: busyValue });
}
exports.closeLocalFile = closeLocalFile;
/**
* Open a local file in CICS
* @param {AbstractSession} session - the session to connect to CMCI with
* @param {ILocalFileParms} parms - parameters for opening the local file
* @param {string} parms.name - the name of the local file to open (1-8 characters)
* @param {string} parms.regionName - the CICS region name
* @param {string} [parms.cicsPlex] - the CICSPlex name (optional)
* @returns {Promise<ICMCIApiResponse>} promise that resolves to the response
* @throws {ImperativeError} CICS local file name not defined, blank, or exceeds maximum length
* @throws {ImperativeError} CICS region name not defined or blank
* @throws {ImperativeError} CicsCmciRestClient request fails
*/
async function openLocalFile(session, parms) {
// Validate required parameters
imperative_1.ImperativeExpect.toBeDefinedAndNonBlank(parms.name, "CICS Local File name", "CICS local file name is required");
imperative_1.ImperativeExpect.toBeDefinedAndNonBlank(parms.regionName, "CICS Region name", "CICS region name is required");
// Validate file name length (CICS resource names are limited to 8 characters)
if (parms.name.length > constants_1.CicsCmciConstants.CICS_LOCAL_FILE_MAX_LENGTH) {
throw new imperative_1.ImperativeError({
msg: `CICS local file name "${parms.name}" exceeds maximum length of ${constants_1.CicsCmciConstants.CICS_LOCAL_FILE_MAX_LENGTH} characters`,
});
}
imperative_1.Logger.getAppLogger().debug(`Attempting to open a local file with the following parameters:\n%s`, JSON.stringify(parms));
// Use generic performAction utility (no additional parameters needed for OPEN)
return (0, ResourceActions_1.performAction)(session, constants_1.CicsCmciConstants.CICS_CMCI_LOCAL_FILE, "OPEN", {
name: parms.name,
regionName: parms.regionName,
cicsPlex: parms.cicsPlex,
}, constants_1.CicsCmciConstants.CICS_LOCAL_FILE_CRITERIA_FIELD);
}
exports.openLocalFile = openLocalFile;
/**
* Enable a local file in CICS (future implementation)
* @param {AbstractSession} session - the session to connect to CMCI with
* @param {ILocalFileParms} parms - parameters for enabling the local file
* @returns {Promise<ICMCIApiResponse>} promise that resolves to the response
* @throws {ImperativeError} Feature not yet implemented
*/
async function enableLocalFile(session, parms) {
throw new imperative_1.ImperativeError({
msg: "ENABLE action not yet implemented. This feature requires SDK support for enabling local files.",
});
}
exports.enableLocalFile = enableLocalFile;
/**
* Disable a local file in CICS (future implementation)
* @param {AbstractSession} session - the session to connect to CMCI with
* @param {ILocalFileParms} parms - parameters for disabling the local file
* @returns {Promise<ICMCIApiResponse>} promise that resolves to the response
* @throws {ImperativeError} Feature not yet implemented
*/
async function disableLocalFile(session, parms) {
throw new imperative_1.ImperativeError({
msg: "DISABLE action not yet implemented. This feature requires SDK support for disabling local files.",
});
}
exports.disableLocalFile = disableLocalFile;
//# sourceMappingURL=LocalFile.js.map