diff --git a/package-lock.json b/package-lock.json index 6c25c668..6fb95eb5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@zowe/cics_monorepo", - "version": "6.0.2", + "version": "6.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@zowe/cics_monorepo", - "version": "6.0.2", + "version": "6.1.0", "workspaces": [ "packages/*" ], @@ -15711,13 +15711,13 @@ }, "packages/cli": { "name": "@zowe/cics-for-zowe-cli", - "version": "6.0.0", + "version": "6.1.0", "bundleDependencies": [ "@zowe/cics-for-zowe-sdk" ], "license": "EPL-2.0", "dependencies": { - "@zowe/cics-for-zowe-sdk": "6.0.0" + "@zowe/cics-for-zowe-sdk": "6.1.0" }, "engines": { "node": ">=18.12.0" @@ -15728,7 +15728,7 @@ }, "packages/sdk": { "name": "@zowe/cics-for-zowe-sdk", - "version": "6.0.0", + "version": "6.1.0", "license": "EPL-2.0", "dependencies": { "xml2js": "0.5.0" @@ -15762,9 +15762,9 @@ }, "packages/vsce": { "name": "cics-extension-for-zowe", - "version": "3.0.2", + "version": "3.1.0", "dependencies": { - "@zowe/cics-for-zowe-sdk": "6.0.0", + "@zowe/cics-for-zowe-sdk": "6.1.0", "@zowe/core-for-zowe-sdk": "^8.0.0", "@zowe/zowe-explorer-api": "^3.0.3", "axios": "^1.6.7", diff --git a/package.json b/package.json index 072b39d1..934bfe12 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@zowe/cics_monorepo", "private": true, - "version": "6.0.2", + "version": "6.1.0", "publishConfig": { "registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/" }, diff --git a/packages/cli/package.json b/packages/cli/package.json index 4f945909..6429d9f8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cics-for-zowe-cli", - "version": "6.0.0", + "version": "6.1.0", "author": "Zowe", "license": "EPL-2.0", "description": "IBM CICS Plug-in for Zowe CLI", @@ -51,7 +51,7 @@ "configurationModule": "lib/imperative.js" }, "dependencies": { - "@zowe/cics-for-zowe-sdk": "6.0.0" + "@zowe/cics-for-zowe-sdk": "6.1.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 9be40ec7..1b713cd3 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the IBM® CICS® Plug-in for Zowe CLI will be documented in this file. +## `6.1.0` + +- Enhancement: Made the region name optional on the getResource SDK method. [#162](https://github.com/zowe/cics-for-zowe-client/issues/162) + ## `6.0.0` - MAJOR: v6.0.0 release diff --git a/packages/sdk/__tests__/__unit__/add-to-list/AddToList.csdGroup.unit.test.ts b/packages/sdk/__tests__/__unit__/add-to-list/AddToList.csdGroup.unit.test.ts index 1ad3f52b..12372d8c 100644 --- a/packages/sdk/__tests__/__unit__/add-to-list/AddToList.csdGroup.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/add-to-list/AddToList.csdGroup.unit.test.ts @@ -166,7 +166,7 @@ describe("CMCI - Add csdGroup to list", () => { it("should be able to add a csdGroup to list without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_CSDGROUP + "/" + addToListParms.regionName + - "?CRITERIA=NAME=='" + addToListParms.name + "'"; + "?CRITERIA=(NAME%3D%3D'" + addToListParms.name + "')"; response = await addCSDGroupToList(dummySession, addToListParms); @@ -179,7 +179,7 @@ describe("CMCI - Add csdGroup to list", () => { addToListParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_CSDGROUP + "/" + addToListParms.cicsPlex + "/" + addToListParms.regionName + - "?CRITERIA=NAME=='" + addToListParms.name + "'"; + "?CRITERIA=(NAME%3D%3D'" + addToListParms.name + "')"; response = await addCSDGroupToList(dummySession, addToListParms); @@ -192,7 +192,7 @@ describe("CMCI - Add csdGroup to list", () => { addToListParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_CSDGROUP + "/" + addToListParms.cicsPlex + "/" + addToListParms.regionName + - "?CRITERIA=NAME=='" + addToListParms.name + "'"; + "?CRITERIA=(NAME%3D%3D'" + addToListParms.name + "')"; response = await addCSDGroupToList(dummySession, addToListParms); diff --git a/packages/sdk/__tests__/__unit__/delete/Delete.program.unit.test.ts b/packages/sdk/__tests__/__unit__/delete/Delete.program.unit.test.ts index e6a2c324..8763250e 100644 --- a/packages/sdk/__tests__/__unit__/delete/Delete.program.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/delete/Delete.program.unit.test.ts @@ -173,7 +173,7 @@ describe("CMCI - Delete program", () => { it("should be able to delete a program without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_PROGRAM + "/" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteProgram(dummySession, deleteParms); @@ -186,7 +186,7 @@ describe("CMCI - Delete program", () => { deleteParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_PROGRAM + "//" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteProgram(dummySession, deleteParms); @@ -199,7 +199,7 @@ describe("CMCI - Delete program", () => { deleteParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_PROGRAM + "/" + cicsPlex + "/" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteProgram(dummySession, deleteParms); diff --git a/packages/sdk/__tests__/__unit__/delete/Delete.transaction.unit.test.ts b/packages/sdk/__tests__/__unit__/delete/Delete.transaction.unit.test.ts index c05dfd48..a8d14937 100644 --- a/packages/sdk/__tests__/__unit__/delete/Delete.transaction.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/delete/Delete.transaction.unit.test.ts @@ -179,7 +179,7 @@ describe("CMCI - Discard transaction", () => { it("should be able to delete a transaction without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "/" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteTransaction(dummySession, deleteParms); @@ -192,7 +192,7 @@ describe("CMCI - Discard transaction", () => { deleteParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "//" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteTransaction(dummySession, deleteParms); @@ -205,7 +205,7 @@ describe("CMCI - Discard transaction", () => { deleteParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "/" + cicsPlex + "/" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteTransaction(dummySession, deleteParms); diff --git a/packages/sdk/__tests__/__unit__/delete/Delete.urimap.unit.test.ts b/packages/sdk/__tests__/__unit__/delete/Delete.urimap.unit.test.ts index 701eb516..cdb72180 100644 --- a/packages/sdk/__tests__/__unit__/delete/Delete.urimap.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/delete/Delete.urimap.unit.test.ts @@ -104,7 +104,7 @@ describe("CMCI - Delete urimap", () => { it("should be able to delete a urimap", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_URIMAP + "/" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteUrimap(dummySession, deleteParms); expect(response).toContain(content); diff --git a/packages/sdk/__tests__/__unit__/delete/Delete.webservice.unit.test.ts b/packages/sdk/__tests__/__unit__/delete/Delete.webservice.unit.test.ts index 91bedd2c..8109f69e 100644 --- a/packages/sdk/__tests__/__unit__/delete/Delete.webservice.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/delete/Delete.webservice.unit.test.ts @@ -104,7 +104,7 @@ describe("CMCI - Delete web service", () => { it("should be able to delete a web service", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_WEBSERVICE + "/" + region + - `?CRITERIA=(NAME=${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; + `?CRITERIA=(NAME%3D${deleteParms.name})&PARAMETER=CSDGROUP(${deleteParms.csdGroup})`; response = await deleteWebservice(dummySession, deleteParms); expect(response).toContain(content); diff --git a/packages/sdk/__tests__/__unit__/disable/Disable.urimap.unit.test.ts b/packages/sdk/__tests__/__unit__/disable/Disable.urimap.unit.test.ts index bbe563c6..f1dcad99 100644 --- a/packages/sdk/__tests__/__unit__/disable/Disable.urimap.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/disable/Disable.urimap.unit.test.ts @@ -89,7 +89,7 @@ describe("CMCI - Disable urimap", () => { it("should be able to disable a urimap", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_URIMAP + "/" + region + - `?CRITERIA=(NAME=${disableParms.name})`; + `?CRITERIA=(NAME%3D${disableParms.name})`; requestBody = { request: { update: { diff --git a/packages/sdk/__tests__/__unit__/discard/Discard.program.unit.test.ts b/packages/sdk/__tests__/__unit__/discard/Discard.program.unit.test.ts index 8a2b9ed1..5cfdaf82 100644 --- a/packages/sdk/__tests__/__unit__/discard/Discard.program.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/discard/Discard.program.unit.test.ts @@ -129,7 +129,7 @@ describe("CMCI - Discard program", () => { it("should be able to discard a program without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_PROGRAM_RESOURCE + "/" + region + - "?CRITERIA=(PROGRAM=" + discardParms.name + ")"; + "?CRITERIA=(PROGRAM%3D" + discardParms.name + ")"; response = await discardProgram(dummySession, discardParms); @@ -142,7 +142,7 @@ describe("CMCI - Discard program", () => { discardParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_PROGRAM_RESOURCE + "//" + region + - "?CRITERIA=(PROGRAM=" + discardParms.name + ")"; + "?CRITERIA=(PROGRAM%3D" + discardParms.name + ")"; response = await discardProgram(dummySession, discardParms); @@ -155,7 +155,7 @@ describe("CMCI - Discard program", () => { discardParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_PROGRAM_RESOURCE + "/" + cicsPlex + "/" + region + - "?CRITERIA=(PROGRAM=" + discardParms.name + ")"; + "?CRITERIA=(PROGRAM%3D" + discardParms.name + ")"; response = await discardProgram(dummySession, discardParms); diff --git a/packages/sdk/__tests__/__unit__/discard/Discard.transaction.unit.test.ts b/packages/sdk/__tests__/__unit__/discard/Discard.transaction.unit.test.ts index f0f45fdf..09365c09 100644 --- a/packages/sdk/__tests__/__unit__/discard/Discard.transaction.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/discard/Discard.transaction.unit.test.ts @@ -147,7 +147,7 @@ describe("CMCI - Discard transaction", () => { it("should be able to discard a transaction without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_LOCAL_TRANSACTION + "/" + region + - "?CRITERIA=(TRANID=" + discardParms.name + ")"; + "?CRITERIA=(TRANID%3D" + discardParms.name + ")"; response = await discardTransaction(dummySession, discardParms); @@ -160,7 +160,7 @@ describe("CMCI - Discard transaction", () => { discardParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_LOCAL_TRANSACTION + "//" + region + - "?CRITERIA=(TRANID=" + discardParms.name + ")"; + "?CRITERIA=(TRANID%3D" + discardParms.name + ")"; response = await discardTransaction(dummySession, discardParms); @@ -173,7 +173,7 @@ describe("CMCI - Discard transaction", () => { discardParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_LOCAL_TRANSACTION + "/" + cicsPlex + "/" + region + - "?CRITERIA=(TRANID=" + discardParms.name + ")"; + "?CRITERIA=(TRANID%3D" + discardParms.name + ")"; response = await discardTransaction(dummySession, discardParms); diff --git a/packages/sdk/__tests__/__unit__/discard/Discard.urimap.unit.test.ts b/packages/sdk/__tests__/__unit__/discard/Discard.urimap.unit.test.ts index c5408eca..b1987c90 100644 --- a/packages/sdk/__tests__/__unit__/discard/Discard.urimap.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/discard/Discard.urimap.unit.test.ts @@ -88,7 +88,7 @@ describe("CMCI - Discard urimap", () => { it("should be able to discard a urimap", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_URIMAP + "/" + region + - `?CRITERIA=(NAME='${discardParms.name}')`; + `?CRITERIA=(NAME%3D${discardParms.name})`; response = await discardUrimap(dummySession, discardParms); expect(response).toContain(content); diff --git a/packages/sdk/__tests__/__unit__/enable/Enable.urimap.unit.test.ts b/packages/sdk/__tests__/__unit__/enable/Enable.urimap.unit.test.ts index 467480ed..5f5f5e6f 100644 --- a/packages/sdk/__tests__/__unit__/enable/Enable.urimap.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/enable/Enable.urimap.unit.test.ts @@ -89,7 +89,7 @@ describe("CMCI - enable urimap", () => { it("should be able to enable a urimap", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_URIMAP + "/" + region + - `?CRITERIA=(NAME=${enableParms.name})`; + `?CRITERIA=(NAME%3D${enableParms.name})`; requestBody = { request: { update: { diff --git a/packages/sdk/__tests__/__unit__/get/Get.resource.unit.test.ts b/packages/sdk/__tests__/__unit__/get/Get.resource.unit.test.ts index b1e2eb11..893736d7 100644 --- a/packages/sdk/__tests__/__unit__/get/Get.resource.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/get/Get.resource.unit.test.ts @@ -26,13 +26,6 @@ describe("CMCI - Get resource", () => { const criteria = "program=D*"; const content = "This\nis\r\na\ntest" as unknown as ICMCIApiResponse; - const resourceParms: IResourceParms = { - regionName: region, - name: resource, - criteria, - cicsPlex: undefined - }; - const dummySession = new Session({ user: "fake", password: "fake", @@ -43,11 +36,19 @@ describe("CMCI - Get resource", () => { let error: any; let response: any; let endPoint: string; + let resourceParms: IResourceParms; + describe("validation", () => { beforeEach(() => { response = undefined; error = undefined; + resourceParms = { + regionName: region, + name: resource, + criteria: undefined, + cicsPlex: undefined + }; }); it("should throw error if no parms are defined", async () => { @@ -77,21 +78,6 @@ describe("CMCI - Get resource", () => { expect(error.message).toContain("CICS resource name is required"); }); - it("should throw error if CICS Region name is not defined", async () => { - try { - response = await getResource(dummySession, { - regionName: undefined, - name: "fake" - }); - } catch (err) { - error = err; - } - - expect(response).toBeUndefined(); - expect(error).toBeDefined(); - expect(error.message).toContain("CICS region name is required"); - }); - it("should throw error if resource name is missing", async () => { try { response = await getResource(dummySession, { @@ -106,21 +92,6 @@ describe("CMCI - Get resource", () => { expect(error).toBeDefined(); expect(error.message).toContain("Required parameter 'CICS Resource name' must not be blank"); }); - - it("should throw error if CICS Region name is missing", async () => { - try { - response = await getResource(dummySession, { - regionName: "", - name: "fake" - }); - } catch (err) { - error = err; - } - - expect(response).toBeUndefined(); - expect(error).toBeDefined(); - expect(error.message).toContain("Required parameter 'CICS Region name' must not be blank"); - }); }); describe("success scenarios", () => { @@ -130,13 +101,49 @@ describe("CMCI - Get resource", () => { beforeEach(() => { response = undefined; error = undefined; + resourceParms = { + regionName: region, + name: resource, + criteria: undefined, + cicsPlex: undefined + }; deleteSpy.mockClear(); deleteSpy.mockResolvedValue(content); }); + it("should be able to get a resource without CICS Region name being defined", async () => { + try { + resourceParms.regionName = undefined; + response = await getResource(dummySession, resourceParms); + } catch (err) { + error = err; + } + + endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + + resource + "/"; + + expect(response).toContain(content); + expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []); + }); + + it("should be able to get a resource without CICS Region name being specified", async () => { + try { + resourceParms.regionName = ""; + response = await getResource(dummySession, resourceParms); + } catch (err) { + error = err; + } + + endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + + resource + "/"; + + expect(response).toContain(content); + expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []); + }); + it("should be able to get a resource without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + resource + - "/" + region + "?CRITERIA=(" + encodeURIComponent(resourceParms.criteria) + ")"; + "/" + region; response = await getResource(dummySession, resourceParms); diff --git a/packages/sdk/__tests__/__unit__/install/Install.program.unit.test.ts b/packages/sdk/__tests__/__unit__/install/Install.program.unit.test.ts index 348ea8ab..125f2969 100644 --- a/packages/sdk/__tests__/__unit__/install/Install.program.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/install/Install.program.unit.test.ts @@ -177,7 +177,7 @@ describe("CMCI - Install program", () => { it("should be able to install a program without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_PROGRAM + "/" + region + - "?CRITERIA=(NAME=" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; + "?CRITERIA=(NAME%3D" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; response = await installProgram(dummySession, installParms); @@ -190,7 +190,7 @@ describe("CMCI - Install program", () => { installParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_PROGRAM + "//" + region + - "?CRITERIA=(NAME=" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; + "?CRITERIA=(NAME%3D" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; response = await installProgram(dummySession, installParms); @@ -203,7 +203,7 @@ describe("CMCI - Install program", () => { installParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_PROGRAM + "/" + cicsPlex + "/" + region + - "?CRITERIA=(NAME=" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; + "?CRITERIA=(NAME%3D" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; response = await installProgram(dummySession, installParms); diff --git a/packages/sdk/__tests__/__unit__/install/Install.transaction.unit.test.ts b/packages/sdk/__tests__/__unit__/install/Install.transaction.unit.test.ts index 9bc16187..04bacbaf 100644 --- a/packages/sdk/__tests__/__unit__/install/Install.transaction.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/install/Install.transaction.unit.test.ts @@ -180,7 +180,7 @@ describe("CMCI - Install transaction", () => { it("should be able to install a transaction without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "/" + region + - "?CRITERIA=(NAME=" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; + "?CRITERIA=(NAME%3D" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; response = await installTransaction(dummySession, installParms); @@ -193,7 +193,7 @@ describe("CMCI - Install transaction", () => { installParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "//" + region + - "?CRITERIA=(NAME=" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; + "?CRITERIA=(NAME%3D" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; response = await installTransaction(dummySession, installParms); @@ -206,7 +206,7 @@ describe("CMCI - Install transaction", () => { installParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "/" + cicsPlex + "/" + region + - "?CRITERIA=(NAME=" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; + "?CRITERIA=(NAME%3D" + installParms.name + ")&PARAMETER=CSDGROUP(" + installParms.csdGroup + ")"; response = await installTransaction(dummySession, installParms); diff --git a/packages/sdk/__tests__/__unit__/install/Install.urimap.unit.test.ts b/packages/sdk/__tests__/__unit__/install/Install.urimap.unit.test.ts index ffa95fc3..4c8d46b0 100644 --- a/packages/sdk/__tests__/__unit__/install/Install.urimap.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/install/Install.urimap.unit.test.ts @@ -105,7 +105,7 @@ describe("CMCI - Install urimap", () => { it("should be able to install a urimap", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_DEFINITION_URIMAP + "/" + region + - `?CRITERIA=(NAME=${installParms.name})&PARAMETER=CSDGROUP(${installParms.csdGroup})`; + `?CRITERIA=(NAME%3D${installParms.name})&PARAMETER=CSDGROUP(${installParms.csdGroup})`; requestBody = { request: { action: { diff --git a/packages/sdk/__tests__/__unit__/refresh/Refresh.program.unit.test.ts b/packages/sdk/__tests__/__unit__/refresh/Refresh.program.unit.test.ts index 70f849c3..7d855123 100644 --- a/packages/sdk/__tests__/__unit__/refresh/Refresh.program.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/refresh/Refresh.program.unit.test.ts @@ -139,7 +139,7 @@ describe("CMCI - Refresh program", () => { it("should be able to refresh a program without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_PROGRAM_RESOURCE + "/" + region + - "?CRITERIA=(PROGRAM=" + refreshParms.name + ")"; + "?CRITERIA=(PROGRAM%3D" + refreshParms.name + ")"; response = await programNewcopy(dummySession, refreshParms); @@ -152,7 +152,7 @@ describe("CMCI - Refresh program", () => { refreshParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_PROGRAM_RESOURCE + "//" + region + - "?CRITERIA=(PROGRAM=" + refreshParms.name + ")"; + "?CRITERIA=(PROGRAM%3D" + refreshParms.name + ")"; response = await programNewcopy(dummySession, refreshParms); @@ -165,7 +165,7 @@ describe("CMCI - Refresh program", () => { refreshParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_PROGRAM_RESOURCE + "/" + cicsPlex + "/" + region + - "?CRITERIA=(PROGRAM=" + refreshParms.name + ")"; + "?CRITERIA=(PROGRAM%3D" + refreshParms.name + ")"; response = await programNewcopy(dummySession, refreshParms); diff --git a/packages/sdk/__tests__/__unit__/remove-from-list/RemoveFromList.csdGroup.unit.test.ts b/packages/sdk/__tests__/__unit__/remove-from-list/RemoveFromList.csdGroup.unit.test.ts index 81166369..d84a45b5 100644 --- a/packages/sdk/__tests__/__unit__/remove-from-list/RemoveFromList.csdGroup.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/remove-from-list/RemoveFromList.csdGroup.unit.test.ts @@ -150,7 +150,7 @@ describe("CMCI - Remove csdGroup from list", () => { it("should be able to remove a csdGroup from list without cicsPlex specified", async () => { endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_CSDGROUP_IN_LIST + "/" + removeFromListParms.regionName + - "?CRITERIA=(CSDLIST=='" + removeFromListParms.csdList + "')%20AND%20(CSDGROUP=='" + removeFromListParms.name + "')"; + "?CRITERIA=(CSDLIST%3D%3D'" + removeFromListParms.csdList + "')%20AND%20(CSDGROUP%3D%3D'" + removeFromListParms.name + "')"; response = await removeCSDGroupFromList(dummySession, removeFromListParms); @@ -163,7 +163,7 @@ describe("CMCI - Remove csdGroup from list", () => { removeFromListParms.cicsPlex = ""; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_CSDGROUP_IN_LIST + "/" + removeFromListParms.cicsPlex + "/" + removeFromListParms.regionName + - "?CRITERIA=(CSDLIST=='" + removeFromListParms.csdList + "')%20AND%20(CSDGROUP=='" + removeFromListParms.name + "')"; + "?CRITERIA=(CSDLIST%3D%3D'" + removeFromListParms.csdList + "')%20AND%20(CSDGROUP%3D%3D'" + removeFromListParms.name + "')"; response = await removeCSDGroupFromList(dummySession, removeFromListParms); @@ -176,7 +176,7 @@ describe("CMCI - Remove csdGroup from list", () => { removeFromListParms.cicsPlex = cicsPlex; endPoint = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + CicsCmciConstants.CICS_CSDGROUP_IN_LIST + "/" + removeFromListParms.cicsPlex + "/" + removeFromListParms.regionName + - "?CRITERIA=(CSDLIST=='" + removeFromListParms.csdList + "')%20AND%20(CSDGROUP=='" + removeFromListParms.name + "')"; + "?CRITERIA=(CSDLIST%3D%3D'" + removeFromListParms.csdList + "')%20AND%20(CSDGROUP%3D%3D'" + removeFromListParms.name + "')"; response = await removeCSDGroupFromList(dummySession, removeFromListParms); diff --git a/packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts b/packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts new file mode 100644 index 00000000..56d26200 --- /dev/null +++ b/packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts @@ -0,0 +1,227 @@ +/** + * 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. + * + */ + +import { Utils } from "../../../src/utils"; +import { IGetResourceUriOptions } from "../../../src"; + +describe("Utils - getResourceUri", () => { + + let error: any; + let response: any; + + describe("validation", () => { + beforeEach(() => { + response = undefined; + error = undefined; + }); + + it("should throw error if resourceName is empty", async () => { + try { + response = Utils.getResourceUri(""); + } catch (err) { + error = err; + } + + expect(response).toBeUndefined(); + expect(error).toBeDefined(); + expect(error.message).toEqual("Expect Error: Required parameter 'CICS Resource name' must not be blank"); + }); + + it("should throw error if resourceName is undefined", async () => { + try { + response = Utils.getResourceUri(undefined); + } catch (err) { + error = err; + } + + expect(response).toBeUndefined(); + expect(error).toBeDefined(); + expect(error.message).toEqual("Expect Error: CICS resource name is required"); + }); + + it("should throw error if resourceName is null", async () => { + try { + response = Utils.getResourceUri(null); + } catch (err) { + error = err; + } + + expect(response).toBeUndefined(); + expect(error).toBeDefined(); + expect(error.message).toEqual("Expect Error: CICS resource name is required"); + }); + }); + + describe("success scenarios", () => { + + beforeEach(() => { + response = undefined; + error = undefined; + }); + + it("should be able to get a resource uri with only the resource name specified", async () => { + try { + response = Utils.getResourceUri("resource1"); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/"); + }); + + it("should be able to get a resource uri with the cicsplex and resource name specified", async () => { + try { + + const options: IGetResourceUriOptions = { + "cicsPlex": "cicsplex1", + "regionName": "" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/"); + }); + + it("should be able to get a resource uri with the region and resource names specified", async () => { + try { + const options: IGetResourceUriOptions = { + "cicsPlex": "", + "regionName": "region1" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1//region1"); + }); + + it("should be able to get a resource uri with the plex, region and resource names specified", async () => { + try { + const options: IGetResourceUriOptions = { + "cicsPlex": "cicsplex1", + "regionName": "region1" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1"); + }); + + it("should be able to get a resource uri with the criteria is unspecified", async () => { + try { + const options: IGetResourceUriOptions = { + "cicsPlex": "cicsplex1", + "regionName": "region1", + "criteria": "" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1"); + }); + + it("should be able to get a resource uri with the criteria is specified", async () => { + try { + const options: IGetResourceUriOptions = { + "cicsPlex": "cicsplex1", + "regionName": "region1", + "criteria": "NAME=test" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?CRITERIA=(NAME%3Dtest)"); + }); + + it("should be able to get a resource uri with the parameter is unspecified", async () => { + try { + const options: IGetResourceUriOptions = { + "cicsPlex": "cicsplex1", + "regionName": "region1", + "criteria": "", + "parameter": "" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1"); + }); + + it("should be able to get a resource uri with the parameter is specified", async () => { + try { + const options: IGetResourceUriOptions = { + "cicsPlex": "cicsplex1", + "regionName": "region1", + "criteria": "", + "parameter": "PARAM=test" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?PARAMETER=PARAM%3Dtest"); + }); + + it("should be able to get a resource uri when both criteria and parameter are specified", async () => { + try { + const options: IGetResourceUriOptions = { + "cicsPlex": "cicsplex1", + "regionName": "region1", + "criteria": "NAME=test1", + "parameter": "PARAM=test2" + }; + + response = Utils.getResourceUri("resource1", options); + } catch (err) { + error = err; + } + + expect(response).toBeDefined(); + expect(error).toBeUndefined(); + expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?CRITERIA=(NAME%3Dtest1)&PARAMETER=PARAM%3Dtest2"); + }); + }); +}); diff --git a/packages/sdk/package.json b/packages/sdk/package.json index b376acc5..c96e2f6a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cics-for-zowe-sdk", - "version": "6.0.0", + "version": "6.1.0", "author": "Zowe", "license": "EPL-2.0", "description": "IBM CICS for Zowe SDK", diff --git a/packages/sdk/src/doc/IGetResourceUriOptions.ts b/packages/sdk/src/doc/IGetResourceUriOptions.ts new file mode 100644 index 00000000..c4d9c4ad --- /dev/null +++ b/packages/sdk/src/doc/IGetResourceUriOptions.ts @@ -0,0 +1,42 @@ +/** + * 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. + * + */ + +export interface IGetResourceUriOptions { + + /** + * CICS Plex of the program + */ + cicsPlex?: string; + + /** + * The name of the CICS region of the program + */ + regionName?: string; + + /** + * Criteria by which to filter the records + * + * Examples: + * "TRANID=TRAN" + * "PROGRAM=PRG*" + * "NAME=C* AND PROGRAM=D*" + */ + criteria?: string; + + /** + * Parameter by which to refine the records + * + * Example: + * "CSDGROUP(GRP1)" + * "CSDGROUP(D*)" + */ + parameter?: string; +} diff --git a/packages/sdk/src/doc/IResourceParms.ts b/packages/sdk/src/doc/IResourceParms.ts index 23145c1b..12f47081 100644 --- a/packages/sdk/src/doc/IResourceParms.ts +++ b/packages/sdk/src/doc/IResourceParms.ts @@ -37,7 +37,7 @@ export interface IResourceParms { /** * The name of the CICS region of the program */ - regionName: string; + regionName?: string; /** * CICS Plex of the program diff --git a/packages/sdk/src/doc/index.ts b/packages/sdk/src/doc/index.ts index 084dcaa8..c418516a 100644 --- a/packages/sdk/src/doc/index.ts +++ b/packages/sdk/src/doc/index.ts @@ -17,3 +17,4 @@ export * from "./IResourceParms"; export * from "./ITransactionParms"; export * from "./IURIMapParms"; export * from "./IWebServiceParms"; +export * from "./IGetResourceUriOptions"; diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 6925fe7f..512fde32 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -13,3 +13,4 @@ export * from "./constants"; export * from "./methods"; export * from "./doc"; export * from "./rest"; +export * from "./utils"; diff --git a/packages/sdk/src/methods/add-to-list/AddToList.ts b/packages/sdk/src/methods/add-to-list/AddToList.ts index 45b1fb8e..fb711c80 100644 --- a/packages/sdk/src/methods/add-to-list/AddToList.ts +++ b/packages/sdk/src/methods/add-to-list/AddToList.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, ICSDGroupParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, ICSDGroupParms, IGetResourceUriOptions } from "../../doc"; /** * Add a new CSD Group resource to a CSD List in CICS through CMCI REST API @@ -31,10 +32,13 @@ export function addCSDGroupToList(session: AbstractSession, parms: ICSDGroupParm Logger.getAppLogger().debug("Attempting to add a CSD Group to a CSD List with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_CSDGROUP + "/" + cicsPlex + parms.regionName + - "?CRITERIA=NAME=='" + parms.name + "'"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CSDGROUP, options); const requestBody: any = { request: { diff --git a/packages/sdk/src/methods/define/Define.ts b/packages/sdk/src/methods/define/Define.ts index cbf7d4d9..86da4786 100644 --- a/packages/sdk/src/methods/define/Define.ts +++ b/packages/sdk/src/methods/define/Define.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IProgramParms, ITransactionParms, IURIMapParms, IWebServiceParms } from "../../doc"; +import { ICMCIApiResponse, IProgramParms, ITransactionParms, IURIMapParms, IWebServiceParms, IGetResourceUriOptions } from "../../doc"; +import { Utils } from "../../utils"; /** * Define a new program resource to CICS through CMCI REST API @@ -49,9 +50,12 @@ export function defineProgram(session: AbstractSession, parms: IProgramParms): P } }; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_PROGRAM + "/" + cicsPlex + parms.regionName; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_PROGRAM, options); return CicsCmciRestClient.postExpectParsedXml(session, cmciResource, [], requestBody) as any; } @@ -93,10 +97,12 @@ export function defineTransaction(session: AbstractSession, parms: ITransactionP } }; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "/" + cicsPlex + - parms.regionName; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_TRANSACTION, options); return CicsCmciRestClient.postExpectParsedXml(session, cmciResource, [], requestBody) as any; } @@ -124,9 +130,12 @@ export function defineUrimapServer(session: AbstractSession, parms: IURIMapParms const requestBody: any = buildUrimapRequestBody(parms, "server"); requestBody.request.create.attributes.$.program = parms.programName; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_URIMAP + "/" + cicsPlex + parms.regionName; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_URIMAP, options); return CicsCmciRestClient.postExpectParsedXml(session, cmciResource, [], requestBody) as any; } @@ -150,9 +159,12 @@ export function defineUrimapClient(session: AbstractSession, parms: IURIMapParms Logger.getAppLogger().debug("Attempting to define a client URIMap with the following parameters:\n%s", JSON.stringify(parms)); const requestBody: any = buildUrimapRequestBody(parms, "client"); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_URIMAP + "/" + cicsPlex + parms.regionName; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_URIMAP, options); return CicsCmciRestClient.postExpectParsedXml(session, cmciResource, [], requestBody) as any; } @@ -179,9 +191,12 @@ export function defineUrimapPipeline(session: AbstractSession, parms: IURIMapPar const requestBody: any = buildUrimapRequestBody(parms, "pipeline"); requestBody.request.create.attributes.$.pipeline = parms.pipelineName; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_URIMAP + "/" + cicsPlex + parms.regionName; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_URIMAP, options); return CicsCmciRestClient.postExpectParsedXml(session, cmciResource, [], requestBody) as any; } @@ -305,10 +320,12 @@ export function defineWebservice(session: AbstractSession, parms: IWebServicePar } }; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_WEBSERVICE + "/" + cicsPlex + - parms.regionName; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_WEBSERVICE, options); return CicsCmciRestClient.postExpectParsedXml(session, cmciResource, [], requestBody) as any; } diff --git a/packages/sdk/src/methods/delete/Delete.ts b/packages/sdk/src/methods/delete/Delete.ts index 07a232fe..1addff6b 100644 --- a/packages/sdk/src/methods/delete/Delete.ts +++ b/packages/sdk/src/methods/delete/Delete.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IProgramParms, ITransactionParms, IURIMapParms, IWebServiceParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, IProgramParms, ITransactionParms, IURIMapParms, IWebServiceParms, IGetResourceUriOptions } from "../../doc"; /** * Delete a program installed in CICS through CMCI REST API @@ -31,10 +32,15 @@ export async function deleteProgram(session: AbstractSession, parms: IProgramPar Logger.getAppLogger().debug("Attempting to delete a program with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_PROGRAM + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME=${parms.name})&PARAMETER=CSDGROUP(${parms.csdGroup})`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}`, + "parameter": `CSDGROUP(${parms.csdGroup})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_PROGRAM, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []); } @@ -55,10 +61,15 @@ export async function deleteTransaction(session: AbstractSession, parms: ITransa Logger.getAppLogger().debug("Attempting to delete a transaction with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME=${parms.name})&PARAMETER=CSDGROUP(${parms.csdGroup})`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}`, + "parameter": `CSDGROUP(${parms.csdGroup})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_TRANSACTION, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []); } @@ -80,10 +91,15 @@ export async function deleteUrimap(session: AbstractSession, parms: IURIMapParms Logger.getAppLogger().debug("Attempting to delete a URIMap with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_URIMAP + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME=${parms.name})&PARAMETER=CSDGROUP(${parms.csdGroup})`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}`, + "parameter": `CSDGROUP(${parms.csdGroup})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_URIMAP, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []); } @@ -105,9 +121,14 @@ export async function deleteWebservice(session: AbstractSession, parms: IWebServ Logger.getAppLogger().debug("Attempting to delete a web service with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_WEBSERVICE + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME=${parms.name})&PARAMETER=CSDGROUP(${parms.csdGroup})`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}`, + "parameter": `CSDGROUP(${parms.csdGroup})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_WEBSERVICE, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []); } diff --git a/packages/sdk/src/methods/disable/Disable.ts b/packages/sdk/src/methods/disable/Disable.ts index d1f9c22a..498f5d0f 100644 --- a/packages/sdk/src/methods/disable/Disable.ts +++ b/packages/sdk/src/methods/disable/Disable.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IURIMapParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, IURIMapParms, IGetResourceUriOptions } from "../../doc"; /** * Disable a URIMap installed in CICS through CMCI REST API @@ -32,10 +33,14 @@ export async function disableUrimap(session: AbstractSession, parms: IURIMapParm Logger.getAppLogger().debug("Attempting to disable a URIMap with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_URIMAP + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME=${parms.name})`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_URIMAP, options); + const requestBody: any = { request: { update: { diff --git a/packages/sdk/src/methods/discard/Discard.ts b/packages/sdk/src/methods/discard/Discard.ts index fc962ad3..91da9c42 100644 --- a/packages/sdk/src/methods/discard/Discard.ts +++ b/packages/sdk/src/methods/discard/Discard.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IProgramParms, ITransactionParms, IURIMapParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, IProgramParms, ITransactionParms, IURIMapParms, IGetResourceUriOptions } from "../../doc"; /** * Discard a program installed in CICS through CMCI REST API @@ -30,10 +31,14 @@ export async function discardProgram(session: AbstractSession, parms: IProgramPa Logger.getAppLogger().debug("Attempting to discard a program with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_PROGRAM_RESOURCE + "/" + cicsPlex + parms.regionName + - "?CRITERIA=(PROGRAM=" + parms.name + ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `PROGRAM=${parms.name}` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_PROGRAM_RESOURCE, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []); } @@ -53,10 +58,14 @@ export async function discardTransaction(session: AbstractSession, parms: ITrans Logger.getAppLogger().debug("Attempting to discard a transaction with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_LOCAL_TRANSACTION + "/" + cicsPlex + parms.regionName + - "?CRITERIA=(TRANID=" + parms.name + ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `(TRANID=${parms.name})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_LOCAL_TRANSACTION, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []); } @@ -66,9 +75,13 @@ export async function discardUrimap(session: AbstractSession, parms: IURIMapParm Logger.getAppLogger().debug("Attempting to discard a URIMap with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_URIMAP + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME='${parms.name}')`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `(NAME=${parms.name})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_URIMAP, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []); } diff --git a/packages/sdk/src/methods/enable/Enable.ts b/packages/sdk/src/methods/enable/Enable.ts index 91f0cc41..8d8459ed 100644 --- a/packages/sdk/src/methods/enable/Enable.ts +++ b/packages/sdk/src/methods/enable/Enable.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IURIMapParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, IURIMapParms, IGetResourceUriOptions } from "../../doc"; /** * Enable a URIMap installed in CICS through CMCI REST API @@ -32,10 +33,14 @@ export async function enableUrimap(session: AbstractSession, parms: IURIMapParms Logger.getAppLogger().debug("Attempting to enable a URIMap with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_URIMAP + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME=${parms.name})`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_URIMAP, options); + const requestBody: any = { request: { update: { diff --git a/packages/sdk/src/methods/get/Get.ts b/packages/sdk/src/methods/get/Get.ts index a83fefd1..fb60be42 100644 --- a/packages/sdk/src/methods/get/Get.ts +++ b/packages/sdk/src/methods/get/Get.ts @@ -11,8 +11,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; -import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IResourceParms } from "../../doc"; +import { ICMCIApiResponse, IResourceParms, IGetResourceUriOptions } from "../../doc"; +import { Utils } from "../../utils"; /** * Get resources on in CICS through CMCI REST API @@ -26,23 +26,17 @@ import { ICMCIApiResponse, IResourceParms } from "../../doc"; */ export async function getResource(session: AbstractSession, parms: IResourceParms): Promise { ImperativeExpect.toBeDefinedAndNonBlank(parms.name, "CICS Resource name", "CICS resource name is required"); - ImperativeExpect.toBeDefinedAndNonBlank(parms.regionName, "CICS Region name", "CICS region name is required"); - - let delimiter = "?"; // initial delimiter Logger.getAppLogger().debug("Attempting to get resource(s) with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - let cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - parms.name + "/" + cicsPlex + parms.regionName; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": parms.criteria, + "parameter": parms.parameter + }; - if (parms.criteria != null) { - cmciResource = cmciResource + delimiter + "CRITERIA=(" + encodeURIComponent(parms.criteria) + ")"; - delimiter = "&"; - } + const cmciResource = Utils.getResourceUri(parms.name, options); - if (parms.parameter != null) { - cmciResource = cmciResource + delimiter + "PARAMETER=" + encodeURIComponent(parms.parameter); - } return CicsCmciRestClient.getExpectParsedXml(session, cmciResource, []); } diff --git a/packages/sdk/src/methods/install/Install.ts b/packages/sdk/src/methods/install/Install.ts index 5a0fc6a9..ed1b1d87 100644 --- a/packages/sdk/src/methods/install/Install.ts +++ b/packages/sdk/src/methods/install/Install.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IProgramParms, IURIMapParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, IProgramParms, IURIMapParms, IGetResourceUriOptions } from "../../doc"; /** * Install a program definition to CICS through CMCI REST API @@ -41,10 +42,15 @@ export function installProgram(session: AbstractSession, parms: IProgramParms): } }; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_PROGRAM + "/" + cicsPlex + parms.regionName + - "?CRITERIA=(NAME=" + parms.name + ")&PARAMETER=CSDGROUP(" + parms.csdGroup + ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}`, + "parameter": `CSDGROUP(${parms.csdGroup})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_PROGRAM, options); + return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody) as any; } @@ -75,10 +81,15 @@ export function installTransaction(session: AbstractSession, parms: IProgramParm } }; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_TRANSACTION + "/" + cicsPlex + parms.regionName + - "?CRITERIA=(NAME=" + parms.name + ")&PARAMETER=CSDGROUP(" + parms.csdGroup + ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}`, + "parameter": `CSDGROUP(${parms.csdGroup})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_TRANSACTION, options); + return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody) as any; } @@ -102,10 +113,15 @@ export function installUrimap(session: AbstractSession, parms: IURIMapParms): Pr Logger.getAppLogger().debug("Attempting to install a URIMap with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_DEFINITION_URIMAP + "/" + cicsPlex + - `${parms.regionName}?CRITERIA=(NAME=${parms.name})&PARAMETER=CSDGROUP(${parms.csdGroup})`; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `NAME=${parms.name}`, + "parameter": `CSDGROUP(${parms.csdGroup})` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_DEFINITION_URIMAP, options); + const requestBody: any = { request: { action: { @@ -115,5 +131,6 @@ export function installUrimap(session: AbstractSession, parms: IURIMapParms): Pr } } }; + return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/sdk/src/methods/remove-from-list/RemoveFromList.ts b/packages/sdk/src/methods/remove-from-list/RemoveFromList.ts index 149f47f1..a0c50acd 100644 --- a/packages/sdk/src/methods/remove-from-list/RemoveFromList.ts +++ b/packages/sdk/src/methods/remove-from-list/RemoveFromList.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, ICSDGroupParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, ICSDGroupParms, IGetResourceUriOptions } from "../../doc"; /** * Remove a CSD Group resource from a CSD List in CICS through CMCI REST API @@ -31,9 +32,13 @@ export function removeCSDGroupFromList(session: AbstractSession, parms: ICSDGrou Logger.getAppLogger().debug("Attempting to remove a CSD Group from a CSD List with the following parameters:\n%s", JSON.stringify(parms)); - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_CSDGROUP_IN_LIST + "/" + cicsPlex + parms.regionName + - "?CRITERIA=(CSDLIST=='" + parms.csdList + "')%20AND%20(CSDGROUP=='" + parms.name + "')"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `(CSDLIST=='${parms.csdList}') AND (CSDGROUP=='${parms.name}')` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CSDGROUP_IN_LIST, options); + return CicsCmciRestClient.deleteExpectParsedXml(session, cmciResource, []) as any; } diff --git a/packages/sdk/src/methods/set/Set.ts b/packages/sdk/src/methods/set/Set.ts index d5cb0258..dff16dd5 100644 --- a/packages/sdk/src/methods/set/Set.ts +++ b/packages/sdk/src/methods/set/Set.ts @@ -12,7 +12,8 @@ import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative"; import { CicsCmciRestClient } from "../../rest"; import { CicsCmciConstants } from "../../constants"; -import { ICMCIApiResponse, IProgramParms } from "../../doc"; +import { Utils } from "../../utils"; +import { ICMCIApiResponse, IProgramParms, IGetResourceUriOptions } from "../../doc"; /** * Refresh a program definition on CICS through CMCI REST API @@ -39,9 +40,13 @@ export function programNewcopy(session: AbstractSession, parms: IProgramParms): } }; - const cicsPlex = parms.cicsPlex == null ? "" : parms.cicsPlex + "/"; - const cmciResource = "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + - CicsCmciConstants.CICS_PROGRAM_RESOURCE + "/" + cicsPlex + parms.regionName + - "?CRITERIA=(PROGRAM=" + parms.name + ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `PROGRAM=${parms.name}` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_PROGRAM_RESOURCE, options); + return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody) as any; } diff --git a/packages/sdk/src/utils/Utils.ts b/packages/sdk/src/utils/Utils.ts new file mode 100644 index 00000000..9be391a4 --- /dev/null +++ b/packages/sdk/src/utils/Utils.ts @@ -0,0 +1,54 @@ +/** + * 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. + * + */ + +import { ImperativeExpect } from "@zowe/imperative"; +import { CicsCmciConstants } from "../constants"; +import { IGetResourceUriOptions } from "../doc"; + +/** + * Class for providing static utility methods + * @export + * @class Utils + */ +export class Utils { + + /** + * Get uri for requesting a resources in CICS through CMCI REST API + * @param {string} resourceName - CMCI resource name + * @param {IGetResourceUriOptions} options - CMCI resource options + */ + public static getResourceUri(resourceName: string, options?: IGetResourceUriOptions) : string { + ImperativeExpect.toBeDefinedAndNonBlank(resourceName, "CICS Resource name", "CICS resource name is required"); + + let delimiter = "?"; // initial delimiter + + const cicsPlex = (options && options.cicsPlex) == null ? "" : `${options.cicsPlex}/`; + const region = (options && options.regionName) == null ? "" : options.regionName; + + let cmciResource = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resourceName}/${cicsPlex}${region}`; + + if (options != null) { + if (options.criteria != null && options.criteria.length > 0) { + const addParentheses = options.criteria.charAt(0) !== '('; + + cmciResource = cmciResource + delimiter + "CRITERIA=" + (addParentheses ? "(": "") + + encodeURIComponent(options.criteria) + (addParentheses ? ")": "") ; + delimiter = "&"; + } + + if (options.parameter != null && options.parameter.length > 0) { + cmciResource = cmciResource + delimiter + "PARAMETER=" + encodeURIComponent(options.parameter); + } + } + + return cmciResource; + } +} diff --git a/packages/sdk/src/utils/index.ts b/packages/sdk/src/utils/index.ts new file mode 100644 index 00000000..ff161f3e --- /dev/null +++ b/packages/sdk/src/utils/index.ts @@ -0,0 +1,12 @@ +/** + * 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. + * + */ + +export * from "./Utils"; diff --git a/packages/vsce/package.json b/packages/vsce/package.json index 5cadeac5..e0db1981 100644 --- a/packages/vsce/package.json +++ b/packages/vsce/package.json @@ -8,7 +8,7 @@ "type": "git", "url": "https://github.com/zowe/cics-for-zowe-client.git" }, - "version": "3.0.2", + "version": "3.1.0", "engines": { "vscode": "^1.79.0" }, @@ -892,7 +892,7 @@ "@vscode/vsce": "^2.32.0" }, "dependencies": { - "@zowe/cics-for-zowe-sdk": "6.0.0", + "@zowe/cics-for-zowe-sdk": "6.1.0", "@zowe/core-for-zowe-sdk": "^8.0.0", "@zowe/zowe-explorer-api": "^3.0.3", "axios": "^1.6.7",