Skip to content

Commit

Permalink
Updated following review
Browse files Browse the repository at this point in the history
Signed-off-by: EKhan <[email protected]>
  • Loading branch information
enamkhan committed Jan 6, 2025
1 parent de30129 commit 8cdf317
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 31 deletions.
19 changes: 17 additions & 2 deletions packages/sdk/src/constants/CicsCmci.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,24 @@ export const CicsCmciConstants = {
PARAMETER: "PARAMETER",

/**
* The CICS CMCI external resource names
* The CICS CMCI transaction definition
*/
CICS_CMCI_EXTERNAL_RESOURCES: ["CICSLocalTransaction", "CICSRemoteTransaction", "CICSDefinitionTransaction", "CICSLocalFile"],
CICS_CMCI_TRANSACTION_DEFINITION: "CICSDefinitionTransaction",

/**
* The CICS CMCI local transaction
*/
CICS_CMCI_LOCAL_TRANSACTION: "CICSLocalTransaction",

/**
* The CICS CMCI remote transaction
*/
CICS_CMCI_REMOTE_TRANSACTION: "CICSRemoteTransaction",

/**
* The CICS CMCI local file
*/
CICS_CMCI_LOCAL_FILE: "CICSLocalFile",

/**
* CICSTask parameter
Expand Down
48 changes: 23 additions & 25 deletions packages/sdk/src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,34 @@ export class Utils {

let delimiter = "?"; // initial delimiter

const cicsPlex = (options && options.cicsPlex) == null ? "" : `${encodeURIComponent(options.cicsPlex)}/`;
const region = (options && options.regionName) == null ? "" : encodeURIComponent(options.regionName);
const cicsPlex = options?.cicsPlex == null ? "" : `${encodeURIComponent(options.cicsPlex)}/`;
const region = options?.regionName == null ? "" : encodeURIComponent(options.regionName);

let cmciResource = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resourceName}/${cicsPlex}${region}`;

if (options) {
if (options.criteria) {
cmciResource += `${delimiter}${CicsCmciConstants.CRITERIA}=${this.enforceParentheses(encodeURIComponent(options.criteria))}`;
delimiter = "&";
}
if (options?.criteria) {
cmciResource += `${delimiter}${CicsCmciConstants.CRITERIA}=${this.enforceParentheses(encodeURIComponent(options.criteria))}`;
delimiter = "&";
}

if (options.parameter) {
cmciResource += `${delimiter}PARAMETER=${encodeURIComponent(options.parameter)}`;
delimiter = "&";
}
if (options?.parameter) {
cmciResource += `${delimiter}PARAMETER=${encodeURIComponent(options.parameter)}`;
delimiter = "&";
}

if (options.queryParams && options.queryParams.summonly) {
cmciResource += `${delimiter}${CicsCmciConstants.SUMM_ONLY}`;
delimiter = "&";
}
if (options?.queryParams?.summonly) {
cmciResource += `${delimiter}${CicsCmciConstants.SUMM_ONLY}`;
delimiter = "&";
}

if (options.queryParams && options.queryParams.nodiscard) {
cmciResource += `${delimiter}${CicsCmciConstants.NO_DISCARD}`;
delimiter = "&";
}
if (options?.queryParams?.nodiscard) {
cmciResource += `${delimiter}${CicsCmciConstants.NO_DISCARD}`;
delimiter = "&";
}

if (options.queryParams && options.queryParams.overrideWarningCount) {
cmciResource += `${delimiter}${CicsCmciConstants.OVERRIDE_WARNING_COUNT}`;
delimiter = "&";
}
if (options?.queryParams?.overrideWarningCount) {
cmciResource += `${delimiter}${CicsCmciConstants.OVERRIDE_WARNING_COUNT}`;
delimiter = "&";
}

return cmciResource;
Expand All @@ -71,7 +69,7 @@ export class Utils {

let cmciResource = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${CicsCmciConstants.CICS_RESULT_CACHE}/${cacheToken}`;

if (options && options.startIndex) {
if (options?.startIndex) {
cmciResource += `/${options.startIndex}`;

if (options.count) {
Expand All @@ -87,7 +85,7 @@ export class Utils {
delimiter = "&";
}

if (options && options.summonly) {
if (options?.summonly) {
cmciResource += `${delimiter}${CicsCmciConstants.SUMM_ONLY}`;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vsce/src/commands/closeLocalFileCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async function closeLocalFile(
"criteria": `FILE='${parms.name}'`
};

const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options);
const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options);

return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody);
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async function disableLocalFile(
"criteria": `FILE='${parms.name}'`
};

const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options);
const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options);

return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody);
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async function enableLocalFile(session: imperative.AbstractSession, parms: { nam
"criteria": `FILE='${parms.name}'`
};

const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options);
const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options);

return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody);
}
2 changes: 1 addition & 1 deletion packages/vsce/src/commands/openLocalFileCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function openLocalFile(session: imperative.AbstractSession, parms: { name:
"criteria": `FILE='${parms.name}'`
};

const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options);
const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options);

return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody);
}

0 comments on commit 8cdf317

Please sign in to comment.