@drivelock/n8n-nodes-drivelock 0.2.4 → 0.2.6
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 +21 -466
- package/dist/nodes/Drivelock/Drivelock.node.js.map +1 -1
- package/dist/nodes/Drivelock/handlers/computerHandler.d.ts +2 -0
- package/dist/nodes/Drivelock/handlers/computerHandler.js +84 -0
- package/dist/nodes/Drivelock/handlers/computerHandler.js.map +1 -0
- package/dist/nodes/Drivelock/handlers/controlRuleHandler.d.ts +5 -0
- package/dist/nodes/Drivelock/handlers/controlRuleHandler.js +72 -0
- package/dist/nodes/Drivelock/handlers/controlRuleHandler.js.map +1 -0
- package/dist/nodes/Drivelock/handlers/customPropertyHandler.d.ts +2 -0
- package/dist/nodes/Drivelock/handlers/customPropertyHandler.js +111 -0
- package/dist/nodes/Drivelock/handlers/customPropertyHandler.js.map +1 -0
- package/dist/nodes/Drivelock/handlers/entityHandler.d.ts +2 -0
- package/dist/nodes/Drivelock/handlers/entityHandler.js +143 -0
- package/dist/nodes/Drivelock/handlers/entityHandler.js.map +1 -0
- package/dist/nodes/Drivelock/handlers/groupHandler.d.ts +2 -0
- package/dist/nodes/Drivelock/handlers/groupHandler.js +33 -0
- package/dist/nodes/Drivelock/handlers/groupHandler.js.map +1 -0
- package/dist/nodes/Drivelock/helper/GenericFunctions.d.ts +1 -1
- package/dist/nodes/Drivelock/helper/GenericFunctions.js +32 -11
- package/dist/nodes/Drivelock/helper/GenericFunctions.js.map +1 -1
- package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.js +28 -28
- package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.js.map +1 -1
- package/dist/nodes/Drivelock/operations/ComputerOperations.js +28 -28
- package/dist/nodes/Drivelock/operations/ComputerOperations.js.map +1 -1
- package/dist/nodes/Drivelock/operations/CustomPropertyOperations.js +9 -9
- package/dist/nodes/Drivelock/operations/EntityBinariesOperations.js +1 -216
- package/dist/nodes/Drivelock/operations/EntityBinariesOperations.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/nodes/Drivelock/operations/PolicyOperations.d.ts +0 -2
- package/dist/nodes/Drivelock/operations/PolicyOperations.js +0 -96
- package/dist/nodes/Drivelock/operations/PolicyOperations.js.map +0 -1
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -39,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
6
|
exports.Drivelock = void 0;
|
|
40
7
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
41
8
|
const GenericFunctions_1 = require("./helper/GenericFunctions");
|
|
42
|
-
const FilterBuilder_1 = require("./helper/FilterBuilder");
|
|
43
9
|
const AcBinaries_json_1 = __importDefault(require("./helper/fields/AcBinaries.json"));
|
|
44
10
|
const Computers_json_1 = __importDefault(require("./helper/fields/Computers.json"));
|
|
45
11
|
const DefinedGroupMemberships_json_1 = __importDefault(require("./helper/fields/DefinedGroupMemberships.json"));
|
|
@@ -64,8 +30,6 @@ const FILTER_FIELDS = {
|
|
|
64
30
|
Users: Users_json_1.default,
|
|
65
31
|
WhiteLists: WhiteLists_json_1.default,
|
|
66
32
|
};
|
|
67
|
-
const ValidationHelpers_1 = require("./helper/ValidationHelpers");
|
|
68
|
-
const customPropHelper = __importStar(require("./helper/CustomPropertyHelper"));
|
|
69
33
|
const ApplicationRuleOperations_1 = require("./operations/ApplicationRuleOperations");
|
|
70
34
|
const ComputerOperations_1 = require("./operations/ComputerOperations");
|
|
71
35
|
const CustomPropertyOperations_1 = require("./operations/CustomPropertyOperations");
|
|
@@ -73,80 +37,20 @@ const DeviceRuleOperations_1 = require("./operations/DeviceRuleOperations");
|
|
|
73
37
|
const DriveRuleOperations_1 = require("./operations/DriveRuleOperations");
|
|
74
38
|
const EntityOperations_1 = require("./operations/EntityOperations");
|
|
75
39
|
const GroupOperations_1 = require("./operations/GroupOperations");
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
result.error = error;
|
|
91
|
-
if (data !== undefined)
|
|
92
|
-
result.data = data;
|
|
93
|
-
if (total !== undefined)
|
|
94
|
-
result.total = total;
|
|
95
|
-
if (additionalInfo !== undefined && additionalInfo !== null) {
|
|
96
|
-
result.additionalInfo = additionalInfo;
|
|
97
|
-
}
|
|
98
|
-
for (const key of Object.keys(rest)) {
|
|
99
|
-
if (rest[key] !== undefined && rest[key] !== null) {
|
|
100
|
-
result[key] = rest[key];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
return { success: true, data: response };
|
|
106
|
-
}
|
|
107
|
-
function getControlRuleConfig(operation) {
|
|
108
|
-
if (operation.includes('Collection')) {
|
|
109
|
-
return { ruleSubPath: 'collections', bodyKey: 'collections' };
|
|
110
|
-
}
|
|
111
|
-
if (operation.includes('Behavior')) {
|
|
112
|
-
return { ruleSubPath: 'behaviorRules', bodyKey: 'rules' };
|
|
113
|
-
}
|
|
114
|
-
return { ruleSubPath: 'rules', bodyKey: 'rules' };
|
|
115
|
-
}
|
|
116
|
-
async function executeControlRuleOperation(execFns, controlPath, dataParamName, operation, i) {
|
|
117
|
-
const configId = execFns.getNodeParameter('configId', i);
|
|
118
|
-
const configVersion = execFns.getNodeParameter('configVersion', i);
|
|
119
|
-
const { ruleSubPath, bodyKey } = getControlRuleConfig(operation);
|
|
120
|
-
const basePath = `/api/administration/${controlPath}/${ruleSubPath}`;
|
|
121
|
-
if (operation.startsWith('get')) {
|
|
122
|
-
const qs = {};
|
|
123
|
-
if (configVersion > 0)
|
|
124
|
-
qs.configVersion = configVersion;
|
|
125
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(execFns, 'GET', `${basePath}/${configId}`, {}, qs);
|
|
126
|
-
return extractResponseData(response);
|
|
127
|
-
}
|
|
128
|
-
if (operation.startsWith('create') || operation.startsWith('update')) {
|
|
129
|
-
const dataStr = execFns.getNodeParameter(dataParamName, i);
|
|
130
|
-
const parsedData = (0, ValidationHelpers_1.parseJsonParameter)(dataStr, execFns.getNode(), i, dataParamName);
|
|
131
|
-
const body = { configId };
|
|
132
|
-
if (configVersion > 0)
|
|
133
|
-
body.configVersion = configVersion;
|
|
134
|
-
body[bodyKey] = parsedData;
|
|
135
|
-
const method = operation.startsWith('create') ? 'POST' : 'PATCH';
|
|
136
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(execFns, method, basePath, body);
|
|
137
|
-
return extractResponseData(response);
|
|
138
|
-
}
|
|
139
|
-
if (operation.startsWith('delete')) {
|
|
140
|
-
const ruleIdsStr = execFns.getNodeParameter('ruleIds', i);
|
|
141
|
-
const ruleIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(ruleIdsStr, execFns.getNode(), i, 'ruleIds');
|
|
142
|
-
const body = { configId, ruleIds };
|
|
143
|
-
if (configVersion > 0)
|
|
144
|
-
body.configVersion = configVersion;
|
|
145
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(execFns, 'DELETE', basePath, body);
|
|
146
|
-
return extractResponseData(response);
|
|
147
|
-
}
|
|
148
|
-
throw new n8n_workflow_1.NodeOperationError(execFns.getNode(), `Unknown operation: ${operation}`);
|
|
149
|
-
}
|
|
40
|
+
const customPropertyHandler_1 = require("./handlers/customPropertyHandler");
|
|
41
|
+
const computerHandler_1 = require("./handlers/computerHandler");
|
|
42
|
+
const entityHandler_1 = require("./handlers/entityHandler");
|
|
43
|
+
const groupHandler_1 = require("./handlers/groupHandler");
|
|
44
|
+
const controlRuleHandler_1 = require("./handlers/controlRuleHandler");
|
|
45
|
+
const RESOURCE_HANDLERS = {
|
|
46
|
+
customproperty: customPropertyHandler_1.executeCustomPropertyOperation,
|
|
47
|
+
computer: computerHandler_1.executeComputerOperation,
|
|
48
|
+
entity: entityHandler_1.executeEntityOperation,
|
|
49
|
+
group: groupHandler_1.executeGroupOperation,
|
|
50
|
+
applicationRules: controlRuleHandler_1.executeApplicationRulesOperation,
|
|
51
|
+
deviceRules: controlRuleHandler_1.executeDeviceRulesOperation,
|
|
52
|
+
driveRules: controlRuleHandler_1.executeDriveRulesOperation,
|
|
53
|
+
};
|
|
150
54
|
class Drivelock {
|
|
151
55
|
constructor() {
|
|
152
56
|
this.description = {
|
|
@@ -209,12 +113,12 @@ class Drivelock {
|
|
|
209
113
|
description: 'Manage groups',
|
|
210
114
|
},
|
|
211
115
|
{
|
|
212
|
-
name: 'Manage Schema
|
|
116
|
+
name: 'Manage Schema Extension',
|
|
213
117
|
value: 'customproperty',
|
|
214
118
|
description: 'Check and manage schema extensions for entities computer, drives, devices, software and binaries',
|
|
215
119
|
},
|
|
216
120
|
],
|
|
217
|
-
default: '
|
|
121
|
+
default: 'applicationRules',
|
|
218
122
|
},
|
|
219
123
|
...ApplicationRuleOperations_1.applicationRuleOperations,
|
|
220
124
|
...ComputerOperations_1.computerOperations,
|
|
@@ -415,366 +319,17 @@ class Drivelock {
|
|
|
415
319
|
};
|
|
416
320
|
}
|
|
417
321
|
async execute() {
|
|
418
|
-
var _a, _b, _c;
|
|
419
322
|
const items = this.getInputData();
|
|
420
323
|
const returnData = [];
|
|
421
|
-
const length = items.length;
|
|
422
324
|
const resource = this.getNodeParameter('resource', 0);
|
|
423
325
|
const operation = this.getNodeParameter('operation', 0);
|
|
424
|
-
for (let i = 0; i < length; i++) {
|
|
326
|
+
for (let i = 0; i < items.length; i++) {
|
|
425
327
|
try {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
if (operation === 'check') {
|
|
430
|
-
const createOrUpdateIfNotExists = this.getNodeParameter('createOrUpdateIfNotExists', i);
|
|
431
|
-
const customProperties = this.getNodeParameter('customProperties', i).customPropertyValues;
|
|
432
|
-
let customSchemes = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/customSchema/getCustomSchemas', {});
|
|
433
|
-
if (Array.isArray(customSchemes.data)) {
|
|
434
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. data should be an object' });
|
|
435
|
-
}
|
|
436
|
-
else if (!customSchemes.data.customProps) {
|
|
437
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. object is missing' });
|
|
438
|
-
}
|
|
439
|
-
let checkResult = customPropHelper.checkPropsAndTypes(customSchemes.data.customProps[schemaExtention], customProperties);
|
|
440
|
-
let allPropertiesFound = Object.values(checkResult).every((v) => v.name === true);
|
|
441
|
-
let allDataTypesCorrect = Object.values(checkResult).every((v) => v.datatype === true);
|
|
442
|
-
let allNotChanged = Object.values(checkResult).every((v) => v.changed === false);
|
|
443
|
-
if (allDataTypesCorrect && createOrUpdateIfNotExists) {
|
|
444
|
-
const adjustedProps = customPropHelper.adjustProps(checkResult, schemaExtention, customSchemes.data.customProps, customProperties);
|
|
445
|
-
const endpoint = '/api/administration/entity/customSchema/setCustomSchemas';
|
|
446
|
-
const body = { customProps: adjustedProps };
|
|
447
|
-
const updateResult = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', endpoint, body, {}, { returnFullResponse: true });
|
|
448
|
-
const statusCode = updateResult.statusCode;
|
|
449
|
-
if (statusCode !== undefined && statusCode !== 200) {
|
|
450
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The update errored - returned status-code ${statusCode}. ${JSON.stringify(updateResult.body)}`, { itemIndex: i });
|
|
451
|
-
}
|
|
452
|
-
customSchemes = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/customSchema/getCustomSchemas', {});
|
|
453
|
-
if (Array.isArray(customSchemes.data)) {
|
|
454
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. data should be an object' });
|
|
455
|
-
}
|
|
456
|
-
else if (!customSchemes.data.customProps) {
|
|
457
|
-
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. object is missing' });
|
|
458
|
-
}
|
|
459
|
-
checkResult = customPropHelper.checkPropsAndTypes(customSchemes.data.customProps[schemaExtention], customProperties);
|
|
460
|
-
allPropertiesFound = Object.values(checkResult).every((v) => v.name === true);
|
|
461
|
-
allDataTypesCorrect = Object.values(checkResult).every((v) => v.datatype === true);
|
|
462
|
-
allNotChanged = Object.values(checkResult).every((v) => v.changed === false);
|
|
463
|
-
}
|
|
464
|
-
const success = allPropertiesFound && allDataTypesCorrect;
|
|
465
|
-
const responseData = { allPropertiesFound, allDataTypesCorrect, allNotChanged, details: checkResult };
|
|
466
|
-
if (success) {
|
|
467
|
-
returnData.push(responseData);
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
const outputData = JSON.stringify(responseData);
|
|
471
|
-
if (!createOrUpdateIfNotExists) {
|
|
472
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Please configure the Custom properties proper here or in DOC. Tick the 'Create properties ...' Button to create missing entries here (or in DOC).\n\nCheck says ${outputData}`, { itemIndex: i });
|
|
473
|
-
}
|
|
474
|
-
else if (!allPropertiesFound) {
|
|
475
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `While trying to create: Some custom properties are missing or have incorrect data types. Details: ${outputData}`, { itemIndex: i });
|
|
476
|
-
}
|
|
477
|
-
else if (!allDataTypesCorrect) {
|
|
478
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Some custom properties have incorrect data types. Details: ${outputData}`, { itemIndex: i });
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
else if (operation === 'update') {
|
|
483
|
-
const customPropertyId = this.getNodeParameter('customPropertyId', i);
|
|
484
|
-
const updateProperties = this.getNodeParameter('updateProperties', i).customPropertiesValues;
|
|
485
|
-
const payload = customPropHelper.createSetPayload(customPropertyId.value, updateProperties);
|
|
486
|
-
const url = `/api/administration/entity/customSchema/setCustomData/${schemaExtention}`;
|
|
487
|
-
await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', url, payload);
|
|
488
|
-
returnData.push({ success: true, payload });
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
else if (resource === 'computer') {
|
|
492
|
-
if (operation === 'delete') {
|
|
493
|
-
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
494
|
-
const computerIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(computerIdsStr, this.getNode(), i, 'computerIds');
|
|
495
|
-
const deleteRecoveryData = this.getNodeParameter('deleteRecoveryData', i);
|
|
496
|
-
const deleteEvents = this.getNodeParameter('deleteEvents', i);
|
|
497
|
-
const deleteGroupDefinitions = this.getNodeParameter('deleteGroupDefinitions', i);
|
|
498
|
-
const body = {
|
|
499
|
-
computerIds,
|
|
500
|
-
deleteRecoveryData,
|
|
501
|
-
deleteEvents,
|
|
502
|
-
deleteGroupDefinitions,
|
|
503
|
-
};
|
|
504
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/delete', body);
|
|
505
|
-
returnData.push(extractResponseData(response));
|
|
506
|
-
}
|
|
507
|
-
else if (operation === 'executeActions') {
|
|
508
|
-
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
509
|
-
const computerIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(computerIdsStr, this.getNode(), i, 'computerIds');
|
|
510
|
-
const actionsStr = this.getNodeParameter('actions', i);
|
|
511
|
-
const notifyAgent = this.getNodeParameter('notifyAgent', i);
|
|
512
|
-
const actions = (0, ValidationHelpers_1.parseJsonParameter)(actionsStr, this.getNode(), i, 'actions');
|
|
513
|
-
const body = { computerIds, actions, notifyAgent };
|
|
514
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/actions', body);
|
|
515
|
-
returnData.push(extractResponseData(response));
|
|
516
|
-
}
|
|
517
|
-
else if (operation === 'onlineUnlock') {
|
|
518
|
-
const computerId = this.getNodeParameter('computerId', i);
|
|
519
|
-
const unlockDataStr = this.getNodeParameter('unlockData', i);
|
|
520
|
-
const data = (0, ValidationHelpers_1.parseJsonParameter)(unlockDataStr, this.getNode(), i, 'unlockData');
|
|
521
|
-
const body = { computerId, data };
|
|
522
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/online/unlock', body);
|
|
523
|
-
returnData.push(extractResponseData(response));
|
|
524
|
-
}
|
|
525
|
-
else if (operation === 'stopOnlineUnlock') {
|
|
526
|
-
const computerId = this.getNodeParameter('computerId', i);
|
|
527
|
-
const body = { computerId };
|
|
528
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/online/stopUnlock', body);
|
|
529
|
-
returnData.push(extractResponseData(response));
|
|
530
|
-
}
|
|
531
|
-
else if (operation === 'markForRejoin') {
|
|
532
|
-
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
533
|
-
const computerIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(computerIdsStr, this.getNode(), i, 'computerIds');
|
|
534
|
-
const allowToRejoin = this.getNodeParameter('allowToRejoin', i);
|
|
535
|
-
const body = { computerIds, allowToRejoin };
|
|
536
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/markAgentForRejoin', body);
|
|
537
|
-
returnData.push(extractResponseData(response));
|
|
538
|
-
}
|
|
539
|
-
else if (operation === 'clearAgentIdToken') {
|
|
540
|
-
const computerId = this.getNodeParameter('computerId', i);
|
|
541
|
-
const body = { computerId };
|
|
542
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/clearAgentIdToken', body);
|
|
543
|
-
returnData.push(extractResponseData(response));
|
|
544
|
-
}
|
|
545
|
-
else if (operation === 'setImageFlag') {
|
|
546
|
-
const computerId = this.getNodeParameter('computerId', i);
|
|
547
|
-
const imageFlag = this.getNodeParameter('imageFlag', i);
|
|
548
|
-
const body = { computerId, imageFlag };
|
|
549
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/setImageFlag', body);
|
|
550
|
-
returnData.push(extractResponseData(response));
|
|
551
|
-
}
|
|
552
|
-
else if (operation === 'stopOnlineUnlocks') {
|
|
553
|
-
const computerIdsStr = this.getNodeParameter('computerIds', i);
|
|
554
|
-
const computerIds = computerIdsStr.split(',').map((id) => id.trim()).filter(Boolean);
|
|
555
|
-
const body = { computerIds };
|
|
556
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/stopOnlineUnlocks', body);
|
|
557
|
-
returnData.push(extractResponseData(response));
|
|
558
|
-
}
|
|
559
|
-
else if (operation === 'bitlockerRecovery') {
|
|
560
|
-
const recoveryId = this.getNodeParameter('recoveryId', i);
|
|
561
|
-
const body = { recoveryId };
|
|
562
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/recovery/bitlockerRecovery', body);
|
|
563
|
-
returnData.push(extractResponseData(response));
|
|
564
|
-
}
|
|
565
|
-
else if (operation === 'bitlocker2goRecovery') {
|
|
566
|
-
const recoveryId = this.getNodeParameter('recoveryId', i);
|
|
567
|
-
const body = { recoveryId };
|
|
568
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/recovery/bitlocker2goRecovery', body);
|
|
569
|
-
returnData.push(extractResponseData(response));
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
else if (resource === 'entity') {
|
|
573
|
-
const entityName = this.getNodeParameter('entityName', i);
|
|
574
|
-
if (operation === 'getList') {
|
|
575
|
-
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
576
|
-
const qs = {};
|
|
577
|
-
if (['AcBinaries', 'Computers', 'Users', 'Devices', 'Softwares', 'DefinedGroupMemberships', 'DriveLockConfigs', 'Drives', 'Events', 'Groups', 'WhiteLists'].includes(entityName)) {
|
|
578
|
-
const propertiesMode = this.getNodeParameter('propertiesMode', i, 'builder');
|
|
579
|
-
if (propertiesMode === 'raw') {
|
|
580
|
-
const propertiesRaw = this.getNodeParameter('propertiesRaw', i, '');
|
|
581
|
-
if (propertiesRaw)
|
|
582
|
-
qs.select = `id,${propertiesRaw}`;
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
const propertiesToInclude = this.getNodeParameter('properties', i, []);
|
|
586
|
-
if (Array.isArray(propertiesToInclude) && propertiesToInclude.length) {
|
|
587
|
-
qs.select = `id,${propertiesToInclude.join(',')}`;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
const sortMode = this.getNodeParameter('sortMode', i, 'builder');
|
|
591
|
-
if (sortMode === 'raw') {
|
|
592
|
-
const sortRaw = this.getNodeParameter('sortRaw', i, '');
|
|
593
|
-
if (sortRaw)
|
|
594
|
-
qs.sortBy = sortRaw;
|
|
595
|
-
}
|
|
596
|
-
else {
|
|
597
|
-
const sortFieldsParam = this.getNodeParameter('sortFields', i, { fields: [] });
|
|
598
|
-
if ((_a = sortFieldsParam.fields) === null || _a === void 0 ? void 0 : _a.length) {
|
|
599
|
-
qs.sortBy = sortFieldsParam.fields.map((f) => `${f.direction}${f.field}`).join(',');
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
if (additionalFields.getFullObjects !== undefined)
|
|
603
|
-
qs.getFullObjects = additionalFields.getFullObjects;
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
if (additionalFields.select)
|
|
607
|
-
qs.select = additionalFields.select;
|
|
608
|
-
if (additionalFields.sortBy)
|
|
609
|
-
qs.sortBy = additionalFields.sortBy;
|
|
610
|
-
}
|
|
611
|
-
if (additionalFields.groupBy)
|
|
612
|
-
qs.groupBy = additionalFields.groupBy;
|
|
613
|
-
if (additionalFields.skip !== undefined)
|
|
614
|
-
qs.skip = additionalFields.skip;
|
|
615
|
-
if (additionalFields.take !== undefined)
|
|
616
|
-
qs.take = additionalFields.take;
|
|
617
|
-
if (additionalFields.getTotalCount !== undefined)
|
|
618
|
-
qs.getTotalCount = additionalFields.getTotalCount;
|
|
619
|
-
if (additionalFields.includeLinkedObjects !== undefined)
|
|
620
|
-
qs.includeLinkedObjects = additionalFields.includeLinkedObjects;
|
|
621
|
-
if (additionalFields.getAsFlattenedList !== undefined)
|
|
622
|
-
qs.getAsFlattenedList = additionalFields.getAsFlattenedList;
|
|
623
|
-
const filterMode = this.getNodeParameter('filterMode', i, 'builder');
|
|
624
|
-
const filterRaw = this.getNodeParameter('filterRaw', i, '');
|
|
625
|
-
const filterCombinator = this.getNodeParameter('filterCombinator', i, 'and');
|
|
626
|
-
const filterGroupsParam = this.getNodeParameter('filterGroups', i, { groups: [] });
|
|
627
|
-
const builtQuery = (0, FilterBuilder_1.buildFilterQuery)(filterMode, filterRaw, filterCombinator, filterGroupsParam);
|
|
628
|
-
if (builtQuery)
|
|
629
|
-
qs.query = builtQuery;
|
|
630
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}`, {}, qs);
|
|
631
|
-
returnData.push(extractResponseData(response));
|
|
632
|
-
}
|
|
633
|
-
else if (operation === 'getCount') {
|
|
634
|
-
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
635
|
-
const qs = {};
|
|
636
|
-
if (additionalFields.groupBy)
|
|
637
|
-
qs.groupBy = additionalFields.groupBy;
|
|
638
|
-
const filterMode = this.getNodeParameter('filterMode', i, 'builder');
|
|
639
|
-
const filterRaw = this.getNodeParameter('filterRaw', i, '');
|
|
640
|
-
const filterCombinator = this.getNodeParameter('filterCombinator', i, 'and');
|
|
641
|
-
const filterGroupsParam = this.getNodeParameter('filterGroups', i, { groups: [] });
|
|
642
|
-
const builtQuery = (0, FilterBuilder_1.buildFilterQuery)(filterMode, filterRaw, filterCombinator, filterGroupsParam);
|
|
643
|
-
if (builtQuery)
|
|
644
|
-
qs.query = builtQuery;
|
|
645
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}/count`, {}, qs);
|
|
646
|
-
returnData.push(extractResponseData(response));
|
|
647
|
-
}
|
|
648
|
-
else if (operation === 'getById') {
|
|
649
|
-
const entityId = this.getNodeParameter('entityId', i);
|
|
650
|
-
const includeLinkedObjects = this.getNodeParameter('includeLinkedObjects', i);
|
|
651
|
-
const qs = { includeLinkedObjects };
|
|
652
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}/${entityId}`, {}, qs);
|
|
653
|
-
returnData.push(extractResponseData(response));
|
|
654
|
-
}
|
|
655
|
-
else if (operation === 'export') {
|
|
656
|
-
const exportFormat = this.getNodeParameter('exportFormat', i);
|
|
657
|
-
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
658
|
-
const exportOptions = this.getNodeParameter('exportOptions', i);
|
|
659
|
-
const qs = { exportFormat };
|
|
660
|
-
if (['AcBinaries', 'Computers', 'Users', 'Devices', 'Softwares', 'DefinedGroupMemberships', 'DriveLockConfigs', 'Drives', 'Events', 'Groups', 'WhiteLists'].includes(entityName)) {
|
|
661
|
-
const propertiesMode = this.getNodeParameter('propertiesMode', i, 'builder');
|
|
662
|
-
if (propertiesMode === 'raw') {
|
|
663
|
-
const propertiesRaw = this.getNodeParameter('propertiesRaw', i, '');
|
|
664
|
-
if (propertiesRaw)
|
|
665
|
-
qs.select = `id,${propertiesRaw}`;
|
|
666
|
-
}
|
|
667
|
-
else {
|
|
668
|
-
const propertiesToInclude = this.getNodeParameter('properties', i, []);
|
|
669
|
-
if (Array.isArray(propertiesToInclude) && propertiesToInclude.length) {
|
|
670
|
-
qs.select = `id,${propertiesToInclude.join(',')}`;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
const sortMode = this.getNodeParameter('sortMode', i, 'builder');
|
|
674
|
-
if (sortMode === 'raw') {
|
|
675
|
-
const sortRaw = this.getNodeParameter('sortRaw', i, '');
|
|
676
|
-
if (sortRaw)
|
|
677
|
-
qs.sortBy = sortRaw;
|
|
678
|
-
}
|
|
679
|
-
else {
|
|
680
|
-
const sortFieldsParam = this.getNodeParameter('sortFields', i, { fields: [] });
|
|
681
|
-
if ((_b = sortFieldsParam.fields) === null || _b === void 0 ? void 0 : _b.length) {
|
|
682
|
-
qs.sortBy = sortFieldsParam.fields.map((f) => `${f.direction}${f.field}`).join(',');
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
if (additionalFields.getFullObjects !== undefined)
|
|
686
|
-
qs.getFullObjects = additionalFields.getFullObjects;
|
|
687
|
-
}
|
|
688
|
-
else {
|
|
689
|
-
if (additionalFields.select)
|
|
690
|
-
qs.select = additionalFields.select;
|
|
691
|
-
if (additionalFields.sortBy)
|
|
692
|
-
qs.sortBy = additionalFields.sortBy;
|
|
693
|
-
}
|
|
694
|
-
if (additionalFields.groupBy)
|
|
695
|
-
qs.groupBy = additionalFields.groupBy;
|
|
696
|
-
if (additionalFields.skip !== undefined)
|
|
697
|
-
qs.skip = additionalFields.skip;
|
|
698
|
-
if (additionalFields.take !== undefined)
|
|
699
|
-
qs.take = additionalFields.take;
|
|
700
|
-
if (additionalFields.includeLinkedObjects !== undefined)
|
|
701
|
-
qs.includeLinkedObjects = additionalFields.includeLinkedObjects;
|
|
702
|
-
if (additionalFields.getAsFlattenedList !== undefined)
|
|
703
|
-
qs.getAsFlattenedList = additionalFields.getAsFlattenedList;
|
|
704
|
-
if (additionalFields.maskUserProperties !== undefined)
|
|
705
|
-
qs.maskUserProperties = additionalFields.maskUserProperties;
|
|
706
|
-
if (additionalFields.maskComputerProperties !== undefined)
|
|
707
|
-
qs.maskComputerProperties = additionalFields.maskComputerProperties;
|
|
708
|
-
const filterMode = this.getNodeParameter('filterMode', i, 'builder');
|
|
709
|
-
const filterRaw = this.getNodeParameter('filterRaw', i, '');
|
|
710
|
-
const filterCombinator = this.getNodeParameter('filterCombinator', i, 'and');
|
|
711
|
-
const filterGroupsParam = this.getNodeParameter('filterGroups', i, { groups: [] });
|
|
712
|
-
const builtQuery = (0, FilterBuilder_1.buildFilterQuery)(filterMode, filterRaw, filterCombinator, filterGroupsParam);
|
|
713
|
-
if (builtQuery)
|
|
714
|
-
qs.query = builtQuery;
|
|
715
|
-
if (exportOptions.readability !== undefined)
|
|
716
|
-
qs.readability = exportOptions.readability;
|
|
717
|
-
if (exportOptions.separator)
|
|
718
|
-
qs.separator = exportOptions.separator;
|
|
719
|
-
if (exportOptions.language)
|
|
720
|
-
qs.language = exportOptions.language;
|
|
721
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}/export`, {}, qs, { json: false });
|
|
722
|
-
returnData.push(extractResponseData(response));
|
|
723
|
-
}
|
|
724
|
-
else if (operation === 'getPermissions') {
|
|
725
|
-
const entityId = this.getNodeParameter('entityId', i);
|
|
726
|
-
const body = { entityName, entityId };
|
|
727
|
-
const permResponse = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/entity/getEntityPermissions', body);
|
|
728
|
-
returnData.push(extractResponseData(permResponse));
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
else if (resource === 'group') {
|
|
732
|
-
if (operation === 'addComputerToGroup' || operation === 'removeComputerFromGroup') {
|
|
733
|
-
const groupId = this.getNodeParameter('groupId', i);
|
|
734
|
-
const membershipsParam = this.getNodeParameter('memberships', i, {});
|
|
735
|
-
const isExclude = operation === 'removeComputerFromGroup';
|
|
736
|
-
const memberships = ((_c = membershipsParam.membershipValues) !== null && _c !== void 0 ? _c : []).map((m) => {
|
|
737
|
-
var _a;
|
|
738
|
-
return ({
|
|
739
|
-
name: m.computerName,
|
|
740
|
-
isExclude,
|
|
741
|
-
comment: (_a = m.comment) !== null && _a !== void 0 ? _a : '',
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
const body = { groupId, memberships };
|
|
745
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/group/definedGroupMemberships/computers', body);
|
|
746
|
-
returnData.push(extractResponseData(response));
|
|
747
|
-
}
|
|
748
|
-
else if (operation === 'removeGroupMemberships') {
|
|
749
|
-
const membershipIdsStr = this.getNodeParameter('membershipIds', i);
|
|
750
|
-
const membershipIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(membershipIdsStr, this.getNode(), i, 'membershipIds');
|
|
751
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'DELETE', '/api/administration/group/definedGroupMemberships', membershipIds);
|
|
752
|
-
returnData.push(extractResponseData(response));
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
else if (resource === 'applicationRules') {
|
|
756
|
-
returnData.push(await executeControlRuleOperation(this, 'applicationControl', 'rules', operation, i));
|
|
757
|
-
}
|
|
758
|
-
else if (resource === 'deviceRules') {
|
|
759
|
-
if (operation === 'getRule') {
|
|
760
|
-
const ruleId = this.getNodeParameter('ruleId', i);
|
|
761
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/deviceControl/rules/${ruleId}`);
|
|
762
|
-
returnData.push(extractResponseData(response));
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
returnData.push(await executeControlRuleOperation(this, 'deviceControl', 'rulesData', operation, i));
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
else if (resource === 'driveRules') {
|
|
769
|
-
if (operation === 'getRule') {
|
|
770
|
-
const ruleId = this.getNodeParameter('ruleId', i);
|
|
771
|
-
const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/driveControl/rules/${ruleId}`);
|
|
772
|
-
returnData.push(extractResponseData(response));
|
|
773
|
-
}
|
|
774
|
-
else {
|
|
775
|
-
returnData.push(await executeControlRuleOperation(this, 'driveControl', 'rulesData', operation, i));
|
|
776
|
-
}
|
|
328
|
+
const handler = RESOURCE_HANDLERS[resource];
|
|
329
|
+
if (!handler) {
|
|
330
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown resource: ${resource}`);
|
|
777
331
|
}
|
|
332
|
+
returnData.push(await handler(this, operation, i));
|
|
778
333
|
}
|
|
779
334
|
catch (error) {
|
|
780
335
|
if (this.continueOnFail()) {
|