How to Use Zowe Node Client SDK

Dan Kelosky
Apr 21 · 3 min read
Zowe Client SDK for Node Example

{Core} The Open Mainframe Project’s Zowe Client SDK for Node.js is a node package manager (npm) package that you can include in a development / automation project. It handles the details of loading profiles along with calling the right mainframe REST API endpoints.

Here we’ll get setup and build a short program that reads mainframe connection info, extracts credentials, and then calls to get a list of z/OS jobs.

Initialize a Project

To get started, create a directory and initialize a package.json:

Add zowe dependencies:

Add dev dependencies:

Initialize tsconfig.json:

Initialize git:

Add Code

Create a typescript file, index.ts, in the root of the project, with these contents:

Copied from here

An example SDK method is on line 26 — GetJobs.getJobsByOwner(session, owner).

Optionally Handle Secure Credentials

If you securely store your credentials (instead of having them in plain text) uncomment line 11 and run npm install --save keytar.

Add Profile

Create a z/OSMF profile (if you don’t have one already). This contains connection and credential information for mainframe access.

zowe profiles create zosmf <name> --host <host> --user prompt* --password prompt*

You might also need a --port <port> and --reject-unauthorized false. See zowe profiles create zosmf --help for more info.

Build

Your project structure should look like this:

Project structure

“Compile” your typescript via running npx tsc. The output should be a index.js file.

Run

From a terminal, run: node index.js:

Response Sample

Summary

From here you can tailor the program making use of other SDK methods to build your own mainframe automation on the Zowe Client SDK for Node.js.

The basic job functions can be found here, but you can find other SDK examples in other packages within the repo.

The finished version of the project described above is here.

Finding out more

If you enjoyed this blog, check out more Zowe blogs here. Or, ask a question and join the conversation on the Open Mainframe Project Slack Channel #Zowe-dev, #Zowe-user or #Zowe-onboarding. If this is your first time using the OMP slack channel register here.

Zowe

Zowe is the modern open source interface for the mainframe…

Zowe

Zowe is the modern open source interface for the mainframe and z/OS. The Zowe blog has how-to’s, tips & tricks and other helpful insights for mainframe devops. Zowe is a project within the Linux Foundation’s Open Mainframe Project (OMP). Download @ Zowe.org.

Dan Kelosky

Written by

Likes programming/automation in mainframe (assembler, C/C++), distributed (Node.js), and web development (Firebase, Angular).

Zowe

Zowe is the modern open source interface for the mainframe and z/OS. The Zowe blog has how-to’s, tips & tricks and other helpful insights for mainframe devops. Zowe is a project within the Linux Foundation’s Open Mainframe Project (OMP). Download @ Zowe.org.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store