@itentialopensource/adapter-slack 2.5.5 → 2.6.2
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/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +58 -55
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +225 -502
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +352 -60
- package/adapterBase.js +1021 -245
- package/entities/.generic/action.json +110 -5
- package/entities/.generic/schema.json +6 -1
- package/entities/Channels/schema.json +12 -1
- package/entities/Chat/schema.json +12 -1
- package/entities/Files/schema.json +12 -1
- package/entities/Groups/schema.json +12 -1
- package/entities/Im/schema.json +12 -1
- package/entities/Mpim/schema.json +12 -1
- package/error.json +12 -0
- package/package.json +20 -13
- package/pronghorn.json +652 -378
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +436 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653493672906.json +120 -0
- package/sampleProperties.json +96 -4
- package/storage/metrics.json +2228 -0
- package/test/integration/adapterTestBasicGet.js +2 -2
- package/test/integration/adapterTestIntegration.js +34 -108
- package/test/unit/adapterBaseTestUnit.js +35 -27
- package/test/unit/adapterTestUnit.js +543 -145
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/basicGet.js +1 -14
- package/utils/entitiesToDB.js +179 -0
- package/utils/modify.js +1 -1
- package/utils/packModificationScript.js +1 -1
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +3 -0
- package/utils/removeHooks.js +20 -0
- package/utils/tbScript.js +43 -22
- package/utils/tbUtils.js +126 -29
- package/utils/testRunner.js +16 -16
- package/utils/troubleshootingAdapter.js +2 -26
package/SUMMARY.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
This adapter is used to integrate the Itential Automation Platform (IAP) with the Slack System. The API that was used to build the adapter for Slack is usually available in the report directory of this adapter. The adapter utilizes the Slack API to provide the integrations that are deemed pertinent to IAP. The ReadMe file is intended to provide information on this adapter it is generated from various other Markdown files.
|
|
4
|
+
|
|
5
|
+
>**Note**: It is possible that some integrations will be supported through the Slack adapter while other integrations will not. If you need additional API calls, you can use the Update capabilities provided by the Adapter Builder or request Itential to add them if the Adapter is an Itential opensourced adapter.
|
|
6
|
+
|
|
7
|
+
Itential provides information on all of its product adapters in the Customer Knowledge Base. Information in the <a href="https://itential.atlassian.net/servicedesk/customer/portals" target="_blank">Customer Knowledge Base</a> is consistently maintained and goes through documentation reviews. As a result, it should be the first place to go for information.
|
|
8
|
+
|
|
9
|
+
For opensourced and custom built adapters, the ReadMe is a starting point to understand what you have built, provide the information for you to be able to update the adapter, and assist you with deploying the adapter into IAP.
|
package/SYSTEMINFO.md
ADDED
package/TROUBLESHOOT.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## Troubleshoot
|
|
2
|
+
|
|
3
|
+
Run `npm run troubleshoot` to start the interactive troubleshooting process. The command allows you to verify and update connection, authentication as well as healthcheck configuration. After that it will test these properties by sending HTTP request to the endpoint. If the tests pass, it will persist these changes into IAP.
|
|
4
|
+
|
|
5
|
+
You also have the option to run individual commands to perform specific test:
|
|
6
|
+
|
|
7
|
+
- `npm run healthcheck` will perform a healthcheck request of with current setting.
|
|
8
|
+
- `npm run basicget` will perform some non-parameter GET request with current setting.
|
|
9
|
+
- `npm run connectivity` will perform networking diagnostics of the adatper endpoint.
|
|
10
|
+
|
|
11
|
+
### Connectivity Issues
|
|
12
|
+
|
|
13
|
+
1. You can run the adapter troubleshooting script which will check connectivity, run the healthcheck and run basic get calls.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run troubleshoot
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Verify the adapter properties are set up correctly.
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
3. Verify there is connectivity between the Itential Platform Server and Slack Server.
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
ping the ip address of Slack server
|
|
29
|
+
try telnet to the ip address port of Slack
|
|
30
|
+
execute a curl command to the other system
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4. Verify the credentials provided for Slack.
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
login to Slack using the provided credentials
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
5. Verify the API of the call utilized for Slack Healthcheck.
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Functional Issues
|
|
46
|
+
|
|
47
|
+
Adapter logs are located in `/var/log/pronghorn`. In older releases of the Itential Platform, there is a `pronghorn.log` file which contains logs for all of the Itential Platform. In newer versions, adapters can be configured to log into their own files.
|
package/adapter.js
CHANGED
|
@@ -82,10 +82,18 @@ class Slacktest extends AdapterBaseCl {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* @
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
let myIgnore = [
|
|
85
|
+
* @iapGetAdapterWorkflowFunctions
|
|
86
|
+
*/
|
|
87
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
88
|
+
let myIgnore = [
|
|
89
|
+
'healthCheck',
|
|
90
|
+
'iapGetAdapterWorkflowFunctions',
|
|
91
|
+
'iapHasAdapterEntity',
|
|
92
|
+
'iapVerifyAdapterCapability',
|
|
93
|
+
'iapUpdateAdapterEntityCache',
|
|
94
|
+
'hasEntities',
|
|
95
|
+
'getAuthorization'
|
|
96
|
+
];
|
|
89
97
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
90
98
|
myIgnore = inIgnore;
|
|
91
99
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -96,15 +104,15 @@ class Slacktest extends AdapterBaseCl {
|
|
|
96
104
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
97
105
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
98
106
|
|
|
99
|
-
return super.
|
|
107
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
/**
|
|
103
|
-
*
|
|
111
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
104
112
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
105
113
|
* file system.
|
|
106
114
|
*
|
|
107
|
-
* @function
|
|
115
|
+
* @function iapUpdateAdapterConfiguration
|
|
108
116
|
* @param {string} configFile - the name of the file being updated (required)
|
|
109
117
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
110
118
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
@@ -112,36 +120,42 @@ class Slacktest extends AdapterBaseCl {
|
|
|
112
120
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
113
121
|
* @param {Callback} callback - The results of the call
|
|
114
122
|
*/
|
|
115
|
-
|
|
116
|
-
const
|
|
123
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
124
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
125
|
+
const origin = `${this.id}-${meth}`;
|
|
117
126
|
log.trace(origin);
|
|
118
|
-
|
|
127
|
+
|
|
128
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
/**
|
|
122
132
|
* See if the API path provided is found in this adapter
|
|
123
133
|
*
|
|
124
|
-
* @function
|
|
134
|
+
* @function iapFindAdapterPath
|
|
125
135
|
* @param {string} apiPath - the api path to check on
|
|
126
136
|
* @param {Callback} callback - The results of the call
|
|
127
137
|
*/
|
|
128
|
-
|
|
129
|
-
const
|
|
138
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
139
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
140
|
+
const origin = `${this.id}-${meth}`;
|
|
130
141
|
log.trace(origin);
|
|
131
|
-
|
|
142
|
+
|
|
143
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
132
144
|
}
|
|
133
145
|
|
|
134
146
|
/**
|
|
135
147
|
* @summary Suspends adapter
|
|
136
148
|
*
|
|
137
|
-
* @function
|
|
149
|
+
* @function iapSuspendAdapter
|
|
138
150
|
* @param {Callback} callback - callback function
|
|
139
151
|
*/
|
|
140
|
-
|
|
141
|
-
const
|
|
152
|
+
iapSuspendAdapter(mode, callback) {
|
|
153
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
154
|
+
const origin = `${this.id}-${meth}`;
|
|
142
155
|
log.trace(origin);
|
|
156
|
+
|
|
143
157
|
try {
|
|
144
|
-
return super.
|
|
158
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
145
159
|
} catch (error) {
|
|
146
160
|
log.error(`${origin}: ${error}`);
|
|
147
161
|
return callback(null, error);
|
|
@@ -151,14 +165,16 @@ class Slacktest extends AdapterBaseCl {
|
|
|
151
165
|
/**
|
|
152
166
|
* @summary Unsuspends adapter
|
|
153
167
|
*
|
|
154
|
-
* @function
|
|
168
|
+
* @function iapUnsuspendAdapter
|
|
155
169
|
* @param {Callback} callback - callback function
|
|
156
170
|
*/
|
|
157
|
-
|
|
158
|
-
const
|
|
171
|
+
iapUnsuspendAdapter(callback) {
|
|
172
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
173
|
+
const origin = `${this.id}-${meth}`;
|
|
159
174
|
log.trace(origin);
|
|
175
|
+
|
|
160
176
|
try {
|
|
161
|
-
return super.
|
|
177
|
+
return super.iapUnsuspendAdapter(callback);
|
|
162
178
|
} catch (error) {
|
|
163
179
|
log.error(`${origin}: ${error}`);
|
|
164
180
|
return callback(null, error);
|
|
@@ -168,29 +184,33 @@ class Slacktest extends AdapterBaseCl {
|
|
|
168
184
|
/**
|
|
169
185
|
* @summary Get the Adaoter Queue
|
|
170
186
|
*
|
|
171
|
-
* @function
|
|
187
|
+
* @function iapGetAdapterQueue
|
|
172
188
|
* @param {Callback} callback - callback function
|
|
173
189
|
*/
|
|
174
|
-
|
|
175
|
-
const
|
|
190
|
+
iapGetAdapterQueue(callback) {
|
|
191
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
192
|
+
const origin = `${this.id}-${meth}`;
|
|
176
193
|
log.trace(origin);
|
|
177
|
-
|
|
194
|
+
|
|
195
|
+
return super.iapGetAdapterQueue(callback);
|
|
178
196
|
}
|
|
179
197
|
|
|
180
198
|
/**
|
|
181
199
|
* @summary Runs troubleshoot scripts for adapter
|
|
182
200
|
*
|
|
183
|
-
* @function
|
|
201
|
+
* @function iapTroubleshootAdapter
|
|
184
202
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
185
203
|
*
|
|
186
204
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
187
205
|
* @param {Callback} callback - The results of the call
|
|
188
206
|
*/
|
|
189
|
-
|
|
190
|
-
const
|
|
207
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
208
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
209
|
+
const origin = `${this.id}-${meth}`;
|
|
191
210
|
log.trace(origin);
|
|
211
|
+
|
|
192
212
|
try {
|
|
193
|
-
return super.
|
|
213
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
194
214
|
} catch (error) {
|
|
195
215
|
log.error(`${origin}: ${error}`);
|
|
196
216
|
return callback(null, error);
|
|
@@ -200,15 +220,17 @@ class Slacktest extends AdapterBaseCl {
|
|
|
200
220
|
/**
|
|
201
221
|
* @summary runs healthcheck script for adapter
|
|
202
222
|
*
|
|
203
|
-
* @function
|
|
223
|
+
* @function iapRunAdapterHealthcheck
|
|
204
224
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
205
225
|
* @param {Callback} callback - callback function
|
|
206
226
|
*/
|
|
207
|
-
|
|
208
|
-
const
|
|
227
|
+
iapRunAdapterHealthcheck(callback) {
|
|
228
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
229
|
+
const origin = `${this.id}-${meth}`;
|
|
209
230
|
log.trace(origin);
|
|
231
|
+
|
|
210
232
|
try {
|
|
211
|
-
return super.
|
|
233
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
212
234
|
} catch (error) {
|
|
213
235
|
log.error(`${origin}: ${error}`);
|
|
214
236
|
return callback(null, error);
|
|
@@ -218,14 +240,16 @@ class Slacktest extends AdapterBaseCl {
|
|
|
218
240
|
/**
|
|
219
241
|
* @summary runs connectivity check script for adapter
|
|
220
242
|
*
|
|
221
|
-
* @function
|
|
243
|
+
* @function iapRunAdapterConnectivity
|
|
222
244
|
* @param {Callback} callback - callback function
|
|
223
245
|
*/
|
|
224
|
-
|
|
225
|
-
const
|
|
246
|
+
iapRunAdapterConnectivity(callback) {
|
|
247
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
248
|
+
const origin = `${this.id}-${meth}`;
|
|
226
249
|
log.trace(origin);
|
|
250
|
+
|
|
227
251
|
try {
|
|
228
|
-
return super.
|
|
252
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
229
253
|
} catch (error) {
|
|
230
254
|
log.error(`${origin}: ${error}`);
|
|
231
255
|
return callback(null, error);
|
|
@@ -235,44 +259,67 @@ class Slacktest extends AdapterBaseCl {
|
|
|
235
259
|
/**
|
|
236
260
|
* @summary runs basicGet script for adapter
|
|
237
261
|
*
|
|
238
|
-
* @function
|
|
262
|
+
* @function iapRunAdapterBasicGet
|
|
239
263
|
* @param {Callback} callback - callback function
|
|
240
264
|
*/
|
|
241
|
-
|
|
242
|
-
const
|
|
265
|
+
iapRunAdapterBasicGet(callback) {
|
|
266
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
267
|
+
const origin = `${this.id}-${meth}`;
|
|
243
268
|
log.trace(origin);
|
|
269
|
+
|
|
244
270
|
try {
|
|
245
|
-
return super.
|
|
271
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
246
272
|
} catch (error) {
|
|
247
273
|
log.error(`${origin}: ${error}`);
|
|
248
274
|
return callback(null, error);
|
|
249
275
|
}
|
|
250
276
|
}
|
|
251
277
|
|
|
278
|
+
/**
|
|
279
|
+
* @summary moves entites into Mongo DB
|
|
280
|
+
*
|
|
281
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
282
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
283
|
+
* or the error
|
|
284
|
+
*/
|
|
285
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
286
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
287
|
+
const origin = `${this.id}-${meth}`;
|
|
288
|
+
log.trace(origin);
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
292
|
+
} catch (err) {
|
|
293
|
+
log.error(`${origin}: ${err}`);
|
|
294
|
+
return callback(null, err);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* BROKER CALLS */
|
|
252
299
|
/**
|
|
253
300
|
* @summary Determines if this adapter supports the specific entity
|
|
254
301
|
*
|
|
255
|
-
* @function
|
|
302
|
+
* @function iapHasAdapterEntity
|
|
256
303
|
* @param {String} entityType - the entity type to check for
|
|
257
304
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
258
305
|
*
|
|
259
306
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
260
307
|
* desired capability or an error
|
|
261
308
|
*/
|
|
262
|
-
|
|
263
|
-
const origin = `${this.id}-adapter-
|
|
309
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
310
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
264
311
|
log.trace(origin);
|
|
265
312
|
|
|
266
313
|
// Make the call -
|
|
267
|
-
//
|
|
268
|
-
return this.
|
|
314
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
315
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
269
316
|
}
|
|
270
317
|
|
|
271
318
|
/**
|
|
272
319
|
* @summary Provides a way for the adapter to tell north bound integrations
|
|
273
320
|
* whether the adapter supports type, action and specific entity
|
|
274
321
|
*
|
|
275
|
-
* @function
|
|
322
|
+
* @function iapVerifyAdapterCapability
|
|
276
323
|
* @param {String} entityType - the entity type to check for
|
|
277
324
|
* @param {String} actionType - the action type to check for
|
|
278
325
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
@@ -280,15 +327,15 @@ class Slacktest extends AdapterBaseCl {
|
|
|
280
327
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
281
328
|
* desired capability or an error
|
|
282
329
|
*/
|
|
283
|
-
|
|
284
|
-
const meth = 'adapterBase-
|
|
330
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
331
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
285
332
|
const origin = `${this.id}-${meth}`;
|
|
286
333
|
log.trace(origin);
|
|
287
334
|
|
|
288
335
|
// if caching
|
|
289
336
|
if (this.caching) {
|
|
290
|
-
// Make the call -
|
|
291
|
-
return this.requestHandlerInst.
|
|
337
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
338
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
|
292
339
|
if (error) {
|
|
293
340
|
return callback(null, error);
|
|
294
341
|
}
|
|
@@ -306,7 +353,7 @@ class Slacktest extends AdapterBaseCl {
|
|
|
306
353
|
}
|
|
307
354
|
|
|
308
355
|
// need to check the cache again since it has been updated
|
|
309
|
-
return this.requestHandlerInst.
|
|
356
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
310
357
|
if (verror) {
|
|
311
358
|
return callback(null, verror);
|
|
312
359
|
}
|
|
@@ -339,7 +386,7 @@ class Slacktest extends AdapterBaseCl {
|
|
|
339
386
|
// if no entity id
|
|
340
387
|
if (!entityId) {
|
|
341
388
|
// need to check the cache again since it has been updated
|
|
342
|
-
return this.requestHandlerInst.
|
|
389
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
343
390
|
if (verror) {
|
|
344
391
|
return callback(null, verror);
|
|
345
392
|
}
|
|
@@ -360,7 +407,7 @@ class Slacktest extends AdapterBaseCl {
|
|
|
360
407
|
}
|
|
361
408
|
|
|
362
409
|
// need to check the cache again since it has been updated
|
|
363
|
-
return this.requestHandlerInst.
|
|
410
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
364
411
|
if (verror) {
|
|
365
412
|
return callback(null, verror);
|
|
366
413
|
}
|
|
@@ -401,11 +448,11 @@ class Slacktest extends AdapterBaseCl {
|
|
|
401
448
|
/**
|
|
402
449
|
* @summary Updates the cache for all entities by call the get All entity method
|
|
403
450
|
*
|
|
404
|
-
* @function
|
|
451
|
+
* @function iapUpdateAdapterEntityCache
|
|
405
452
|
*
|
|
406
453
|
*/
|
|
407
|
-
|
|
408
|
-
const origin = `${this.id}-adapter-
|
|
454
|
+
iapUpdateAdapterEntityCache() {
|
|
455
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
409
456
|
log.trace(origin);
|
|
410
457
|
|
|
411
458
|
if (this.caching) {
|
|
@@ -418,6 +465,140 @@ class Slacktest extends AdapterBaseCl {
|
|
|
418
465
|
}
|
|
419
466
|
}
|
|
420
467
|
|
|
468
|
+
/**
|
|
469
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
470
|
+
*
|
|
471
|
+
* @function hasEntities
|
|
472
|
+
* @param {String} entityType - the entity type to check for
|
|
473
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
474
|
+
*
|
|
475
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
476
|
+
* value is true or false
|
|
477
|
+
*/
|
|
478
|
+
hasEntities(entityType, entityList, callback) {
|
|
479
|
+
const meth = 'adapter-hasEntities';
|
|
480
|
+
const origin = `${this.id}-${meth}`;
|
|
481
|
+
log.trace(origin);
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
485
|
+
} catch (err) {
|
|
486
|
+
log.error(`${origin}: ${err}`);
|
|
487
|
+
return callback(null, err);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* @summary Get Appliance that match the deviceName
|
|
493
|
+
*
|
|
494
|
+
* @function getDevice
|
|
495
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
496
|
+
*
|
|
497
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
498
|
+
* (appliance) or the error
|
|
499
|
+
*/
|
|
500
|
+
getDevice(deviceName, callback) {
|
|
501
|
+
const meth = 'adapter-getDevice';
|
|
502
|
+
const origin = `${this.id}-${meth}`;
|
|
503
|
+
log.trace(origin);
|
|
504
|
+
|
|
505
|
+
try {
|
|
506
|
+
return super.getDevice(deviceName, callback);
|
|
507
|
+
} catch (err) {
|
|
508
|
+
log.error(`${origin}: ${err}`);
|
|
509
|
+
return callback(null, err);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* @summary Get Appliances that match the filter
|
|
515
|
+
*
|
|
516
|
+
* @function getDevicesFiltered
|
|
517
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
518
|
+
*
|
|
519
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
520
|
+
* (appliances) or the error
|
|
521
|
+
*/
|
|
522
|
+
getDevicesFiltered(options, callback) {
|
|
523
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
524
|
+
const origin = `${this.id}-${meth}`;
|
|
525
|
+
log.trace(origin);
|
|
526
|
+
|
|
527
|
+
try {
|
|
528
|
+
return super.getDevicesFiltered(options, callback);
|
|
529
|
+
} catch (err) {
|
|
530
|
+
log.error(`${origin}: ${err}`);
|
|
531
|
+
return callback(null, err);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @summary Gets the status for the provided appliance
|
|
537
|
+
*
|
|
538
|
+
* @function isAlive
|
|
539
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
540
|
+
*
|
|
541
|
+
* @param {configCallback} callback - callback function to return the result
|
|
542
|
+
* (appliance isAlive) or the error
|
|
543
|
+
*/
|
|
544
|
+
isAlive(deviceName, callback) {
|
|
545
|
+
const meth = 'adapter-isAlive';
|
|
546
|
+
const origin = `${this.id}-${meth}`;
|
|
547
|
+
log.trace(origin);
|
|
548
|
+
|
|
549
|
+
try {
|
|
550
|
+
return super.isAlive(deviceName, callback);
|
|
551
|
+
} catch (err) {
|
|
552
|
+
log.error(`${origin}: ${err}`);
|
|
553
|
+
return callback(null, err);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* @summary Gets a config for the provided Appliance
|
|
559
|
+
*
|
|
560
|
+
* @function getConfig
|
|
561
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
562
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
563
|
+
*
|
|
564
|
+
* @param {configCallback} callback - callback function to return the result
|
|
565
|
+
* (appliance config) or the error
|
|
566
|
+
*/
|
|
567
|
+
getConfig(deviceName, format, callback) {
|
|
568
|
+
const meth = 'adapter-getConfig';
|
|
569
|
+
const origin = `${this.id}-${meth}`;
|
|
570
|
+
log.trace(origin);
|
|
571
|
+
|
|
572
|
+
try {
|
|
573
|
+
return super.getConfig(deviceName, format, callback);
|
|
574
|
+
} catch (err) {
|
|
575
|
+
log.error(`${origin}: ${err}`);
|
|
576
|
+
return callback(null, err);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @summary Gets the device count from the system
|
|
582
|
+
*
|
|
583
|
+
* @function iapGetDeviceCount
|
|
584
|
+
*
|
|
585
|
+
* @param {getCallback} callback - callback function to return the result
|
|
586
|
+
* (count) or the error
|
|
587
|
+
*/
|
|
588
|
+
iapGetDeviceCount(callback) {
|
|
589
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
590
|
+
const origin = `${this.id}-${meth}`;
|
|
591
|
+
log.trace(origin);
|
|
592
|
+
|
|
593
|
+
try {
|
|
594
|
+
return super.iapGetDeviceCount(callback);
|
|
595
|
+
} catch (err) {
|
|
596
|
+
log.error(`${origin}: ${err}`);
|
|
597
|
+
return callback(null, err);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
421
602
|
/**
|
|
422
603
|
* Makes the requested generic call
|
|
423
604
|
*
|
|
@@ -528,6 +709,116 @@ class Slacktest extends AdapterBaseCl {
|
|
|
528
709
|
}
|
|
529
710
|
}
|
|
530
711
|
|
|
712
|
+
/**
|
|
713
|
+
* Makes the requested generic call with no base path or version
|
|
714
|
+
*
|
|
715
|
+
* @function genericAdapterRequestNoBasePath
|
|
716
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
717
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
718
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
719
|
+
* Can be a stringified Object.
|
|
720
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
721
|
+
* Can be a stringified Object.
|
|
722
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
723
|
+
* Can be a stringified Object.
|
|
724
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
725
|
+
* or the error
|
|
726
|
+
*/
|
|
727
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
728
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
729
|
+
const origin = `${this.id}-${meth}`;
|
|
730
|
+
log.trace(origin);
|
|
731
|
+
|
|
732
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
733
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
734
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
735
|
+
return callback(null, errorObj);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
739
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
740
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
741
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
742
|
+
return callback(null, errorObj);
|
|
743
|
+
}
|
|
744
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
745
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
746
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
747
|
+
return callback(null, errorObj);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
751
|
+
// remove any leading / and split the uripath into path variables
|
|
752
|
+
let myPath = uriPath;
|
|
753
|
+
while (myPath.indexOf('/') === 0) {
|
|
754
|
+
myPath = myPath.substring(1);
|
|
755
|
+
}
|
|
756
|
+
const pathVars = myPath.split('/');
|
|
757
|
+
const queryParamsAvailable = queryData;
|
|
758
|
+
const queryParams = {};
|
|
759
|
+
const bodyVars = requestBody;
|
|
760
|
+
|
|
761
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
762
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
763
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
764
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
765
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
770
|
+
const reqObj = {
|
|
771
|
+
payload: bodyVars,
|
|
772
|
+
uriPathVars: pathVars,
|
|
773
|
+
uriQuery: queryParams,
|
|
774
|
+
uriOptions: {}
|
|
775
|
+
};
|
|
776
|
+
// add headers if provided
|
|
777
|
+
if (addlHeaders) {
|
|
778
|
+
reqObj.addlHeaders = addlHeaders;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// determine the call and return flag
|
|
782
|
+
let action = 'getGenericsNoBase';
|
|
783
|
+
let returnF = true;
|
|
784
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
785
|
+
action = 'createGenericNoBase';
|
|
786
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
787
|
+
action = 'updateGenericNoBase';
|
|
788
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
789
|
+
action = 'patchGenericNoBase';
|
|
790
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
791
|
+
action = 'deleteGenericNoBase';
|
|
792
|
+
returnF = false;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
try {
|
|
796
|
+
// Make the call -
|
|
797
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
798
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
799
|
+
// if we received an error or their is no response on the results
|
|
800
|
+
// return an error
|
|
801
|
+
if (irReturnError) {
|
|
802
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
803
|
+
return callback(null, irReturnError);
|
|
804
|
+
}
|
|
805
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
806
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
807
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
808
|
+
return callback(null, errorObj);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
812
|
+
// return the response
|
|
813
|
+
return callback(irReturnData, null);
|
|
814
|
+
});
|
|
815
|
+
} catch (ex) {
|
|
816
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
817
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
818
|
+
return callback(null, errorObj);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
531
822
|
/**
|
|
532
823
|
* @callback healthCallback
|
|
533
824
|
* @param {Object} result - the result of the get request (contains an id and a status)
|
|
@@ -4992,10 +5283,11 @@ class Slacktest extends AdapterBaseCl {
|
|
|
4992
5283
|
* @param {string} content - File contents via a POST variable. If omitting this parameter, you must provide a `file`.
|
|
4993
5284
|
* @param {string} token - Authentication token. Requires scope: `files:write:user`
|
|
4994
5285
|
* @param {string} file - File contents via `multipart\/form-data`. If omitting this parameter, you must submit `content`.
|
|
5286
|
+
* @param {number} threadTs - Unique identifier of a thread's parent message
|
|
4995
5287
|
* @param {getCallback} callback - a callback function to return the result
|
|
4996
5288
|
*/
|
|
4997
5289
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4998
|
-
postFilesupload(channels, title, initialComment, filetype, filename, content, token, file, callback) {
|
|
5290
|
+
postFilesupload(channels, title, initialComment, filetype, filename, content, token, file, threadTs, callback) {
|
|
4999
5291
|
const meth = 'adapter-postFilesupload';
|
|
5000
5292
|
const origin = `${this.id}-${meth}`;
|
|
5001
5293
|
log.trace(origin);
|
|
@@ -5012,7 +5304,7 @@ class Slacktest extends AdapterBaseCl {
|
|
|
5012
5304
|
const queryParamsAvailable = {};
|
|
5013
5305
|
const queryParams = {};
|
|
5014
5306
|
const pathVars = [];
|
|
5015
|
-
const bodyVars = {};
|
|
5307
|
+
const bodyVars = { channels, title, initialComment, filetype, filename, content, file, threadTs };
|
|
5016
5308
|
|
|
5017
5309
|
// loop in template. long callback arg name to avoid identifier conflicts
|
|
5018
5310
|
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|