Update sdnc/oam for ODL Potassium release
[sdnc/oam.git] / configbackuprestore / vnfconfigbackupservice / src / main / webapp / js / sdnc-services / sdnc-compareConfig-service.js
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : SDNC-FEATURES
4  * ================================================================================
5  * Copyright 2018 TechMahindra
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 myApp.service('deviceConfigService', ['$http','VNF_API_BASE', function($http, VNF_API_BASE) {
21
22    
23         this.getAllVNFFromRc = function() {
24         var rctestlist = {};
25         return $http.get('/getAllBackupVnfIds')
26             .then(function(response) {
27                    console.log("---validationTestService::getAllVNF From Restconf::TestResponse---" + JSON.stringify(response));
28                     vnflist = response.data;
29                     return vnflist;
30                 },
31                 function(response) {
32                    console.log("validationTestService::getAllVNF From Restconf::Status Code", response.status);
33                     return response;
34                 });
35
36     };
37        
38         this.getAllVNF = function() {
39         var testlist = {};
40         return $http.get('/getAllBackupVnfIds')
41             .then(function(response) {
42                     console.log("---validationTestService::getAllVNF::TestResponse---" + JSON.stringify(response));
43                     vnflist = response.data;
44                     return vnflist;
45                 },
46                 function(response) {
47                     console.log("validationTestService::getAllVNF::Status Code", response.status);
48                     return response;
49                 });
50
51     };
52
53     this.getAllVnfIds = function() {
54         var rctestlist = {};
55         return $http.get('/getAllVnfIds')
56             .then(function(response) {
57                    console.log("---validationTestService::getAllVNF From Restconf::TestResponse---" + JSON.stringify(response));
58                     vnflist = response.data;
59                     return vnflist;
60                 },
61                 function(response) {
62                    console.log("validationTestService::getAllVNF From Restconf::Status Code", response.status);
63                     return response;
64                 });
65
66     };
67     
68     this.getVersions = function(vnfId) {
69
70         var data = {};
71         data.vnfId = vnfId;
72         var config = {
73             params: data,
74             headers: {
75                 'Accept': 'application/json'
76             }
77         };
78
79         console.log("deviceConfigService::getVersions::config", JSON.stringify(config));
80
81         var baseUrl = VNF_API_BASE;
82         var request = {
83             method: 'GET',
84             url: '/configDetailsById/'+vnfId,
85             
86             headers: {
87                 'Content-Type': 'application/json',
88             }
89         };
90
91         return $http(request)
92             .then(function(response) {
93                     console.log("---deviceConfigService::getVersions::Response---" + JSON.stringify(response));
94                     return response;
95                 },
96                 function(response) {
97                     console.log("--deviceConfigService::getVersions::Status Code--", response.status);
98                     return response;
99                 });
100
101
102     }
103     
104     this.invokeBackup = function() {
105         var testlist = {};
106         return $http.get('/backup')
107             .then(function(response) {
108                     console.log("---validationTestService::getAllVNF::TestResponse---" + response);
109                     vnflist = response;
110                     return vnflist;
111                 },
112                 function(response) {
113                     console.log("validationTestService::getAllVNF::Status Code", response);
114                     return response;
115                 });
116
117     };
118     
119     this.getlastupdated = function() {
120         var testlist = {};
121         return $http.get('/backuptime')
122             .then(function(response) {
123                     console.log("---validationTestService::getBackuptime::---" + response);         
124                     return response;
125                 })          
126
127     };
128     
129     this.runApplyconfig = function(vnfid, newConfig) {
130
131  
132         
133         var url='/vnf-list/'+vnfid;
134         
135         
136         
137         var config = {
138                  headers : {
139                      'Content-Type': 'application/json'
140                  }
141              }
142
143          $http.put(url, newConfig, config)
144          .success(function(newConfig) {
145              console.log("---validationTestService::getAllVNF::TestResponse---" ,response);
146              
147              return  newConfig;
148          },
149          function(newConfig) {
150              console.log("validationTestService::getAllVNF::Status Code", response);
151              return newConfig;
152          });
153     };
154         
155
156 }]);