Merge "Supporting user config task parameters in GUI"
[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             SUTDetail: function() {
62                 return $resource(Base_URL + '/api/v2/yardstick/environments/:envId/sut', { envId: "@envId" }, {
63                     'get': {
64                         method: 'GET'
65                     }
66                 })
67             },
68             ImageDetail: function() {
69                 return $resource(Base_URL + '/api/v2/yardstick/images/:image_id', { image_id: "@image_id" }, {
70                     'get': {
71                         method: 'GET'
72                     }
73                 })
74             },
75             podDeatil: function() {
76                 return $resource(Base_URL + '/api/v2/yardstick/pods/:podId', { podId: "@podId" }, {
77                     'get': {
78                         method: 'GET'
79                     }
80                 })
81             },
82             containerDetail: function() {
83                 return $resource(Base_URL + '/api/v2/yardstick/containers/:containerId', { containerId: "@containerId" }, {
84                     'get': {
85                         method: 'GET'
86                     }
87                 })
88             },
89             ImageList: function() {
90                 return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
91                     'get': {
92                         method: 'GET'
93                     }
94                 })
95             },
96             getImage: function(){
97                 return $resource(Base_URL + '/api/v2/yardstick/images/:imageId', {imageId: "@imageId"}, {
98                     'get': {
99                         method: 'GET'
100                     }
101                 })
102             },
103             deleteImage: function() {
104                 return $resource(Base_URL + '/api/v2/yardstick/images/:imageId', { imageId: '@imageId' }, {
105                     'delete': {
106                         method: 'DELETE'
107                     }
108                 })
109             },
110             uploadImage: function() {
111                 return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
112                     'post': {
113                         method: 'POST'
114                     }
115                 })
116             },
117             uploadImageByUrl: function() {
118                 return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
119                     'post': {
120                         method: 'POST'
121                     }
122                 })
123             },
124             getPodDetail: function() {
125                 return $resource(Base_URL + '/api/v2/yardstick/pods/:podId', { podId: "@podId" }, {
126                     'get': {
127                         method: 'GET'
128                     }
129                 })
130             },
131             runAcontainer: function() {
132                 return $resource(Base_URL + '/api/v2/yardstick/containers', { podId: "@podId" }, {
133                     'post': {
134                         method: 'POST'
135                     }
136                 })
137             },
138             getTestcaselist: function() {
139                 return $resource(Base_URL + '/api/v2/yardstick/testcases', {}, {
140                     'get': {
141                         method: 'GET'
142                     }
143                 })
144             },
145             getTestcaseDetail: function() {
146                 return $resource(Base_URL + '/api/v2/yardstick/testcases/:testcasename', { testcasename: "@testcasename" }, {
147                     'get': {
148                         method: 'GET'
149                     }
150                 })
151             },
152             suiteList: function() {
153                 return $resource(Base_URL + '/api/v2/yardstick/testsuites', {}, {
154                     'get': {
155                         method: 'GET'
156                     }
157                 })
158             },
159             suiteDetail: function() {
160                 return $resource(Base_URL + '/api/v2/yardstick/testsuites/:suiteName', { suiteName: "@suiteName" }, {
161                     'get': {
162                         method: 'GET'
163                     }
164                 })
165             },
166             suiteCreate: function() {
167                 return $resource(Base_URL + '/api/v2/yardstick/testsuites', {}, {
168                     'post': {
169                         method: 'POST'
170                     }
171                 })
172             },
173             projectList: function() {
174                 return $resource(Base_URL + '/api/v2/yardstick/projects', {}, {
175                     'get': {
176                         method: 'GET'
177                     }
178                 })
179             },
180             createProjectName: function() {
181                 return $resource(Base_URL + '/api/v2/yardstick/projects', {}, {
182                     'post': {
183                         method: 'POST'
184                     }
185                 })
186             },
187             getProjectDetail: function() {
188                 return $resource(Base_URL + '/api/v2/yardstick/projects/:project_id', { project_id: "@project_id" }, {
189                     'post': {
190                         method: 'POST'
191                     }
192                 })
193             },
194             createTask: function() {
195                 return $resource(Base_URL + '/api/v2/yardstick/tasks', {}, {
196                     'post': {
197                         method: 'POST'
198                     }
199                 })
200             },
201             getTaskDetail: function() {
202                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId', { taskId: "@taskId" }, {
203                     'get': {
204                         method: 'GET'
205                     }
206                 })
207             },
208
209             getTaskLog: function(){
210                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId/log?index=:index', { taskId: "@taskId", index: "@index" }, {
211                     'get': {
212                         method: 'GET'
213                     }
214                 })
215             },
216
217             taskAddEnv: function() {
218                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId', { taskId: "@taskId" }, {
219                     'put': {
220                         method: 'PUT'
221                     }
222                 })
223             },
224
225             taskAddParams: function() {
226                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:taskId', { taskId: "@taskId" }, {
227                     'put': {
228                         method: 'PUT'
229                     }
230                 })
231             },
232             //delete operate
233             deleteEnv: function() {
234                 return $resource(Base_URL + '/api/v2/yardstick/environments/:env_id', { env_id: '@env_id' }, {
235                     'delete': {
236                         method: 'DELETE'
237                     }
238                 })
239             },
240             deleteOpenrc: function() {
241                 return $resource(Base_URL + '/api/v2/yardstick/openrcs/:openrc', { openrc: '@openrc' }, {
242                     'delete': {
243                         method: 'DELETE'
244                     }
245                 })
246             },
247             deletePod: function() {
248                 return $resource(Base_URL + '/api/v2/yardstick/pods/:podId', { podId: '@podId' }, {
249                     'delete': {
250                         method: 'DELETE'
251                     }
252                 })
253             },
254             deleteContainer: function() {
255                 return $resource(Base_URL + '/api/v2/yardstick/containers/:containerId', { containerId: '@containerId' }, {
256                     'delete': {
257                         method: 'DELETE'
258                     }
259                 })
260             },
261             deleteTestCase: function() {
262                 return $resource(Base_URL + '/api/v2/yardstick/testcases/:caseName', { caseName: '@caseName' }, {
263                     'delete': {
264                         method: 'DELETE'
265                     }
266                 })
267             },
268             deleteTestSuite: function() {
269                 return $resource(Base_URL + '/api/v2/yardstick/testsuites/:suite_name', { suite_name: '@suite_name' }, {
270                     'delete': {
271                         method: 'DELETE'
272                     }
273                 })
274             },
275             deleteProject: function() {
276                 return $resource(Base_URL + '/api/v2/yardstick/projects/:project_id', { project_id: '@project_id' }, {
277                     'delete': {
278                         method: 'DELETE'
279                     }
280                 })
281             },
282             deleteTask: function() {
283                 return $resource(Base_URL + '/api/v2/yardstick/tasks/:task_id', { task_id: '@task_id' }, {
284                     'delete': {
285                         method: 'DELETE'
286                     }
287                 })
288             },
289             errorHandler1: function(response){
290                 toaster.pop({
291                     'type': 'error',
292                     'title': 'error',
293                     'body': response.result,
294                     'showCloseButton': true
295                 });
296             },
297             errorHandler2: function(response){
298                 toaster.pop({
299                     'type': 'error',
300                     'title': response.status,
301                     'body': response.statusText,
302                     'showCloseButton': true
303                 });
304             }
305
306         };
307     }]);