@manyos/smileconnect-api 1.38.1 → 1.39.1
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/app.js +8 -0
- package/conf/clients.json +1 -2
- package/conf/scripts/checkGlobalParams.js +3 -0
- package/controller/cmdbobjectController.js +21 -21
- package/controller/customFormController.js +19 -19
- package/controller/relatedObjectsController.js +5 -5
- package/controller/scriptController.js +9 -8
- package/controller/taskController.js +31 -30
- package/controller/ticketController.js +18 -24
- package/controller/ticketWorkLogController.js +11 -11
- package/docs/_config.yml +2 -0
- package/docs/configuration/adapter.md +317 -0
- package/docs/configuration/scripts.md +207 -0
- package/package.json +1 -1
- package/routes/cmdbObjectRoutes.js +12 -7
- package/routes/customFormRoutes.js +7 -5
- package/routes/taskRoutes.js +22 -11
- package/routes/ticketRoutes.js +7 -5
- package/routes/ticketWorkLogRoutes.js +8 -4
|
@@ -14,12 +14,12 @@ const mappingUtil = require('../util/mappingUtil');
|
|
|
14
14
|
|
|
15
15
|
const ticketCache = new CacheService(process.env.CACHETTL_TICKETS || 1); // Create a new cache service instance
|
|
16
16
|
|
|
17
|
-
function getTickets(ticketConfig, config, includeString, customOptions) {
|
|
17
|
+
function getTickets(ticketConfig, config, includeString, customOptions, globalScriptParams) {
|
|
18
18
|
let query = '1=1';
|
|
19
|
-
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString);
|
|
19
|
+
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString, globalScriptParams);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
async function createTicket(ticketConfig, clientConfig, data) {
|
|
22
|
+
async function createTicket(ticketConfig, clientConfig, data, globalScriptParams) {
|
|
23
23
|
const scripts = clientConfig[ticketConfig.requestType].scripts.POST;
|
|
24
24
|
|
|
25
25
|
//run preScripts
|
|
@@ -39,7 +39,7 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
39
39
|
|
|
40
40
|
//run postScripts
|
|
41
41
|
if (scripts && scripts.postMapping) {
|
|
42
|
-
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
42
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const result = await arquery.createEntry(ticketConfig.forms.new, data, clientConfig.options)
|
|
@@ -50,12 +50,6 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
50
50
|
const resultInterfaceCreate = await arquery.executeARQuery(ticketConfig.forms.new, null, "'1'=\"" + ticketCreateId + "\"", ticketConfig.ticketIdField, clientConfig.options)
|
|
51
51
|
if (resultInterfaceCreate.data && Array.isArray(resultInterfaceCreate.data) && resultInterfaceCreate.data.length && resultInterfaceCreate.data[0][ticketConfig.ticketIdField]) {
|
|
52
52
|
const ticketId = resultInterfaceCreate.data[0][ticketConfig.ticketIdField];
|
|
53
|
-
//todo fix create worklog
|
|
54
|
-
/*createWorklog(clientConfig, ticketId, 'Created', 'Incident ' + CONSTANTS.TEXT_CREATED_BY, false).then(function (worklogResult) {
|
|
55
|
-
log.debug('Worklog', worklogResult);
|
|
56
|
-
}).catch(function (error) {
|
|
57
|
-
log.error('HPD:Worklog creation error', error)
|
|
58
|
-
});*/
|
|
59
53
|
} else {
|
|
60
54
|
log.error('Cannot create Ticket', resultInterfaceCreate);
|
|
61
55
|
throw({message: 'Cannot create Ticket', details : resultInterfaceCreate});
|
|
@@ -63,12 +57,12 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
63
57
|
|
|
64
58
|
//run afterExecution
|
|
65
59
|
if (scripts && scripts.afterExecution) {
|
|
66
|
-
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
60
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
67
61
|
}
|
|
68
62
|
return resultInterfaceCreate;
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString) {
|
|
65
|
+
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
|
|
72
66
|
log.debug('config', ticketConfig);
|
|
73
67
|
const includeArray = getIncludeArray(includeString);
|
|
74
68
|
log.debug('ticketConfig.requestType', ticketConfig.requestType);
|
|
@@ -101,7 +95,7 @@ function queryTickets(ticketConfig, clientConfig, query, mapping, customFields,
|
|
|
101
95
|
if (result && result.data && result.data.length) {
|
|
102
96
|
let x = 0;
|
|
103
97
|
for (x=0; x< result.data.length; x++) {
|
|
104
|
-
const ticket = await handleTicket(ticketConfig, result.data[x], mapping, clientConfig, includeArray, globalRelationObjects);
|
|
98
|
+
const ticket = await handleTicket(ticketConfig, result.data[x], mapping, clientConfig, includeArray, globalRelationObjects, globalScriptParams);
|
|
105
99
|
tickets.push(ticket);
|
|
106
100
|
}
|
|
107
101
|
}
|
|
@@ -113,7 +107,7 @@ function queryTickets(ticketConfig, clientConfig, query, mapping, customFields,
|
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
109
|
|
|
116
|
-
async function handleTicket(ticketConfig, ticket, mapping, clientConfig, includeArray, globalRelationObjects) {
|
|
110
|
+
async function handleTicket(ticketConfig, ticket, mapping, clientConfig, includeArray, globalRelationObjects, globalScriptParams) {
|
|
117
111
|
const allScripts = clientConfig[ticketConfig.requestType].scripts;
|
|
118
112
|
let scripts = [];
|
|
119
113
|
if (allScripts) {
|
|
@@ -136,7 +130,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
136
130
|
const preScripts = scripts.preMapping;
|
|
137
131
|
try {
|
|
138
132
|
for (let x = 0; x < preScripts.length; x++) {
|
|
139
|
-
const result = await scriptController.executeScript(preScripts[x], ticket, null, clientConfig.clientId);
|
|
133
|
+
const result = await scriptController.executeScript(preScripts[x], ticket, null, clientConfig.clientId, globalScriptParams);
|
|
140
134
|
}
|
|
141
135
|
} catch (error) {
|
|
142
136
|
throw error;
|
|
@@ -160,7 +154,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
160
154
|
const postScripts = scripts.postMapping;
|
|
161
155
|
try {
|
|
162
156
|
for (let x = 0; x < postScripts.length; x++) {
|
|
163
|
-
const result = await scriptController.executeScript(postScripts[x], ticket, null, clientConfig.clientId);
|
|
157
|
+
const result = await scriptController.executeScript(postScripts[x], ticket, null, clientConfig.clientId, globalScriptParams);
|
|
164
158
|
}
|
|
165
159
|
} catch (error) {
|
|
166
160
|
throw error;
|
|
@@ -260,7 +254,7 @@ function checkFieldsProblem(problem, globalRelationObjects) {
|
|
|
260
254
|
}
|
|
261
255
|
|
|
262
256
|
|
|
263
|
-
async function getTicket(ticketConfig, config, id, mapping, includeString) {
|
|
257
|
+
async function getTicket(ticketConfig, config, id, mapping, includeString, globalScriptParams) {
|
|
264
258
|
let query = '1=2';
|
|
265
259
|
const requestType = ticketConfig.requestType;
|
|
266
260
|
if (requestType === 'incident') {
|
|
@@ -272,18 +266,18 @@ async function getTicket(ticketConfig, config, id, mapping, includeString) {
|
|
|
272
266
|
} else if (requestType === 'workOrder') {
|
|
273
267
|
query = `'Work Order ID'=\"${id}\"`;
|
|
274
268
|
}
|
|
275
|
-
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString);
|
|
269
|
+
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString, globalScriptParams);
|
|
276
270
|
const ticket = returnValue.data[0];
|
|
277
271
|
return {data: ticket, included: returnValue.included};
|
|
278
272
|
}
|
|
279
273
|
|
|
280
|
-
async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
274
|
+
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams) {
|
|
281
275
|
const scripts = clientConfig[ticketConfig.requestType].scripts.PUT;
|
|
282
276
|
const fields = clientConfig[ticketConfig.requestType].fields
|
|
283
277
|
|
|
284
278
|
//run preScripts
|
|
285
279
|
if (scripts && scripts.preMapping) {
|
|
286
|
-
await scriptController.runScripts(scripts.preMapping, ticketData, clientConfig.clientId);
|
|
280
|
+
await scriptController.runScripts(scripts.preMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
287
281
|
}
|
|
288
282
|
|
|
289
283
|
log.debug(clientConfig[ticketConfig.requestType]);
|
|
@@ -298,10 +292,10 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
|
298
292
|
|
|
299
293
|
//run postMapping
|
|
300
294
|
if (scripts && scripts.postMapping) {
|
|
301
|
-
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId);
|
|
295
|
+
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
302
296
|
}
|
|
303
297
|
|
|
304
|
-
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping);
|
|
298
|
+
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams);
|
|
305
299
|
log.debug('Ticket to Update', ticket);
|
|
306
300
|
//todo Abfangen wenn getTicket nichts liefert.
|
|
307
301
|
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData);
|
|
@@ -314,12 +308,12 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
|
314
308
|
return update;
|
|
315
309
|
}
|
|
316
310
|
|
|
317
|
-
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString) {
|
|
311
|
+
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
|
318
312
|
const mapping = config.getMapping(ticketConfig.requestType);
|
|
319
313
|
const mappedString = searchUtil.applyMapping(searchString, mapping);
|
|
320
314
|
const customFields = searchUtil.getCustomFields(clientConfig[ticketConfig.requestType].fields, mapping, fields);
|
|
321
315
|
options.sort = searchUtil.applySortMapping(options.sort, mapping);
|
|
322
|
-
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString);
|
|
316
|
+
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams);
|
|
323
317
|
}
|
|
324
318
|
|
|
325
319
|
module.exports = {
|
|
@@ -11,7 +11,7 @@ const scriptController = require('./scriptController');
|
|
|
11
11
|
|
|
12
12
|
const ticketCache = new CacheService(process.env.CACHETTL_TICKETS || 1); // Create a new cache service instance
|
|
13
13
|
|
|
14
|
-
async function createWorklog(ticketConfig, clientConfig, ticketId, summary, text, isPublic) {
|
|
14
|
+
async function createWorklog(ticketConfig, clientConfig, ticketId, summary, text, isPublic, globalScriptParams) {
|
|
15
15
|
const scripts = clientConfig[ticketConfig.requestTypeWorkLog].scripts.POST;
|
|
16
16
|
const mapping = config.getMapping(ticketConfig.requestTypeWorkLog);
|
|
17
17
|
const fields = clientConfig[ticketConfig.requestTypeWorkLog].fields;
|
|
@@ -61,21 +61,21 @@ async function createWorklog(ticketConfig, clientConfig, ticketId, summary, text
|
|
|
61
61
|
|
|
62
62
|
//run preScripts
|
|
63
63
|
if (scripts && scripts.preMapping) {
|
|
64
|
-
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
|
|
64
|
+
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId, globalScriptParams);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConstants, fields);
|
|
68
68
|
|
|
69
69
|
//run postScripts
|
|
70
70
|
if (scripts && scripts.postMapping) {
|
|
71
|
-
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
71
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const result = arquery.createEntry(ticketConfig.forms.workLog, data, clientConfig.options)
|
|
75
75
|
|
|
76
76
|
//run afterExecution
|
|
77
77
|
if (scripts && scripts.afterExecution) {
|
|
78
|
-
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
78
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return result;
|
|
@@ -102,7 +102,7 @@ function getAttachmentFieldId(attachmentId) {
|
|
|
102
102
|
return attachmentFieldId;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
async function getWorklogs(ticketConfig, clientConfig, ticketId, mapping) {
|
|
105
|
+
async function getWorklogs(ticketConfig, clientConfig, ticketId, mapping, globalScriptParams) {
|
|
106
106
|
let query = '1=2';
|
|
107
107
|
const requestType = ticketConfig.requestType;
|
|
108
108
|
if (requestType === 'incident') {
|
|
@@ -114,11 +114,11 @@ async function getWorklogs(ticketConfig, clientConfig, ticketId, mapping) {
|
|
|
114
114
|
} else if (requestType === 'workOrder') {
|
|
115
115
|
query = `'Work Order ID'=\"${ticketId}\"`;
|
|
116
116
|
}
|
|
117
|
-
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping);
|
|
117
|
+
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping, globalScriptParams);
|
|
118
118
|
return {data: returnValue.data};
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mapping) {
|
|
121
|
+
async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mapping, globalScriptParams) {
|
|
122
122
|
let query = '1=2';
|
|
123
123
|
const requestType = ticketConfig.requestType;
|
|
124
124
|
if (requestType === 'incident') {
|
|
@@ -130,7 +130,7 @@ async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mappi
|
|
|
130
130
|
} else if (requestType === 'workOrder') {
|
|
131
131
|
query = `'Work Order ID'=\"${ticketId}\" AND '1' = \"${worklogId}\"`;
|
|
132
132
|
}
|
|
133
|
-
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping);
|
|
133
|
+
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping, globalScriptParams);
|
|
134
134
|
const urls = {
|
|
135
135
|
"attachmentUrl":
|
|
136
136
|
`${ticketConfig.baseURI}/${ticketId}/worklogs/${worklogId}/attachments/1`
|
|
@@ -147,7 +147,7 @@ async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mappi
|
|
|
147
147
|
return {data: returnValue.data[0], urls};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
async function queryWorklogs(ticketConfig, clientConfig, query, mapping) {
|
|
150
|
+
async function queryWorklogs(ticketConfig, clientConfig, query, mapping, globalScriptParams) {
|
|
151
151
|
const baseQuery = clientConfig[ticketConfig.requestTypeWorkLog].basequery;
|
|
152
152
|
const fields = clientConfig[ticketConfig.requestTypeWorkLog].fields;
|
|
153
153
|
const key = 'worklog' + baseQuery + fields.toString() + query;
|
|
@@ -169,12 +169,12 @@ async function queryWorklogs(ticketConfig, clientConfig, query, mapping) {
|
|
|
169
169
|
const element = result.data[x];
|
|
170
170
|
//run preScripts
|
|
171
171
|
if (scripts && scripts.preMapping) {
|
|
172
|
-
await scriptController.runScripts(scripts.preMapping, result.data, clientConfig.clientId);
|
|
172
|
+
await scriptController.runScripts(scripts.preMapping, result.data, clientConfig.clientId, globalScriptParams);
|
|
173
173
|
}
|
|
174
174
|
applyMapping(element, mapping, 'Entry ID');
|
|
175
175
|
//run postScripts
|
|
176
176
|
if (scripts && scripts.postMapping) {
|
|
177
|
-
await scriptController.runScripts(scripts.postMapping, result.data, clientConfig.clientId);
|
|
177
|
+
await scriptController.runScripts(scripts.postMapping, result.data, clientConfig.clientId, globalScriptParams);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
return {
|
package/docs/_config.yml
CHANGED
|
@@ -24,6 +24,8 @@ navbar-links:
|
|
|
24
24
|
Resources:
|
|
25
25
|
- Architecture: "general/architecture"
|
|
26
26
|
- Configuration: "general/config"
|
|
27
|
+
- Scripts: "configuration/scripts"
|
|
28
|
+
- Adapter: "configuration/adapter"
|
|
27
29
|
- Specification: "spec/index.html"
|
|
28
30
|
How-Tos:
|
|
29
31
|
- Authenticate: "howto/token"
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Adapter
|
|
4
|
+
subtitle: Talk to the outside world
|
|
5
|
+
use-site-title: true
|
|
6
|
+
bigimg: /img/gb-isapi.jpg
|
|
7
|
+
toc: true
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Introduction
|
|
11
|
+
|
|
12
|
+
Adapter are used to integrate with different systems. SMILEconnect comes with a flexible adapter architecture. Multiple types of adapters can be used and also multiple adapters of the same type can be configured. This can be useful if you need to interact e.g. with two different LDAP Systems.
|
|
13
|
+
|
|
14
|
+
# Adapter Configuration
|
|
15
|
+
|
|
16
|
+
Adapter are configured in the file *adapterConfig.js* in the root of the conf folder. Within the configuration file the variable *env* can be used to access system environment variables. E.g. *env.AR_USER* reflects the value of the system variable *AR_USER*.
|
|
17
|
+
|
|
18
|
+
For security, it is advised to store confidential information, like passwords, in the environment variables and not in the configuration file itself.
|
|
19
|
+
|
|
20
|
+
Configuration example:
|
|
21
|
+
```javascript
|
|
22
|
+
const adapterParams = {
|
|
23
|
+
remedy: {
|
|
24
|
+
type: "remedy",
|
|
25
|
+
arServer: env.AR_SERVER,
|
|
26
|
+
arUser: env.AR_USER,
|
|
27
|
+
arPassword: env.AR_PASSWORD,
|
|
28
|
+
arPort: env.AR_PORT,
|
|
29
|
+
rapiUri: env.RAPI_URL,
|
|
30
|
+
cacheTime: env.AR_CACHE_TTL,
|
|
31
|
+
limitDefault: env.LIMIT_DEFAULT || 100,
|
|
32
|
+
limitMax: env.LIMIT_MAX
|
|
33
|
+
},
|
|
34
|
+
ldap: {
|
|
35
|
+
type: "ldap",
|
|
36
|
+
ldapUrl: env.LDAP_URL,
|
|
37
|
+
ldapBind: env.LDAP_BIND,
|
|
38
|
+
ldapSecret: env.LDAP_SECRET
|
|
39
|
+
},
|
|
40
|
+
ldapIDM: {
|
|
41
|
+
type: "ldap",
|
|
42
|
+
ldapUrl: env.LDAP_IDM_URL,
|
|
43
|
+
ldapBind: env.LDAP_IDM_BIND,
|
|
44
|
+
ldapSecret: env.LDAP_IDM_SECRET
|
|
45
|
+
},
|
|
46
|
+
smileconnect: {
|
|
47
|
+
type: "SMILEconnect",
|
|
48
|
+
clientId: env.SC_CLIENT,
|
|
49
|
+
secret: env.SC_SECRET,
|
|
50
|
+
ssoUrl: env.SC_SSO_URL,
|
|
51
|
+
smileConnectUrl: env.SC_SMILECONNECT_URL
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// noinspection JSAnnotator
|
|
56
|
+
return adapterParams;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The different Adapter and their configuration values are described in detail below.
|
|
60
|
+
|
|
61
|
+
## Remedy
|
|
62
|
+
|
|
63
|
+
The Remedy Adapter is used to connect to BMC Remedy Action Request Servers. It allows you to create, query and update records.
|
|
64
|
+
|
|
65
|
+
### Configuration values
|
|
66
|
+
|
|
67
|
+
**arServer**: The name of the arsystem server. e.g. ars1.mydomain.com
|
|
68
|
+
|
|
69
|
+
**arUser**: The user which is used to connect to the remedy server. E.g. Allen
|
|
70
|
+
|
|
71
|
+
**arPassword**: The password of the ar user.
|
|
72
|
+
|
|
73
|
+
**arPort**: The port of the arsystem server. e.g. 5142. Use 0 if you want to a portmapper.
|
|
74
|
+
|
|
75
|
+
**rapiUri**: The URL of the RAPI Server wich is used as middleware to connect to the arsystem server. e.g. https://rapi.mydomain.com
|
|
76
|
+
|
|
77
|
+
**cacheTime**: The default time in seconds in which the result of queries is stored in a cache. This is used to increase performance dramatically. Defaults to 300s.
|
|
78
|
+
|
|
79
|
+
**limitDefault**: The default limit of records retrieved in a query. This value is used whenever no value is specified. Can be overwritten in queries.
|
|
80
|
+
|
|
81
|
+
**limitMax**: The maximum number of records retrieved in a query. This parameter can be used to enforce a limit. The limit can not be overwritten by queries.
|
|
82
|
+
|
|
83
|
+
### Functions
|
|
84
|
+
|
|
85
|
+
#### Search
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
async function search(form, query, fields, options)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Parameter:
|
|
92
|
+
|
|
93
|
+
* form (string):
|
|
94
|
+
|
|
95
|
+
The form used to query data. e.g. CTM:People
|
|
96
|
+
|
|
97
|
+
* query (string):
|
|
98
|
+
|
|
99
|
+
The query used in the form. e.g. 'Remedy Login ID' = "Allen"
|
|
100
|
+
|
|
101
|
+
* fields (comma separated list):
|
|
102
|
+
|
|
103
|
+
The fields to be returned by the query. e.g. "Full Name, Remedy Login ID, First Name, Last Name, Department"
|
|
104
|
+
|
|
105
|
+
Full example:
|
|
106
|
+
```javascript
|
|
107
|
+
const result = await adapter.remedy.search(
|
|
108
|
+
"CTM:People",
|
|
109
|
+
"'Remedy Login ID' = \"Allen\"",
|
|
110
|
+
"Full Name, Remedy Login ID, First Name, Last Name, Department");
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Will return an object with a data array and some meta data.
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
{
|
|
117
|
+
"status": "success",
|
|
118
|
+
"query": "'Remedy Login ID' = \"Allen\"",
|
|
119
|
+
"server": "arserver:51423",
|
|
120
|
+
"form": "CTM:People",
|
|
121
|
+
"runtime": 106,
|
|
122
|
+
"dataSize": 1,
|
|
123
|
+
"data": [
|
|
124
|
+
{
|
|
125
|
+
"Person ID": "PPL000000000013",
|
|
126
|
+
"Remedy Login ID": "Allen",
|
|
127
|
+
"Department": "Customer Service",
|
|
128
|
+
"Full Name": "Allen Allbrook",
|
|
129
|
+
"Last Name": "Allbrook",
|
|
130
|
+
"First Name": "Allen"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
#### Create
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
async function create(form, entry, options)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Parameter:
|
|
144
|
+
|
|
145
|
+
* form (string):
|
|
146
|
+
|
|
147
|
+
The form in which a new record is created. e.g. CTM:People
|
|
148
|
+
|
|
149
|
+
* entry (object):
|
|
150
|
+
|
|
151
|
+
The entry object that is ceated.
|
|
152
|
+
|
|
153
|
+
e.g.
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
{
|
|
157
|
+
"Source Keyword": "SMILEcatalog",
|
|
158
|
+
"Company": "Calbro Services",
|
|
159
|
+
"AppRequestSummary": "New Request from SMILEcatalog",
|
|
160
|
+
"TitleInstanceID": "SRGAA5V0GEfds7LO5YL6Q945Z",
|
|
161
|
+
"Login ID": "Allen"
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Full example:
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
const settings = {
|
|
169
|
+
"createForm":"SRM:RequestInterface_Create",
|
|
170
|
+
"entry": {
|
|
171
|
+
"Source Keyword": "SMILEcatalog",
|
|
172
|
+
"Company": "Calbro Services",
|
|
173
|
+
"AppRequestSummary": "New Request from SMILEcatalog",
|
|
174
|
+
"TitleInstanceID": "SRGAA5V0GEfds7LO5YL6Q945Z",
|
|
175
|
+
"Login ID": "Allen"
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
//Create Service Request
|
|
179
|
+
const resultCreate = await adapter.remedy.create(settings.createForm, settings.entry);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Will return return the id of the created record. e.g. REQ00000002893
|
|
183
|
+
|
|
184
|
+
#### Options
|
|
185
|
+
|
|
186
|
+
* limit
|
|
187
|
+
|
|
188
|
+
The maximum number of records that should be returned by this query. e.g. 5. Use this value to increase performance or to overwrite a default limit.
|
|
189
|
+
|
|
190
|
+
* offset
|
|
191
|
+
|
|
192
|
+
Use together with limit to allow pagination. e.g. limit=10 & offset=10
|
|
193
|
+
|
|
194
|
+
* dateFormat
|
|
195
|
+
|
|
196
|
+
The format in which dates are returned.
|
|
197
|
+
|
|
198
|
+
* sort
|
|
199
|
+
|
|
200
|
+
The fields that are to sort the result on the remedy server. Use 1 for ascending and -1 for descending order.
|
|
201
|
+
|
|
202
|
+
e.g.
|
|
203
|
+
```javascript
|
|
204
|
+
{
|
|
205
|
+
"Name": 1,
|
|
206
|
+
"Status": -1
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
* countOnly (only search)
|
|
211
|
+
|
|
212
|
+
Can be used to retrieve only the size of the results without any payload. This improves performance.
|
|
213
|
+
|
|
214
|
+
Full example:
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
const options = {
|
|
218
|
+
limit: 100,
|
|
219
|
+
offset: 100,
|
|
220
|
+
dafeFormat: "yyyy-MM-dd HH:mm:ss.SSSZ",
|
|
221
|
+
sort: {
|
|
222
|
+
"Name": 1,
|
|
223
|
+
"Status": -1
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## LDAP
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
### Configuration values
|
|
232
|
+
|
|
233
|
+
* ldapUrl
|
|
234
|
+
|
|
235
|
+
The connection URL of the LDAP Server. e.g. ldap://ldap.forumsys.com:389
|
|
236
|
+
|
|
237
|
+
* ldapBind
|
|
238
|
+
|
|
239
|
+
The Bind DN to authenticate with. e.g. cn=smilecatalog-user,dc=example,dc=com
|
|
240
|
+
|
|
241
|
+
* ldapSecret
|
|
242
|
+
|
|
243
|
+
The secret to use with the Bind DN. e.g. password
|
|
244
|
+
|
|
245
|
+
### Functions
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
#### Search
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
async search(base, options)
|
|
252
|
+
```
|
|
253
|
+
Runs a query against the ldap Server.
|
|
254
|
+
|
|
255
|
+
Parameter:
|
|
256
|
+
|
|
257
|
+
* base
|
|
258
|
+
|
|
259
|
+
A DN string to start.
|
|
260
|
+
|
|
261
|
+
* options
|
|
262
|
+
|
|
263
|
+
Options for the search. Like filters and returned attributes. See http://ldapjs.org/client.html for more details.
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
const opts = {
|
|
267
|
+
filter: '(&(l=Seattle)(email=*@foo.com))',
|
|
268
|
+
scope: 'sub',
|
|
269
|
+
attributes: ['dn', 'sn', 'cn']
|
|
270
|
+
};
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Full example:
|
|
274
|
+
|
|
275
|
+
```javascript
|
|
276
|
+
const base = "dc=example,dc=com";
|
|
277
|
+
const options = {
|
|
278
|
+
attributes: ['dn', 'sn', 'cn'],
|
|
279
|
+
scope: "sub",
|
|
280
|
+
filter: "sn=Riemann"
|
|
281
|
+
}
|
|
282
|
+
const result = await adapter.ldap.search(base, options);
|
|
283
|
+
resolve(result);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Returns an array of records. e.g.
|
|
287
|
+
|
|
288
|
+
```javascript
|
|
289
|
+
[
|
|
290
|
+
{
|
|
291
|
+
"dn": "uid=riemann,dc=example,dc=com",
|
|
292
|
+
"controls": [],
|
|
293
|
+
"cn": "Bernhard Riemann",
|
|
294
|
+
"sn": "Riemann"
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## SMILEconnect
|
|
300
|
+
|
|
301
|
+
The SMILEconnect Adapter can be used to do calls against SMILEconnect. It will act as it is called externally.
|
|
302
|
+
|
|
303
|
+
### Configuration values
|
|
304
|
+
|
|
305
|
+
**smileConnectUrl**: The url of your SMILEconnect installation e.g. https://smileconnect.mydomain.io
|
|
306
|
+
|
|
307
|
+
**ssoUrl**: The url of the oidc identity provider. e.g. https://sso.mydomain.io/auth/realms/smileconnect
|
|
308
|
+
|
|
309
|
+
**clientId**: The name of the client that is used to connect to SMILEconnect
|
|
310
|
+
|
|
311
|
+
**secret**: The secret of the client. e.g. jd92hd-03283d-2293s-232
|
|
312
|
+
|
|
313
|
+
### Functions
|
|
314
|
+
|
|
315
|
+
The SMILEconnect adapter is an open source project.
|
|
316
|
+
|
|
317
|
+
[Visit the project homepage for details]https://github.com/manyosit/smileconnect-client
|