added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / main / java / org / oran / otf / api / service / TestInstanceService.java
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\r
3 #   Licensed under the Apache License, Version 2.0 (the "License");            #\r
4 #   you may not use this file except in compliance with the License.           #\r
5 #   You may obtain a copy of the License at                                    #\r
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\r
9 #   Unless required by applicable law or agreed to in writing, software        #\r
10 #   distributed under the License is distributed on an "AS IS" BASIS,          #\r
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
12 #   See the License for the specific language governing permissions and        #\r
13 #   limitations under the License.                                             #\r
14 ##############################################################################*/\r
15 \r
16 \r
17 package org.oran.otf.api.service;\r
18 \r
19 import org.oran.otf.common.model.TestExecution;\r
20 import org.oran.otf.common.model.TestInstance;\r
21 import org.oran.otf.common.model.local.OTFApiResponse;\r
22 import org.oran.otf.common.model.local.TestInstanceCreateRequest;\r
23 import org.oran.otf.common.model.local.WorkflowRequest;\r
24 import io.swagger.v3.oas.annotations.Operation;\r
25 import io.swagger.v3.oas.annotations.Parameter;\r
26 import io.swagger.v3.oas.annotations.media.ArraySchema;\r
27 import io.swagger.v3.oas.annotations.media.Content;\r
28 import io.swagger.v3.oas.annotations.media.Schema;\r
29 import io.swagger.v3.oas.annotations.responses.ApiResponse;\r
30 import io.swagger.v3.oas.annotations.tags.Tag;\r
31 import javax.ws.rs.Consumes;\r
32 import javax.ws.rs.GET;\r
33 import javax.ws.rs.HeaderParam;\r
34 import javax.ws.rs.POST;\r
35 import javax.ws.rs.Path;\r
36 import javax.ws.rs.PathParam;\r
37 import javax.ws.rs.Produces;\r
38 import javax.ws.rs.core.MediaType;\r
39 import javax.ws.rs.core.Response;\r
40 \r
41 import org.springframework.stereotype.Component;\r
42 \r
43 @Component\r
44 @Path("/testInstance")\r
45 @Tag(name = "Test Services", description = "")\r
46 @Produces(MediaType.APPLICATION_JSON)\r
47 public interface TestInstanceService {\r
48   @POST\r
49   @Path("/execute/v1/id/{testInstanceId}")\r
50   @Operation(\r
51       description =\r
52           "Execute a test instance by it's unique identifier. Test instances can be executed"\r
53               + " either both synchronously and asynchronously.",\r
54       summary = "Execute test instance by id",\r
55       responses = {\r
56         @ApiResponse(\r
57             responseCode = "200",\r
58             description =\r
59                 "A successful synchronously executed test returns a test execution object",\r
60             content =\r
61                 @Content(\r
62                     mediaType = "application/json",\r
63                     schema = @Schema(implementation = TestExecution.class))),\r
64         @ApiResponse(\r
65             responseCode = "201",\r
66             description =\r
67                 "A successful asynchronously executed test instance returns a base test execution.",\r
68             content =\r
69                 @Content(\r
70                     mediaType = "application/json",\r
71                     schema = @Schema(implementation = TestExecution.class))),\r
72         @ApiResponse(\r
73             responseCode = "401",\r
74             description =\r
75                 "The mechanized identifier used with the request is prohibited from accessing the resource.",\r
76             content = {\r
77               @Content(\r
78                   mediaType = "application/json",\r
79                   schema = @Schema(implementation = OTFApiResponse.class))\r
80             })\r
81       })\r
82   @Consumes(MediaType.APPLICATION_JSON)\r
83   @Produces(MediaType.APPLICATION_JSON)\r
84   Response execute(\r
85       @Parameter(\r
86               allowEmptyValue = false,\r
87               description = "A string representation of a BSON ObjectId",\r
88               example = "12345678912345678912345f",\r
89               required = true,\r
90               schema =\r
91                   @Schema(\r
92                       type = "string",\r
93                       format = "objectid",\r
94                       description = "The UUID of the test instance"))\r
95           @PathParam("testInstanceId")\r
96           String testInstanceId,\r
97       @Parameter(\r
98               allowEmptyValue = false,\r
99               description = "Base64 encoded Application Authorization Framework credentials",\r
100               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
101               required = true)\r
102           @HeaderParam("Authorization")\r
103           String authorization,\r
104       WorkflowRequest request);\r
105 \r
106   @POST\r
107   @Operation(\r
108       description = "Create a test instance using the latest version of the test definition.",\r
109       summary = "Create test instance by test definition id",\r
110       responses = {\r
111         @ApiResponse(\r
112             responseCode = "201",\r
113             description = "The created Test Instance object is returned when it is created",\r
114             content = {\r
115               @Content(\r
116                   mediaType = "application/json",\r
117                   schema = @Schema(implementation = TestInstance.class))\r
118             })\r
119       })\r
120   @Consumes(MediaType.APPLICATION_JSON)\r
121   @Produces(MediaType.APPLICATION_JSON)\r
122   @Path("/create/v1/testDefinitionId/{testDefinitionId}")\r
123   Response createByTestDefinitionId(\r
124       @Parameter(\r
125               allowEmptyValue = false,\r
126               description = "A string representation of a BSON ObjectId",\r
127               example = "12345678912345678912345f",\r
128               required = true,\r
129               schema =\r
130                   @Schema(\r
131                       type = "string",\r
132                       format = "uuid",\r
133                       description = "The UUID of the test definition"))\r
134           @PathParam("testDefinitionId")\r
135           String testDefinitionId,\r
136       @Parameter(\r
137               allowEmptyValue = false,\r
138               description = "Base64 encoded Application Authorization Framework credentials",\r
139               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
140               required = true)\r
141           @HeaderParam("Authorization")\r
142           String authorization,\r
143       TestInstanceCreateRequest request);\r
144 \r
145   @POST\r
146   @Operation(\r
147       description = "Create a test instance using the specified version of the test definition",\r
148       summary = "Create test instance by test definition id and version",\r
149       responses = {\r
150         @ApiResponse(\r
151             responseCode = "201",\r
152             description = "The created Test Instance object is returned when it is created",\r
153             content = {\r
154               @Content(\r
155                   mediaType = "application/json",\r
156                   schema = @Schema(implementation = TestInstance.class))\r
157             })\r
158       })\r
159   @Consumes(MediaType.APPLICATION_JSON)\r
160   @Produces(MediaType.APPLICATION_JSON)\r
161   @Path("/create/v1/testDefinitionId/{testDefinitionId}/version/{version}")\r
162   Response createByTestDefinitionId(\r
163       @Parameter(\r
164               allowEmptyValue = false,\r
165               description = "A string representation of a BSON ObjectId",\r
166               example = "12345678912345678912345f",\r
167               required = true,\r
168               schema =\r
169                   @Schema(\r
170                       type = "string",\r
171                       format = "uuid",\r
172                       description = "The UUID of the test definition."))\r
173           @PathParam("testDefinitionId")\r
174           String testDefinitionId,\r
175       @Parameter(\r
176               allowEmptyValue = false,\r
177               description = "The version of the test definition used to create the instance",\r
178               example = "2",\r
179               required = true)\r
180           @PathParam("version")\r
181           int version,\r
182       @Parameter(\r
183               allowEmptyValue = false,\r
184               description = "Base64 encoded Application Authorization Framework credentials",\r
185               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
186               required = true)\r
187           @HeaderParam("Authorization")\r
188           String authorization,\r
189       TestInstanceCreateRequest request);\r
190 \r
191   @POST\r
192   @Operation(\r
193       description = "Create a test instance using the latest version of the test definition",\r
194       summary = "Create test instance by process definition key",\r
195       responses = {\r
196         @ApiResponse(\r
197             responseCode = "201",\r
198             description = "The created Test Instance object is returned when it is created",\r
199             content = {\r
200               @Content(\r
201                   mediaType = "application/json",\r
202                   schema = @Schema(implementation = TestInstance.class))\r
203             })\r
204       })\r
205   @Consumes(MediaType.APPLICATION_JSON)\r
206   @Produces(MediaType.APPLICATION_JSON)\r
207   @Path("/create/v1/processDefinitionKey/{processDefinitionKey}")\r
208   Response createByProcessDefinitionKey(\r
209       @Parameter(\r
210               allowEmptyValue = false,\r
211               description = "The process definition key associated with the test definition",\r
212               example = "someUniqueProcessDefinitionKey",\r
213               required = true)\r
214           @PathParam("processDefinitionKey")\r
215           String processDefinitionKey,\r
216       @Parameter(\r
217               allowEmptyValue = false,\r
218               description = "Base64 encoded Application Authorization Framework credentials",\r
219               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
220               required = true)\r
221           @HeaderParam("Authorization")\r
222           String authorization,\r
223       TestInstanceCreateRequest request);\r
224 \r
225   @POST\r
226   @Operation(\r
227       description = "Create a test instance using the unique process definition key and version",\r
228       summary = "Create test instance by process definition key and version",\r
229       responses = {\r
230         @ApiResponse(\r
231             responseCode = "201",\r
232             description = "The created Test Instance object is returned when it is created",\r
233             content = {\r
234               @Content(\r
235                   mediaType = "application/json",\r
236                   schema = @Schema(implementation = TestInstance.class))\r
237             })\r
238       })\r
239   @Consumes(MediaType.APPLICATION_JSON)\r
240   @Produces(MediaType.APPLICATION_JSON)\r
241   @Path("/create/v1/processDefinitionKey/{processDefinitionKey}/version/{version}")\r
242   Response createByProcessDefinitionKey(\r
243       @Parameter(\r
244               allowEmptyValue = false,\r
245               description = "The process definition key associated with the test definition",\r
246               example = "someUniqueProcessDefinitionKey",\r
247               required = true)\r
248           @PathParam("processDefinitionKey")\r
249           String processDefinitionKey,\r
250       @Parameter(\r
251               allowEmptyValue = false,\r
252               description = "The version of the test definition used to create the instance",\r
253               example = "2",\r
254               required = true)\r
255           @PathParam("version")\r
256           int version,\r
257       @Parameter(\r
258               allowEmptyValue = false,\r
259               description = "Base64 encoded Application Authorization Framework credentials",\r
260               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
261               required = true)\r
262           @HeaderParam("Authorization")\r
263           String authorization,\r
264       TestInstanceCreateRequest request);\r
265 \r
266   @GET\r
267   @Operation(\r
268       description = "Finds a test instance by it's unique identifier",\r
269       summary = "Find test instance by id",\r
270       responses = {\r
271         @ApiResponse(\r
272             responseCode = "200",\r
273             description = "A Test Instance object is returned if it exists",\r
274             content = {\r
275               @Content(\r
276                   mediaType = "application/json",\r
277                   schema = @Schema(implementation = TestInstance.class))\r
278             })\r
279       })\r
280   @Produces(MediaType.APPLICATION_JSON)\r
281   @Path("/v1/id/{id}")\r
282   Response findById(\r
283       @Parameter(\r
284               allowEmptyValue = false,\r
285               description = "A string representation of a BSON ObjectId",\r
286               example = "12345678912345678912345f",\r
287               required = true,\r
288               schema =\r
289                   @Schema(\r
290                       type = "string",\r
291                       format = "uuid",\r
292                       description = "The UUID of the test instance"))\r
293           @PathParam("id")\r
294           String testInstanceId,\r
295       @Parameter(\r
296               allowEmptyValue = false,\r
297               description = "Base64 encoded Application Authorization Framework credentials",\r
298               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
299               required = true)\r
300           @HeaderParam("Authorization")\r
301           String authorization);\r
302 \r
303   @GET\r
304   @Operation(\r
305       description = "Finds all test instance belonging to the unique process definition key",\r
306       summary = "Find test instance(s) by process definition key",\r
307       responses = {\r
308         @ApiResponse(\r
309             responseCode = "200",\r
310             description = "An array of found Test Instance objects are returned",\r
311             content = {\r
312               @Content(\r
313                   array = @ArraySchema(schema = @Schema(implementation = TestInstance.class)),\r
314                   mediaType = "application/json")\r
315             })\r
316       })\r
317   @Produces(MediaType.APPLICATION_JSON)\r
318   @Path("/v1/processDefinitionKey/{processDefinitionKey}")\r
319   Response findByProcessDefinitionKey(\r
320       @Parameter(\r
321               allowEmptyValue = false,\r
322               description = "The process definition key associated with the test definition",\r
323               example = "someUniqueProcessDefinitionKey",\r
324               required = true)\r
325           @PathParam("processDefinitionKey")\r
326           String processDefinitionKey,\r
327       @Parameter(\r
328               allowEmptyValue = false,\r
329               description = "Base64 encoded Application Authorization Framework credentials",\r
330               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
331               required = true)\r
332           @HeaderParam("Authorization")\r
333           String authorization);\r
334 \r
335   @GET\r
336   @Operation(\r
337       description =\r
338           "Finds all test instance belonging to the unique process definition key and version",\r
339       summary = "Find test instance(s) by process definition key and version",\r
340       responses = {\r
341         @ApiResponse(\r
342             responseCode = "200",\r
343             description = "An array of found Test Instance objects are returned",\r
344             content = {\r
345               @Content(\r
346                   array = @ArraySchema(schema = @Schema(implementation = TestInstance.class)),\r
347                   mediaType = "application/json")\r
348             })\r
349       })\r
350   @Produces(MediaType.APPLICATION_JSON)\r
351   @Path("/v1/processDefinitionKey/{processDefinitionKey}/version/{version}")\r
352   Response findByProcessDefinitionKeyAndVersion(\r
353       @Parameter(\r
354               allowEmptyValue = false,\r
355               description = "The process definition key associated with the test definition",\r
356               example = "someUniqueProcessDefinitionKey",\r
357               required = true)\r
358           @PathParam("processDefinitionKey")\r
359           String processDefinitionKey,\r
360       @Parameter(\r
361               allowEmptyValue = false,\r
362               description = "The version of the test definition used to create the instance",\r
363               example = "2",\r
364               required = true)\r
365           @PathParam("version")\r
366           String version,\r
367       @Parameter(\r
368               allowEmptyValue = false,\r
369               description = "Base64 encoded Application Authorization Framework credentials",\r
370               example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
371               required = true)\r
372           @HeaderParam("Authorization")\r
373           String authorization);\r
374 }\r