@drivelock/n8n-nodes-drivelock 0.1.2 → 0.2.0
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/dist/nodes/Drivelock/Drivelock.node.js +775 -42
- package/dist/nodes/Drivelock/Drivelock.node.js.map +1 -1
- package/dist/nodes/Drivelock/Drivelockrawapi.node.d.ts +5 -0
- package/dist/nodes/Drivelock/Drivelockrawapi.node.js +1640 -0
- package/dist/nodes/Drivelock/Drivelockrawapi.node.js.map +1 -0
- package/dist/nodes/Drivelock/helper/CustomPropertyHelper.js.map +1 -0
- package/dist/nodes/Drivelock/{GenericFunctions.js → helper/GenericFunctions.js} +2 -3
- package/dist/nodes/Drivelock/helper/GenericFunctions.js.map +1 -0
- package/dist/nodes/Drivelock/helper/utils.js.map +1 -0
- package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.d.ts +2 -0
- package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.js +97 -0
- package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.js.map +1 -0
- package/dist/nodes/Drivelock/operations/BinariesOperations.js +360 -0
- package/dist/nodes/Drivelock/operations/BinariesOperations.js.map +1 -0
- package/dist/nodes/Drivelock/operations/ComputerOperations.d.ts +2 -0
- package/dist/nodes/Drivelock/operations/ComputerOperations.js +169 -0
- package/dist/nodes/Drivelock/operations/ComputerOperations.js.map +1 -0
- package/dist/nodes/Drivelock/{CustomPropertyOperations.js → operations/CustomPropertyOperations.js} +13 -7
- package/dist/nodes/Drivelock/operations/CustomPropertyOperations.js.map +1 -0
- package/dist/nodes/Drivelock/operations/DeviceRuleOperations.d.ts +2 -0
- package/dist/nodes/Drivelock/operations/DeviceRuleOperations.js +105 -0
- package/dist/nodes/Drivelock/operations/DeviceRuleOperations.js.map +1 -0
- package/dist/nodes/Drivelock/operations/DriveRuleOperations.d.ts +2 -0
- package/dist/nodes/Drivelock/operations/DriveRuleOperations.js +105 -0
- package/dist/nodes/Drivelock/operations/DriveRuleOperations.js.map +1 -0
- package/dist/nodes/Drivelock/operations/EntityOperations.d.ts +2 -0
- package/dist/nodes/Drivelock/operations/EntityOperations.js +282 -0
- package/dist/nodes/Drivelock/operations/EntityOperations.js.map +1 -0
- package/dist/nodes/Drivelock/operations/GroupOperations.d.ts +2 -0
- package/dist/nodes/Drivelock/operations/GroupOperations.js +71 -0
- package/dist/nodes/Drivelock/operations/GroupOperations.js.map +1 -0
- package/dist/nodes/Drivelock/operations/PolicyOperations.d.ts +2 -0
- package/dist/nodes/Drivelock/operations/PolicyOperations.js +96 -0
- package/dist/nodes/Drivelock/operations/PolicyOperations.js.map +1 -0
- package/dist/package.json +4 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/dist/nodes/Drivelock/ApplicationRulePropertyOperations.d.ts +0 -2
- package/dist/nodes/Drivelock/ApplicationRulePropertyOperations.js +0 -50
- package/dist/nodes/Drivelock/ApplicationRulePropertyOperations.js.map +0 -1
- package/dist/nodes/Drivelock/BinariesOperations.js +0 -147
- package/dist/nodes/Drivelock/BinariesOperations.js.map +0 -1
- package/dist/nodes/Drivelock/CustomPropertyHelper.js.map +0 -1
- package/dist/nodes/Drivelock/CustomPropertyOperations.js.map +0 -1
- package/dist/nodes/Drivelock/GenericFunctions.js.map +0 -1
- package/dist/nodes/Drivelock/utils.js.map +0 -1
- /package/dist/nodes/Drivelock/{CustomPropertyHelper.d.ts → helper/CustomPropertyHelper.d.ts} +0 -0
- /package/dist/nodes/Drivelock/{CustomPropertyHelper.js → helper/CustomPropertyHelper.js} +0 -0
- /package/dist/nodes/Drivelock/{GenericFunctions.d.ts → helper/GenericFunctions.d.ts} +0 -0
- /package/dist/nodes/Drivelock/{utils.d.ts → helper/utils.d.ts} +0 -0
- /package/dist/nodes/Drivelock/{utils.js → helper/utils.js} +0 -0
- /package/dist/nodes/Drivelock/{BinariesOperations.d.ts → operations/BinariesOperations.d.ts} +0 -0
- /package/dist/nodes/Drivelock/{CustomPropertyOperations.d.ts → operations/CustomPropertyOperations.d.ts} +0 -0
|
@@ -34,16 +34,22 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Drivelock = void 0;
|
|
37
|
-
const GenericFunctions_1 = require("./GenericFunctions");
|
|
37
|
+
const GenericFunctions_1 = require("./helper/GenericFunctions");
|
|
38
38
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
39
|
+
const customPropHelper = __importStar(require("./helper/CustomPropertyHelper"));
|
|
40
|
+
const ApplicationRuleOperations_1 = require("./operations/ApplicationRuleOperations");
|
|
41
|
+
const BinariesOperations_1 = require("./operations/BinariesOperations");
|
|
42
|
+
const ComputerOperations_1 = require("./operations/ComputerOperations");
|
|
43
|
+
const CustomPropertyOperations_1 = require("./operations/CustomPropertyOperations");
|
|
44
|
+
const DeviceRuleOperations_1 = require("./operations/DeviceRuleOperations");
|
|
45
|
+
const DriveRuleOperations_1 = require("./operations/DriveRuleOperations");
|
|
46
|
+
const EntityOperations_1 = require("./operations/EntityOperations");
|
|
47
|
+
const GroupOperations_1 = require("./operations/GroupOperations");
|
|
48
|
+
const PolicyOperations_1 = require("./operations/PolicyOperations");
|
|
43
49
|
class Drivelock {
|
|
44
50
|
constructor() {
|
|
45
51
|
this.description = {
|
|
46
|
-
displayName: 'DriveLock',
|
|
52
|
+
displayName: 'DriveLock API',
|
|
47
53
|
name: 'drivelock',
|
|
48
54
|
icon: 'file:drivelock.svg',
|
|
49
55
|
group: ['transform'],
|
|
@@ -52,7 +58,7 @@ class Drivelock {
|
|
|
52
58
|
subtitle: '={{$if($parameter["operation"], $parameter["operation"] + " : ", "") + $parameter["resource"]}}',
|
|
53
59
|
description: 'Consume DriveLock API',
|
|
54
60
|
defaults: {
|
|
55
|
-
name: 'DriveLock
|
|
61
|
+
name: 'DriveLock API',
|
|
56
62
|
},
|
|
57
63
|
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
58
64
|
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
@@ -60,7 +66,7 @@ class Drivelock {
|
|
|
60
66
|
{
|
|
61
67
|
name: 'driveLockApi',
|
|
62
68
|
required: true,
|
|
63
|
-
testedBy: 'driveLockApiTest'
|
|
69
|
+
testedBy: 'driveLockApiTest',
|
|
64
70
|
}
|
|
65
71
|
],
|
|
66
72
|
usableAsTool: true,
|
|
@@ -72,30 +78,45 @@ class Drivelock {
|
|
|
72
78
|
noDataExpression: true,
|
|
73
79
|
options: [
|
|
74
80
|
{
|
|
75
|
-
name: '
|
|
76
|
-
value: '
|
|
77
|
-
description: 'Manage
|
|
81
|
+
name: 'Application Rule',
|
|
82
|
+
value: 'applicationRules',
|
|
83
|
+
description: 'Manage application rules',
|
|
78
84
|
},
|
|
79
85
|
{
|
|
80
|
-
name: '
|
|
81
|
-
value: '
|
|
82
|
-
description: 'Manage
|
|
86
|
+
name: 'Computer',
|
|
87
|
+
value: 'computer',
|
|
88
|
+
description: 'Manage computers',
|
|
83
89
|
},
|
|
84
90
|
{
|
|
85
|
-
name: '
|
|
86
|
-
value: '
|
|
87
|
-
description: 'Manage
|
|
91
|
+
name: 'Device Rule',
|
|
92
|
+
value: 'deviceRules',
|
|
93
|
+
description: 'Manage device rules',
|
|
88
94
|
},
|
|
89
95
|
{
|
|
90
|
-
name: '
|
|
91
|
-
value: 'software',
|
|
92
|
-
description: 'Manage the software',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'Manage Binary',
|
|
96
|
+
name: 'Binary',
|
|
96
97
|
value: 'binaries',
|
|
97
98
|
description: 'Manage binaries',
|
|
98
99
|
},
|
|
100
|
+
{
|
|
101
|
+
name: 'Entity',
|
|
102
|
+
value: 'entity',
|
|
103
|
+
description: 'Manage entities',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'Group',
|
|
107
|
+
value: 'group',
|
|
108
|
+
description: 'Manage groups',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'Policy',
|
|
112
|
+
value: 'policy',
|
|
113
|
+
description: 'Manage policies',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'Tool',
|
|
117
|
+
value: 'tool',
|
|
118
|
+
description: 'Tool to handle DriveLock node data',
|
|
119
|
+
},
|
|
99
120
|
{
|
|
100
121
|
name: 'Manage Schema Extention',
|
|
101
122
|
value: 'customproperty',
|
|
@@ -104,9 +125,35 @@ class Drivelock {
|
|
|
104
125
|
],
|
|
105
126
|
default: 'customproperty',
|
|
106
127
|
},
|
|
107
|
-
|
|
128
|
+
{
|
|
129
|
+
displayName: 'Operation',
|
|
130
|
+
name: 'operation',
|
|
131
|
+
type: 'options',
|
|
132
|
+
noDataExpression: true,
|
|
133
|
+
displayOptions: {
|
|
134
|
+
show: {
|
|
135
|
+
resource: ['tool'],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
options: [
|
|
139
|
+
{
|
|
140
|
+
name: 'Change JSON Data-Return to Item Array',
|
|
141
|
+
value: 'changeoutput',
|
|
142
|
+
description: 'Change the output',
|
|
143
|
+
action: 'Change JSON data return to item array',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
default: 'changeoutput',
|
|
147
|
+
},
|
|
148
|
+
...ApplicationRuleOperations_1.applicationRuleOperations,
|
|
108
149
|
...BinariesOperations_1.binariesOperations,
|
|
109
|
-
...
|
|
150
|
+
...ComputerOperations_1.computerOperations,
|
|
151
|
+
...CustomPropertyOperations_1.customPropertyOperations,
|
|
152
|
+
...DeviceRuleOperations_1.deviceRuleOperations,
|
|
153
|
+
...DriveRuleOperations_1.driveRuleOperations,
|
|
154
|
+
...EntityOperations_1.entityOperations,
|
|
155
|
+
...GroupOperations_1.groupOperations,
|
|
156
|
+
...PolicyOperations_1.policyOperations,
|
|
110
157
|
],
|
|
111
158
|
};
|
|
112
159
|
this.methods = {
|
|
@@ -145,15 +192,69 @@ class Drivelock {
|
|
|
145
192
|
};
|
|
146
193
|
}
|
|
147
194
|
async execute() {
|
|
148
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
195
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
149
196
|
const items = this.getInputData();
|
|
150
197
|
const returnData = [];
|
|
151
198
|
const length = items.length;
|
|
199
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
200
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
201
|
+
const credentialType = 'driveLockApi';
|
|
202
|
+
const credentials = await this.getCredentials(credentialType);
|
|
203
|
+
const baseUrl = (credentials.baseUrl || 'https://api.drivelock.cloud').replace(/\/$/, '');
|
|
204
|
+
const extractResponseData = (response) => {
|
|
205
|
+
if (!response)
|
|
206
|
+
return { success: true };
|
|
207
|
+
if (typeof response === 'string')
|
|
208
|
+
return { data: response };
|
|
209
|
+
if (typeof response === 'object' && response !== null) {
|
|
210
|
+
const responseObj = response;
|
|
211
|
+
const { errorId, error, data, total, additionalInfo, ...rest } = responseObj;
|
|
212
|
+
const result = {
|
|
213
|
+
success: !error,
|
|
214
|
+
};
|
|
215
|
+
if (errorId !== undefined && errorId !== null) {
|
|
216
|
+
result.errorId = errorId;
|
|
217
|
+
}
|
|
218
|
+
if (error !== undefined && error !== null) {
|
|
219
|
+
result.error = error;
|
|
220
|
+
}
|
|
221
|
+
if (data !== undefined) {
|
|
222
|
+
result.data = data;
|
|
223
|
+
}
|
|
224
|
+
if (total !== undefined) {
|
|
225
|
+
result.total = total;
|
|
226
|
+
}
|
|
227
|
+
if (additionalInfo !== undefined && additionalInfo !== null) {
|
|
228
|
+
result.additionalInfo = additionalInfo;
|
|
229
|
+
}
|
|
230
|
+
Object.keys(rest).forEach(key => {
|
|
231
|
+
if (rest[key] !== undefined && rest[key] !== null) {
|
|
232
|
+
result[key] = rest[key];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
return { success: true, data: response };
|
|
238
|
+
};
|
|
152
239
|
for (let i = 0; i < length; i++) {
|
|
153
240
|
try {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
241
|
+
if (resource === 'tool') {
|
|
242
|
+
if (operation === 'changeoutput') {
|
|
243
|
+
const items = this.getInputData();
|
|
244
|
+
const returnData = items.flatMap((item) => {
|
|
245
|
+
var _a;
|
|
246
|
+
const dataArray = (_a = item === null || item === void 0 ? void 0 : item.json) === null || _a === void 0 ? void 0 : _a.data;
|
|
247
|
+
if (!Array.isArray(dataArray)) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
return dataArray.map((dataItem) => ({
|
|
251
|
+
json: dataItem
|
|
252
|
+
}));
|
|
253
|
+
});
|
|
254
|
+
return [returnData];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else if (resource === 'customproperty') {
|
|
157
258
|
const schema = this.getNodeParameter('schema', i);
|
|
158
259
|
const schemaExtention = `${schema}Extensions`;
|
|
159
260
|
if (operation === 'check') {
|
|
@@ -195,8 +296,7 @@ class Drivelock {
|
|
|
195
296
|
const success = (allPropertiesFound && allDataTypesCorrect);
|
|
196
297
|
const responseData = { allPropertiesFound, allDataTypesCorrect, allNotChanged, details: checkResult };
|
|
197
298
|
if (success) {
|
|
198
|
-
|
|
199
|
-
returnData.push(...executionData);
|
|
299
|
+
returnData.push(responseData);
|
|
200
300
|
}
|
|
201
301
|
else {
|
|
202
302
|
const outputData = JSON.stringify(responseData);
|
|
@@ -218,8 +318,7 @@ class Drivelock {
|
|
|
218
318
|
const payload = customPropHelper.createSetPayload(customPropertyId.value, updateProperties);
|
|
219
319
|
const url = `/api/administration/entity/customSchema/setCustomData/${schemaExtention}`;
|
|
220
320
|
await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', url, payload);
|
|
221
|
-
|
|
222
|
-
returnData.push(...executionData);
|
|
321
|
+
returnData.push({ success: true, payload: payload });
|
|
223
322
|
}
|
|
224
323
|
}
|
|
225
324
|
else if (resource === 'binaries') {
|
|
@@ -250,42 +349,676 @@ class Drivelock {
|
|
|
250
349
|
};
|
|
251
350
|
if (!getFullObject)
|
|
252
351
|
qs.select = `id,${select_fields},`;
|
|
253
|
-
qs.take =
|
|
352
|
+
qs.take = 500;
|
|
353
|
+
let limit = -1;
|
|
254
354
|
if (!returnAll) {
|
|
255
|
-
|
|
355
|
+
limit = this.getNodeParameter('limit', i);
|
|
256
356
|
if (qs.take > limit)
|
|
257
357
|
qs.take = limit;
|
|
258
358
|
}
|
|
259
359
|
const responseData = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', endpoint, {}, qs);
|
|
260
360
|
const total = (_f = responseData.total) !== null && _f !== void 0 ? _f : 0;
|
|
261
|
-
if (
|
|
361
|
+
if ((returnAll && qs.take < total) ||
|
|
362
|
+
(!returnAll && qs.take < limit)) {
|
|
262
363
|
while (((_g = responseData.data) === null || _g === void 0 ? void 0 : _g.length) < total) {
|
|
263
364
|
qs.skip = (_h = responseData.data) === null || _h === void 0 ? void 0 : _h.length;
|
|
365
|
+
if (!returnAll) {
|
|
366
|
+
const nextAll = ((_j = responseData.data) === null || _j === void 0 ? void 0 : _j.length) + qs.take;
|
|
367
|
+
if (nextAll > limit)
|
|
368
|
+
qs.take = nextAll - (nextAll - limit);
|
|
369
|
+
}
|
|
264
370
|
const additionalData = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', endpoint, {}, qs);
|
|
265
371
|
if (!Array.isArray(additionalData.data)) {
|
|
266
372
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Some custom properties are missing or have incorrect data types. Details`, { itemIndex: i });
|
|
267
373
|
}
|
|
268
374
|
responseData.data.push(...additionalData.data);
|
|
375
|
+
if (!returnAll && ((_k = responseData.data) === null || _k === void 0 ? void 0 : _k.length) >= limit)
|
|
376
|
+
break;
|
|
269
377
|
}
|
|
270
378
|
}
|
|
271
|
-
responseData.n8nProcessedTotal = (
|
|
379
|
+
responseData.n8nProcessedTotal = (_l = responseData.data) === null || _l === void 0 ? void 0 : _l.length;
|
|
272
380
|
if (responseData) {
|
|
273
|
-
|
|
274
|
-
|
|
381
|
+
returnData.push(responseData);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
else if (resource === 'computer') {
|
|
386
|
+
if (operation === 'delete') {
|
|
387
|
+
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
388
|
+
const computerIds = computerIdsStr.split(',').map(id => id.trim());
|
|
389
|
+
const deleteRecoveryData = this.getNodeParameter('deleteRecoveryData', i);
|
|
390
|
+
const deleteEvents = this.getNodeParameter('deleteEvents', i);
|
|
391
|
+
const deleteGroupDefinitions = this.getNodeParameter('deleteGroupDefinitions', i);
|
|
392
|
+
const body = {
|
|
393
|
+
computerIds,
|
|
394
|
+
deleteRecoveryData,
|
|
395
|
+
deleteEvents,
|
|
396
|
+
deleteGroupDefinitions,
|
|
397
|
+
};
|
|
398
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
399
|
+
method: 'POST',
|
|
400
|
+
url: `${baseUrl}/api/administration/computer/delete`,
|
|
401
|
+
body,
|
|
402
|
+
json: true,
|
|
403
|
+
});
|
|
404
|
+
returnData.push(extractResponseData(response));
|
|
405
|
+
}
|
|
406
|
+
else if (operation === 'executeActions') {
|
|
407
|
+
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
408
|
+
const computerIds = computerIdsStr.split(',').map(id => id.trim());
|
|
409
|
+
const actionsStr = this.getNodeParameter('actions', i);
|
|
410
|
+
const notifyAgent = this.getNodeParameter('notifyAgent', i);
|
|
411
|
+
let actions;
|
|
412
|
+
try {
|
|
413
|
+
actions = JSON.parse(actionsStr);
|
|
414
|
+
}
|
|
415
|
+
catch {
|
|
416
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in actions field');
|
|
417
|
+
}
|
|
418
|
+
const body = {
|
|
419
|
+
computerIds,
|
|
420
|
+
actions,
|
|
421
|
+
notifyAgent,
|
|
422
|
+
};
|
|
423
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
424
|
+
method: 'POST',
|
|
425
|
+
url: `${baseUrl}/api/administration/computer/actions`,
|
|
426
|
+
body,
|
|
427
|
+
json: true,
|
|
428
|
+
});
|
|
429
|
+
returnData.push(extractResponseData(response));
|
|
430
|
+
}
|
|
431
|
+
else if (operation === 'onlineUnlock') {
|
|
432
|
+
const computerId = this.getNodeParameter('computerId', i);
|
|
433
|
+
const unlockDataStr = this.getNodeParameter('unlockData', i);
|
|
434
|
+
let data;
|
|
435
|
+
try {
|
|
436
|
+
data = JSON.parse(unlockDataStr);
|
|
437
|
+
}
|
|
438
|
+
catch {
|
|
439
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in unlock data field');
|
|
440
|
+
}
|
|
441
|
+
const body = {
|
|
442
|
+
computerId,
|
|
443
|
+
data,
|
|
444
|
+
};
|
|
445
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
446
|
+
method: 'POST',
|
|
447
|
+
url: `${baseUrl}/api/administration/computer/online/unlock`,
|
|
448
|
+
body,
|
|
449
|
+
json: true,
|
|
450
|
+
});
|
|
451
|
+
returnData.push(extractResponseData(response));
|
|
452
|
+
}
|
|
453
|
+
else if (operation === 'stopOnlineUnlock') {
|
|
454
|
+
const computerId = this.getNodeParameter('computerId', i);
|
|
455
|
+
const body = {
|
|
456
|
+
computerId,
|
|
457
|
+
};
|
|
458
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
459
|
+
method: 'POST',
|
|
460
|
+
url: `${baseUrl}/api/administration/computer/online/stopUnlock`,
|
|
461
|
+
body,
|
|
462
|
+
json: true,
|
|
463
|
+
});
|
|
464
|
+
returnData.push(extractResponseData(response));
|
|
465
|
+
}
|
|
466
|
+
else if (operation === 'markForRejoin') {
|
|
467
|
+
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
468
|
+
const computerIds = computerIdsStr.split(',').map(id => id.trim());
|
|
469
|
+
const allowToRejoin = this.getNodeParameter('allowToRejoin', i);
|
|
470
|
+
const body = {
|
|
471
|
+
computerIds,
|
|
472
|
+
allowToRejoin,
|
|
473
|
+
};
|
|
474
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
475
|
+
method: 'POST',
|
|
476
|
+
url: `${baseUrl}/api/administration/computer/markAgentForRejoin`,
|
|
477
|
+
body,
|
|
478
|
+
json: true,
|
|
479
|
+
});
|
|
480
|
+
returnData.push(extractResponseData(response));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
else if (resource === 'entity') {
|
|
484
|
+
const entityName = this.getNodeParameter('entityName', i);
|
|
485
|
+
if (operation === 'getList') {
|
|
486
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
487
|
+
const qs = {};
|
|
488
|
+
if (additionalFields.select)
|
|
489
|
+
qs.select = additionalFields.select;
|
|
490
|
+
if (additionalFields.query)
|
|
491
|
+
qs.query = additionalFields.query;
|
|
492
|
+
if (additionalFields.sortBy)
|
|
493
|
+
qs.sortBy = additionalFields.sortBy;
|
|
494
|
+
if (additionalFields.groupBy)
|
|
495
|
+
qs.groupBy = additionalFields.groupBy;
|
|
496
|
+
if (additionalFields.skip !== undefined)
|
|
497
|
+
qs.skip = additionalFields.skip;
|
|
498
|
+
if (additionalFields.take !== undefined)
|
|
499
|
+
qs.take = additionalFields.take;
|
|
500
|
+
if (additionalFields.getTotalCount !== undefined)
|
|
501
|
+
qs.getTotalCount = additionalFields.getTotalCount;
|
|
502
|
+
if (additionalFields.includeLinkedObjects !== undefined)
|
|
503
|
+
qs.includeLinkedObjects = additionalFields.includeLinkedObjects;
|
|
504
|
+
if (additionalFields.getFullObjects !== undefined)
|
|
505
|
+
qs.getFullObjects = additionalFields.getFullObjects;
|
|
506
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
507
|
+
method: 'GET',
|
|
508
|
+
url: `${baseUrl}/api/administration/entity/${entityName}`,
|
|
509
|
+
qs,
|
|
510
|
+
json: true,
|
|
511
|
+
});
|
|
512
|
+
returnData.push(extractResponseData(response));
|
|
513
|
+
}
|
|
514
|
+
else if (operation === 'getCount') {
|
|
515
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
516
|
+
const qs = {};
|
|
517
|
+
if (additionalFields.query)
|
|
518
|
+
qs.query = additionalFields.query;
|
|
519
|
+
if (additionalFields.groupBy)
|
|
520
|
+
qs.groupBy = additionalFields.groupBy;
|
|
521
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
522
|
+
method: 'GET',
|
|
523
|
+
url: `${baseUrl}/api/administration/entity/${entityName}/count`,
|
|
524
|
+
qs,
|
|
525
|
+
json: true,
|
|
526
|
+
});
|
|
527
|
+
returnData.push(extractResponseData(response));
|
|
528
|
+
}
|
|
529
|
+
else if (operation === 'getById') {
|
|
530
|
+
const entityId = this.getNodeParameter('entityId', i);
|
|
531
|
+
const includeLinkedObjects = this.getNodeParameter('includeLinkedObjects', i);
|
|
532
|
+
const qs = {
|
|
533
|
+
includeLinkedObjects,
|
|
534
|
+
};
|
|
535
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
536
|
+
method: 'GET',
|
|
537
|
+
url: `${baseUrl}/api/administration/entity/${entityName}/${entityId}`,
|
|
538
|
+
qs,
|
|
539
|
+
json: true,
|
|
540
|
+
});
|
|
541
|
+
returnData.push(extractResponseData(response));
|
|
542
|
+
}
|
|
543
|
+
else if (operation === 'export') {
|
|
544
|
+
const exportFormat = this.getNodeParameter('exportFormat', i);
|
|
545
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
546
|
+
const exportOptions = this.getNodeParameter('exportOptions', i);
|
|
547
|
+
const qs = {
|
|
548
|
+
exportFormat,
|
|
549
|
+
};
|
|
550
|
+
if (additionalFields.select)
|
|
551
|
+
qs.select = additionalFields.select;
|
|
552
|
+
if (additionalFields.query)
|
|
553
|
+
qs.query = additionalFields.query;
|
|
554
|
+
if (additionalFields.sortBy)
|
|
555
|
+
qs.sortBy = additionalFields.sortBy;
|
|
556
|
+
if (additionalFields.groupBy)
|
|
557
|
+
qs.groupBy = additionalFields.groupBy;
|
|
558
|
+
if (additionalFields.skip !== undefined)
|
|
559
|
+
qs.skip = additionalFields.skip;
|
|
560
|
+
if (additionalFields.take !== undefined)
|
|
561
|
+
qs.take = additionalFields.take;
|
|
562
|
+
if (additionalFields.includeLinkedObjects !== undefined)
|
|
563
|
+
qs.includeLinkedObjects = additionalFields.includeLinkedObjects;
|
|
564
|
+
if (additionalFields.getFullObjects !== undefined)
|
|
565
|
+
qs.getFullObjects = additionalFields.getFullObjects;
|
|
566
|
+
if (exportOptions.readability !== undefined)
|
|
567
|
+
qs.readability = exportOptions.readability;
|
|
568
|
+
if (exportOptions.separator)
|
|
569
|
+
qs.separator = exportOptions.separator;
|
|
570
|
+
if (exportOptions.language)
|
|
571
|
+
qs.language = exportOptions.language;
|
|
572
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
573
|
+
method: 'GET',
|
|
574
|
+
url: `${baseUrl}/api/administration/entity/${entityName}/export`,
|
|
575
|
+
qs,
|
|
576
|
+
});
|
|
577
|
+
returnData.push(extractResponseData(response));
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
else if (resource === 'group') {
|
|
581
|
+
const groupId = this.getNodeParameter('groupId', i);
|
|
582
|
+
if (operation === 'addComputers') {
|
|
583
|
+
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
584
|
+
const computerIds = computerIdsStr.split(',').map((id) => id.trim());
|
|
585
|
+
const body = {
|
|
586
|
+
groupId,
|
|
587
|
+
computerIds,
|
|
588
|
+
};
|
|
589
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
590
|
+
method: 'POST',
|
|
591
|
+
url: `${baseUrl}/api/administration/group/${groupId}/members/add`,
|
|
592
|
+
body,
|
|
593
|
+
json: true,
|
|
594
|
+
});
|
|
595
|
+
returnData.push(extractResponseData(response));
|
|
596
|
+
}
|
|
597
|
+
else if (operation === 'removeComputers') {
|
|
598
|
+
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
599
|
+
const computerIds = computerIdsStr.split(',').map((id) => id.trim());
|
|
600
|
+
const body = {
|
|
601
|
+
groupId,
|
|
602
|
+
computerIds,
|
|
603
|
+
};
|
|
604
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
605
|
+
method: 'POST',
|
|
606
|
+
url: `${baseUrl}/api/administration/group/${groupId}/members/remove`,
|
|
607
|
+
body,
|
|
608
|
+
json: true,
|
|
609
|
+
});
|
|
610
|
+
returnData.push(extractResponseData(response));
|
|
611
|
+
}
|
|
612
|
+
else if (operation === 'setMembers') {
|
|
613
|
+
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
614
|
+
const computerIds = computerIdsStr.split(',').map((id) => id.trim());
|
|
615
|
+
const body = {
|
|
616
|
+
groupId,
|
|
617
|
+
computerIds,
|
|
618
|
+
};
|
|
619
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
620
|
+
method: 'PUT',
|
|
621
|
+
url: `${baseUrl}/api/administration/group/${groupId}/members`,
|
|
622
|
+
body,
|
|
623
|
+
json: true,
|
|
624
|
+
});
|
|
625
|
+
returnData.push(extractResponseData(response));
|
|
626
|
+
}
|
|
627
|
+
else if (operation === 'getMembers') {
|
|
628
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
629
|
+
method: 'GET',
|
|
630
|
+
url: `${baseUrl}/api/administration/group/${groupId}/members`,
|
|
631
|
+
json: true,
|
|
632
|
+
});
|
|
633
|
+
returnData.push(extractResponseData(response));
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else if (resource === 'applicationRules') {
|
|
637
|
+
const configId = this.getNodeParameter('configId', i);
|
|
638
|
+
const configVersion = this.getNodeParameter('configVersion', i);
|
|
639
|
+
if (operation === 'getRules') {
|
|
640
|
+
const qs = {
|
|
641
|
+
configVersion: configVersion || undefined,
|
|
642
|
+
};
|
|
643
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
644
|
+
method: 'GET',
|
|
645
|
+
url: `${baseUrl}/api/administration/applicationControl/rules/${configId}`,
|
|
646
|
+
qs,
|
|
647
|
+
json: true,
|
|
648
|
+
});
|
|
649
|
+
returnData.push(extractResponseData(response));
|
|
650
|
+
}
|
|
651
|
+
else if (operation === 'createRules') {
|
|
652
|
+
const rulesStr = this.getNodeParameter('rules', i);
|
|
653
|
+
let rules;
|
|
654
|
+
try {
|
|
655
|
+
rules = JSON.parse(rulesStr);
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in rules field');
|
|
659
|
+
}
|
|
660
|
+
const body = {
|
|
661
|
+
configId,
|
|
662
|
+
configVersion: configVersion || undefined,
|
|
663
|
+
rules,
|
|
664
|
+
};
|
|
665
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
666
|
+
method: 'POST',
|
|
667
|
+
url: `${baseUrl}/api/administration/applicationControl/rules`,
|
|
668
|
+
body,
|
|
669
|
+
json: true,
|
|
670
|
+
});
|
|
671
|
+
returnData.push(extractResponseData(response));
|
|
672
|
+
}
|
|
673
|
+
else if (operation === 'updateRules') {
|
|
674
|
+
const rulesStr = this.getNodeParameter('rules', i);
|
|
675
|
+
let rules;
|
|
676
|
+
try {
|
|
677
|
+
rules = JSON.parse(rulesStr);
|
|
275
678
|
}
|
|
679
|
+
catch {
|
|
680
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in rules field');
|
|
681
|
+
}
|
|
682
|
+
const body = {
|
|
683
|
+
configId,
|
|
684
|
+
configVersion: configVersion || undefined,
|
|
685
|
+
rules,
|
|
686
|
+
};
|
|
687
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
688
|
+
method: 'PATCH',
|
|
689
|
+
url: `${baseUrl}/api/administration/applicationControl/rules`,
|
|
690
|
+
body,
|
|
691
|
+
json: true,
|
|
692
|
+
});
|
|
693
|
+
returnData.push(extractResponseData(response));
|
|
694
|
+
}
|
|
695
|
+
else if (operation === 'deleteRules') {
|
|
696
|
+
const ruleIdsStr = this.getNodeParameter('ruleIds', i);
|
|
697
|
+
const ruleIds = ruleIdsStr.split(',').map((id) => id.trim());
|
|
698
|
+
const body = {
|
|
699
|
+
configId,
|
|
700
|
+
configVersion: configVersion || undefined,
|
|
701
|
+
ruleIds,
|
|
702
|
+
};
|
|
703
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
704
|
+
method: 'DELETE',
|
|
705
|
+
url: `${baseUrl}/api/administration/applicationControl/rules`,
|
|
706
|
+
body,
|
|
707
|
+
json: true,
|
|
708
|
+
});
|
|
709
|
+
returnData.push(extractResponseData(response));
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
else if (resource === 'deviceRules') {
|
|
713
|
+
const configId = this.getNodeParameter('configId', i);
|
|
714
|
+
const configVersion = this.getNodeParameter('configVersion', i);
|
|
715
|
+
if (operation === 'getRules') {
|
|
716
|
+
const qs = {
|
|
717
|
+
configVersion: configVersion || undefined,
|
|
718
|
+
};
|
|
719
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
720
|
+
method: 'GET',
|
|
721
|
+
url: `${baseUrl}/api/administration/deviceControl/rules/${configId}`,
|
|
722
|
+
qs,
|
|
723
|
+
json: true,
|
|
724
|
+
});
|
|
725
|
+
returnData.push(extractResponseData(response));
|
|
726
|
+
}
|
|
727
|
+
else if (operation === 'getCollections') {
|
|
728
|
+
const qs = {
|
|
729
|
+
configVersion: configVersion || undefined,
|
|
730
|
+
};
|
|
731
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
732
|
+
method: 'GET',
|
|
733
|
+
url: `${baseUrl}/api/administration/deviceControl/collections/${configId}`,
|
|
734
|
+
qs,
|
|
735
|
+
json: true,
|
|
736
|
+
});
|
|
737
|
+
returnData.push(extractResponseData(response));
|
|
738
|
+
}
|
|
739
|
+
else if (operation === 'createRules') {
|
|
740
|
+
const rulesDataStr = this.getNodeParameter('rulesData', i);
|
|
741
|
+
let rules;
|
|
742
|
+
try {
|
|
743
|
+
rules = JSON.parse(rulesDataStr);
|
|
744
|
+
}
|
|
745
|
+
catch {
|
|
746
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in rules data field');
|
|
747
|
+
}
|
|
748
|
+
const body = {
|
|
749
|
+
configId,
|
|
750
|
+
configVersion: configVersion || undefined,
|
|
751
|
+
rules,
|
|
752
|
+
};
|
|
753
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
754
|
+
method: 'POST',
|
|
755
|
+
url: `${baseUrl}/api/administration/deviceControl/rules`,
|
|
756
|
+
body,
|
|
757
|
+
json: true,
|
|
758
|
+
});
|
|
759
|
+
returnData.push(extractResponseData(response));
|
|
760
|
+
}
|
|
761
|
+
else if (operation === 'updateRules') {
|
|
762
|
+
const rulesDataStr = this.getNodeParameter('rulesData', i);
|
|
763
|
+
let rules;
|
|
764
|
+
try {
|
|
765
|
+
rules = JSON.parse(rulesDataStr);
|
|
766
|
+
}
|
|
767
|
+
catch {
|
|
768
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in rules data field');
|
|
769
|
+
}
|
|
770
|
+
const body = {
|
|
771
|
+
configId,
|
|
772
|
+
configVersion: configVersion || undefined,
|
|
773
|
+
rules,
|
|
774
|
+
};
|
|
775
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
776
|
+
method: 'PATCH',
|
|
777
|
+
url: `${baseUrl}/api/administration/deviceControl/rules`,
|
|
778
|
+
body,
|
|
779
|
+
json: true,
|
|
780
|
+
});
|
|
781
|
+
returnData.push(extractResponseData(response));
|
|
782
|
+
}
|
|
783
|
+
else if (operation === 'updateCollections') {
|
|
784
|
+
const rulesDataStr = this.getNodeParameter('rulesData', i);
|
|
785
|
+
let collections;
|
|
786
|
+
try {
|
|
787
|
+
collections = JSON.parse(rulesDataStr);
|
|
788
|
+
}
|
|
789
|
+
catch {
|
|
790
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in collections data field');
|
|
791
|
+
}
|
|
792
|
+
const body = {
|
|
793
|
+
configId,
|
|
794
|
+
configVersion: configVersion || undefined,
|
|
795
|
+
collections,
|
|
796
|
+
};
|
|
797
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
798
|
+
method: 'PATCH',
|
|
799
|
+
url: `${baseUrl}/api/administration/deviceControl/collections`,
|
|
800
|
+
body,
|
|
801
|
+
json: true,
|
|
802
|
+
});
|
|
803
|
+
returnData.push(extractResponseData(response));
|
|
804
|
+
}
|
|
805
|
+
else if (operation === 'deleteRules') {
|
|
806
|
+
const ruleIdsStr = this.getNodeParameter('ruleIds', i);
|
|
807
|
+
const ruleIds = ruleIdsStr.split(',').map((id) => id.trim());
|
|
808
|
+
const body = {
|
|
809
|
+
configId,
|
|
810
|
+
configVersion: configVersion || undefined,
|
|
811
|
+
ruleIds,
|
|
812
|
+
};
|
|
813
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
814
|
+
method: 'DELETE',
|
|
815
|
+
url: `${baseUrl}/api/administration/deviceControl/rules`,
|
|
816
|
+
body,
|
|
817
|
+
json: true,
|
|
818
|
+
});
|
|
819
|
+
returnData.push(extractResponseData(response));
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
else if (resource === 'driveRules') {
|
|
823
|
+
const configId = this.getNodeParameter('configId', i);
|
|
824
|
+
const configVersion = this.getNodeParameter('configVersion', i);
|
|
825
|
+
if (operation === 'getRules') {
|
|
826
|
+
const qs = {
|
|
827
|
+
configVersion: configVersion || undefined,
|
|
828
|
+
};
|
|
829
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
830
|
+
method: 'GET',
|
|
831
|
+
url: `${baseUrl}/api/administration/driveControl/rules/${configId}`,
|
|
832
|
+
qs,
|
|
833
|
+
json: true,
|
|
834
|
+
});
|
|
835
|
+
returnData.push(extractResponseData(response));
|
|
836
|
+
}
|
|
837
|
+
else if (operation === 'getCollections') {
|
|
838
|
+
const qs = {
|
|
839
|
+
configVersion: configVersion || undefined,
|
|
840
|
+
};
|
|
841
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
842
|
+
method: 'GET',
|
|
843
|
+
url: `${baseUrl}/api/administration/driveControl/collections/${configId}`,
|
|
844
|
+
qs,
|
|
845
|
+
json: true,
|
|
846
|
+
});
|
|
847
|
+
returnData.push(extractResponseData(response));
|
|
848
|
+
}
|
|
849
|
+
else if (operation === 'createRules') {
|
|
850
|
+
const rulesDataStr = this.getNodeParameter('rulesData', i);
|
|
851
|
+
let rules;
|
|
852
|
+
try {
|
|
853
|
+
rules = JSON.parse(rulesDataStr);
|
|
854
|
+
}
|
|
855
|
+
catch {
|
|
856
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in rules data field');
|
|
857
|
+
}
|
|
858
|
+
const body = {
|
|
859
|
+
configId,
|
|
860
|
+
configVersion: configVersion || undefined,
|
|
861
|
+
rules,
|
|
862
|
+
};
|
|
863
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
864
|
+
method: 'POST',
|
|
865
|
+
url: `${baseUrl}/api/administration/driveControl/rules`,
|
|
866
|
+
body,
|
|
867
|
+
json: true,
|
|
868
|
+
});
|
|
869
|
+
returnData.push(extractResponseData(response));
|
|
870
|
+
}
|
|
871
|
+
else if (operation === 'updateRules') {
|
|
872
|
+
const rulesDataStr = this.getNodeParameter('rulesData', i);
|
|
873
|
+
let rules;
|
|
874
|
+
try {
|
|
875
|
+
rules = JSON.parse(rulesDataStr);
|
|
876
|
+
}
|
|
877
|
+
catch {
|
|
878
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in rules data field');
|
|
879
|
+
}
|
|
880
|
+
const body = {
|
|
881
|
+
configId,
|
|
882
|
+
configVersion: configVersion || undefined,
|
|
883
|
+
rules,
|
|
884
|
+
};
|
|
885
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
886
|
+
method: 'PATCH',
|
|
887
|
+
url: `${baseUrl}/api/administration/driveControl/rules`,
|
|
888
|
+
body,
|
|
889
|
+
json: true,
|
|
890
|
+
});
|
|
891
|
+
returnData.push(extractResponseData(response));
|
|
892
|
+
}
|
|
893
|
+
else if (operation === 'updateCollections') {
|
|
894
|
+
const rulesDataStr = this.getNodeParameter('rulesData', i);
|
|
895
|
+
let collections;
|
|
896
|
+
try {
|
|
897
|
+
collections = JSON.parse(rulesDataStr);
|
|
898
|
+
}
|
|
899
|
+
catch {
|
|
900
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in collections data field');
|
|
901
|
+
}
|
|
902
|
+
const body = {
|
|
903
|
+
configId,
|
|
904
|
+
configVersion: configVersion || undefined,
|
|
905
|
+
collections,
|
|
906
|
+
};
|
|
907
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
908
|
+
method: 'PATCH',
|
|
909
|
+
url: `${baseUrl}/api/administration/driveControl/collections`,
|
|
910
|
+
body,
|
|
911
|
+
json: true,
|
|
912
|
+
});
|
|
913
|
+
returnData.push(extractResponseData(response));
|
|
914
|
+
}
|
|
915
|
+
else if (operation === 'deleteRules') {
|
|
916
|
+
const ruleIdsStr = this.getNodeParameter('ruleIds', i);
|
|
917
|
+
const ruleIds = ruleIdsStr.split(',').map((id) => id.trim());
|
|
918
|
+
const body = {
|
|
919
|
+
configId,
|
|
920
|
+
configVersion: configVersion || undefined,
|
|
921
|
+
ruleIds,
|
|
922
|
+
};
|
|
923
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
924
|
+
method: 'DELETE',
|
|
925
|
+
url: `${baseUrl}/api/administration/driveControl/rules`,
|
|
926
|
+
body,
|
|
927
|
+
json: true,
|
|
928
|
+
});
|
|
929
|
+
returnData.push(extractResponseData(response));
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
else if (resource === 'policy') {
|
|
933
|
+
if (operation === 'get') {
|
|
934
|
+
const policyId = this.getNodeParameter('policyId', i);
|
|
935
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
936
|
+
method: 'GET',
|
|
937
|
+
url: `${baseUrl}/api/administration/policy/${policyId}`,
|
|
938
|
+
json: true,
|
|
939
|
+
});
|
|
940
|
+
returnData.push(extractResponseData(response));
|
|
941
|
+
}
|
|
942
|
+
else if (operation === 'create') {
|
|
943
|
+
const policyDataStr = this.getNodeParameter('policyData', i);
|
|
944
|
+
let policyData;
|
|
945
|
+
try {
|
|
946
|
+
policyData = JSON.parse(policyDataStr);
|
|
947
|
+
}
|
|
948
|
+
catch {
|
|
949
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in policy data field');
|
|
950
|
+
}
|
|
951
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
952
|
+
method: 'POST',
|
|
953
|
+
url: `${baseUrl}/api/administration/policy`,
|
|
954
|
+
body: policyData,
|
|
955
|
+
json: true,
|
|
956
|
+
});
|
|
957
|
+
returnData.push(extractResponseData(response));
|
|
958
|
+
}
|
|
959
|
+
else if (operation === 'update') {
|
|
960
|
+
const policyId = this.getNodeParameter('policyId', i);
|
|
961
|
+
const policyDataStr = this.getNodeParameter('policyData', i);
|
|
962
|
+
let policyData;
|
|
963
|
+
try {
|
|
964
|
+
policyData = JSON.parse(policyDataStr);
|
|
965
|
+
}
|
|
966
|
+
catch {
|
|
967
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON in policy data field');
|
|
968
|
+
}
|
|
969
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
970
|
+
method: 'PATCH',
|
|
971
|
+
url: `${baseUrl}/api/administration/policy/${policyId}`,
|
|
972
|
+
body: policyData,
|
|
973
|
+
json: true,
|
|
974
|
+
});
|
|
975
|
+
returnData.push(extractResponseData(response));
|
|
976
|
+
}
|
|
977
|
+
else if (operation === 'delete') {
|
|
978
|
+
const policyId = this.getNodeParameter('policyId', i);
|
|
979
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
980
|
+
method: 'DELETE',
|
|
981
|
+
url: `${baseUrl}/api/administration/policy/${policyId}`,
|
|
982
|
+
json: true,
|
|
983
|
+
});
|
|
984
|
+
returnData.push(extractResponseData(response));
|
|
985
|
+
}
|
|
986
|
+
else if (operation === 'getAssignments') {
|
|
987
|
+
const policyId = this.getNodeParameter('policyId', i);
|
|
988
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
989
|
+
method: 'GET',
|
|
990
|
+
url: `${baseUrl}/api/administration/policy/${policyId}/assignments`,
|
|
991
|
+
json: true,
|
|
992
|
+
});
|
|
993
|
+
returnData.push(extractResponseData(response));
|
|
994
|
+
}
|
|
995
|
+
else if (operation === 'assignToGroups') {
|
|
996
|
+
const policyId = this.getNodeParameter('policyId', i);
|
|
997
|
+
const groupIdsStr = this.getNodeParameter('groupIds', i);
|
|
998
|
+
const groupIds = groupIdsStr.split(',').map((id) => id.trim());
|
|
999
|
+
const body = {
|
|
1000
|
+
policyId,
|
|
1001
|
+
groupIds,
|
|
1002
|
+
};
|
|
1003
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, credentialType, {
|
|
1004
|
+
method: 'POST',
|
|
1005
|
+
url: `${baseUrl}/api/administration/policy/${policyId}/assign`,
|
|
1006
|
+
body,
|
|
1007
|
+
json: true,
|
|
1008
|
+
});
|
|
1009
|
+
returnData.push(extractResponseData(response));
|
|
276
1010
|
}
|
|
277
1011
|
}
|
|
278
1012
|
}
|
|
279
1013
|
catch (error) {
|
|
280
1014
|
if (this.continueOnFail()) {
|
|
281
|
-
|
|
282
|
-
returnData.push(...executionErrorData);
|
|
1015
|
+
returnData.push({ error: error.message });
|
|
283
1016
|
continue;
|
|
284
1017
|
}
|
|
285
1018
|
throw error;
|
|
286
1019
|
}
|
|
287
1020
|
}
|
|
288
|
-
return [returnData];
|
|
1021
|
+
return [this.helpers.returnJsonArray(returnData)];
|
|
289
1022
|
}
|
|
290
1023
|
;
|
|
291
1024
|
}
|