@vaiyen_og/n8n-nodes-ninjaone 1.5.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/README.md +142 -0
- package/dist/credentials/NinjaOneClientCredentialsApi.credentials.d.ts +10 -0
- package/dist/credentials/NinjaOneClientCredentialsApi.credentials.js +78 -0
- package/dist/credentials/NinjaOneClientCredentialsApi.credentials.js.map +1 -0
- package/dist/credentials/NinjaOneOAuth2Api.credentials.d.ts +10 -0
- package/dist/credentials/NinjaOneOAuth2Api.credentials.js +79 -0
- package/dist/credentials/NinjaOneOAuth2Api.credentials.js.map +1 -0
- package/dist/nodes/NinjaOne/GenericFunctions.d.ts +14 -0
- package/dist/nodes/NinjaOne/GenericFunctions.js +98 -0
- package/dist/nodes/NinjaOne/GenericFunctions.js.map +1 -0
- package/dist/nodes/NinjaOne/NinjaOne.node.d.ts +10 -0
- package/dist/nodes/NinjaOne/NinjaOne.node.js +713 -0
- package/dist/nodes/NinjaOne/NinjaOne.node.js.map +1 -0
- package/dist/nodes/NinjaOne/NinjaOneTrigger.node.d.ts +12 -0
- package/dist/nodes/NinjaOne/NinjaOneTrigger.node.js +108 -0
- package/dist/nodes/NinjaOne/NinjaOneTrigger.node.js.map +1 -0
- package/dist/nodes/NinjaOne/descriptions/DeviceDescription.d.ts +3 -0
- package/dist/nodes/NinjaOne/descriptions/DeviceDescription.js +151 -0
- package/dist/nodes/NinjaOne/descriptions/DeviceDescription.js.map +1 -0
- package/dist/nodes/NinjaOne/descriptions/OrganizationDescription.d.ts +3 -0
- package/dist/nodes/NinjaOne/descriptions/OrganizationDescription.js +106 -0
- package/dist/nodes/NinjaOne/descriptions/OrganizationDescription.js.map +1 -0
- package/dist/nodes/NinjaOne/descriptions/OtherDescriptions.d.ts +27 -0
- package/dist/nodes/NinjaOne/descriptions/OtherDescriptions.js +30 -0
- package/dist/nodes/NinjaOne/descriptions/OtherDescriptions.js.map +1 -0
- package/dist/nodes/NinjaOne/descriptions/TicketingDescription.d.ts +3 -0
- package/dist/nodes/NinjaOne/descriptions/TicketingDescription.js +322 -0
- package/dist/nodes/NinjaOne/descriptions/TicketingDescription.js.map +1 -0
- package/dist/nodes/NinjaOne/ninjaone.png +0 -0
- package/package.json +54 -0
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NinjaOne = void 0;
|
|
4
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
5
|
+
const OrganizationDescription_1 = require("./descriptions/OrganizationDescription");
|
|
6
|
+
const DeviceDescription_1 = require("./descriptions/DeviceDescription");
|
|
7
|
+
const TicketingDescription_1 = require("./descriptions/TicketingDescription");
|
|
8
|
+
const OtherDescriptions_1 = require("./descriptions/OtherDescriptions");
|
|
9
|
+
class NinjaOne {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.description = {
|
|
12
|
+
displayName: 'NinjaOne',
|
|
13
|
+
name: 'ninjaOne',
|
|
14
|
+
icon: 'file:ninjaone.png',
|
|
15
|
+
group: ['transform'],
|
|
16
|
+
version: 1,
|
|
17
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
18
|
+
description: 'Consume the NinjaOne RMM API',
|
|
19
|
+
defaults: { name: 'NinjaOne' },
|
|
20
|
+
inputs: ['main'],
|
|
21
|
+
outputs: ['main'],
|
|
22
|
+
credentials: [
|
|
23
|
+
{
|
|
24
|
+
name: 'ninjaOneOAuth2Api',
|
|
25
|
+
required: true,
|
|
26
|
+
displayOptions: { show: { authentication: ['oAuth2'] } },
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'ninjaOneClientCredentialsApi',
|
|
30
|
+
required: true,
|
|
31
|
+
displayOptions: { show: { authentication: ['clientCredentials'] } },
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
properties: [
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Authentication',
|
|
37
|
+
name: 'authentication',
|
|
38
|
+
type: 'options',
|
|
39
|
+
options: [
|
|
40
|
+
{ name: 'OAuth2 (Authorization Code)', value: 'oAuth2' },
|
|
41
|
+
{ name: 'Client Credentials', value: 'clientCredentials' },
|
|
42
|
+
],
|
|
43
|
+
default: 'oAuth2',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
displayName: 'Resource',
|
|
47
|
+
name: 'resource',
|
|
48
|
+
type: 'options',
|
|
49
|
+
noDataExpression: true,
|
|
50
|
+
options: [
|
|
51
|
+
{ name: 'Alert', value: 'alert' },
|
|
52
|
+
{ name: 'Backup', value: 'backup' },
|
|
53
|
+
{ name: 'Custom Field', value: 'customField' },
|
|
54
|
+
{ name: 'Device', value: 'device' },
|
|
55
|
+
{ name: 'Document Template', value: 'docTemplate' },
|
|
56
|
+
{ name: 'Group', value: 'group' },
|
|
57
|
+
{ name: 'Knowledge Base Article', value: 'knowledgeBase' },
|
|
58
|
+
{ name: 'Location', value: 'location' },
|
|
59
|
+
{ name: 'Organization', value: 'organization' },
|
|
60
|
+
{ name: 'Organization Document', value: 'orgDocument' },
|
|
61
|
+
{ name: 'Query', value: 'query' },
|
|
62
|
+
{ name: 'Related Item', value: 'relatedItem' },
|
|
63
|
+
{ name: 'System', value: 'system' },
|
|
64
|
+
{ name: 'Ticketing', value: 'ticketing' },
|
|
65
|
+
{ name: 'User', value: 'user' },
|
|
66
|
+
{ name: 'Webhook', value: 'webhook' },
|
|
67
|
+
],
|
|
68
|
+
default: 'device',
|
|
69
|
+
},
|
|
70
|
+
...OrganizationDescription_1.organizationOperations, ...OrganizationDescription_1.organizationFields,
|
|
71
|
+
...DeviceDescription_1.deviceOperations, ...DeviceDescription_1.deviceFields,
|
|
72
|
+
...TicketingDescription_1.ticketingOperations, ...TicketingDescription_1.ticketingFields,
|
|
73
|
+
...OtherDescriptions_1.systemOperations, ...OtherDescriptions_1.systemFields,
|
|
74
|
+
...OtherDescriptions_1.userOperations, ...OtherDescriptions_1.userFields,
|
|
75
|
+
...OtherDescriptions_1.groupOperations, ...OtherDescriptions_1.groupFields,
|
|
76
|
+
...OtherDescriptions_1.queryOperations, ...OtherDescriptions_1.queryFields,
|
|
77
|
+
...OtherDescriptions_1.alertOperations, ...OtherDescriptions_1.alertFields,
|
|
78
|
+
...OtherDescriptions_1.locationOperations, ...OtherDescriptions_1.locationFields,
|
|
79
|
+
...OtherDescriptions_1.backupOperations, ...OtherDescriptions_1.backupFields,
|
|
80
|
+
...OtherDescriptions_1.webhookOperations, ...OtherDescriptions_1.webhookFields,
|
|
81
|
+
...OtherDescriptions_1.customFieldOperations, ...OtherDescriptions_1.customFieldFields,
|
|
82
|
+
...OtherDescriptions_1.knowledgeBaseOperations, ...OtherDescriptions_1.knowledgeBaseFields,
|
|
83
|
+
...OtherDescriptions_1.orgDocumentOperations, ...OtherDescriptions_1.orgDocumentFields,
|
|
84
|
+
...OtherDescriptions_1.docTemplateOperations, ...OtherDescriptions_1.docTemplateFields,
|
|
85
|
+
...OtherDescriptions_1.relatedItemOperations, ...OtherDescriptions_1.relatedItemFields,
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
this.methods = {
|
|
89
|
+
loadOptions: {
|
|
90
|
+
async getOrganizations() {
|
|
91
|
+
const orgs = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/organizations');
|
|
92
|
+
return orgs.map((o) => ({ name: o.name, value: o.id }));
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async execute() {
|
|
98
|
+
const items = this.getInputData();
|
|
99
|
+
const returnData = [];
|
|
100
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
101
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
102
|
+
for (let i = 0; i < items.length; i++) {
|
|
103
|
+
try {
|
|
104
|
+
let responseData;
|
|
105
|
+
if (resource === 'organization') {
|
|
106
|
+
if (operation === 'getAll') {
|
|
107
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
108
|
+
if (returnAll) {
|
|
109
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequestAllItems.call(this, 'GET', '/api/v2/organizations');
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const limit = this.getNodeParameter('limit', i);
|
|
113
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/organizations', {}, { pageSize: limit });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (operation === 'get') {
|
|
117
|
+
const id = this.getNodeParameter('organizationId', i);
|
|
118
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/organization/${id}`);
|
|
119
|
+
}
|
|
120
|
+
else if (operation === 'create') {
|
|
121
|
+
const name = this.getNodeParameter('name', i);
|
|
122
|
+
const additional = this.getNodeParameter('additionalFields', i);
|
|
123
|
+
const body = { name };
|
|
124
|
+
if (additional.description)
|
|
125
|
+
body.description = additional.description;
|
|
126
|
+
if (additional.nodeApprovalMode)
|
|
127
|
+
body.nodeApprovalMode = additional.nodeApprovalMode;
|
|
128
|
+
if (additional.tags)
|
|
129
|
+
body.tags = additional.tags.split(',').map((t) => t.trim());
|
|
130
|
+
const qs = {};
|
|
131
|
+
if (additional.templateOrganizationId)
|
|
132
|
+
qs.templateOrganizationId = additional.templateOrganizationId;
|
|
133
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', '/api/v2/organizations', body, qs);
|
|
134
|
+
}
|
|
135
|
+
else if (operation === 'update') {
|
|
136
|
+
const id = this.getNodeParameter('organizationId', i);
|
|
137
|
+
const fields = this.getNodeParameter('updateFields', i);
|
|
138
|
+
const body = {};
|
|
139
|
+
if (fields.name)
|
|
140
|
+
body.name = fields.name;
|
|
141
|
+
if (fields.description)
|
|
142
|
+
body.description = fields.description;
|
|
143
|
+
if (fields.nodeApprovalMode)
|
|
144
|
+
body.nodeApprovalMode = fields.nodeApprovalMode;
|
|
145
|
+
if (fields.tags)
|
|
146
|
+
body.tags = fields.tags.split(',').map((t) => t.trim());
|
|
147
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PATCH', `/api/v2/organization/${id}`, body);
|
|
148
|
+
}
|
|
149
|
+
else if (operation === 'delete') {
|
|
150
|
+
const id = this.getNodeParameter('organizationId', i);
|
|
151
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', `/api/v2/organization/${id}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (resource === 'device') {
|
|
155
|
+
if (operation === 'getAll') {
|
|
156
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
157
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
158
|
+
const qs = {};
|
|
159
|
+
if (filters.df)
|
|
160
|
+
qs.df = filters.df;
|
|
161
|
+
if (filters.organizationId)
|
|
162
|
+
qs.organizationId = filters.organizationId;
|
|
163
|
+
if (returnAll) {
|
|
164
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequestAllItems.call(this, 'GET', '/api/v2/devices', {}, qs);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const limit = this.getNodeParameter('limit', i);
|
|
168
|
+
qs.pageSize = limit;
|
|
169
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/devices', {}, qs);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (operation === 'get') {
|
|
173
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
174
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}`);
|
|
175
|
+
}
|
|
176
|
+
else if (operation === 'getActivities') {
|
|
177
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
178
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/activities`);
|
|
179
|
+
}
|
|
180
|
+
else if (operation === 'getCustomFields') {
|
|
181
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
182
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/custom-fields`);
|
|
183
|
+
}
|
|
184
|
+
else if (operation === 'getDisks') {
|
|
185
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
186
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/disks`);
|
|
187
|
+
}
|
|
188
|
+
else if (operation === 'getNetworkInterfaces') {
|
|
189
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
190
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/network-interfaces`);
|
|
191
|
+
}
|
|
192
|
+
else if (operation === 'getOSPatches') {
|
|
193
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
194
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/os-patches`);
|
|
195
|
+
}
|
|
196
|
+
else if (operation === 'getProcessors') {
|
|
197
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
198
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/processors`);
|
|
199
|
+
}
|
|
200
|
+
else if (operation === 'getSoftware') {
|
|
201
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
202
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/software`);
|
|
203
|
+
}
|
|
204
|
+
else if (operation === 'getVolumes') {
|
|
205
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
206
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/volumes`);
|
|
207
|
+
}
|
|
208
|
+
else if (operation === 'updateCustomFields') {
|
|
209
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
210
|
+
const fields = this.getNodeParameter('customFieldsJson', i);
|
|
211
|
+
const body = typeof fields === 'string' ? JSON.parse(fields) : fields;
|
|
212
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PATCH', `/api/v2/device/${id}/custom-fields`, body);
|
|
213
|
+
}
|
|
214
|
+
else if (operation === 'reboot') {
|
|
215
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
216
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/device/${id}/reboot`, { mode: 'NORMAL' });
|
|
217
|
+
}
|
|
218
|
+
else if (operation === 'runScript') {
|
|
219
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
220
|
+
const scriptId = this.getNodeParameter('scriptId', i);
|
|
221
|
+
const params = this.getNodeParameter('scriptParameters', i, '');
|
|
222
|
+
const runAs = this.getNodeParameter('runAs', i, 'SYSTEM');
|
|
223
|
+
const body = { id: scriptId, runAs };
|
|
224
|
+
if (params)
|
|
225
|
+
body.parameters = typeof params === 'string' ? JSON.parse(params) : params;
|
|
226
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/device/${id}/script/run`, body);
|
|
227
|
+
}
|
|
228
|
+
else if (operation === 'maintenance') {
|
|
229
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
230
|
+
const start = this.getNodeParameter('start', i);
|
|
231
|
+
const end = this.getNodeParameter('end', i);
|
|
232
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PUT', `/api/v2/device/${id}/maintenance`, { start, end });
|
|
233
|
+
}
|
|
234
|
+
else if (operation === 'approval') {
|
|
235
|
+
const mode = this.getNodeParameter('approvalMode', i);
|
|
236
|
+
const ids = this.getNodeParameter('deviceIds', i).split(',').map((s) => parseInt(s.trim(), 10));
|
|
237
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/devices/approval/${mode}`, { devices: ids });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else if (resource === 'ticketing') {
|
|
241
|
+
if (operation === 'getAll') {
|
|
242
|
+
const boardId = this.getNodeParameter('boardId', i);
|
|
243
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
244
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
245
|
+
const qs = {};
|
|
246
|
+
if (filters.status && filters.status.length)
|
|
247
|
+
qs.status = filters.status.join(',');
|
|
248
|
+
if (filters.ticketFormId)
|
|
249
|
+
qs.ticketFormId = filters.ticketFormId;
|
|
250
|
+
if (filters.assignedTo)
|
|
251
|
+
qs.assignedTo = filters.assignedTo;
|
|
252
|
+
if (filters.clientId)
|
|
253
|
+
qs.clientId = filters.clientId;
|
|
254
|
+
if (filters.lastUpdated)
|
|
255
|
+
qs.lastUpdated = new Date(filters.lastUpdated).getTime() / 1000;
|
|
256
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/ticketing/trigger/board/${boardId}/run`, {}, qs);
|
|
257
|
+
if (!returnAll) {
|
|
258
|
+
const limit = this.getNodeParameter('limit', i);
|
|
259
|
+
if (Array.isArray(responseData)) {
|
|
260
|
+
responseData = responseData.slice(0, limit);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else if (operation === 'get') {
|
|
265
|
+
const id = this.getNodeParameter('ticketId', i);
|
|
266
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/ticketing/ticket/${id}`);
|
|
267
|
+
}
|
|
268
|
+
else if (operation === 'create') {
|
|
269
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
270
|
+
const summary = this.getNodeParameter('summary', i);
|
|
271
|
+
const additional = this.getNodeParameter('additionalFields', i);
|
|
272
|
+
const body = { clientId, subject: summary };
|
|
273
|
+
if (additional.status)
|
|
274
|
+
body.status = additional.status;
|
|
275
|
+
if (additional.type)
|
|
276
|
+
body.type = additional.type;
|
|
277
|
+
if (additional.priority)
|
|
278
|
+
body.priority = additional.priority;
|
|
279
|
+
if (additional.severity)
|
|
280
|
+
body.severity = additional.severity;
|
|
281
|
+
if (additional.assignedAppUserId)
|
|
282
|
+
body.assignedAppUserId = additional.assignedAppUserId;
|
|
283
|
+
if (additional.requesterUid)
|
|
284
|
+
body.requesterUid = additional.requesterUid;
|
|
285
|
+
if (additional.locationId)
|
|
286
|
+
body.locationId = additional.locationId;
|
|
287
|
+
if (additional.nodeId)
|
|
288
|
+
body.nodeId = additional.nodeId;
|
|
289
|
+
if (additional.ticketFormId)
|
|
290
|
+
body.ticketFormId = additional.ticketFormId;
|
|
291
|
+
if (additional.parentTicketId)
|
|
292
|
+
body.parentTicketId = additional.parentTicketId;
|
|
293
|
+
if (additional.tags)
|
|
294
|
+
body.tags = additional.tags.split(',').map((t) => t.trim());
|
|
295
|
+
if (additional.descriptionBody || additional.descriptionHtmlBody) {
|
|
296
|
+
body.description = { public: true };
|
|
297
|
+
if (additional.descriptionBody)
|
|
298
|
+
body.description.body = additional.descriptionBody;
|
|
299
|
+
if (additional.descriptionHtmlBody)
|
|
300
|
+
body.description.htmlBody = additional.descriptionHtmlBody;
|
|
301
|
+
}
|
|
302
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', '/api/v2/ticketing/ticket', body);
|
|
303
|
+
}
|
|
304
|
+
else if (operation === 'update') {
|
|
305
|
+
const id = this.getNodeParameter('ticketId', i);
|
|
306
|
+
const fields = this.getNodeParameter('updateFields', i);
|
|
307
|
+
const ticket = {};
|
|
308
|
+
if (fields.summary)
|
|
309
|
+
ticket.subject = fields.summary;
|
|
310
|
+
if (fields.status)
|
|
311
|
+
ticket.status = fields.status;
|
|
312
|
+
if (fields.type)
|
|
313
|
+
ticket.type = fields.type;
|
|
314
|
+
if (fields.priority)
|
|
315
|
+
ticket.priority = fields.priority;
|
|
316
|
+
if (fields.severity)
|
|
317
|
+
ticket.severity = fields.severity;
|
|
318
|
+
if (fields.assignedAppUserId)
|
|
319
|
+
ticket.assignedAppUserId = fields.assignedAppUserId;
|
|
320
|
+
if (fields.locationId)
|
|
321
|
+
ticket.locationId = fields.locationId;
|
|
322
|
+
if (fields.nodeId)
|
|
323
|
+
ticket.nodeId = fields.nodeId;
|
|
324
|
+
if (fields.clientId)
|
|
325
|
+
ticket.clientId = fields.clientId;
|
|
326
|
+
if (fields.parentTicketId)
|
|
327
|
+
ticket.parentTicketId = fields.parentTicketId;
|
|
328
|
+
if (fields.tags)
|
|
329
|
+
ticket.tags = fields.tags.split(',').map((t) => t.trim());
|
|
330
|
+
if (fields.followupTime)
|
|
331
|
+
ticket.followupTime = fields.followupTime;
|
|
332
|
+
const body = { ticket };
|
|
333
|
+
if (fields.commentBody) {
|
|
334
|
+
body.comment = { body: fields.commentBody, public: fields.commentPublic ?? true };
|
|
335
|
+
}
|
|
336
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PUT', `/api/v2/ticketing/ticket/${id}`, body);
|
|
337
|
+
}
|
|
338
|
+
else if (operation === 'delete') {
|
|
339
|
+
const id = this.getNodeParameter('ticketId', i);
|
|
340
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', `/api/v2/ticketing/ticket/${id}`);
|
|
341
|
+
}
|
|
342
|
+
else if (operation === 'addComment') {
|
|
343
|
+
const id = this.getNodeParameter('ticketId', i);
|
|
344
|
+
const body = {
|
|
345
|
+
body: this.getNodeParameter('commentBody', i),
|
|
346
|
+
public: this.getNodeParameter('commentPublic', i, true),
|
|
347
|
+
};
|
|
348
|
+
const html = this.getNodeParameter('commentHtmlBody', i, '');
|
|
349
|
+
if (html)
|
|
350
|
+
body.htmlBody = html;
|
|
351
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/ticketing/ticket/${id}/comment`, { comment: body });
|
|
352
|
+
}
|
|
353
|
+
else if (operation === 'getLogEntries') {
|
|
354
|
+
const id = this.getNodeParameter('ticketId', i);
|
|
355
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/ticketing/ticket/${id}/log-entry`);
|
|
356
|
+
}
|
|
357
|
+
else if (operation === 'getBoards') {
|
|
358
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/ticketing/trigger/boards');
|
|
359
|
+
}
|
|
360
|
+
else if (operation === 'getStatuses') {
|
|
361
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/ticketing/statuses');
|
|
362
|
+
}
|
|
363
|
+
else if (operation === 'getTicketForms') {
|
|
364
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/ticketing/ticket-form');
|
|
365
|
+
}
|
|
366
|
+
else if (operation === 'getContacts') {
|
|
367
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/ticketing/contact/contacts');
|
|
368
|
+
}
|
|
369
|
+
else if (operation === 'createContact') {
|
|
370
|
+
const body = {
|
|
371
|
+
email: this.getNodeParameter('contactEmail', i),
|
|
372
|
+
firstName: this.getNodeParameter('contactFirstName', i),
|
|
373
|
+
lastName: this.getNodeParameter('contactLastName', i),
|
|
374
|
+
phone: this.getNodeParameter('contactPhone', i),
|
|
375
|
+
};
|
|
376
|
+
const additional = this.getNodeParameter('contactAdditionalFields', i, {});
|
|
377
|
+
if (additional.organizationId)
|
|
378
|
+
body.organizationId = additional.organizationId;
|
|
379
|
+
if (additional.jobTitle)
|
|
380
|
+
body.jobTitle = additional.jobTitle;
|
|
381
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', '/api/v2/contacts', body);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else if (resource === 'system') {
|
|
385
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
386
|
+
const qs = { ...filters };
|
|
387
|
+
if (operation === 'getActivities') {
|
|
388
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/activities', {}, qs);
|
|
389
|
+
}
|
|
390
|
+
else if (operation === 'getDeviceRoles') {
|
|
391
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/roles');
|
|
392
|
+
}
|
|
393
|
+
else if (operation === 'getPolicies') {
|
|
394
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/policies');
|
|
395
|
+
}
|
|
396
|
+
else if (operation === 'getScriptingLanguages') {
|
|
397
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/scripting/languages');
|
|
398
|
+
}
|
|
399
|
+
else if (operation === 'getScripts') {
|
|
400
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/automation/scripts');
|
|
401
|
+
}
|
|
402
|
+
else if (operation === 'getSoftwareProducts') {
|
|
403
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/software-products');
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
else if (resource === 'user') {
|
|
407
|
+
if (operation === 'getAll') {
|
|
408
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
409
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
410
|
+
const qs = {};
|
|
411
|
+
if (filters.userType)
|
|
412
|
+
qs.userType = filters.userType;
|
|
413
|
+
if (returnAll) {
|
|
414
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequestAllItems.call(this, 'GET', '/api/v2/users', {}, qs);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
qs.pageSize = this.getNodeParameter('limit', i);
|
|
418
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/users', {}, qs);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
else if (operation === 'get') {
|
|
422
|
+
const id = this.getNodeParameter('userId', i);
|
|
423
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/user/${id}`);
|
|
424
|
+
}
|
|
425
|
+
else if (operation === 'create') {
|
|
426
|
+
const body = {
|
|
427
|
+
firstName: this.getNodeParameter('firstName', i),
|
|
428
|
+
lastName: this.getNodeParameter('lastName', i),
|
|
429
|
+
email: this.getNodeParameter('email', i),
|
|
430
|
+
};
|
|
431
|
+
const additional = this.getNodeParameter('additionalFields', i);
|
|
432
|
+
Object.assign(body, additional);
|
|
433
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', '/api/v2/users', body);
|
|
434
|
+
}
|
|
435
|
+
else if (operation === 'update') {
|
|
436
|
+
const id = this.getNodeParameter('userId', i);
|
|
437
|
+
const fields = this.getNodeParameter('updateFields', i);
|
|
438
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PUT', `/api/v2/user/${id}`, fields);
|
|
439
|
+
}
|
|
440
|
+
else if (operation === 'delete') {
|
|
441
|
+
const id = this.getNodeParameter('userId', i);
|
|
442
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', `/api/v2/user/${id}`);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
else if (resource === 'group') {
|
|
446
|
+
if (operation === 'getAll') {
|
|
447
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
448
|
+
if (returnAll) {
|
|
449
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequestAllItems.call(this, 'GET', '/api/v2/groups');
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
const limit = this.getNodeParameter('limit', i);
|
|
453
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/groups', {}, { pageSize: limit });
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
else if (operation === 'get') {
|
|
457
|
+
const id = this.getNodeParameter('groupId', i);
|
|
458
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/group/${id}`);
|
|
459
|
+
}
|
|
460
|
+
else if (operation === 'getDeviceIds') {
|
|
461
|
+
const id = this.getNodeParameter('groupId', i);
|
|
462
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/group/${id}/device-ids`);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
else if (resource === 'query') {
|
|
466
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
467
|
+
const qs = {};
|
|
468
|
+
if (filters.df)
|
|
469
|
+
qs.df = filters.df;
|
|
470
|
+
if (filters.cursor)
|
|
471
|
+
qs.cursor = filters.cursor;
|
|
472
|
+
if (filters.pageSize)
|
|
473
|
+
qs.pageSize = filters.pageSize;
|
|
474
|
+
if (filters.ts)
|
|
475
|
+
qs.ts = filters.ts;
|
|
476
|
+
const queryMap = {
|
|
477
|
+
alerts: '/api/v2/queries/alerts',
|
|
478
|
+
antivirusStatus: '/api/v2/queries/antivirus-status',
|
|
479
|
+
antivirusThreats: '/api/v2/queries/antivirus-threats',
|
|
480
|
+
customFields: '/api/v2/queries/custom-fields',
|
|
481
|
+
deviceHealth: '/api/v2/queries/device-health',
|
|
482
|
+
disks: '/api/v2/queries/disks',
|
|
483
|
+
networkInterfaces: '/api/v2/queries/network-interfaces',
|
|
484
|
+
osPatchInstalls: '/api/v2/queries/os-patch-installs',
|
|
485
|
+
osPatches: '/api/v2/queries/os-patches',
|
|
486
|
+
processors: '/api/v2/queries/processors',
|
|
487
|
+
raidDrives: '/api/v2/queries/raid-drives',
|
|
488
|
+
software: '/api/v2/queries/software',
|
|
489
|
+
softwarePatches: '/api/v2/queries/software-patches',
|
|
490
|
+
windowsServices: '/api/v2/queries/windows-services',
|
|
491
|
+
};
|
|
492
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', queryMap[operation], {}, qs);
|
|
493
|
+
}
|
|
494
|
+
else if (resource === 'alert') {
|
|
495
|
+
if (operation === 'getAll') {
|
|
496
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
497
|
+
const qs = {};
|
|
498
|
+
if (filters.df)
|
|
499
|
+
qs.df = filters.df;
|
|
500
|
+
if (filters.lang)
|
|
501
|
+
qs.lang = filters.lang;
|
|
502
|
+
if (filters.sourceType)
|
|
503
|
+
qs.sourceType = filters.sourceType;
|
|
504
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/alerts', {}, qs);
|
|
505
|
+
}
|
|
506
|
+
else if (operation === 'reset') {
|
|
507
|
+
const uid = this.getNodeParameter('alertUid', i);
|
|
508
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', `/api/v2/alert/${uid}`);
|
|
509
|
+
}
|
|
510
|
+
else if (operation === 'resetWithData') {
|
|
511
|
+
const uid = this.getNodeParameter('alertUid', i);
|
|
512
|
+
const data = this.getNodeParameter('activityData', i);
|
|
513
|
+
const body = typeof data === 'string' ? JSON.parse(data) : data;
|
|
514
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/alert/${uid}/reset`, body);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
else if (resource === 'location') {
|
|
518
|
+
const orgId = this.getNodeParameter('organizationId', i);
|
|
519
|
+
if (operation === 'getAll') {
|
|
520
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/organization/${orgId}/locations`);
|
|
521
|
+
}
|
|
522
|
+
else if (operation === 'create') {
|
|
523
|
+
const name = this.getNodeParameter('name', i);
|
|
524
|
+
const additional = this.getNodeParameter('additionalFields', i, {});
|
|
525
|
+
const body = { name, ...additional };
|
|
526
|
+
if (body.tags)
|
|
527
|
+
body.tags = body.tags.split(',').map((t) => t.trim());
|
|
528
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/organization/${orgId}/locations`, body);
|
|
529
|
+
}
|
|
530
|
+
else if (operation === 'update') {
|
|
531
|
+
const locId = this.getNodeParameter('locationId', i);
|
|
532
|
+
const additional = this.getNodeParameter('additionalFields', i, {});
|
|
533
|
+
const body = { ...additional };
|
|
534
|
+
if (body.tags)
|
|
535
|
+
body.tags = body.tags.split(',').map((t) => t.trim());
|
|
536
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PATCH', `/api/v2/organization/${orgId}/locations/${locId}`, body);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
else if (resource === 'backup') {
|
|
540
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
541
|
+
const qs = {};
|
|
542
|
+
if (filters.cursor)
|
|
543
|
+
qs.cursor = filters.cursor;
|
|
544
|
+
if (filters.df)
|
|
545
|
+
qs.df = filters.df;
|
|
546
|
+
if (filters.pageSize)
|
|
547
|
+
qs.pageSize = filters.pageSize;
|
|
548
|
+
if (filters.planType)
|
|
549
|
+
qs.planType = filters.planType;
|
|
550
|
+
if (filters.status)
|
|
551
|
+
qs.status = filters.status;
|
|
552
|
+
if (filters.includeDeletedDevices)
|
|
553
|
+
qs.includeDeletedDevices = filters.includeDeletedDevices;
|
|
554
|
+
if (operation === 'getBackupJobs') {
|
|
555
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/backup/jobs', {}, qs);
|
|
556
|
+
}
|
|
557
|
+
else if (operation === 'getIntegrityCheck') {
|
|
558
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/backup/integrity-check-jobs', {}, qs);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
else if (resource === 'webhook') {
|
|
562
|
+
if (operation === 'configure') {
|
|
563
|
+
const url = this.getNodeParameter('webhookUrl', i);
|
|
564
|
+
const types = this.getNodeParameter('activityTypes', i, '');
|
|
565
|
+
const body = { url };
|
|
566
|
+
if (types)
|
|
567
|
+
body.activityTypes = types.split(',').map((t) => t.trim());
|
|
568
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PUT', '/api/v2/webhook', body);
|
|
569
|
+
}
|
|
570
|
+
else if (operation === 'delete') {
|
|
571
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', '/api/v2/webhook');
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
else if (resource === 'customField') {
|
|
575
|
+
if (operation === 'getDeviceFields') {
|
|
576
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
577
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/device/${id}/custom-fields`);
|
|
578
|
+
}
|
|
579
|
+
else if (operation === 'getOrgFields') {
|
|
580
|
+
const id = this.getNodeParameter('organizationId', i);
|
|
581
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/organization/${id}/custom-fields`);
|
|
582
|
+
}
|
|
583
|
+
else if (operation === 'updateDeviceFields') {
|
|
584
|
+
const id = this.getNodeParameter('deviceId', i);
|
|
585
|
+
const fields = this.getNodeParameter('customFieldsJson', i);
|
|
586
|
+
const body = typeof fields === 'string' ? JSON.parse(fields) : fields;
|
|
587
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PATCH', `/api/v2/device/${id}/custom-fields`, body);
|
|
588
|
+
}
|
|
589
|
+
else if (operation === 'updateOrgFields') {
|
|
590
|
+
const id = this.getNodeParameter('organizationId', i);
|
|
591
|
+
const fields = this.getNodeParameter('customFieldsJson', i);
|
|
592
|
+
const body = typeof fields === 'string' ? JSON.parse(fields) : fields;
|
|
593
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PATCH', `/api/v2/organization/${id}/custom-fields`, body);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
else if (resource === 'knowledgeBase') {
|
|
597
|
+
if (operation === 'getAll') {
|
|
598
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
599
|
+
if (returnAll) {
|
|
600
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequestAllItems.call(this, 'GET', '/api/v2/knowledgebase/global/articles');
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
const limit = this.getNodeParameter('limit', i);
|
|
604
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/knowledgebase/global/articles', {}, { pageSize: limit });
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
else if (operation === 'get') {
|
|
608
|
+
const id = this.getNodeParameter('articleId', i);
|
|
609
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/knowledgebase/article/${id}`);
|
|
610
|
+
}
|
|
611
|
+
else if (operation === 'create') {
|
|
612
|
+
const body = { title: this.getNodeParameter('title', i), content: this.getNodeParameter('content', i) };
|
|
613
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', '/api/v2/knowledgebase/articles', body);
|
|
614
|
+
}
|
|
615
|
+
else if (operation === 'update') {
|
|
616
|
+
const id = this.getNodeParameter('articleId', i);
|
|
617
|
+
const fields = this.getNodeParameter('updateFields', i);
|
|
618
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PUT', `/api/v2/knowledgebase/article/${id}`, fields);
|
|
619
|
+
}
|
|
620
|
+
else if (operation === 'delete') {
|
|
621
|
+
const id = this.getNodeParameter('articleId', i);
|
|
622
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', `/api/v2/knowledgebase/article/${id}`);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
else if (resource === 'orgDocument') {
|
|
626
|
+
const orgId = this.getNodeParameter('organizationId', i);
|
|
627
|
+
if (operation === 'getAll') {
|
|
628
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
629
|
+
if (returnAll) {
|
|
630
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequestAllItems.call(this, 'GET', `/api/v2/organization/${orgId}/documents`);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
const limit = this.getNodeParameter('limit', i);
|
|
634
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/organization/${orgId}/documents`, {}, { pageSize: limit });
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
else if (operation === 'get') {
|
|
638
|
+
const docId = this.getNodeParameter('documentId', i);
|
|
639
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/organization/${orgId}/document/${docId}`);
|
|
640
|
+
}
|
|
641
|
+
else if (operation === 'create') {
|
|
642
|
+
const templateId = this.getNodeParameter('documentTemplateId', i);
|
|
643
|
+
const fieldsJson = this.getNodeParameter('fieldsJson', i);
|
|
644
|
+
const fields = typeof fieldsJson === 'string' ? JSON.parse(fieldsJson) : fieldsJson;
|
|
645
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/organization/${orgId}/template/${templateId}/document`, { fields });
|
|
646
|
+
}
|
|
647
|
+
else if (operation === 'update') {
|
|
648
|
+
const docId = this.getNodeParameter('documentId', i);
|
|
649
|
+
const fieldsJson = this.getNodeParameter('fieldsJson', i);
|
|
650
|
+
const fields = typeof fieldsJson === 'string' ? JSON.parse(fieldsJson) : fieldsJson;
|
|
651
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'PATCH', `/api/v2/organization/${orgId}/document/${docId}`, { fields });
|
|
652
|
+
}
|
|
653
|
+
else if (operation === 'delete') {
|
|
654
|
+
const docId = this.getNodeParameter('documentId', i);
|
|
655
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', `/api/v2/organization/${orgId}/document/${docId}`);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
else if (resource === 'docTemplate') {
|
|
659
|
+
if (operation === 'getAll') {
|
|
660
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
661
|
+
if (returnAll) {
|
|
662
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequestAllItems.call(this, 'GET', '/api/v2/document-templates');
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
const limit = this.getNodeParameter('limit', i);
|
|
666
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', '/api/v2/document-templates', {}, { pageSize: limit });
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
else if (operation === 'get') {
|
|
670
|
+
const id = this.getNodeParameter('templateId', i);
|
|
671
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/document-templates/${id}`);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
else if (resource === 'relatedItem') {
|
|
675
|
+
const entityType = this.getNodeParameter('entityType', i);
|
|
676
|
+
const entityId = this.getNodeParameter('entityId', i);
|
|
677
|
+
if (operation === 'getAll') {
|
|
678
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'GET', `/api/v2/related-items/${entityType}/${entityId}`);
|
|
679
|
+
}
|
|
680
|
+
else if (operation === 'create') {
|
|
681
|
+
const relType = this.getNodeParameter('relatedEntityType', i);
|
|
682
|
+
const relId = this.getNodeParameter('relatedEntityId', i);
|
|
683
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'POST', `/api/v2/related-items/${entityType}/${entityId}`, { relEntityType: relType, relEntityId: relId });
|
|
684
|
+
}
|
|
685
|
+
else if (operation === 'delete') {
|
|
686
|
+
const relationId = this.getNodeParameter('relationId', i);
|
|
687
|
+
responseData = await GenericFunctions_1.ninjaOneApiRequest.call(this, 'DELETE', `/api/v2/related-items/${entityType}/${entityId}/${relationId}`);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
// Normalize output
|
|
691
|
+
if (Array.isArray(responseData)) {
|
|
692
|
+
returnData.push(...(0, GenericFunctions_1.toItems)(responseData));
|
|
693
|
+
}
|
|
694
|
+
else if (responseData !== undefined && responseData !== null) {
|
|
695
|
+
returnData.push({ json: responseData });
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
returnData.push({ json: { success: true } });
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
catch (error) {
|
|
702
|
+
if (this.continueOnFail()) {
|
|
703
|
+
returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
throw error;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return [returnData];
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
exports.NinjaOne = NinjaOne;
|
|
713
|
+
//# sourceMappingURL=NinjaOne.node.js.map
|