Skip to content

Commit 2df20e0

Browse files
authored
Merge pull request #28 from crshnburn/service_deploy
Service deploy
2 parents 5f71344 + 48e4955 commit 2df20e0

7 files changed

Lines changed: 3482 additions & 44 deletions

File tree

README.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,32 @@
2424
- [Delete an API](#delete-an-api)
2525
- [Services](#services)
2626
- [Retrieve a list of services](#retrieve-a-list-of-services)
27+
- [Create a Service](#create-a-service)
2728
- [Get a service](#get-a-service)
2829
- [Invoke a service](#invoke-a-service)
2930
- [Get the request schema](#get-the-request-schema)
3031
- [Get the response schema](#get-the-response-schema)
32+
<<<<<<< HEAD
3133
- [Get the status of the service](#get-the-status-of-the-service)
3234
- [Module Long Term Support Policy](#module-long-term-support-policy)
35+
=======
36+
- [Update a Service](#update-a-service)
37+
- [Delete a Service](#delete-a-service)
38+
>>>>>>> Complete README updates
3339
- [License](#license)
3440

3541
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
3642

3743
## Node zosconnect
3844

39-
A wrapper service for z/OS&reg; Connect, enabling node applications to discover and access zSystems resources
40-
that are service enabled by z/OS&reg; Connect.
45+
A wrapper service for z/OS&reg; Connect EE, enabling node applications to discover and access zSystems resources
46+
that are service enabled by z/OS&reg; Connect. Version 2 of this module pre-reqs z/OS Connect EE V3.0.8 or later.
4147

42-
Services are identified by name that is unique within the scope of the target z/OS&reg; Connect instance
43-
(or cluster). The node application uses pre-existing knowledge of the service name, or discovers it
44-
dynamically by retrieving a list of available services. The z/OS&reg; Connect node wrapper provides access
45-
to JSON request and response schemas for the specific z/OS&reg; Connect service, enabling the node
46-
application to invoke that service and process the response.
48+
Services and APIs are identified by name that is unique within the scope of the target z/OS&reg; Connect instance
49+
(or cluster). The node application uses pre-existing knowledge of the service or API name, or discovers it
50+
dynamically by retrieving a list of available services or APIs. The z/OS&reg; Connect node wrapper provides access
51+
to JSON request and response schemas for the specific z/OS&reg; Connect service and the Swagger document for APIs,
52+
enabling the node application to invoke that service and process the response.
4753

4854
### Installing
4955

@@ -169,6 +175,12 @@ zosconnect.getApi('healthApi').then((api) => {
169175
zosconnect.getServices().then(console.log);
170176
```
171177

178+
##### Create a Service
179+
180+
```js
181+
zosconnect.createService(fs.readFileSync('dateTimeService.sar')).then(console.log);
182+
```
183+
172184
##### Get a service
173185

174186
```js
@@ -206,22 +218,29 @@ zosconnect.getService('dateTimeService').then((service) => {
206218
});
207219
```
208220

209-
##### Get the status of the service
221+
##### Update a Service
210222

211223
```js
212224
zosconnect.getService('dateTimeService').then((service) => {
213-
service.getStatus().then(console.log).catch(console.log);
225+
service.update(fs.readFileSync('dateTimeService.sar')).catch(console.log);
214226
});
215227
```
216228

229+
##### Delete a Service
230+
231+
```js
232+
zosconnect.getService('dateTimeService').then((service) => {
233+
service.delete().catch(console.log);
234+
})
235+
```
236+
217237
### Module Long Term Support Policy
218238
This module adopts the [Module Long Term Support (LTS)](http://github.com/CloudNativeJS/ModuleLTS) policy, with the following End Of Life (EOL) dates:
219239

220240
| Module Version | Release Date | Minimum EOL | EOL With | Status |
221241
|------------------|--------------|-------------|--------------|---------|
222242
| V1.0.0 | Jul 2017 | Dec 2019 | Node 8 | Current |
223243

224-
225244
### License
226245
```
227246
Licensed under the Apache License, Version 2.0 (the "License");

index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,29 @@ module.exports = function ZosConnect(options) {
155155
});
156156
}));
157157
};
158+
159+
this.createService = (sarFile) => {
160+
let opOptions = {};
161+
opOptions = extend(opOptions, this.options);
162+
opOptions.uri += '/zosConnect/services';
163+
opOptions.method = 'POST';
164+
opOptions.body = sarFile;
165+
opOptions.headers = {
166+
'Content-Type': 'application/zip',
167+
};
168+
return new Promise(((resolve, reject) => {
169+
request(opOptions, (error, response, body) => {
170+
if (error) {
171+
reject(error);
172+
} else if (response.statusCode !== 201) {
173+
reject(new Error(`Unable to create Service (${response.statusCode})`));
174+
} else {
175+
const serviceData = JSON.parse(body);
176+
const invokeUrl = url.parse(serviceData.zosConnect.serviceInvokeURL);
177+
resolve(new Service(opOptions, serviceData.ServiceName,
178+
this.options.uri + invokeUrl.pathname + invokeUrl.search));
179+
}
180+
});
181+
}));
182+
};
158183
};

0 commit comments

Comments
 (0)