n8n-nodes-arubaclearpass 1.0.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/credentials/ClearPassApi.credentials.d.ts +7 -0
- package/dist/credentials/ClearPassApi.credentials.js +69 -0
- package/dist/credentials/ClearPassOAuth2Api.credentials.d.ts +10 -0
- package/dist/credentials/ClearPassOAuth2Api.credentials.js +55 -0
- package/dist/nodes/ArubaCentral/clearpass.svg +4 -0
- package/dist/nodes/ArubaClearPass/ArubaClearPass.node.d.ts +5 -0
- package/dist/nodes/ArubaClearPass/ArubaClearPass.node.js +173 -0
- package/dist/nodes/ArubaClearPass/descriptions/EnforcementProfile/EnforcementProfile.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/EnforcementProfile/EnforcementProfile.descriptions.js +361 -0
- package/dist/nodes/ArubaClearPass/descriptions/EnforcementProfile/index.d.ts +2 -0
- package/dist/nodes/ArubaClearPass/descriptions/EnforcementProfile/index.js +11 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/ApiClient.descriptions.d.ts +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/ApiClient.descriptions.js +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/DenyListedUsers.descriptions.d.ts +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/DenyListedUsers.descriptions.js +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/Device.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/Device.descriptions.js +668 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/Endpoint.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/Endpoint.descriptions.js +255 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/ExternalAccount.descriptions.d.ts +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/ExternalAccount.descriptions.js +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/GuestUser.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/GuestUser.descriptions.js +477 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/LocalUser.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/LocalUser.descriptions.js +384 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/StaticHostList.descriptions.d.ts +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/StaticHostList.descriptions.js +0 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/index.d.ts +2 -0
- package/dist/nodes/ArubaClearPass/descriptions/Identities/index.js +23 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/EnforcementPolicy.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/EnforcementPolicy.descriptions.js +432 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/Role.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/Role.descriptions.js +263 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/RoleMapping.descriptions.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/RoleMapping.descriptions.js +365 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/index.d.ts +2 -0
- package/dist/nodes/ArubaClearPass/descriptions/PolicyElements/index.js +19 -0
- package/dist/nodes/ArubaClearPass/helpers/apiRequest.d.ts +9 -0
- package/dist/nodes/ArubaClearPass/helpers/apiRequest.js +72 -0
- package/dist/nodes/ArubaClearPass/helpers/errorHandler.d.ts +4 -0
- package/dist/nodes/ArubaClearPass/helpers/errorHandler.js +31 -0
- package/dist/nodes/ArubaClearPass/helpers/executeOperation.d.ts +5 -0
- package/dist/nodes/ArubaClearPass/helpers/executeOperation.js +164 -0
- package/dist/nodes/ArubaClearPass/helpers/responseFormatter.d.ts +5 -0
- package/dist/nodes/ArubaClearPass/helpers/responseFormatter.js +17 -0
- package/dist/nodes/ArubaClearPass/helpers/tokenManager.d.ts +5 -0
- package/dist/nodes/ArubaClearPass/helpers/tokenManager.js +63 -0
- package/dist/nodes/ArubaClearPass/methods/EnforcementProfile/EnforcementProfile.methods.d.ts +41 -0
- package/dist/nodes/ArubaClearPass/methods/EnforcementProfile/EnforcementProfile.methods.js +395 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/Device.methods.d.ts +41 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/Device.methods.js +409 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/Endpoint.methods.d.ts +33 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/Endpoint.methods.js +212 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/GuestUser.methods.d.ts +41 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/GuestUser.methods.js +589 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/LocalUser.methods.d.ts +41 -0
- package/dist/nodes/ArubaClearPass/methods/Identities/LocalUser.methods.js +407 -0
- package/dist/nodes/ArubaClearPass/methods/PolicyElements/EnforcementPolicy.methods.d.ts +41 -0
- package/dist/nodes/ArubaClearPass/methods/PolicyElements/EnforcementPolicy.methods.js +361 -0
- package/dist/nodes/ArubaClearPass/methods/PolicyElements/Role.methods.d.ts +41 -0
- package/dist/nodes/ArubaClearPass/methods/PolicyElements/Role.methods.js +298 -0
- package/dist/nodes/ArubaClearPass/methods/PolicyElements/RoleMapping.methods.d.ts +41 -0
- package/dist/nodes/ArubaClearPass/methods/PolicyElements/RoleMapping.methods.js +358 -0
- package/dist/nodes/ArubaClearPass/types/EnforcementProfile/EnforcementProfile.types.d.ts +131 -0
- package/dist/nodes/ArubaClearPass/types/EnforcementProfile/EnforcementProfile.types.js +2 -0
- package/dist/nodes/ArubaClearPass/types/Identities/Device.types.d.ts +55 -0
- package/dist/nodes/ArubaClearPass/types/Identities/Device.types.js +2 -0
- package/dist/nodes/ArubaClearPass/types/Identities/Endpoint.types.d.ts +12 -0
- package/dist/nodes/ArubaClearPass/types/Identities/Endpoint.types.js +2 -0
- package/dist/nodes/ArubaClearPass/types/Identities/GuestUser.types.d.ts +31 -0
- package/dist/nodes/ArubaClearPass/types/Identities/GuestUser.types.js +2 -0
- package/dist/nodes/ArubaClearPass/types/Identities/LocalUser.types.d.ts +51 -0
- package/dist/nodes/ArubaClearPass/types/Identities/LocalUser.types.js +2 -0
- package/dist/nodes/ArubaClearPass/types/PolicyElements/EnforcementPolicy.types.d.ts +37 -0
- package/dist/nodes/ArubaClearPass/types/PolicyElements/EnforcementPolicy.types.js +2 -0
- package/dist/nodes/ArubaClearPass/types/PolicyElements/Role.types.d.ts +15 -0
- package/dist/nodes/ArubaClearPass/types/PolicyElements/Role.types.js +2 -0
- package/dist/nodes/ArubaClearPass/types/PolicyElements/RoleMapping.types.d.ts +63 -0
- package/dist/nodes/ArubaClearPass/types/PolicyElements/RoleMapping.types.js +2 -0
- package/package.json +72 -0
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listGuestUsers = listGuestUsers;
|
|
4
|
+
exports.getGuestUser = getGuestUser;
|
|
5
|
+
exports.getGuestUserByUsername = getGuestUserByUsername;
|
|
6
|
+
exports.createGuestUser = createGuestUser;
|
|
7
|
+
exports.updateGuestUser = updateGuestUser;
|
|
8
|
+
exports.updateGuestUserByUsername = updateGuestUserByUsername;
|
|
9
|
+
exports.replaceGuestUser = replaceGuestUser;
|
|
10
|
+
exports.replaceGuestUserByUsername = replaceGuestUserByUsername;
|
|
11
|
+
exports.deleteGuestUser = deleteGuestUser;
|
|
12
|
+
exports.deleteGuestUserByUsername = deleteGuestUserByUsername;
|
|
13
|
+
// methods/Identities/GuestUser.methods.ts
|
|
14
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
15
|
+
const apiRequest_1 = require("../../helpers/apiRequest");
|
|
16
|
+
const responseFormatter_1 = require("../../helpers/responseFormatter");
|
|
17
|
+
/**
|
|
18
|
+
* Get a list of all guest accounts
|
|
19
|
+
*/
|
|
20
|
+
async function listGuestUsers() {
|
|
21
|
+
try {
|
|
22
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
23
|
+
const filters = this.getNodeParameter('filters', 0, {});
|
|
24
|
+
const endpoint = '/guest';
|
|
25
|
+
let responseData;
|
|
26
|
+
if (returnAll) {
|
|
27
|
+
responseData = await apiRequest_1.apiRequestAllItems.call(this, 'GET', endpoint, {}, filters);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const limit = this.getNodeParameter('limit', 0);
|
|
31
|
+
if (!filters.limit) {
|
|
32
|
+
filters.limit = limit;
|
|
33
|
+
}
|
|
34
|
+
responseData = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, filters);
|
|
35
|
+
}
|
|
36
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const errorObject = {};
|
|
40
|
+
if (error instanceof Error) {
|
|
41
|
+
errorObject.message = error.message;
|
|
42
|
+
if (error.stack) {
|
|
43
|
+
errorObject.stackTrace = error.stack;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
errorObject.message = 'Unknown error in listGuestUsers';
|
|
48
|
+
}
|
|
49
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get a guest account by ID
|
|
54
|
+
*/
|
|
55
|
+
async function getGuestUser() {
|
|
56
|
+
try {
|
|
57
|
+
const guestUserId = this.getNodeParameter('guestUserId', 0);
|
|
58
|
+
const endpoint = `/guest/${guestUserId}`;
|
|
59
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'GET', endpoint);
|
|
60
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const errorObject = {};
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
errorObject.message = error.message;
|
|
66
|
+
if (error.stack) {
|
|
67
|
+
errorObject.stackTrace = error.stack;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
errorObject.message = 'Unknown error in getGuestUser';
|
|
72
|
+
}
|
|
73
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get a guest account by username
|
|
78
|
+
*/
|
|
79
|
+
async function getGuestUserByUsername() {
|
|
80
|
+
try {
|
|
81
|
+
const username = this.getNodeParameter('username', 0);
|
|
82
|
+
const endpoint = `/guest/username/${username}`;
|
|
83
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'GET', endpoint);
|
|
84
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const errorObject = {};
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
errorObject.message = error.message;
|
|
90
|
+
if (error.stack) {
|
|
91
|
+
errorObject.stackTrace = error.stack;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
errorObject.message = 'Unknown error in getGuestUserByUsername';
|
|
96
|
+
}
|
|
97
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a new guest user account
|
|
102
|
+
*/
|
|
103
|
+
async function createGuestUser() {
|
|
104
|
+
try {
|
|
105
|
+
const body = {};
|
|
106
|
+
// Required parameters
|
|
107
|
+
body.username = this.getNodeParameter('username', 0);
|
|
108
|
+
body.password = this.getNodeParameter('password', 0);
|
|
109
|
+
body.role_id = this.getNodeParameter('roleId', 0);
|
|
110
|
+
body.sponsor_name = this.getNodeParameter('sponsorName', 0);
|
|
111
|
+
body.sponsor_profile = this.getNodeParameter('sponsorProfile', 0);
|
|
112
|
+
body.enabled = this.getNodeParameter('enabled', 0);
|
|
113
|
+
body.start_time = this.getNodeParameter('startTime', 0);
|
|
114
|
+
body.expire_time = this.getNodeParameter('expireTime', 0);
|
|
115
|
+
// Optional parameters from additionalFields
|
|
116
|
+
const additionalFields = this.getNodeParameter('additionalFields', 0, {});
|
|
117
|
+
if (additionalFields.email) {
|
|
118
|
+
body.email = additionalFields.email;
|
|
119
|
+
}
|
|
120
|
+
if (additionalFields.mac) {
|
|
121
|
+
body.mac = additionalFields.mac;
|
|
122
|
+
}
|
|
123
|
+
if (additionalFields.notes) {
|
|
124
|
+
body.notes = additionalFields.notes;
|
|
125
|
+
}
|
|
126
|
+
if (additionalFields.simultaneous_use !== undefined) {
|
|
127
|
+
body.simultaneous_use = additionalFields.simultaneous_use;
|
|
128
|
+
}
|
|
129
|
+
if (additionalFields.do_expire !== undefined) {
|
|
130
|
+
body.do_expire = additionalFields.do_expire;
|
|
131
|
+
}
|
|
132
|
+
if (additionalFields.sponsor_email) {
|
|
133
|
+
body.sponsor_email = additionalFields.sponsor_email;
|
|
134
|
+
}
|
|
135
|
+
if (additionalFields.visitor_name) {
|
|
136
|
+
body.visitor_name = additionalFields.visitor_name;
|
|
137
|
+
}
|
|
138
|
+
if (additionalFields.visitor_company) {
|
|
139
|
+
body.visitor_company = additionalFields.visitor_company;
|
|
140
|
+
}
|
|
141
|
+
if (additionalFields.visitor_phone) {
|
|
142
|
+
body.visitor_phone = additionalFields.visitor_phone;
|
|
143
|
+
}
|
|
144
|
+
// Handle custom fields as JSON
|
|
145
|
+
if (additionalFields.customFields) {
|
|
146
|
+
try {
|
|
147
|
+
const customFieldsJson = additionalFields.customFields;
|
|
148
|
+
const customFields = JSON.parse(customFieldsJson);
|
|
149
|
+
// Add each custom field to the body
|
|
150
|
+
for (const key of Object.keys(customFields)) {
|
|
151
|
+
body[key] = customFields[key];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (jsonError) {
|
|
155
|
+
const errorObject = {};
|
|
156
|
+
errorObject.message = `Invalid JSON in customFields: ${jsonError.message}`;
|
|
157
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Query parameter for change of authorization
|
|
161
|
+
const qs = {};
|
|
162
|
+
const changeOfAuthorization = this.getNodeParameter('changeOfAuthorization', 0);
|
|
163
|
+
if (changeOfAuthorization) {
|
|
164
|
+
qs.change_of_authorization = 'true';
|
|
165
|
+
}
|
|
166
|
+
const endpoint = '/guest';
|
|
167
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, body, qs);
|
|
168
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const errorObject = {};
|
|
172
|
+
if (error instanceof Error) {
|
|
173
|
+
errorObject.message = error.message;
|
|
174
|
+
if (error.stack) {
|
|
175
|
+
errorObject.stackTrace = error.stack;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
errorObject.message = 'Unknown error in createGuestUser';
|
|
180
|
+
}
|
|
181
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Update a guest user account
|
|
186
|
+
*/
|
|
187
|
+
async function updateGuestUser() {
|
|
188
|
+
try {
|
|
189
|
+
const guestUserId = this.getNodeParameter('guestUserId', 0);
|
|
190
|
+
const body = {};
|
|
191
|
+
// Check if password should be updated
|
|
192
|
+
const updatePassword = this.getNodeParameter('updatePassword', 0);
|
|
193
|
+
if (updatePassword) {
|
|
194
|
+
body.password = this.getNodeParameter('password', 0);
|
|
195
|
+
}
|
|
196
|
+
// Check if role should be updated
|
|
197
|
+
const updateRole = this.getNodeParameter('updateRole', 0);
|
|
198
|
+
if (updateRole) {
|
|
199
|
+
body.role_id = this.getNodeParameter('roleId', 0);
|
|
200
|
+
}
|
|
201
|
+
// Get optional parameters
|
|
202
|
+
const additionalFields = this.getNodeParameter('additionalFields', 0, {});
|
|
203
|
+
// Optional string fields
|
|
204
|
+
const stringFields = [
|
|
205
|
+
'email',
|
|
206
|
+
'mac',
|
|
207
|
+
'notes',
|
|
208
|
+
'sponsor_email',
|
|
209
|
+
'visitor_name',
|
|
210
|
+
'visitor_company',
|
|
211
|
+
'visitor_phone',
|
|
212
|
+
'sponsor_name',
|
|
213
|
+
'sponsor_profile',
|
|
214
|
+
];
|
|
215
|
+
stringFields.forEach((field) => {
|
|
216
|
+
if (additionalFields[field] !== undefined) {
|
|
217
|
+
body[field] = additionalFields[field];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
// Optional numeric/boolean fields
|
|
221
|
+
if (additionalFields.simultaneous_use !== undefined) {
|
|
222
|
+
body.simultaneous_use = additionalFields.simultaneous_use;
|
|
223
|
+
}
|
|
224
|
+
if (additionalFields.do_expire !== undefined) {
|
|
225
|
+
body.do_expire = additionalFields.do_expire;
|
|
226
|
+
}
|
|
227
|
+
if (additionalFields.enabled !== undefined) {
|
|
228
|
+
body.enabled = additionalFields.enabled;
|
|
229
|
+
}
|
|
230
|
+
// Optional date fields
|
|
231
|
+
if (additionalFields.start_time !== undefined) {
|
|
232
|
+
body.start_time = additionalFields.start_time;
|
|
233
|
+
}
|
|
234
|
+
if (additionalFields.expire_time !== undefined) {
|
|
235
|
+
body.expire_time = additionalFields.expire_time;
|
|
236
|
+
}
|
|
237
|
+
// Handle custom fields as JSON
|
|
238
|
+
if (additionalFields.customFields) {
|
|
239
|
+
try {
|
|
240
|
+
const customFieldsJson = additionalFields.customFields;
|
|
241
|
+
const customFields = JSON.parse(customFieldsJson);
|
|
242
|
+
// Add each custom field to the body
|
|
243
|
+
for (const key of Object.keys(customFields)) {
|
|
244
|
+
body[key] = customFields[key];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (jsonError) {
|
|
248
|
+
const errorObject = {};
|
|
249
|
+
errorObject.message = `Invalid JSON in customFields: ${jsonError.message}`;
|
|
250
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// Query parameter for change of authorization
|
|
254
|
+
const qs = {};
|
|
255
|
+
const changeOfAuthorization = this.getNodeParameter('changeOfAuthorization', 0);
|
|
256
|
+
if (changeOfAuthorization) {
|
|
257
|
+
qs.change_of_authorization = 'true';
|
|
258
|
+
}
|
|
259
|
+
const endpoint = `/guest/${guestUserId}`;
|
|
260
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, body, qs);
|
|
261
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
const errorObject = {};
|
|
265
|
+
if (error instanceof Error) {
|
|
266
|
+
errorObject.message = error.message;
|
|
267
|
+
if (error.stack) {
|
|
268
|
+
errorObject.stackTrace = error.stack;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
errorObject.message = 'Unknown error in updateGuestUser';
|
|
273
|
+
}
|
|
274
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Update a guest user account by username
|
|
279
|
+
*/
|
|
280
|
+
async function updateGuestUserByUsername() {
|
|
281
|
+
try {
|
|
282
|
+
const username = this.getNodeParameter('username', 0);
|
|
283
|
+
const body = {};
|
|
284
|
+
// Check if password should be updated
|
|
285
|
+
const updatePassword = this.getNodeParameter('updatePassword', 0);
|
|
286
|
+
if (updatePassword) {
|
|
287
|
+
body.password = this.getNodeParameter('password', 0);
|
|
288
|
+
}
|
|
289
|
+
// Check if role should be updated
|
|
290
|
+
const updateRole = this.getNodeParameter('updateRole', 0);
|
|
291
|
+
if (updateRole) {
|
|
292
|
+
body.role_id = this.getNodeParameter('roleId', 0);
|
|
293
|
+
}
|
|
294
|
+
// Get optional parameters
|
|
295
|
+
const additionalFields = this.getNodeParameter('additionalFields', 0, {});
|
|
296
|
+
// Optional string fields
|
|
297
|
+
const stringFields = [
|
|
298
|
+
'email',
|
|
299
|
+
'mac',
|
|
300
|
+
'notes',
|
|
301
|
+
'sponsor_email',
|
|
302
|
+
'visitor_name',
|
|
303
|
+
'visitor_company',
|
|
304
|
+
'visitor_phone',
|
|
305
|
+
'sponsor_name',
|
|
306
|
+
'sponsor_profile',
|
|
307
|
+
];
|
|
308
|
+
stringFields.forEach((field) => {
|
|
309
|
+
if (additionalFields[field] !== undefined) {
|
|
310
|
+
body[field] = additionalFields[field];
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
// Optional numeric/boolean fields
|
|
314
|
+
if (additionalFields.simultaneous_use !== undefined) {
|
|
315
|
+
body.simultaneous_use = additionalFields.simultaneous_use;
|
|
316
|
+
}
|
|
317
|
+
if (additionalFields.do_expire !== undefined) {
|
|
318
|
+
body.do_expire = additionalFields.do_expire;
|
|
319
|
+
}
|
|
320
|
+
if (additionalFields.enabled !== undefined) {
|
|
321
|
+
body.enabled = additionalFields.enabled;
|
|
322
|
+
}
|
|
323
|
+
// Optional date fields
|
|
324
|
+
if (additionalFields.start_time !== undefined) {
|
|
325
|
+
body.start_time = additionalFields.start_time;
|
|
326
|
+
}
|
|
327
|
+
if (additionalFields.expire_time !== undefined) {
|
|
328
|
+
body.expire_time = additionalFields.expire_time;
|
|
329
|
+
}
|
|
330
|
+
// Handle custom fields as JSON
|
|
331
|
+
if (additionalFields.customFields) {
|
|
332
|
+
try {
|
|
333
|
+
const customFieldsJson = additionalFields.customFields;
|
|
334
|
+
const customFields = JSON.parse(customFieldsJson);
|
|
335
|
+
// Add each custom field to the body
|
|
336
|
+
for (const key of Object.keys(customFields)) {
|
|
337
|
+
body[key] = customFields[key];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
catch (jsonError) {
|
|
341
|
+
const errorObject = {};
|
|
342
|
+
errorObject.message = `Invalid JSON in customFields: ${jsonError.message}`;
|
|
343
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Query parameter for change of authorization
|
|
347
|
+
const qs = {};
|
|
348
|
+
const changeOfAuthorization = this.getNodeParameter('changeOfAuthorization', 0);
|
|
349
|
+
if (changeOfAuthorization) {
|
|
350
|
+
qs.change_of_authorization = 'true';
|
|
351
|
+
}
|
|
352
|
+
const endpoint = `/guest/username/${username}`;
|
|
353
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, body, qs);
|
|
354
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
const errorObject = {};
|
|
358
|
+
if (error instanceof Error) {
|
|
359
|
+
errorObject.message = error.message;
|
|
360
|
+
if (error.stack) {
|
|
361
|
+
errorObject.stackTrace = error.stack;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
errorObject.message = 'Unknown error in updateGuestUserByUsername';
|
|
366
|
+
}
|
|
367
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Replace a guest user account
|
|
372
|
+
*/
|
|
373
|
+
async function replaceGuestUser() {
|
|
374
|
+
try {
|
|
375
|
+
const guestUserId = this.getNodeParameter('guestUserId', 0);
|
|
376
|
+
const body = {};
|
|
377
|
+
// Required parameters
|
|
378
|
+
body.password = this.getNodeParameter('password', 0);
|
|
379
|
+
body.role_id = this.getNodeParameter('roleId', 0);
|
|
380
|
+
body.sponsor_name = this.getNodeParameter('sponsorName', 0);
|
|
381
|
+
body.sponsor_profile = this.getNodeParameter('sponsorProfile', 0);
|
|
382
|
+
body.enabled = this.getNodeParameter('enabled', 0);
|
|
383
|
+
body.start_time = this.getNodeParameter('startTime', 0);
|
|
384
|
+
body.expire_time = this.getNodeParameter('expireTime', 0);
|
|
385
|
+
// Optional parameters from additionalFields
|
|
386
|
+
const additionalFields = this.getNodeParameter('additionalFields', 0, {});
|
|
387
|
+
// Optional string fields
|
|
388
|
+
const stringFields = [
|
|
389
|
+
'email',
|
|
390
|
+
'mac',
|
|
391
|
+
'notes',
|
|
392
|
+
'sponsor_email',
|
|
393
|
+
'visitor_name',
|
|
394
|
+
'visitor_company',
|
|
395
|
+
'visitor_phone',
|
|
396
|
+
'username',
|
|
397
|
+
];
|
|
398
|
+
stringFields.forEach((field) => {
|
|
399
|
+
if (additionalFields[field] !== undefined) {
|
|
400
|
+
body[field] = additionalFields[field];
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
// Optional numeric fields
|
|
404
|
+
if (additionalFields.simultaneous_use !== undefined) {
|
|
405
|
+
body.simultaneous_use = additionalFields.simultaneous_use;
|
|
406
|
+
}
|
|
407
|
+
if (additionalFields.do_expire !== undefined) {
|
|
408
|
+
body.do_expire = additionalFields.do_expire;
|
|
409
|
+
}
|
|
410
|
+
// Handle custom fields as JSON
|
|
411
|
+
if (additionalFields.customFields) {
|
|
412
|
+
try {
|
|
413
|
+
const customFieldsJson = additionalFields.customFields;
|
|
414
|
+
const customFields = JSON.parse(customFieldsJson);
|
|
415
|
+
// Add each custom field to the body
|
|
416
|
+
for (const key of Object.keys(customFields)) {
|
|
417
|
+
body[key] = customFields[key];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
catch (jsonError) {
|
|
421
|
+
const errorObject = {};
|
|
422
|
+
errorObject.message = `Invalid JSON in customFields: ${jsonError.message}`;
|
|
423
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// Query parameter for change of authorization
|
|
427
|
+
const qs = {};
|
|
428
|
+
const changeOfAuthorization = this.getNodeParameter('changeOfAuthorization', 0);
|
|
429
|
+
if (changeOfAuthorization) {
|
|
430
|
+
qs.change_of_authorization = 'true';
|
|
431
|
+
}
|
|
432
|
+
const endpoint = `/guest/${guestUserId}`;
|
|
433
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PUT', endpoint, body, qs);
|
|
434
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
const errorObject = {};
|
|
438
|
+
if (error instanceof Error) {
|
|
439
|
+
errorObject.message = error.message;
|
|
440
|
+
if (error.stack) {
|
|
441
|
+
errorObject.stackTrace = error.stack;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
errorObject.message = 'Unknown error in replaceGuestUser';
|
|
446
|
+
}
|
|
447
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Replace a guest user account by username
|
|
452
|
+
*/
|
|
453
|
+
async function replaceGuestUserByUsername() {
|
|
454
|
+
try {
|
|
455
|
+
const username = this.getNodeParameter('username', 0);
|
|
456
|
+
const body = {};
|
|
457
|
+
// Required parameters
|
|
458
|
+
body.username = username;
|
|
459
|
+
body.password = this.getNodeParameter('password', 0);
|
|
460
|
+
body.role_id = this.getNodeParameter('roleId', 0);
|
|
461
|
+
body.sponsor_name = this.getNodeParameter('sponsorName', 0);
|
|
462
|
+
body.sponsor_profile = this.getNodeParameter('sponsorProfile', 0);
|
|
463
|
+
body.enabled = this.getNodeParameter('enabled', 0);
|
|
464
|
+
body.start_time = this.getNodeParameter('startTime', 0);
|
|
465
|
+
body.expire_time = this.getNodeParameter('expireTime', 0);
|
|
466
|
+
// Optional parameters from additionalFields
|
|
467
|
+
const additionalFields = this.getNodeParameter('additionalFields', 0, {});
|
|
468
|
+
// Optional string fields
|
|
469
|
+
const stringFields = [
|
|
470
|
+
'email',
|
|
471
|
+
'mac',
|
|
472
|
+
'notes',
|
|
473
|
+
'sponsor_email',
|
|
474
|
+
'visitor_name',
|
|
475
|
+
'visitor_company',
|
|
476
|
+
'visitor_phone',
|
|
477
|
+
];
|
|
478
|
+
stringFields.forEach((field) => {
|
|
479
|
+
if (additionalFields[field] !== undefined) {
|
|
480
|
+
body[field] = additionalFields[field];
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
// Optional numeric fields
|
|
484
|
+
if (additionalFields.simultaneous_use !== undefined) {
|
|
485
|
+
body.simultaneous_use = additionalFields.simultaneous_use;
|
|
486
|
+
}
|
|
487
|
+
if (additionalFields.do_expire !== undefined) {
|
|
488
|
+
body.do_expire = additionalFields.do_expire;
|
|
489
|
+
}
|
|
490
|
+
// Handle custom fields as JSON
|
|
491
|
+
if (additionalFields.customFields) {
|
|
492
|
+
try {
|
|
493
|
+
const customFieldsJson = additionalFields.customFields;
|
|
494
|
+
const customFields = JSON.parse(customFieldsJson);
|
|
495
|
+
// Add each custom field to the body
|
|
496
|
+
for (const key of Object.keys(customFields)) {
|
|
497
|
+
body[key] = customFields[key];
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
catch (jsonError) {
|
|
501
|
+
const errorObject = {};
|
|
502
|
+
errorObject.message = `Invalid JSON in customFields: ${jsonError.message}`;
|
|
503
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
// Query parameter for change of authorization
|
|
507
|
+
const qs = {};
|
|
508
|
+
const changeOfAuthorization = this.getNodeParameter('changeOfAuthorization', 0);
|
|
509
|
+
if (changeOfAuthorization) {
|
|
510
|
+
qs.change_of_authorization = 'true';
|
|
511
|
+
}
|
|
512
|
+
const endpoint = `/guest/username/${username}`;
|
|
513
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PUT', endpoint, body, qs);
|
|
514
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
const errorObject = {};
|
|
518
|
+
if (error instanceof Error) {
|
|
519
|
+
errorObject.message = error.message;
|
|
520
|
+
if (error.stack) {
|
|
521
|
+
errorObject.stackTrace = error.stack;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
errorObject.message = 'Unknown error in replaceGuestUserByUsername';
|
|
526
|
+
}
|
|
527
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Delete a guest user account
|
|
532
|
+
*/
|
|
533
|
+
async function deleteGuestUser() {
|
|
534
|
+
try {
|
|
535
|
+
const guestUserId = this.getNodeParameter('guestUserId', 0);
|
|
536
|
+
// Query parameter for change of authorization
|
|
537
|
+
const qs = {};
|
|
538
|
+
const changeOfAuthorization = this.getNodeParameter('changeOfAuthorization', 0);
|
|
539
|
+
if (changeOfAuthorization) {
|
|
540
|
+
qs.change_of_authorization = 'true';
|
|
541
|
+
}
|
|
542
|
+
const endpoint = `/guest/${guestUserId}`;
|
|
543
|
+
await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, qs);
|
|
544
|
+
return [{ json: { success: true } }];
|
|
545
|
+
}
|
|
546
|
+
catch (error) {
|
|
547
|
+
const errorObject = {};
|
|
548
|
+
if (error instanceof Error) {
|
|
549
|
+
errorObject.message = error.message;
|
|
550
|
+
if (error.stack) {
|
|
551
|
+
errorObject.stackTrace = error.stack;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
errorObject.message = 'Unknown error in deleteGuestUser';
|
|
556
|
+
}
|
|
557
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Delete a guest user account by username
|
|
562
|
+
*/
|
|
563
|
+
async function deleteGuestUserByUsername() {
|
|
564
|
+
try {
|
|
565
|
+
const username = this.getNodeParameter('username', 0);
|
|
566
|
+
// Query parameter for change of authorization
|
|
567
|
+
const qs = {};
|
|
568
|
+
const changeOfAuthorization = this.getNodeParameter('changeOfAuthorization', 0);
|
|
569
|
+
if (changeOfAuthorization) {
|
|
570
|
+
qs.change_of_authorization = 'true';
|
|
571
|
+
}
|
|
572
|
+
const endpoint = `/guest/username/${username}`;
|
|
573
|
+
await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, qs);
|
|
574
|
+
return [{ json: { success: true } }];
|
|
575
|
+
}
|
|
576
|
+
catch (error) {
|
|
577
|
+
const errorObject = {};
|
|
578
|
+
if (error instanceof Error) {
|
|
579
|
+
errorObject.message = error.message;
|
|
580
|
+
if (error.stack) {
|
|
581
|
+
errorObject.stackTrace = error.stack;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
errorObject.message = 'Unknown error in deleteGuestUserByUsername';
|
|
586
|
+
}
|
|
587
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Get a list of all local users
|
|
4
|
+
*/
|
|
5
|
+
export declare function listLocalUsers(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Get a local user by ID
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLocalUser(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Get a local user by User ID
|
|
12
|
+
*/
|
|
13
|
+
export declare function getLocalUserByUserId(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new local user
|
|
16
|
+
*/
|
|
17
|
+
export declare function createLocalUser(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Update a local user
|
|
20
|
+
*/
|
|
21
|
+
export declare function updateLocalUser(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a local user by User ID
|
|
24
|
+
*/
|
|
25
|
+
export declare function updateLocalUserByUserId(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Replace a local user
|
|
28
|
+
*/
|
|
29
|
+
export declare function replaceLocalUser(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Replace a local user by User ID
|
|
32
|
+
*/
|
|
33
|
+
export declare function replaceLocalUserByUserId(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Delete a local user
|
|
36
|
+
*/
|
|
37
|
+
export declare function deleteLocalUser(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Delete a local user by User ID
|
|
40
|
+
*/
|
|
41
|
+
export declare function deleteLocalUserByUserId(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|