summaryrefslogtreecommitdiffstats
path: root/server/lib/external-backends
diff options
context:
space:
mode:
authorJannik Schönartz2018-08-02 23:17:50 +0200
committerJannik Schönartz2018-08-02 23:17:50 +0200
commitcee3b5539762d12ad8b22e90404b76219886af44 (patch)
tree5cf0633c8f7016e39f5539b0d7fe3de0302c1907 /server/lib/external-backends
parent[groups] bugfix + add doubleclick to enter group/client + small design change (diff)
downloadbas-cee3b5539762d12ad8b22e90404b76219886af44.tar.gz
bas-cee3b5539762d12ad8b22e90404b76219886af44.tar.xz
bas-cee3b5539762d12ad8b22e90404b76219886af44.zip
[server/external-backends] Added sync settings for the backends. Method for getting the backend oject types and the client / group mapping saved in the db.
Diffstat (limited to 'server/lib/external-backends')
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js32
-rw-r--r--server/lib/external-backends/external-backends.js5
2 files changed, 34 insertions, 3 deletions
diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js
index cdd4dde..de41481 100644
--- a/server/lib/external-backends/backends/idoit-backend.js
+++ b/server/lib/external-backends/backends/idoit-backend.js
@@ -26,6 +26,35 @@ class IdoitBackend extends ExternalBackends {
return this.getSession(c)
}
+ // Return the list of object types created in iDoIT.
+ async getObjectTypes (credentials) {
+ var c = this.mapCredentials(credentials)
+ var login = await this.getSession(c)
+ var sid = login.data.result['session-id']
+
+ // Headers
+ var headers = {
+ 'X-RPC-Auth-Session': sid
+ }
+
+ // Params
+ var params = {
+ 'apikey': c.apikey,
+ 'language': 'en'
+ }
+
+ var result = {}
+ result.types = await this.axiosRequest(c.url, 'cmdb.object_types', params, headers)
+ result.types = result.types.data.result
+
+ var types = []
+ result.types.forEach(type => {
+ types.push({ id: type.id, title: type.title })
+ })
+
+ return types
+ }
+
// Optional functions e.g. helperfunctions or testing stuff.
// Helper function, to map the array of credential objects into a single js object.
@@ -68,9 +97,6 @@ class IdoitBackend extends ExternalBackends {
result.object = result.object.data.result
result.childs = result.childs.data.result
- console.log(result)
- // Make an request to read the object
- //return this.axiosRequest(c.url, 'cmdb.location_tree', params, headers)
return result
}
diff --git a/server/lib/external-backends/external-backends.js b/server/lib/external-backends/external-backends.js
index 7d306b3..20f8ce6 100644
--- a/server/lib/external-backends/external-backends.js
+++ b/server/lib/external-backends/external-backends.js
@@ -31,6 +31,11 @@ class ExternalBackends {
console.log('If this method gets called the backend class has NOT IMPLEMENTED the checkConnection method!')
return null
}
+
+ // Return an empty array [] if the backends doesn't have such a function.
+ async getObjectTypes (credentials) {
+ return []
+ }
}
module.exports = ExternalBackends