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,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatResponse = formatResponse;
|
|
4
|
+
/**
|
|
5
|
+
* Format the API response data into n8n node execution data
|
|
6
|
+
*/
|
|
7
|
+
function formatResponse(responseData) {
|
|
8
|
+
if (!responseData) {
|
|
9
|
+
return [{ json: { success: true } }];
|
|
10
|
+
}
|
|
11
|
+
if (!Array.isArray(responseData)) {
|
|
12
|
+
return [{ json: responseData }];
|
|
13
|
+
}
|
|
14
|
+
return responseData.map((item) => ({
|
|
15
|
+
json: item,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Get a bearer token using client credentials
|
|
4
|
+
*/
|
|
5
|
+
export declare function getToken(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, credentials: IDataObject): Promise<string>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getToken = getToken;
|
|
4
|
+
// helpers/tokenManager.ts
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
// Store tokens in memory with expiration
|
|
7
|
+
const tokenCache = {};
|
|
8
|
+
/**
|
|
9
|
+
* Get a bearer token using client credentials
|
|
10
|
+
*/
|
|
11
|
+
async function getToken(credentials) {
|
|
12
|
+
const clientId = credentials.clientId;
|
|
13
|
+
const clientSecret = credentials.clientSecret;
|
|
14
|
+
const baseUrl = credentials.url;
|
|
15
|
+
// Generate a cache key based on client credentials
|
|
16
|
+
const cacheKey = `${baseUrl}:${clientId}:${clientSecret}`;
|
|
17
|
+
// Check if we have a valid cached token
|
|
18
|
+
const cachedToken = tokenCache[cacheKey];
|
|
19
|
+
if (cachedToken && cachedToken.expiresAt > Date.now()) {
|
|
20
|
+
return cachedToken.token;
|
|
21
|
+
}
|
|
22
|
+
// If no valid token in cache, request a new one
|
|
23
|
+
try {
|
|
24
|
+
const options = {
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: {
|
|
30
|
+
client_id: clientId,
|
|
31
|
+
client_secret: clientSecret,
|
|
32
|
+
grant_type: 'client_credentials',
|
|
33
|
+
},
|
|
34
|
+
uri: `${baseUrl}/api/oauth`,
|
|
35
|
+
json: true,
|
|
36
|
+
};
|
|
37
|
+
const response = (await this.helpers.request(options));
|
|
38
|
+
// Cache the token with expiration (add some buffer to ensure we refresh before it expires)
|
|
39
|
+
const expiresInMs = response.expires_in * 1000 - 60000; // Subtract 1 minute as buffer
|
|
40
|
+
tokenCache[cacheKey] = {
|
|
41
|
+
token: response.access_token,
|
|
42
|
+
expiresAt: Date.now() + expiresInMs,
|
|
43
|
+
};
|
|
44
|
+
return response.access_token;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
// Fix error handling to use JsonObject without undefined properties
|
|
48
|
+
const errorObject = {};
|
|
49
|
+
if (error instanceof Error) {
|
|
50
|
+
errorObject.message = error.message;
|
|
51
|
+
// Only add stack if it exists, and convert to string to ensure it's a JsonValue
|
|
52
|
+
if (error.stack) {
|
|
53
|
+
errorObject.stackTrace = error.stack; // Changed property name and ensured it's not undefined
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
errorObject.message = 'Unknown error when obtaining token';
|
|
58
|
+
}
|
|
59
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject, {
|
|
60
|
+
message: 'Failed to obtain access token',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* List all enforcement profiles
|
|
4
|
+
*/
|
|
5
|
+
export declare function listEnforcementProfiles(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Create a new enforcement profile
|
|
8
|
+
*/
|
|
9
|
+
export declare function createEnforcementProfile(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Get an enforcement profile by ID
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEnforcementProfile(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get an enforcement profile by name
|
|
16
|
+
*/
|
|
17
|
+
export declare function getEnforcementProfileByName(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Update an enforcement profile by ID
|
|
20
|
+
*/
|
|
21
|
+
export declare function updateEnforcementProfile(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Update an enforcement profile by name
|
|
24
|
+
*/
|
|
25
|
+
export declare function updateEnforcementProfileByName(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Replace an enforcement profile by ID
|
|
28
|
+
*/
|
|
29
|
+
export declare function replaceEnforcementProfile(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Replace an enforcement profile by name
|
|
32
|
+
*/
|
|
33
|
+
export declare function replaceEnforcementProfileByName(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Delete an enforcement profile by ID
|
|
36
|
+
*/
|
|
37
|
+
export declare function deleteEnforcementProfile(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Delete an enforcement profile by name
|
|
40
|
+
*/
|
|
41
|
+
export declare function deleteEnforcementProfileByName(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listEnforcementProfiles = listEnforcementProfiles;
|
|
4
|
+
exports.createEnforcementProfile = createEnforcementProfile;
|
|
5
|
+
exports.getEnforcementProfile = getEnforcementProfile;
|
|
6
|
+
exports.getEnforcementProfileByName = getEnforcementProfileByName;
|
|
7
|
+
exports.updateEnforcementProfile = updateEnforcementProfile;
|
|
8
|
+
exports.updateEnforcementProfileByName = updateEnforcementProfileByName;
|
|
9
|
+
exports.replaceEnforcementProfile = replaceEnforcementProfile;
|
|
10
|
+
exports.replaceEnforcementProfileByName = replaceEnforcementProfileByName;
|
|
11
|
+
exports.deleteEnforcementProfile = deleteEnforcementProfile;
|
|
12
|
+
exports.deleteEnforcementProfileByName = deleteEnforcementProfileByName;
|
|
13
|
+
// methods/EnforcementProfile/EnforcementProfile.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
|
+
* List all enforcement profiles
|
|
19
|
+
*/
|
|
20
|
+
async function listEnforcementProfiles() {
|
|
21
|
+
try {
|
|
22
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
23
|
+
const filters = this.getNodeParameter('filters', 0, {});
|
|
24
|
+
const endpoint = '/enforcement-profile';
|
|
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 listEnforcementProfiles';
|
|
48
|
+
}
|
|
49
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a new enforcement profile
|
|
54
|
+
*/
|
|
55
|
+
async function createEnforcementProfile() {
|
|
56
|
+
try {
|
|
57
|
+
const body = {};
|
|
58
|
+
// Add required fields
|
|
59
|
+
body.name = this.getNodeParameter('name', 0);
|
|
60
|
+
body.type = this.getNodeParameter('type', 0);
|
|
61
|
+
// Add optional fields
|
|
62
|
+
const description = this.getNodeParameter('description', 0, '');
|
|
63
|
+
if (description) {
|
|
64
|
+
body.description = description;
|
|
65
|
+
}
|
|
66
|
+
const action = this.getNodeParameter('action', 0, '');
|
|
67
|
+
if (action) {
|
|
68
|
+
body.action = action;
|
|
69
|
+
}
|
|
70
|
+
// Add complex configuration
|
|
71
|
+
const profileConfigJson = this.getNodeParameter('profileConfig', 0, '{}');
|
|
72
|
+
try {
|
|
73
|
+
const profileConfig = JSON.parse(profileConfigJson);
|
|
74
|
+
// Merge the profile config with the body
|
|
75
|
+
Object.entries(profileConfig).forEach(([key, value]) => {
|
|
76
|
+
body[key] = value;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (parseError) {
|
|
80
|
+
throw new Error(`Invalid JSON in profile configuration: ${parseError.message}`);
|
|
81
|
+
}
|
|
82
|
+
const endpoint = '/enforcement-profile';
|
|
83
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, body);
|
|
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 createEnforcementProfile';
|
|
96
|
+
}
|
|
97
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get an enforcement profile by ID
|
|
102
|
+
*/
|
|
103
|
+
async function getEnforcementProfile() {
|
|
104
|
+
try {
|
|
105
|
+
const enforcementProfileId = this.getNodeParameter('enforcementProfileId', 0);
|
|
106
|
+
const endpoint = `/enforcement-profile/${enforcementProfileId}`;
|
|
107
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'GET', endpoint);
|
|
108
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
const errorObject = {};
|
|
112
|
+
if (error instanceof Error) {
|
|
113
|
+
errorObject.message = error.message;
|
|
114
|
+
if (error.stack) {
|
|
115
|
+
errorObject.stackTrace = error.stack;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
errorObject.message = 'Unknown error in getEnforcementProfile';
|
|
120
|
+
}
|
|
121
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get an enforcement profile by name
|
|
126
|
+
*/
|
|
127
|
+
async function getEnforcementProfileByName() {
|
|
128
|
+
try {
|
|
129
|
+
const name = this.getNodeParameter('name', 0);
|
|
130
|
+
const endpoint = `/enforcement-profile/name/${name}`;
|
|
131
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'GET', endpoint);
|
|
132
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const errorObject = {};
|
|
136
|
+
if (error instanceof Error) {
|
|
137
|
+
errorObject.message = error.message;
|
|
138
|
+
if (error.stack) {
|
|
139
|
+
errorObject.stackTrace = error.stack;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
errorObject.message = 'Unknown error in getEnforcementProfileByName';
|
|
144
|
+
}
|
|
145
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Update an enforcement profile by ID
|
|
150
|
+
*/
|
|
151
|
+
async function updateEnforcementProfile() {
|
|
152
|
+
try {
|
|
153
|
+
const enforcementProfileId = this.getNodeParameter('enforcementProfileId', 0);
|
|
154
|
+
const updateFields = this.getNodeParameter('updateFields', 0, {});
|
|
155
|
+
if (!Object.keys(updateFields).length) {
|
|
156
|
+
throw new Error('Please specify at least one field to update');
|
|
157
|
+
}
|
|
158
|
+
const body = {};
|
|
159
|
+
// Handle regular fields
|
|
160
|
+
if (updateFields.name)
|
|
161
|
+
body.name = updateFields.name;
|
|
162
|
+
if (updateFields.description)
|
|
163
|
+
body.description = updateFields.description;
|
|
164
|
+
if (updateFields.type)
|
|
165
|
+
body.type = updateFields.type;
|
|
166
|
+
if (updateFields.action)
|
|
167
|
+
body.action = updateFields.action;
|
|
168
|
+
// Handle complex profile configuration if provided
|
|
169
|
+
if (updateFields.profileConfig) {
|
|
170
|
+
try {
|
|
171
|
+
const profileConfig = JSON.parse(updateFields.profileConfig);
|
|
172
|
+
// Merge the profile config with the body
|
|
173
|
+
Object.entries(profileConfig).forEach(([key, value]) => {
|
|
174
|
+
body[key] = value;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (parseError) {
|
|
178
|
+
throw new Error(`Invalid JSON in profile configuration: ${parseError.message}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const endpoint = `/enforcement-profile/${enforcementProfileId}`;
|
|
182
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, body);
|
|
183
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
const errorObject = {};
|
|
187
|
+
if (error instanceof Error) {
|
|
188
|
+
errorObject.message = error.message;
|
|
189
|
+
if (error.stack) {
|
|
190
|
+
errorObject.stackTrace = error.stack;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
errorObject.message = 'Unknown error in updateEnforcementProfile';
|
|
195
|
+
}
|
|
196
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Update an enforcement profile by name
|
|
201
|
+
*/
|
|
202
|
+
async function updateEnforcementProfileByName() {
|
|
203
|
+
try {
|
|
204
|
+
const name = this.getNodeParameter('name', 0);
|
|
205
|
+
const updateFields = this.getNodeParameter('updateFields', 0, {});
|
|
206
|
+
if (!Object.keys(updateFields).length) {
|
|
207
|
+
throw new Error('Please specify at least one field to update');
|
|
208
|
+
}
|
|
209
|
+
const body = {};
|
|
210
|
+
// Handle regular fields
|
|
211
|
+
if (updateFields.name)
|
|
212
|
+
body.name = updateFields.name;
|
|
213
|
+
if (updateFields.description)
|
|
214
|
+
body.description = updateFields.description;
|
|
215
|
+
if (updateFields.type)
|
|
216
|
+
body.type = updateFields.type;
|
|
217
|
+
if (updateFields.action)
|
|
218
|
+
body.action = updateFields.action;
|
|
219
|
+
// Handle complex profile configuration if provided
|
|
220
|
+
if (updateFields.profileConfig) {
|
|
221
|
+
try {
|
|
222
|
+
const profileConfig = JSON.parse(updateFields.profileConfig);
|
|
223
|
+
// Merge the profile config with the body
|
|
224
|
+
Object.entries(profileConfig).forEach(([key, value]) => {
|
|
225
|
+
body[key] = value;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
catch (parseError) {
|
|
229
|
+
throw new Error(`Invalid JSON in profile configuration: ${parseError.message}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const endpoint = `/enforcement-profile/name/${name}`;
|
|
233
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, body);
|
|
234
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
const errorObject = {};
|
|
238
|
+
if (error instanceof Error) {
|
|
239
|
+
errorObject.message = error.message;
|
|
240
|
+
if (error.stack) {
|
|
241
|
+
errorObject.stackTrace = error.stack;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
errorObject.message = 'Unknown error in updateEnforcementProfileByName';
|
|
246
|
+
}
|
|
247
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Replace an enforcement profile by ID
|
|
252
|
+
*/
|
|
253
|
+
async function replaceEnforcementProfile() {
|
|
254
|
+
try {
|
|
255
|
+
const enforcementProfileId = this.getNodeParameter('enforcementProfileId', 0);
|
|
256
|
+
const body = {};
|
|
257
|
+
// Add required fields
|
|
258
|
+
body.name = this.getNodeParameter('name', 0);
|
|
259
|
+
body.type = this.getNodeParameter('type', 0);
|
|
260
|
+
// Add optional fields
|
|
261
|
+
const description = this.getNodeParameter('description', 0, '');
|
|
262
|
+
if (description) {
|
|
263
|
+
body.description = description;
|
|
264
|
+
}
|
|
265
|
+
const action = this.getNodeParameter('action', 0, '');
|
|
266
|
+
if (action) {
|
|
267
|
+
body.action = action;
|
|
268
|
+
}
|
|
269
|
+
// Add complex configuration
|
|
270
|
+
const profileConfigJson = this.getNodeParameter('profileConfig', 0, '{}');
|
|
271
|
+
try {
|
|
272
|
+
const profileConfig = JSON.parse(profileConfigJson);
|
|
273
|
+
// Merge the profile config with the body
|
|
274
|
+
Object.entries(profileConfig).forEach(([key, value]) => {
|
|
275
|
+
body[key] = value;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch (parseError) {
|
|
279
|
+
throw new Error(`Invalid JSON in profile configuration: ${parseError.message}`);
|
|
280
|
+
}
|
|
281
|
+
const endpoint = `/enforcement-profile/${enforcementProfileId}`;
|
|
282
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PUT', endpoint, body);
|
|
283
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
const errorObject = {};
|
|
287
|
+
if (error instanceof Error) {
|
|
288
|
+
errorObject.message = error.message;
|
|
289
|
+
if (error.stack) {
|
|
290
|
+
errorObject.stackTrace = error.stack;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
errorObject.message = 'Unknown error in replaceEnforcementProfile';
|
|
295
|
+
}
|
|
296
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Replace an enforcement profile by name
|
|
301
|
+
*/
|
|
302
|
+
async function replaceEnforcementProfileByName() {
|
|
303
|
+
try {
|
|
304
|
+
const name = this.getNodeParameter('name', 0);
|
|
305
|
+
const body = {};
|
|
306
|
+
// Add required fields
|
|
307
|
+
body.name = this.getNodeParameter('name', 0);
|
|
308
|
+
body.type = this.getNodeParameter('type', 0);
|
|
309
|
+
// Add optional fields
|
|
310
|
+
const description = this.getNodeParameter('description', 0, '');
|
|
311
|
+
if (description) {
|
|
312
|
+
body.description = description;
|
|
313
|
+
}
|
|
314
|
+
const action = this.getNodeParameter('action', 0, '');
|
|
315
|
+
if (action) {
|
|
316
|
+
body.action = action;
|
|
317
|
+
}
|
|
318
|
+
// Add complex configuration
|
|
319
|
+
const profileConfigJson = this.getNodeParameter('profileConfig', 0, '{}');
|
|
320
|
+
try {
|
|
321
|
+
const profileConfig = JSON.parse(profileConfigJson);
|
|
322
|
+
// Merge the profile config with the body
|
|
323
|
+
Object.entries(profileConfig).forEach(([key, value]) => {
|
|
324
|
+
body[key] = value;
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
catch (parseError) {
|
|
328
|
+
throw new Error(`Invalid JSON in profile configuration: ${parseError.message}`);
|
|
329
|
+
}
|
|
330
|
+
const endpoint = `/enforcement-profile/name/${name}`;
|
|
331
|
+
const responseData = await apiRequest_1.apiRequest.call(this, 'PUT', endpoint, body);
|
|
332
|
+
return responseFormatter_1.formatResponse.call(this, responseData);
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
const errorObject = {};
|
|
336
|
+
if (error instanceof Error) {
|
|
337
|
+
errorObject.message = error.message;
|
|
338
|
+
if (error.stack) {
|
|
339
|
+
errorObject.stackTrace = error.stack;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
errorObject.message = 'Unknown error in replaceEnforcementProfileByName';
|
|
344
|
+
}
|
|
345
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Delete an enforcement profile by ID
|
|
350
|
+
*/
|
|
351
|
+
async function deleteEnforcementProfile() {
|
|
352
|
+
try {
|
|
353
|
+
const enforcementProfileId = this.getNodeParameter('enforcementProfileId', 0);
|
|
354
|
+
const endpoint = `/enforcement-profile/${enforcementProfileId}`;
|
|
355
|
+
await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint);
|
|
356
|
+
return [{ json: { success: true } }];
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
const errorObject = {};
|
|
360
|
+
if (error instanceof Error) {
|
|
361
|
+
errorObject.message = error.message;
|
|
362
|
+
if (error.stack) {
|
|
363
|
+
errorObject.stackTrace = error.stack;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
errorObject.message = 'Unknown error in deleteEnforcementProfile';
|
|
368
|
+
}
|
|
369
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Delete an enforcement profile by name
|
|
374
|
+
*/
|
|
375
|
+
async function deleteEnforcementProfileByName() {
|
|
376
|
+
try {
|
|
377
|
+
const name = this.getNodeParameter('name', 0);
|
|
378
|
+
const endpoint = `/enforcement-profile/name/${name}`;
|
|
379
|
+
await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint);
|
|
380
|
+
return [{ json: { success: true } }];
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
const errorObject = {};
|
|
384
|
+
if (error instanceof Error) {
|
|
385
|
+
errorObject.message = error.message;
|
|
386
|
+
if (error.stack) {
|
|
387
|
+
errorObject.stackTrace = error.stack;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
errorObject.message = 'Unknown error in deleteEnforcementProfileByName';
|
|
392
|
+
}
|
|
393
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), errorObject);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* List all device accounts
|
|
4
|
+
*/
|
|
5
|
+
export declare function listDevices(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Get a device account by ID
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDevice(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Get a device account by MAC address
|
|
12
|
+
*/
|
|
13
|
+
export declare function getDeviceByMac(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new device account
|
|
16
|
+
*/
|
|
17
|
+
export declare function createDevice(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Update a device account by ID
|
|
20
|
+
*/
|
|
21
|
+
export declare function updateDevice(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a device account by MAC address
|
|
24
|
+
*/
|
|
25
|
+
export declare function updateDeviceByMac(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Replace a device account by ID
|
|
28
|
+
*/
|
|
29
|
+
export declare function replaceDevice(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Replace a device account by MAC address
|
|
32
|
+
*/
|
|
33
|
+
export declare function replaceDeviceByMac(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Delete a device account by ID
|
|
36
|
+
*/
|
|
37
|
+
export declare function deleteDevice(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Delete a device account by MAC address
|
|
40
|
+
*/
|
|
41
|
+
export declare function deleteDeviceByMac(this: IExecuteFunctions): Promise<INodeExecutionData[]>;
|