1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\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
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\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
17 package org.oran.otf.api.service;
\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
41 import org.springframework.stereotype.Component;
\r
44 @Path("/testInstance")
\r
45 @Tag(name = "Test Services", description = "")
\r
46 @Produces(MediaType.APPLICATION_JSON)
\r
47 public interface TestInstanceService {
\r
49 @Path("/execute/v1/id/{testInstanceId}")
\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
57 responseCode = "200",
\r
59 "A successful synchronously executed test returns a test execution object",
\r
62 mediaType = "application/json",
\r
63 schema = @Schema(implementation = TestExecution.class))),
\r
65 responseCode = "201",
\r
67 "A successful asynchronously executed test instance returns a base test execution.",
\r
70 mediaType = "application/json",
\r
71 schema = @Schema(implementation = TestExecution.class))),
\r
73 responseCode = "401",
\r
75 "The mechanized identifier used with the request is prohibited from accessing the resource.",
\r
78 mediaType = "application/json",
\r
79 schema = @Schema(implementation = OTFApiResponse.class))
\r
82 @Consumes(MediaType.APPLICATION_JSON)
\r
83 @Produces(MediaType.APPLICATION_JSON)
\r
86 allowEmptyValue = false,
\r
87 description = "A string representation of a BSON ObjectId",
\r
88 example = "12345678912345678912345f",
\r
93 format = "objectid",
\r
94 description = "The UUID of the test instance"))
\r
95 @PathParam("testInstanceId")
\r
96 String testInstanceId,
\r
98 allowEmptyValue = false,
\r
99 description = "Base64 encoded Application Authorization Framework credentials",
\r
100 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
102 @HeaderParam("Authorization")
\r
103 String authorization,
\r
104 WorkflowRequest request);
\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
112 responseCode = "201",
\r
113 description = "The created Test Instance object is returned when it is created",
\r
116 mediaType = "application/json",
\r
117 schema = @Schema(implementation = TestInstance.class))
\r
120 @Consumes(MediaType.APPLICATION_JSON)
\r
121 @Produces(MediaType.APPLICATION_JSON)
\r
122 @Path("/create/v1/testDefinitionId/{testDefinitionId}")
\r
123 Response createByTestDefinitionId(
\r
125 allowEmptyValue = false,
\r
126 description = "A string representation of a BSON ObjectId",
\r
127 example = "12345678912345678912345f",
\r
133 description = "The UUID of the test definition"))
\r
134 @PathParam("testDefinitionId")
\r
135 String testDefinitionId,
\r
137 allowEmptyValue = false,
\r
138 description = "Base64 encoded Application Authorization Framework credentials",
\r
139 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
141 @HeaderParam("Authorization")
\r
142 String authorization,
\r
143 TestInstanceCreateRequest request);
\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
151 responseCode = "201",
\r
152 description = "The created Test Instance object is returned when it is created",
\r
155 mediaType = "application/json",
\r
156 schema = @Schema(implementation = TestInstance.class))
\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
164 allowEmptyValue = false,
\r
165 description = "A string representation of a BSON ObjectId",
\r
166 example = "12345678912345678912345f",
\r
172 description = "The UUID of the test definition."))
\r
173 @PathParam("testDefinitionId")
\r
174 String testDefinitionId,
\r
176 allowEmptyValue = false,
\r
177 description = "The version of the test definition used to create the instance",
\r
180 @PathParam("version")
\r
183 allowEmptyValue = false,
\r
184 description = "Base64 encoded Application Authorization Framework credentials",
\r
185 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
187 @HeaderParam("Authorization")
\r
188 String authorization,
\r
189 TestInstanceCreateRequest request);
\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
197 responseCode = "201",
\r
198 description = "The created Test Instance object is returned when it is created",
\r
201 mediaType = "application/json",
\r
202 schema = @Schema(implementation = TestInstance.class))
\r
205 @Consumes(MediaType.APPLICATION_JSON)
\r
206 @Produces(MediaType.APPLICATION_JSON)
\r
207 @Path("/create/v1/processDefinitionKey/{processDefinitionKey}")
\r
208 Response createByProcessDefinitionKey(
\r
210 allowEmptyValue = false,
\r
211 description = "The process definition key associated with the test definition",
\r
212 example = "someUniqueProcessDefinitionKey",
\r
214 @PathParam("processDefinitionKey")
\r
215 String processDefinitionKey,
\r
217 allowEmptyValue = false,
\r
218 description = "Base64 encoded Application Authorization Framework credentials",
\r
219 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
221 @HeaderParam("Authorization")
\r
222 String authorization,
\r
223 TestInstanceCreateRequest request);
\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
231 responseCode = "201",
\r
232 description = "The created Test Instance object is returned when it is created",
\r
235 mediaType = "application/json",
\r
236 schema = @Schema(implementation = TestInstance.class))
\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
244 allowEmptyValue = false,
\r
245 description = "The process definition key associated with the test definition",
\r
246 example = "someUniqueProcessDefinitionKey",
\r
248 @PathParam("processDefinitionKey")
\r
249 String processDefinitionKey,
\r
251 allowEmptyValue = false,
\r
252 description = "The version of the test definition used to create the instance",
\r
255 @PathParam("version")
\r
258 allowEmptyValue = false,
\r
259 description = "Base64 encoded Application Authorization Framework credentials",
\r
260 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
262 @HeaderParam("Authorization")
\r
263 String authorization,
\r
264 TestInstanceCreateRequest request);
\r
268 description = "Finds a test instance by it's unique identifier",
\r
269 summary = "Find test instance by id",
\r
272 responseCode = "200",
\r
273 description = "A Test Instance object is returned if it exists",
\r
276 mediaType = "application/json",
\r
277 schema = @Schema(implementation = TestInstance.class))
\r
280 @Produces(MediaType.APPLICATION_JSON)
\r
281 @Path("/v1/id/{id}")
\r
284 allowEmptyValue = false,
\r
285 description = "A string representation of a BSON ObjectId",
\r
286 example = "12345678912345678912345f",
\r
292 description = "The UUID of the test instance"))
\r
294 String testInstanceId,
\r
296 allowEmptyValue = false,
\r
297 description = "Base64 encoded Application Authorization Framework credentials",
\r
298 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
300 @HeaderParam("Authorization")
\r
301 String authorization);
\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
309 responseCode = "200",
\r
310 description = "An array of found Test Instance objects are returned",
\r
313 array = @ArraySchema(schema = @Schema(implementation = TestInstance.class)),
\r
314 mediaType = "application/json")
\r
317 @Produces(MediaType.APPLICATION_JSON)
\r
318 @Path("/v1/processDefinitionKey/{processDefinitionKey}")
\r
319 Response findByProcessDefinitionKey(
\r
321 allowEmptyValue = false,
\r
322 description = "The process definition key associated with the test definition",
\r
323 example = "someUniqueProcessDefinitionKey",
\r
325 @PathParam("processDefinitionKey")
\r
326 String processDefinitionKey,
\r
328 allowEmptyValue = false,
\r
329 description = "Base64 encoded Application Authorization Framework credentials",
\r
330 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
332 @HeaderParam("Authorization")
\r
333 String authorization);
\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
342 responseCode = "200",
\r
343 description = "An array of found Test Instance objects are returned",
\r
346 array = @ArraySchema(schema = @Schema(implementation = TestInstance.class)),
\r
347 mediaType = "application/json")
\r
350 @Produces(MediaType.APPLICATION_JSON)
\r
351 @Path("/v1/processDefinitionKey/{processDefinitionKey}/version/{version}")
\r
352 Response findByProcessDefinitionKeyAndVersion(
\r
354 allowEmptyValue = false,
\r
355 description = "The process definition key associated with the test definition",
\r
356 example = "someUniqueProcessDefinitionKey",
\r
358 @PathParam("processDefinitionKey")
\r
359 String processDefinitionKey,
\r
361 allowEmptyValue = false,
\r
362 description = "The version of the test definition used to create the instance",
\r
365 @PathParam("version")
\r
368 allowEmptyValue = false,
\r
369 description = "Base64 encoded Application Authorization Framework credentials",
\r
370 example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",
\r
372 @HeaderParam("Authorization")
\r
373 String authorization);
\r