2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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=========================================================
23 var AaiService = function($http, $log, PropertyService, UtilityService) {
25 getSubscriptionServiceTypeList : function(globalCustomerId,
26 successCallbackFunction) {
28 .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: "
31 PropertyService.getAaiBaseUrl()
33 + globalCustomerId + "?r=" + Math.random(),
35 timeout : PropertyService
36 .getServerResponseTimeoutMsec()
37 }).then(function(response) {
38 if (response.data && response.data["service-subscriptions"]) {
39 var serviceTypes = [];
40 var serviceSubscriptions = response.data["service-subscriptions"]["service-subscription"];
42 for (var i = 0; i < serviceSubscriptions.length; i++) {
43 serviceTypes.push(serviceSubscriptions[i]["service-type"]);
46 successCallbackFunction(serviceTypes);
48 successCallbackFunction([]);
51 (UtilityService.runHttpErrorHandler);
53 getLcpCloudRegionTenantList : function(globalCustomerId, serviceType,
54 successCallbackFunction) {
56 .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: "
58 var url = PropertyService.getAaiBaseUrl()
60 + globalCustomerId + "/" + serviceType + "?r=" + Math.random();
64 timeout : PropertyService
65 .getServerResponseTimeoutMsec()
66 }).then(function(response) {
67 var lcpCloudRegionTenants = [];
68 var aaiLcpCloudRegionTenants = response.data;
70 lcpCloudRegionTenants.push({
72 "tenantName": "Please choose a region",
76 for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) {
77 lcpCloudRegionTenants.push({
78 "cloudRegionId": aaiLcpCloudRegionTenants[i]["cloudRegionID"],
79 "tenantName": aaiLcpCloudRegionTenants[i]["tenantName"],
80 "tenantId": aaiLcpCloudRegionTenants[i]["tenantID"]
84 successCallbackFunction(lcpCloudRegionTenants);
86 (UtilityService.runHttpErrorHandler);
88 getSubscribers : function(successCallbackFunction) {
90 .debug("AaiService:getSubscribers");
91 var url = PropertyService.getAaiBaseUrl()
92 + "/aai_get_subscribers?r=" + Math.random();
96 timeout : PropertyService
97 .getServerResponseTimeoutMsec()
98 }).then(function(response) {
100 successCallbackFunction(response.data.customer);
102 successCallbackFunction([]);
105 (UtilityService.runHttpErrorHandler);
110 app.factory("AaiService", [ "$http", "$log", "PropertyService",
111 "UtilityService", AaiService ]);