added svcapi ui and camunda code
[it/otf.git] / otf-frontend / server / src / feathers / hooks / delete-definition.js
diff --git a/otf-frontend/server/src/feathers/hooks/delete-definition.js b/otf-frontend/server/src/feathers/hooks/delete-definition.js
new file mode 100644 (file)
index 0000000..718abb5
--- /dev/null
@@ -0,0 +1,46 @@
+/*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
+#                                                                              #\r
+#   Licensed under the Apache License, Version 2.0 (the "License");            #\r
+#   you may not use this file except in compliance with the License.           #\r
+#   You may obtain a copy of the License at                                    #\r
+#                                                                              #\r
+#       http://www.apache.org/licenses/LICENSE-2.0                             #\r
+#                                                                              #\r
+#   Unless required by applicable law or agreed to in writing, software        #\r
+#   distributed under the License is distributed on an "AS IS" BASIS,          #\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
+#   See the License for the specific language governing permissions and        #\r
+#   limitations under the License.                                             #\r
+##############################################################################*/\r
+\r
+\r
+const util = require('../../lib/otf-util');\r
+const request = require('request');\r
+module.exports = function (options = {}) { // eslint-disable-line no-unused-vars\r
+    return async context => {\r
+        let options = {\r
+            url: context.app.get('serviceApi').url + 'testStrategy/delete/v1/testDefinitionId/' + context.id,\r
+            headers: {\r
+                'Authorization': 'Basic ' + util.base64Encode(context.app.get('serviceApi').aafId + ':' + context.app.get('serviceApi').aafPassword)\r
+            },\r
+            rejectUnauthorized: false,\r
+        }\r
+        \r
+        await new Promise((resolve, reject) => {\r
+            request.delete(options, (err, res, body) => {\r
+                if(err){\r
+                    reject(err);\r
+                }\r
+                if(res && res.statusCode == 200){\r
+                    resolve(body);\r
+                }else{\r
+                    reject(res);\r
+                }\r
+            });\r
+        }).then(result => {\r
+            \r
+        }).catch(err => {\r
+            console.log(err);\r
+        });\r
+    };\r
+};\r