summaryrefslogtreecommitdiffstats
path: root/server/lib/external-backends/backends/idoit-backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/external-backends/backends/idoit-backend.js')
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js32
1 files changed, 29 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
}