4 appDS2.service('TestEnvironmentsService', ['$q', '$http', '$log', 'COMPONENT', 'UtilityService', testEnvironmentsService]);
6 function testEnvironmentsService($q, $http, $log, COMPONENT, UtilityService) {
7 this.loadAAIestEnvironments = function(type) {
8 var deferred = $q.defer();
9 $http.get(COMPONENT.AAI_GET_TEST_ENVIRONMENTS + type)
10 .success(function (response) {
11 if(response.httpCode == 200) {
12 deferred.resolve({operationalEnvironment: response.t.operationalEnvironment});
15 deferred.reject({message: response.errorMessage, status: response.httpCode});
18 .error(function(data, status, headers, config) {
19 deferred.reject({message: data, status: status});
22 return deferred.promise;
25 this.createApplicationEnv = function(request) {
26 var deferred = $q.defer();
28 $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_CREATE, JSON.stringify(request.requestDetails))
29 .success(function (response) {
30 deferred.resolve({data: response});
31 }).error(function (data, status) {
32 deferred.reject({message: data, status: status});
35 return deferred.promise;
38 this.deactivateApplicationEnv = function(request) {
39 var deferred = $q.defer();
41 $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_DEACTIVATE + request.envId, JSON.stringify({}))
42 .success(function (response) {
43 deferred.resolve({data: response});
44 }).error(function (data, status) {
45 deferred.reject({message: data, status: status});
48 return deferred.promise;
51 this.activateApplicationEnv = function(request) {
52 var deferred = $q.defer();
54 $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_ACTIVATE + request.envId, JSON.stringify({
55 "relatedInstanceId": request.relatedInstanceId
56 , "relatedInstanceName": request.relatedInstanceName
57 , "workloadContext": request.workloadContext
58 , "manifest": request.manifest
60 .success(function (response) {
61 deferred.resolve({data: response});
62 }).error(function (response, status) {
63 UtilityService.runHttpErrorHandler({data:response, status:status});
65 return deferred.promise;
68 this.getRequestStatus = function(requestId, successCallback) {
69 $http.get(COMPONENT.OPERATIONAL_ENVIRONMENT_STATUS + requestId)
70 .success(function(response) {
71 successCallback({data: response});
73 .catch(UtilityService.runHttpErrorHandler);