Fixing vPE config creation anf bring up issues.
[yardstick.git] / gui / app / scripts / factory / main.factory.js
1 'use strict';
2
3 /**
4  * get data factory
5  */
6
7
8 var Base_URL;
9 var Grafana_URL;
10
11 angular.module('yardStickGui2App')
12     .factory('mainFactory', ['$resource','$rootScope','$http', '$location', 'toaster',function($resource, $rootScope ,$http ,$location, toaster) {
13
14         Base_URL = 'http://' + $location.host() + ':' + $location.port();
15         Grafana_URL = 'http://' + $location.host();
16
17         return {
18
19             postEnvironmentVariable: function() {
20                 return $resource(Base_URL + '/api/v2/yardstick/openrcs', {}, {
21                     'post': {
22                         method: 'POST'
23                     }
24                 })
25             },
26             uploadOpenrc: function() {
27                 return $resource(Base_URL + '/ap/v2/yardstick/openrcs', {}, {
28                     'post': {
29                         method: 'POST'
30                     }
31                 })
32             },
33             getEnvironmentList: function() {
34                 return $resource(Base_URL+ '/api/v2/yardstick/environments', {}, {
35                     'get': {
36                         method: 'GET'
37                     }
38                 })
39             },
40             getEnvironmentDetail: function() {
41                 return $resource(Base_URL + '/api/v2/yardstick/openrcs/:openrc_id', { openrc_id: "@openrc_id" }, {
42                     'get': {
43                         method: 'GET'
44                     }
45                 })
46             },
47             addEnvName: function() {
48                 return $resource(Base_URL + '/api/v2/yardstick/environments', {}, {
49                     'post': {
50                         method: 'POST'
51                     }
52                 })
53             },
54             ItemDetail: function() {
55                 return $resource(Base_URL + '/api/v2/yardstick/environments/:envId', { envId: "@envId" }, {
56                     'get': {
57                         method: 'GET'
58                     }
59                 })
60             },
61             ImageDetail: function() {
62                 return $resource(Base_URL + '/api/v2/yardstick/images/:image_id', { image_id: "@image_id" }, {
63                     'get': {
64                         method: 'GET'
65                     }
66                 })
67             },
68             podDeatil: function() {
69                 return $resource(Base_URL + '/api/v2/yardstick/pods/:podId', { podId: "@podId" }, {
70                     'get': {
71                         method: 'GET'
72                     }
73                 })
74             },
75             containerDetail: function() {
76                 return $resource(Base_URL + '/api/v2/yardstick/containers/:containerId', { containerId: "@containerId" }, {
77                     'get': {
78                         method: 'GET'
79                     }
80                 })
81             },
82             ImageList: function() {
83                 return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
84                     'get': {
85                         method: 'GET'
86                     }
87                 })
88             },
89             getImage: function(){
90                 return $resource(Base_URL + '/api/v2/yardstick/images/:imageId', {imageId: "@imageId"}, {
91                     'get': {
92                         method: 'GET'
93                     }
94                 })
95             },
96             deleteImage: function() {
97                 return $resource(Base_URL + '/api/v2/yardstick/images/:imageId', { imageId: '@imageId' }, {
98                     'delete': {
99                         method: 'DELETE'
100                     }
101                 })
102             },
103             uploadImage: function() {
104                 return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
105                     'post': {
106                         method: 'POST'
107                     }
108                 })
109             },
110             uploadImageByUrl: function() {
111                 return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
112                     'post': {
113                         method: 'POST'
114                     }
115                 })
116             },
117             getPodDetail: function() {
118                 return $resource(Base_URL + '/api/v2/yardstick/pods/:podId', { podId: "@podId" }, {
119                     'get': {
120                         method: 'GET'
121                     }
122                 })
123             },
124             runAcontainer: function() {
125                 return $resource(Base_URL + '/api/v2/yardstick/containers', { podId: "@podId" }, {
126                     'post': {
127                         method: 'POST'
128                     }
129                 })
130             },
131             getTestcaselist: function() {
132                 return $resource(Base_URL + '/api/v2/yardstick/testcases', {}, {
133                     'get': {
134                         method: 'GET'
135                     }
136                 })
137             },
138             getTestcaseDetail: function() {
139                 return $resource(Base_URL + '/api/v2/yardstick/testcases/:testcasename', { testcasename: "@testcasename" }, {
140                     'get': {
141                         method: 'GET'
142                     }
143                 })
144             },
145             suiteList: function() {
146                 return $resource(Base_URL + '/api/v2/yardstick/testsuites', {}, {
147                     'get': {
148                         method: 'GET'
149                     }
150                 })
151             },
152             suiteDetail: function() {
153                 return $resource(Base_URL + '/api/v2/yardstick/testsuites/:suiteName', { suiteName: "@suiteName" }, {
154                     'get': {
155                         method: 'GET'
156                     }
157                 })
158             },
159             suiteCreate: function() {
160                 return $resource(Base_URL + '/api/v2/yardstick/testsuites', {}, {
161                     'post': {
162                         method: 'POST'
163                     }
164                 })
165             },
166             projectList: function() {
167                 return $resource(Base_URL + '/api/v2/yardstick/projects', {}, {
168                     'get': {
169                         method: 'GET'
170                     }
171                 })
172             },
173             createProjectName: function() {
174                 return $resource(Base_URL + '/api/v2/yardstick/projects', {}, {
175                     'post': {
176                         method: 'POST'
177                     }
178                 })
179             },
180             getProjectDetail: function() {
181                 return $resource(Base_URL + '/api/v2/yardstick/projects/:project_id', { project_id: "@project_id" }, {
182                     'post': {
183                         method: 'POST'
184                     }
185                 })
186             },
187             createTask: function() {
188                 return $resource(Base_URL + '/api/v2/yardstick/tasks', {}, {
189                     'post': {
190                         method: 'POST'
191                     }
192                 })
193             },
194             getTaskDetail: function() {
195                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId', { taskId: "@taskId" }, {
196                     'get': {
197                         method: 'GET'
198                     }
199                 })
200             },
201
202             getTaskLog: function(){
203                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId/log?index=:index', { taskId: "@taskId", index: "@index" }, {
204                     'get': {
205                         method: 'GET'
206                     }
207                 })
208             },
209
210             taskAddEnv: function() {
211                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId', { taskId: "@taskId" }, {
212                     'put': {
213                         method: 'PUT'
214                     }
215                 })
216             },
217             //delete operate
218             deleteEnv: function() {
219                 return $resource(Base_URL + '/api/v2/yardstick/environments/:env_id', { env_id: '@env_id' }, {
220                     'delete': {
221                         method: 'DELETE'
222                     }
223                 })
224             },
225             deleteOpenrc: function() {
226                 return $resource(Base_URL + '/api/v2/yardstick/openrcs/:openrc', { openrc: '@openrc' }, {
227                     'delete': {
228                         method: 'DELETE'
229                     }
230                 })
231             },
232             deletePod: function() {
233                 return $resource(Base_URL + '/api/v2/yardstick/pods/:podId', { podId: '@podId' }, {
234                     'delete': {
235                         method: 'DELETE'
236                     }
237                 })
238             },
239             deleteContainer: function() {
240                 return $resource(Base_URL + '/api/v2/yardstick/containers/:containerId', { containerId: '@containerId' }, {
241                     'delete': {
242                         method: 'DELETE'
243                     }
244                 })
245             },
246             deleteTestCase: function() {
247                 return $resource(Base_URL + '/api/v2/yardstick/testcases/:caseName', { caseName: '@caseName' }, {
248                     'delete': {
249                         method: 'DELETE'
250                     }
251                 })
252             },
253             deleteTestSuite: function() {
254                 return $resource(Base_URL + '/api/v2/yardstick/testsuites/:suite_name', { suite_name: '@suite_name' }, {
255                     'delete': {
256                         method: 'DELETE'
257                     }
258                 })
259             },
260             deleteProject: function() {
261                 return $resource(Base_URL + '/api/v2/yardstick/projects/:project_id', { project_id: '@project_id' }, {
262                     'delete': {
263                         method: 'DELETE'
264                     }
265                 })
266             },
267             deleteTask: function() {
268                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:task_id', { task_id: '@task_id' }, {
269                     'delete': {
270                         method: 'DELETE'
271                     }
272                 })
273             },
274             errorHandler1: function(response){
275                 toaster.pop({
276                     'type': 'error',
277                     'title': 'error',
278                     'body': response.result,
279                     'showCloseButton': true
280                 });
281             },
282             errorHandler2: function(response){
283                 toaster.pop({
284                     'type': 'error',
285                     'title': response.status,
286                     'body': response.statusText,
287                     'showCloseButton': true
288                 });
289             }
290
291         };
292     }]);