@itentialopensource/adapter-netbrain 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ## 1.1.1 [09-06-2022]
3
+
4
+ * Update Healthcheck and change tenantId Usage
5
+
6
+ See merge request itentialopensource/adapters/controller-orchestrator/adapter-netbrain!16
7
+
8
+ ---
9
+
2
10
  ## 1.1.0 [05-22-2022]
3
11
 
4
12
  * Migration to the latest Adapter Foundation
package/adapter.js CHANGED
@@ -73,12 +73,50 @@ class Netbrain extends AdapterBaseCl {
73
73
  * @param {Callback} callback - The results of the call
74
74
  */
75
75
  healthCheck(reqObj, callback) {
76
- // you can modify what is passed into the healthcheck by changing things in the newReq
77
- let newReq = null;
78
- if (reqObj) {
79
- newReq = Object.assign(...reqObj);
76
+ let myRequest = reqObj;
77
+ const origin = `${this.id}-adapter-healthCheck`;
78
+
79
+ // we are overriding the adapterBase healthcheck so that it goes through the same process as other NetBrain calls.
80
+ if (this.healthcheckQuery && Object.keys(this.healthcheckQuery).length > 0) {
81
+ if (myRequest && myRequest.uriQuery) {
82
+ myRequest.uriQuery = { ...myRequest.uriQuery, ...this.healthcheckQuery };
83
+ } else if (myRequest) {
84
+ myRequest.uriQuery = this.healthcheckQuery;
85
+ } else {
86
+ myRequest = {
87
+ uriQuery: this.healthcheckQuery
88
+ };
89
+ }
80
90
  }
81
- super.healthCheck(newReq, callback);
91
+ // super.healthCheck(newReq, callback);
92
+ return this.processRequest('.system', 'healthcheck', myRequest, false, 0, (irReturnData, irReturnError) => {
93
+ // unhealthy
94
+ if (irReturnError) {
95
+ // if we were healthy, toggle health
96
+ if (this.healthy) {
97
+ this.emit('OFFLINE', { id: this.id });
98
+ this.emit('DEGRADED', { id: this.id });
99
+ this.healthy = false;
100
+ log.error(`${origin}: HEALTH CHECK - Error ${irReturnError}`);
101
+ } else {
102
+ // still log but set the level to trace
103
+ log.trace(`${origin}: HEALTH CHECK - Still Errors ${irReturnError}`);
104
+ }
105
+
106
+ return callback(false);
107
+ }
108
+ // if we were unhealthy, toggle health
109
+ if (!this.healthy) {
110
+ this.emit('FIXED', { id: this.id });
111
+ this.emit('ONLINE', { id: this.id });
112
+ this.healthy = true;
113
+ log.info(`${origin}: HEALTH CHECK SUCCESSFUL`);
114
+ } else {
115
+ // still log but set the level to trace
116
+ log.trace(`${origin}: HEALTH CHECK STILL SUCCESSFUL`);
117
+ }
118
+ return callback(true);
119
+ });
82
120
  }
83
121
 
84
122
  /**
@@ -1219,7 +1257,7 @@ class Netbrain extends AdapterBaseCl {
1219
1257
  * @summary Query all the domains info in system.
1220
1258
  *
1221
1259
  * @function getV1CMDBDomains
1222
- * @param {string} tenantId - tenantId param
1260
+ * @param {string} tenantId - tenantId param, if passed empty it will get it from the adapter config
1223
1261
  * @param {getCallback} callback - a callback function to return the result
1224
1262
  */
1225
1263
 
@@ -1235,14 +1273,25 @@ class Netbrain extends AdapterBaseCl {
1235
1273
  return callback(null, errorObj);
1236
1274
  }
1237
1275
 
1238
- /* HERE IS WHERE YOU VALIDATE DATA */
1239
-
1240
1276
  /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1241
- const queryParamsAvailable = { tenantId };
1277
+ let configtenantId = tenantId;
1278
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1279
+ if (this.allProps.authentication.tenantId) {
1280
+ configtenantId = this.allProps.authentication.tenantId;
1281
+ }
1282
+ }
1283
+ const queryParamsAvailable = { configtenantId };
1242
1284
  const queryParams = {};
1243
1285
  const pathVars = [];
1244
1286
  const bodyVars = {};
1245
1287
 
1288
+ /* HERE IS WHERE YOU VALIDATE DATA */
1289
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1290
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantId'], null, null, null);
1291
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1292
+ return callback(null, errorObj);
1293
+ }
1294
+
1246
1295
  // loop in template. long callback arg name to avoid identifier conflicts
1247
1296
  Object.keys(queryParamsAvailable)
1248
1297
  .forEach((thisKeyInQueryParamsAvailable) => {
@@ -1700,19 +1749,25 @@ class Netbrain extends AdapterBaseCl {
1700
1749
  return callback(null, errorObj);
1701
1750
  }
1702
1751
 
1752
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1753
+ let configtenantId = tenantId;
1754
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1755
+ if (this.allProps.authentication.tenantId) {
1756
+ configtenantId = this.allProps.authentication.tenantId;
1757
+ }
1758
+ }
1759
+ const queryParamsAvailable = {};
1760
+ const queryParams = {};
1761
+ const pathVars = [configtenantId];
1762
+ const bodyVars = {};
1763
+
1703
1764
  /* HERE IS WHERE YOU VALIDATE DATA */
1704
- if (tenantId === undefined || tenantId === null || tenantId === '') {
1765
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1705
1766
  const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantId'], null, null, null);
1706
1767
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1707
1768
  return callback(null, errorObj);
1708
1769
  }
1709
1770
 
1710
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1711
- const queryParamsAvailable = {};
1712
- const queryParams = {};
1713
- const pathVars = [tenantId];
1714
- const bodyVars = {};
1715
-
1716
1771
  // loop in template. long callback arg name to avoid identifier conflicts
1717
1772
  Object.keys(queryParamsAvailable)
1718
1773
  .forEach((thisKeyInQueryParamsAvailable) => {
@@ -8652,11 +8707,15 @@ class Netbrain extends AdapterBaseCl {
8652
8707
  return callback(null, errorObj);
8653
8708
  }
8654
8709
 
8655
- /* HERE IS WHERE YOU VALIDATE DATA */
8656
-
8657
8710
  /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
8711
+ let configtenantId = tenantId;
8712
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
8713
+ if (this.allProps.authentication.tenantId) {
8714
+ configtenantId = this.allProps.authentication.tenantId;
8715
+ }
8716
+ }
8658
8717
  const queryParamsAvailable = {
8659
- tenantId,
8718
+ configtenantId,
8660
8719
  domainId,
8661
8720
  fromDate,
8662
8721
  toDate
@@ -8665,6 +8724,13 @@ class Netbrain extends AdapterBaseCl {
8665
8724
  const pathVars = [];
8666
8725
  const bodyVars = {};
8667
8726
 
8727
+ /* HERE IS WHERE YOU VALIDATE DATA */
8728
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
8729
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantId'], null, null, null);
8730
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
8731
+ return callback(null, errorObj);
8732
+ }
8733
+
8668
8734
  // loop in template. long callback arg name to avoid identifier conflicts
8669
8735
  Object.keys(queryParamsAvailable)
8670
8736
  .forEach((thisKeyInQueryParamsAvailable) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-netbrain",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "This adapter integrates with system described as: netbrainRestfulApi.",
5
5
  "main": "adapter.js",
6
6
  "systemName": "NetBrain",
package/pronghorn.json CHANGED
@@ -783,7 +783,7 @@
783
783
  {
784
784
  "name": "tenantId",
785
785
  "type": "string",
786
- "info": ": string",
786
+ "info": ": string : if not passed the tenantId from the adapter config will be used",
787
787
  "required": false,
788
788
  "schema": {
789
789
  "title": "tenantId",
@@ -953,8 +953,8 @@
953
953
  {
954
954
  "name": "tenantId",
955
955
  "type": "string",
956
- "info": "This is the identifier of the Tenant.: string",
957
- "required": true,
956
+ "info": ": string : if not passed the tenantId from the adapter config will be used",
957
+ "required": false,
958
958
  "schema": {
959
959
  "title": "tenantId",
960
960
  "type": "string"
@@ -3641,7 +3641,7 @@
3641
3641
  {
3642
3642
  "name": "tenantId",
3643
3643
  "type": "string",
3644
- "info": "Tenant ID.: string",
3644
+ "info": ": string : if not passed the tenantId from the adapter config will be used",
3645
3645
  "required": false,
3646
3646
  "schema": {
3647
3647
  "title": "tenantId",
Binary file
@@ -44,6 +44,7 @@ samProps.ssl.accept_invalid_cert = false;
44
44
  samProps.request.attempt_timeout = 60000;
45
45
  const attemptTimeout = samProps.request.attempt_timeout;
46
46
  const { stub } = samProps;
47
+ samProps.authentication.tenantId = '';
47
48
 
48
49
  // these are the adapter properties. You generally should not need to alter
49
50
  // any of these after they are initially set up