UNPKG

7.71 kBMarkdownView Raw
1[![Build status](https://travis-ci.org/zosconnect/zosconnect-node.svg?branch=master)](https://travis-ci.org/zosconnect/zosconnect-node)
2[![codecov.io](https://codecov.io/github/zosconnect/zosconnect-node/coverage.svg?branch=master)](http://codecov.io/github/zosconnect/zosconnect-node?branch=master)
3[![Dependencies](https://david-dm.org/zosconnect/zosconnect-node.svg)](https://david-dm.org/zosconnect/zosconnect-node)
4[![Module LTS Adopted'](https://img.shields.io/badge/Module%20LTS-Adopted-brightgreen.svg?style=flat)](http://github.com/CloudNativeJS/ModuleLTS)
5
6<!-- START doctoc generated TOC please keep comment here to allow auto update -->
7<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
8**Table of Contents**
9
10- [Node zosconnect](#node-zosconnect)
11 - [Installing](#installing)
12 - [Usage](#usage)
13 - [Connecting to z/OS Connect](#connecting-to-zos-connect)
14 - [HTTPs Support](#https-support)
15 - [Basic Authentication](#basic-authentication)
16 - [APIs](#apis)
17 - [Retrieve a list of APIs](#retrieve-a-list-of-apis)
18 - [Get an API](#get-an-api)
19 - [Create an API](#create-an-api)
20 - [Call an API](#call-an-api)
21 - [Get the Swagger document for an API](#get-the-swagger-document-for-an-api)
22 - [Start or Stop an API](#start-or-stop-an-api)
23 - [Update an API](#update-an-api)
24 - [Delete an API](#delete-an-api)
25 - [Services](#services)
26 - [Retrieve a list of services](#retrieve-a-list-of-services)
27 - [Create a Service](#create-a-service)
28 - [Get a service](#get-a-service)
29 - [Invoke a service](#invoke-a-service)
30 - [Get the request schema](#get-the-request-schema)
31 - [Get the response schema](#get-the-response-schema)
32 - [Update a Service](#update-a-service)
33 - [Delete a Service](#delete-a-service)
34 - [Module Long Term Support Policy](#module-long-term-support-policy)
35 - [License](#license)
36
37<!-- END doctoc generated TOC please keep comment here to allow auto update -->
38
39## Node zosconnect
40
41A wrapper service for z/OS&reg; Connect EE, enabling node applications to discover and access zSystems resources
42that are service enabled by z/OS&reg; Connect. Version 2 of this module pre-reqs z/OS Connect EE V3.0.8 or later.
43
44Services and APIs are identified by name that is unique within the scope of the target z/OS&reg; Connect instance
45(or cluster). The node application uses pre-existing knowledge of the service or API name, or discovers it
46dynamically by retrieving a list of available services or APIs. The z/OS&reg; Connect node wrapper provides access
47to JSON request and response schemas for the specific z/OS&reg; Connect service and the Swagger document for APIs,
48enabling the node application to invoke that service and process the response.
49
50### Installing
51
52```
53npm install zosconnect-node
54```
55
56### Usage
57
58#### Connecting to z/OS Connect
59
60```js
61var ZosConnect = require('zosconnect-node');
62var options = {
63 uri:'http://mainframe:8080'
64}
65var zosconnect = new ZosConnect(options);
66```
67The `options` object matches exactly the options described by the [request/request](https://github.com/request/request) module. The uri or url parameter must be specified.
68
69##### HTTPs Support
70Create the options object with locations for the CA certificate file and optionally the client certificate and client private key (if using client authentication). If the strictSSL option is set to false then invalid SSL certificates can be used which may be of use in development environments.
71```js
72var fs = require('fs');
73var path = require('path');
74var caFile = path.resolve(__dirname, 'ca.pem');
75var certFile = path.resolve(__dirname, 'cert.pem');
76var keyFile = path.resolve(__dirname, 'key.pem');
77var options = {
78 uri:'https://mainframe:9443',
79 ca: fs.readFileSync(caFile),
80 cert: fs.readFileSync(certFile),
81 key: fs.readFileSync(keyFile),
82 passphrase: 'passw0rd',
83 strictSSL: true
84}
85```
86
87##### Basic Authentication
88Add the authentication credentials to the options object.
89```js
90var options = {
91 uri: 'http://mainframe:9080',
92 auth: {
93 user: 'userId',
94 pass: 'password'
95 }
96}
97```
98
99#### APIs
100
101##### Retrieve a list of APIs
102
103```js
104zosconnect.getApis().then(console.log);
105```
106
107##### Get an API
108
109```js
110zosconnect.getApi('healthApi').then(console.log);
111```
112
113##### Create an API
114
115```js
116zosconnect.createApi(fs.readFileSync('api.aar')).then(console.log);
117```
118
119##### Call an API
120
121```js
122zosconnect.getApi('healthApi').then((api) => {
123 api.invoke('patient/12345', 'GET', null).then((response) => {
124 if(response.statusCode != 200) {
125 console.log('Invoke failed with respCode = ' + response.statusCode);
126 } else {
127 console.log(response.body);
128 }
129 }).catch(console.log);
130});
131```
132
133##### Get the Swagger document for an API
134
135```js
136zosconnect.getApi('healthApi').then((api) => {
137 api.getApiDoc('swagger').then(console.log);
138});
139```
140
141##### Start or Stop an API
142
143```js
144zosconnect.getApi('healthApi', function(error, api){
145 api.stop().catch(console.log);
146 api.start().catch(console.log);
147})
148```
149
150##### Update an API
151
152```js
153zosconnect.getApi('healthApi').then((api) => {
154 api.update(fs.readFileSync('healthApi.aar')).catch(console.log);
155});
156```
157
158##### Delete an API
159
160```js
161zosconnect.getApi('healthApi').then((api) => {
162 api.delete().catch(console.log);
163})
164```
165
166#### Services
167
168##### Retrieve a list of services
169
170```js
171zosconnect.getServices().then(console.log);
172```
173
174##### Create a Service
175
176```js
177zosconnect.createService(fs.readFileSync('dateTimeService.sar')).then(console.log);
178```
179
180##### Get a service
181
182```js
183zosconnect.getService('dateTimeService').then(console.log);
184//normally this would then go on and work with the service
185```
186
187##### Invoke a service
188
189```js
190zosconnect.getService('dateTimeService').then((service) => {
191 service.invoke({input:'data'}).then((response) => {
192 if(response.statusCode != 200) {
193 console.log('Invoke failed with respCode = ' + response.statusCode);
194 } else {
195 console.log(response.body);
196 }
197 }).catch(console.log);
198});
199```
200
201##### Get the request schema
202
203```js
204zosconnect.getService('dateTimeService').then((service) => {
205 service.getRequestSchema().then(console.log).catch(console.log);
206});
207```
208
209##### Get the response schema
210
211```js
212zosconnect.getService('dateTimeService').then((service) => {
213 service.getResponseSchema().then(console.log).catch(console.log);;
214});
215```
216
217##### Update a Service
218
219```js
220zosconnect.getService('dateTimeService').then((service) => {
221 service.update(fs.readFileSync('dateTimeService.sar')).catch(console.log);
222});
223```
224
225##### Delete a Service
226
227```js
228zosconnect.getService('dateTimeService').then((service) => {
229 service.delete().catch(console.log);
230})
231```
232
233### Module Long Term Support Policy
234 This module adopts the [Module Long Term Support (LTS)](http://github.com/CloudNativeJS/ModuleLTS) policy, with the following End Of Life (EOL) dates:
235
236 | Module Version | Release Date | Minimum EOL | EOL With | Status |
237 |------------------|--------------|-------------|--------------|---------|
238 | 2.x.x | Jul 2018 | Dec 2019 | | Current
239 | 1.x.x | Jul 2017 | Dec 2019 | Node 8 | LTS |
240
241### License
242```
243Licensed under the Apache License, Version 2.0 (the "License");
244you may not use this file except in compliance with the License.
245You may obtain a copy of the License at
246
247 http://www.apache.org/licenses/LICENSE-2.0
248
249Unless required by applicable law or agreed to in writing, software
250distributed under the License is distributed on an "AS IS" BASIS,
251WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
252See the License for the specific language governing permissions and
253limitations under the License.
254```