Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit c3de993

Browse files
authored
Merge pull request #1 from Dell-SMI/add-wsman-callback-handler
add callback handler for wsman microservices
2 parents 24d5b66 + f994e16 commit c3de993

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

lib/api/1.1/southbound/callback.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2016, DELL, Inc.
2+
3+
'use strict';
4+
5+
var di = require('di'),
6+
express = require('express'),
7+
parser = require('body-parser');
8+
9+
module.exports = DellWsmanCallbackRouter;
10+
di.annotate(DellWsmanCallbackRouter, new di.Provide('Http.Api.Dell.Wsman.InventoryCallback'));
11+
di.annotate(DellWsmanCallbackRouter, new di.Inject('Logger', 'Promise', 'Protocol.Events', '_'));
12+
13+
function DellWsmanCallbackRouter(Logger, Promise, eventsProtocol, _) {
14+
var logger = Logger.initialize(DellWsmanCallbackRouter);
15+
var router = express.Router();
16+
17+
18+
/**
19+
* @api {post} /api/1.1/callback/:identifier POST /:id
20+
* @apiVersion 1.1.0
21+
* @apiDescription Receive unique callback for wsman inventory request
22+
* @apiName callback
23+
* @apiGroup callback
24+
* @apiParam {String} request identifier
25+
* @apiError NotFound There is no request with the <code>identifier</code>
26+
* @apiErrorExample Error-Response:
27+
* HTTP/1.1 404 Not Found
28+
* {
29+
* "error": "Not Found"
30+
* }
31+
*/
32+
router.post('/wsmanCallback/:identifier', function (req, res) {
33+
var name = req.body.options.defaults.type;
34+
var data = req.body.options.defaults;
35+
36+
if(name === null || _.isEmpty(name) || data === null || _.isEmpty(data)){
37+
throw new Error('CALLBACK: Callback data is invalid.');
38+
}
39+
return Promise.resolve()
40+
.then(function() {
41+
eventsProtocol.publishHttpResponseUuid(req.params.identifier, data);
42+
res.status(200).end();
43+
}).catch(function(err) {
44+
logger.error("Error processing inventory callback.", {
45+
error: err,
46+
id: req.params.identifier
47+
});
48+
});
49+
});
50+
51+
return router;
52+
}

0 commit comments

Comments
 (0)