Skip to content

Commit

Permalink
Merge branch 'main' into clean-up-obsolete-web-page
Browse files Browse the repository at this point in the history
Signed-off-by: Chinmay Das <[email protected]>
  • Loading branch information
chinmdas authored Dec 18, 2024
2 parents 5b495f1 + 1ea123b commit 0b2dad1
Show file tree
Hide file tree
Showing 14 changed files with 353 additions and 54 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zowe/cics_monorepo",
"private": true,
"version": "6.1.0",
"version": "6.1.1",
"publishConfig": {
"registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the IBM® CICS® Plug-in for Zowe CLI will be documented in this file.

## Recent Changes

- Enhancement: Add optional query parameters on getResource SDK method. [#168](https://github.com/zowe/cics-for-zowe-client/issues/168)

## `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)
Expand Down
69 changes: 69 additions & 0 deletions packages/sdk/__tests__/__unit__/get/Get.resource.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,74 @@ describe("CMCI - Get resource", () => {
expect(response).toContain(content);
expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []);
});

it("should be able to get a resource with SUMMONLY specified", async () => {
resourceParms.cicsPlex = "plex1";
resourceParms.regionName = "reg1";
resourceParms.queryParams = {
summonly: true,
};
endPoint = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resource}/plex1/reg1?SUMMONLY`;
response = await getResource(dummySession, resourceParms);

expect(response).toContain(content);
expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []);
});

it("should be able to get a resource with NODISCARD specified", async () => {
resourceParms.cicsPlex = "plex1";
resourceParms.regionName = "reg1";
resourceParms.queryParams = {
nodiscard: true,
};
endPoint = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resource}/plex1/reg1?NODISCARD`;
response = await getResource(dummySession, resourceParms);

expect(response).toContain(content);
expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []);
});

it("should be able to get a resource with OVERRIDEWARNINGCOUNT specified", async () => {
resourceParms.cicsPlex = "plex1";
resourceParms.regionName = "reg1";
resourceParms.queryParams = {
overrideWarningCount: true,
};
endPoint = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resource}/plex1/reg1?OVERRIDEWARNINGCOUNT`;
response = await getResource(dummySession, resourceParms);

expect(response).toContain(content);
expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []);
});

it("should be able to get a resource with all query params specified", async () => {
resourceParms.cicsPlex = "plex1";
resourceParms.regionName = "reg1";
resourceParms.queryParams = {
overrideWarningCount: true,
summonly: true,
nodiscard: true,
};
endPoint = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resource}/plex1/reg1?SUMMONLY&NODISCARD&OVERRIDEWARNINGCOUNT`;
response = await getResource(dummySession, resourceParms);

expect(response).toContain(content);
expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []);
});

it("should be able to get a resource with no context and all query params specified", async () => {
resourceParms.cicsPlex = undefined;
resourceParms.regionName = undefined;
resourceParms.queryParams = {
overrideWarningCount: true,
summonly: true,
nodiscard: true,
};
endPoint = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resource}/?SUMMONLY&NODISCARD&OVERRIDEWARNINGCOUNT`;
response = await getResource(dummySession, resourceParms);

expect(response).toContain(content);
expect(deleteSpy).toHaveBeenCalledWith(dummySession, endPoint, []);
});
});
});
190 changes: 190 additions & 0 deletions packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,195 @@ describe("Utils - getResourceUri", () => {
expect(error).toBeUndefined();
expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?CRITERIA=(NAME%3Dtest1)&PARAMETER=PARAM%3Dtest2");
});

it("should be able to get a resource uri with SUMMONLY specified", async () => {
try {
const options: IGetResourceUriOptions = {
cicsPlex: "cicsplex1",
regionName: "region1",
queryParams: {
summonly: true,
}
};

response = Utils.getResourceUri("resource1", options);
} catch (err) {
error = err;
}

expect(response).toBeDefined();
expect(error).toBeUndefined();
expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?SUMMONLY");
});

it("should be able to get a resource uri with SUMMONLY specified to false", async () => {
try {
const options: IGetResourceUriOptions = {
cicsPlex: "cicsplex1",
regionName: "region1",
queryParams: {
summonly: false,
}
};

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 NODISCARD specified", async () => {
try {
const options: IGetResourceUriOptions = {
cicsPlex: "cicsplex1",
regionName: "region1",
queryParams: {
nodiscard: true,
}
};

response = Utils.getResourceUri("resource1", options);
} catch (err) {
error = err;
}

expect(response).toBeDefined();
expect(error).toBeUndefined();
expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?NODISCARD");
});

it("should be able to get a resource uri with NODISCARD specified", async () => {
try {
const options: IGetResourceUriOptions = {
cicsPlex: "cicsplex1",
regionName: "region1",
queryParams: {
nodiscard: false,
}
};

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 OVERRIDEWARNINGCOUNT specified", async () => {
try {
const options: IGetResourceUriOptions = {
cicsPlex: "cicsplex1",
regionName: "region1",
queryParams: {
overrideWarningCount: true,
}
};

response = Utils.getResourceUri("resource1", options);
} catch (err) {
error = err;
}

expect(response).toBeDefined();
expect(error).toBeUndefined();
expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?OVERRIDEWARNINGCOUNT");
});

it("should be able to get a resource uri with OVERRIDEWARNINGCOUNT specified to false", async () => {
try {
const options: IGetResourceUriOptions = {
cicsPlex: "cicsplex1",
regionName: "region1",
queryParams: {
overrideWarningCount: false,
}
};

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 all query params specified", async () => {
try {
const options: IGetResourceUriOptions = {
cicsPlex: "cicsplex1",
regionName: "region1",
queryParams: {
summonly: true,
nodiscard: true,
overrideWarningCount: true,
}
};

response = Utils.getResourceUri("resource1", options);
} catch (err) {
error = err;
}

expect(response).toBeDefined();
expect(error).toBeUndefined();
expect(response).toEqual("/CICSSystemManagement/resource1/cicsplex1/region1?SUMMONLY&NODISCARD&OVERRIDEWARNINGCOUNT");
});

it("should be able to get a resource uri with all query params specified and no context", async () => {
try {
const options: IGetResourceUriOptions = {
queryParams: {
summonly: true,
nodiscard: true,
overrideWarningCount: true,
}
};

response = Utils.getResourceUri("resource1", options);
} catch (err) {
error = err;
}

expect(response).toBeDefined();
expect(error).toBeUndefined();
expect(response).toEqual("/CICSSystemManagement/resource1/?SUMMONLY&NODISCARD&OVERRIDEWARNINGCOUNT");
});
});
});

describe('Utils - enforceParentheses', () => {

it("should add brackets when none exist", () => {
const output = Utils.enforceParentheses("input");
expect(output).toEqual("(input)");
});

it("should add first bracket when end exists", () => {
const output = Utils.enforceParentheses("input with spaces)");
expect(output).toEqual("(input with spaces)");
});

it("should add last bracket when first exists", () => {
const output = Utils.enforceParentheses("(input with spec1@| characters");
expect(output).toEqual("(input with spec1@| characters)");
});

it("should do nothing when both brackets exist", () => {
const output = Utils.enforceParentheses("(fully covered)");
expect(output).toEqual("(fully covered)");
});

it("should do nothing when multiple brackets exist", () => {
const output = Utils.enforceParentheses("((()))");
expect(output).toEqual("((()))");
});
});
7 changes: 6 additions & 1 deletion packages/sdk/src/constants/CicsCmci.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Constants to be used by the API
*/
export const CicsCmciConstants: { [key: string]: any } = {
export const CicsCmciConstants = {
/**
* Specifies the required part of the REST interface URI
*/
Expand Down Expand Up @@ -79,6 +79,11 @@ export const CicsCmciConstants: { [key: string]: any } = {
*/
NO_DISCARD: "NODISCARD",

/**
* OVERRIDEWARNINGCOUNT parameter
*/
OVERRIDE_WARNING_COUNT: "OVERRIDEWARNINGCOUNT",

/**
* CRITERIA parameter
*/
Expand Down
7 changes: 7 additions & 0 deletions packages/sdk/src/doc/IGetResourceUriOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*
*/

import { IResourceQueryParams } from "./IResourceQueryParms";

export interface IGetResourceUriOptions {

/**
Expand Down Expand Up @@ -39,4 +41,9 @@ export interface IGetResourceUriOptions {
* "CSDGROUP(D*)"
*/
parameter?: string;

/**
* Query parameters to be used in the HTTP request
*/
queryParams?: IResourceQueryParams;
}
33 changes: 3 additions & 30 deletions packages/sdk/src/doc/IResourceParms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,11 @@
*
*/

export interface IResourceParms {
import { IGetResourceUriOptions } from "./IGetResourceUriOptions";

export interface IResourceParms extends IGetResourceUriOptions {
/**
* The name of the resource
*/
name: 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;

/**
* The name of the CICS region of the program
*/
regionName?: string;

/**
* CICS Plex of the program
*/
cicsPlex?: string;
}
Loading

0 comments on commit 0b2dad1

Please sign in to comment.