aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/webapp/app/vid/scripts/services/testEnvironmentsService.js
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/services/testEnvironmentsService.js')
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/testEnvironmentsService.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/testEnvironmentsService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/testEnvironmentsService.js
new file mode 100644
index 000000000..6ae675a01
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/testEnvironmentsService.js
@@ -0,0 +1,79 @@
+(function () {
+ 'use strict';
+
+ appDS2.service('TestEnvironmentsService', ['$q', '$http', '$log', 'COMPONENT', 'UtilityService', testEnvironmentsService]);
+
+ function testEnvironmentsService($q, $http, $log, COMPONENT, UtilityService) {
+ this.loadAAIestEnvironments = function(type) {
+ var deferred = $q.defer();
+ $http.get(COMPONENT.AAI_GET_TEST_ENVIRONMENTS + type)
+ .success(function (response) {
+ if(response.httpCode == 200) {
+ deferred.resolve({operationalEnvironment: response.t.operationalEnvironment});
+ }
+ else {
+ deferred.reject({message: response.errorMessage, status: response.httpCode});
+ }
+ })
+ .error(function(data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+
+ return deferred.promise;
+ };
+
+ this.createApplicationEnv = function(request) {
+ var deferred = $q.defer();
+
+ $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_CREATE, JSON.stringify(request.requestDetails))
+ .success(function (response) {
+ deferred.resolve({data: response});
+ }).error(function (data, status) {
+ deferred.reject({message: data, status: status});
+ });
+
+ return deferred.promise;
+ }
+
+ this.deactivateApplicationEnv = function(request) {
+ var deferred = $q.defer();
+
+ $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_DEACTIVATE + request.envId, JSON.stringify({}))
+ .success(function (response) {
+ deferred.resolve({data: response});
+ }).error(function (data, status) {
+ deferred.reject({message: data, status: status});
+ });
+
+ return deferred.promise;
+ };
+
+ this.activateApplicationEnv = function(request) {
+ var deferred = $q.defer();
+
+ $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_ACTIVATE + request.envId, JSON.stringify({
+ "relatedInstanceId": request.relatedInstanceId
+ , "relatedInstanceName": request.relatedInstanceName
+ , "workloadContext": request.workloadContext
+ , "manifest": request.manifest
+ }))
+ .success(function (response) {
+ deferred.resolve({data: response});
+ }).error(function (response, status) {
+ UtilityService.runHttpErrorHandler({data:response, status:status});
+ });
+ return deferred.promise;
+ };
+
+ this.getRequestStatus = function(requestId, successCallback) {
+ $http.get(COMPONENT.OPERATIONAL_ENVIRONMENT_STATUS + requestId)
+ .success(function(response) {
+ successCallback({data: response});
+ } )
+ .catch(UtilityService.runHttpErrorHandler);
+ };
+ }
+
+
+})();
+