Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SDK getCache method #172

Merged
merged 3 commits into from
Dec 18, 2024
Merged

Add SDK getCache method #172

merged 3 commits into from
Dec 18, 2024

Conversation

AndrewTwydell
Copy link
Contributor

@AndrewTwydell AndrewTwydell commented Dec 17, 2024

Requires #171 - Merged!

What It Does
Resolves #169

Adds getCache method to the SDK to retrieve a cached result from CMCI using a cache token returned by getResource.

This will allow the VSCE to paginate large result sets using the SDK rather than axios HTTP requests.

Review Checklist
I certify that I have:

@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.81%. Comparing base (1ea123b) to head (d3b74e1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #172      +/-   ##
==========================================
+ Coverage   93.62%   93.81%   +0.18%     
==========================================
  Files          74       75       +1     
  Lines         753      776      +23     
  Branches       41       45       +4     
==========================================
+ Hits          705      728      +23     
  Misses         48       48              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AndrewTwydell AndrewTwydell force-pushed the get-resource-query-params branch from f17635b to 96512f1 Compare December 17, 2024 19:06
Base automatically changed from get-resource-query-params to main December 17, 2024 20:39
@AndrewTwydell AndrewTwydell marked this pull request as ready for review December 18, 2024 09:52
Copy link

@davenice davenice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good I think.

Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 😋
For these new set of APIs, (as well as SUMMONLY, NODISCARD, OVERRIDEWARNINGCOUNT), Could we add some system tests?

Depending on people's environment, having system tests might help determine whether the APIs work as expected, or if there are edge cases to consider 😋


We could handle system tests in a follow up PR (for both, cache, and the new query params) if you'd like to get this one merged sooner rather than later 🙏


Update: Created the issue below:

Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality works great!
I like the pagination use case.

I was playing around, but I could not properly test the OVERRIDEWARNINGCOUNT queryParm (likely because the DEFAULTWARNCNT was never specified during the WUI configuration) 😢

I say "Let's keep moving forward" and let's handle the system tests in a separate PR 🙏


For those testing...

Feel free to use this script
/* Save this file as `test.mjs` and run `node test.mjs` */

import { ProfileInfo } from "@zowe/imperative";
import * as sdk from "@zowe/cics-for-zowe-sdk";

(async () => {
    const profInfo = new ProfileInfo("zowe");
    await profInfo.readProfilesFromDisk();
    const profAttrs = profInfo.getDefaultProfile("cics");
    const mergedArgs = profInfo.mergeArgsForProfile(profAttrs, { getSecureVals: true });
    const session = ProfileInfo.createSession(mergedArgs.knownArgs);

    let response;
    response = (await sdk.getResource(session, {name: "CICSCSDResource", queryParams: {summonly: true, nodiscard: true}}));
    const cacheToken = response.response.resultsummary.cachetoken;
    console.log("Cache token: ", cacheToken);

    // Use the above cache token and play around with the `startIndex` and `count` values
    response = (await sdk.getCache(session, {cacheToken, startIndex:1, count:100})).response.records.cicscsdresource.map(x => x.defname);
    console.log(response);
})().catch((err) => {
    console.error(err);
    process.exit(1);
});

@zFernand0 zFernand0 merged commit c56c91c into main Dec 18, 2024
16 checks passed
@zFernand0 zFernand0 deleted the sdk-cache branch December 18, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

Create SDK method to retrieve CICS Result Cache
4 participants