2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
24 appDS2.service('TestEnvironmentsService', ['$q', '$http', '$log', 'COMPONENT', 'UtilityService', testEnvironmentsService]);
26 function testEnvironmentsService($q, $http, $log, COMPONENT, UtilityService) {
27 this.loadAAIestEnvironments = function(type) {
28 var deferred = $q.defer();
29 $http.get(COMPONENT.AAI_GET_TEST_ENVIRONMENTS + type)
30 .success(function (response) {
31 if(response.httpCode == 200) {
32 deferred.resolve({operationalEnvironment: response.t.operationalEnvironment});
35 deferred.reject({message: response.errorMessage, status: response.httpCode});
38 .error(function(data, status, headers, config) {
39 deferred.reject({message: data, status: status});
42 return deferred.promise;
45 this.createApplicationEnv = function(request) {
46 var deferred = $q.defer();
48 $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_CREATE, JSON.stringify(request.requestDetails))
49 .success(function (response) {
50 deferred.resolve({data: response});
51 }).error(function (data, status) {
52 deferred.reject({message: data, status: status});
55 return deferred.promise;
58 this.deactivateApplicationEnv = function(request) {
59 var deferred = $q.defer();
61 $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_DEACTIVATE + request.envId, JSON.stringify({}))
62 .success(function (response) {
63 deferred.resolve({data: response});
64 }).error(function (data, status) {
65 deferred.reject({message: data, status: status});
68 return deferred.promise;
71 this.activateApplicationEnv = function(request) {
72 var deferred = $q.defer();
74 $http.post(COMPONENT.OPERATIONAL_ENVIRONMENT_ACTIVATE + request.envId, JSON.stringify({
75 "relatedInstanceId": request.relatedInstanceId
76 , "relatedInstanceName": request.relatedInstanceName
77 , "workloadContext": request.workloadContext
78 , "manifest": request.manifest
80 .success(function (response) {
81 deferred.resolve({data: response});
82 }).error(function (response, status) {
83 UtilityService.runHttpErrorHandler({data:response, status:status});
85 return deferred.promise;
88 this.getRequestStatus = function(requestId, successCallback) {
89 $http.get(COMPONENT.OPERATIONAL_ENVIRONMENT_STATUS + requestId)
90 .success(function(response) {
91 successCallback({data: response});
93 .catch(UtilityService.runHttpErrorHandler);