IBM RSE API Plug-in for Zowe CLI as nodejs SDK package
IBM® RSE API Plug-in for Zowe™ CLI (RSE API plug-in) nodejs package can also be used as a Software Development Kit (SDK) to build client application and scripts that link with the mainframe through RSE rest APIs.
With Zowe SDKs as a dependency of the RSE API plug-in, projects that adopt the RSE API plug-in as an SDK needs to adopt some Zowe SDKs as well as a dependency depending on the needs of the project. Zowe imperative is a peer dependency of the RSE API plug-in and is needed for required instances of imperative. Session that are passed to the RSE API plug-in methods with connection information for the rest requests. More information on the Zowe SDK can be found at zowe.org.
Examples
Get system information
import * as imperative from "@zowe/imperative";
import { CheckStatus } from "@ibm/rse-api-for-zowe-cli";
export class exampleRseSdkClass {
public static async getSystemInfo(): Promise<void> {
//pass an instance of imperative.Session with connection information to the rest call
const response = await CheckStatus.getRseStatus(session);
const output = imperative.TextUtils.prettyJson(response);
console.log(output);
}
}
List data set members
import * as imperative from "@zowe/imperative";
import { List } from "@ibm/rse-api-for-zowe-cli";
export class exampleRseSdkClass {
public static async getMemberList(): Promise<void> {
// prompt for or pass partitioned data set name for rest call
// format: HLQ.PDS
const dsName = imperative.CliUtils.readPrompt(
"Enter data set name to list it's members:"
);
if (dsName) {
//pass an instance of imperative.Session with connection information to the rest call
const response = await List.allMembers(session, String(dsName));
const list: String[] = [];
response.apiResponse.items.forEach((obj: any) =>
list.push(obj?.memberName)
);
const output = String(list).replaceAll(",", "\n");
console.log(output);
} else {
console.log("operation cancelled");
}
}
}
Submit data set member as job
import * as imperative from "@zowe/imperative";
import { SubmitJobs } from "@ibm/rse-api-for-zowe-cli";
export class exampleRseSdkClass {
public static async submitAsJob(): Promise<void> {
// prompt for or pass data set member name for rest call
// format: HLQ.PDS(MEMBER)
const jobName = imperative.CliUtils.readPrompt(
"Enter data set member name to submit as job:"
);
if (jobName) {
//pass an instance of imperative.Session with connection information to the rest call
const response = await SubmitJobs.submitJob(session, {
jobDataSet: String(jobName)
});
console.log(JSON.stringify(response));
} else {
console.log("operation cancelled");
}
}
}