added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / main / java / org / oran / otf / api / service / TestInstanceService.java
diff --git a/otf-service-api/src/main/java/org/oran/otf/api/service/TestInstanceService.java b/otf-service-api/src/main/java/org/oran/otf/api/service/TestInstanceService.java
new file mode 100644 (file)
index 0000000..6b60801
--- /dev/null
@@ -0,0 +1,374 @@
+/*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
+#                                                                              #\r
+#   Licensed under the Apache License, Version 2.0 (the "License");            #\r
+#   you may not use this file except in compliance with the License.           #\r
+#   You may obtain a copy of the License at                                    #\r
+#                                                                              #\r
+#       http://www.apache.org/licenses/LICENSE-2.0                             #\r
+#                                                                              #\r
+#   Unless required by applicable law or agreed to in writing, software        #\r
+#   distributed under the License is distributed on an "AS IS" BASIS,          #\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
+#   See the License for the specific language governing permissions and        #\r
+#   limitations under the License.                                             #\r
+##############################################################################*/\r
+\r
+\r
+package org.oran.otf.api.service;\r
+\r
+import org.oran.otf.common.model.TestExecution;\r
+import org.oran.otf.common.model.TestInstance;\r
+import org.oran.otf.common.model.local.OTFApiResponse;\r
+import org.oran.otf.common.model.local.TestInstanceCreateRequest;\r
+import org.oran.otf.common.model.local.WorkflowRequest;\r
+import io.swagger.v3.oas.annotations.Operation;\r
+import io.swagger.v3.oas.annotations.Parameter;\r
+import io.swagger.v3.oas.annotations.media.ArraySchema;\r
+import io.swagger.v3.oas.annotations.media.Content;\r
+import io.swagger.v3.oas.annotations.media.Schema;\r
+import io.swagger.v3.oas.annotations.responses.ApiResponse;\r
+import io.swagger.v3.oas.annotations.tags.Tag;\r
+import javax.ws.rs.Consumes;\r
+import javax.ws.rs.GET;\r
+import javax.ws.rs.HeaderParam;\r
+import javax.ws.rs.POST;\r
+import javax.ws.rs.Path;\r
+import javax.ws.rs.PathParam;\r
+import javax.ws.rs.Produces;\r
+import javax.ws.rs.core.MediaType;\r
+import javax.ws.rs.core.Response;\r
+\r
+import org.springframework.stereotype.Component;\r
+\r
+@Component\r
+@Path("/testInstance")\r
+@Tag(name = "Test Services", description = "")\r
+@Produces(MediaType.APPLICATION_JSON)\r
+public interface TestInstanceService {\r
+  @POST\r
+  @Path("/execute/v1/id/{testInstanceId}")\r
+  @Operation(\r
+      description =\r
+          "Execute a test instance by it's unique identifier. Test instances can be executed"\r
+              + " either both synchronously and asynchronously.",\r
+      summary = "Execute test instance by id",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "200",\r
+            description =\r
+                "A successful synchronously executed test returns a test execution object",\r
+            content =\r
+                @Content(\r
+                    mediaType = "application/json",\r
+                    schema = @Schema(implementation = TestExecution.class))),\r
+        @ApiResponse(\r
+            responseCode = "201",\r
+            description =\r
+                "A successful asynchronously executed test instance returns a base test execution.",\r
+            content =\r
+                @Content(\r
+                    mediaType = "application/json",\r
+                    schema = @Schema(implementation = TestExecution.class))),\r
+        @ApiResponse(\r
+            responseCode = "401",\r
+            description =\r
+                "The mechanized identifier used with the request is prohibited from accessing the resource.",\r
+            content = {\r
+              @Content(\r
+                  mediaType = "application/json",\r
+                  schema = @Schema(implementation = OTFApiResponse.class))\r
+            })\r
+      })\r
+  @Consumes(MediaType.APPLICATION_JSON)\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  Response execute(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "A string representation of a BSON ObjectId",\r
+              example = "12345678912345678912345f",\r
+              required = true,\r
+              schema =\r
+                  @Schema(\r
+                      type = "string",\r
+                      format = "objectid",\r
+                      description = "The UUID of the test instance"))\r
+          @PathParam("testInstanceId")\r
+          String testInstanceId,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization,\r
+      WorkflowRequest request);\r
+\r
+  @POST\r
+  @Operation(\r
+      description = "Create a test instance using the latest version of the test definition.",\r
+      summary = "Create test instance by test definition id",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "201",\r
+            description = "The created Test Instance object is returned when it is created",\r
+            content = {\r
+              @Content(\r
+                  mediaType = "application/json",\r
+                  schema = @Schema(implementation = TestInstance.class))\r
+            })\r
+      })\r
+  @Consumes(MediaType.APPLICATION_JSON)\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  @Path("/create/v1/testDefinitionId/{testDefinitionId}")\r
+  Response createByTestDefinitionId(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "A string representation of a BSON ObjectId",\r
+              example = "12345678912345678912345f",\r
+              required = true,\r
+              schema =\r
+                  @Schema(\r
+                      type = "string",\r
+                      format = "uuid",\r
+                      description = "The UUID of the test definition"))\r
+          @PathParam("testDefinitionId")\r
+          String testDefinitionId,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization,\r
+      TestInstanceCreateRequest request);\r
+\r
+  @POST\r
+  @Operation(\r
+      description = "Create a test instance using the specified version of the test definition",\r
+      summary = "Create test instance by test definition id and version",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "201",\r
+            description = "The created Test Instance object is returned when it is created",\r
+            content = {\r
+              @Content(\r
+                  mediaType = "application/json",\r
+                  schema = @Schema(implementation = TestInstance.class))\r
+            })\r
+      })\r
+  @Consumes(MediaType.APPLICATION_JSON)\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  @Path("/create/v1/testDefinitionId/{testDefinitionId}/version/{version}")\r
+  Response createByTestDefinitionId(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "A string representation of a BSON ObjectId",\r
+              example = "12345678912345678912345f",\r
+              required = true,\r
+              schema =\r
+                  @Schema(\r
+                      type = "string",\r
+                      format = "uuid",\r
+                      description = "The UUID of the test definition."))\r
+          @PathParam("testDefinitionId")\r
+          String testDefinitionId,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "The version of the test definition used to create the instance",\r
+              example = "2",\r
+              required = true)\r
+          @PathParam("version")\r
+          int version,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization,\r
+      TestInstanceCreateRequest request);\r
+\r
+  @POST\r
+  @Operation(\r
+      description = "Create a test instance using the latest version of the test definition",\r
+      summary = "Create test instance by process definition key",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "201",\r
+            description = "The created Test Instance object is returned when it is created",\r
+            content = {\r
+              @Content(\r
+                  mediaType = "application/json",\r
+                  schema = @Schema(implementation = TestInstance.class))\r
+            })\r
+      })\r
+  @Consumes(MediaType.APPLICATION_JSON)\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  @Path("/create/v1/processDefinitionKey/{processDefinitionKey}")\r
+  Response createByProcessDefinitionKey(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "The process definition key associated with the test definition",\r
+              example = "someUniqueProcessDefinitionKey",\r
+              required = true)\r
+          @PathParam("processDefinitionKey")\r
+          String processDefinitionKey,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization,\r
+      TestInstanceCreateRequest request);\r
+\r
+  @POST\r
+  @Operation(\r
+      description = "Create a test instance using the unique process definition key and version",\r
+      summary = "Create test instance by process definition key and version",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "201",\r
+            description = "The created Test Instance object is returned when it is created",\r
+            content = {\r
+              @Content(\r
+                  mediaType = "application/json",\r
+                  schema = @Schema(implementation = TestInstance.class))\r
+            })\r
+      })\r
+  @Consumes(MediaType.APPLICATION_JSON)\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  @Path("/create/v1/processDefinitionKey/{processDefinitionKey}/version/{version}")\r
+  Response createByProcessDefinitionKey(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "The process definition key associated with the test definition",\r
+              example = "someUniqueProcessDefinitionKey",\r
+              required = true)\r
+          @PathParam("processDefinitionKey")\r
+          String processDefinitionKey,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "The version of the test definition used to create the instance",\r
+              example = "2",\r
+              required = true)\r
+          @PathParam("version")\r
+          int version,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization,\r
+      TestInstanceCreateRequest request);\r
+\r
+  @GET\r
+  @Operation(\r
+      description = "Finds a test instance by it's unique identifier",\r
+      summary = "Find test instance by id",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "200",\r
+            description = "A Test Instance object is returned if it exists",\r
+            content = {\r
+              @Content(\r
+                  mediaType = "application/json",\r
+                  schema = @Schema(implementation = TestInstance.class))\r
+            })\r
+      })\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  @Path("/v1/id/{id}")\r
+  Response findById(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "A string representation of a BSON ObjectId",\r
+              example = "12345678912345678912345f",\r
+              required = true,\r
+              schema =\r
+                  @Schema(\r
+                      type = "string",\r
+                      format = "uuid",\r
+                      description = "The UUID of the test instance"))\r
+          @PathParam("id")\r
+          String testInstanceId,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization);\r
+\r
+  @GET\r
+  @Operation(\r
+      description = "Finds all test instance belonging to the unique process definition key",\r
+      summary = "Find test instance(s) by process definition key",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "200",\r
+            description = "An array of found Test Instance objects are returned",\r
+            content = {\r
+              @Content(\r
+                  array = @ArraySchema(schema = @Schema(implementation = TestInstance.class)),\r
+                  mediaType = "application/json")\r
+            })\r
+      })\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  @Path("/v1/processDefinitionKey/{processDefinitionKey}")\r
+  Response findByProcessDefinitionKey(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "The process definition key associated with the test definition",\r
+              example = "someUniqueProcessDefinitionKey",\r
+              required = true)\r
+          @PathParam("processDefinitionKey")\r
+          String processDefinitionKey,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization);\r
+\r
+  @GET\r
+  @Operation(\r
+      description =\r
+          "Finds all test instance belonging to the unique process definition key and version",\r
+      summary = "Find test instance(s) by process definition key and version",\r
+      responses = {\r
+        @ApiResponse(\r
+            responseCode = "200",\r
+            description = "An array of found Test Instance objects are returned",\r
+            content = {\r
+              @Content(\r
+                  array = @ArraySchema(schema = @Schema(implementation = TestInstance.class)),\r
+                  mediaType = "application/json")\r
+            })\r
+      })\r
+  @Produces(MediaType.APPLICATION_JSON)\r
+  @Path("/v1/processDefinitionKey/{processDefinitionKey}/version/{version}")\r
+  Response findByProcessDefinitionKeyAndVersion(\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "The process definition key associated with the test definition",\r
+              example = "someUniqueProcessDefinitionKey",\r
+              required = true)\r
+          @PathParam("processDefinitionKey")\r
+          String processDefinitionKey,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "The version of the test definition used to create the instance",\r
+              example = "2",\r
+              required = true)\r
+          @PathParam("version")\r
+          String version,\r
+      @Parameter(\r
+              allowEmptyValue = false,\r
+              description = "Base64 encoded Application Authorization Framework credentials",\r
+              example = "Basic b3RmQGF0dC5jb206cGFzc3dvcmQxMjM=",\r
+              required = true)\r
+          @HeaderParam("Authorization")\r
+          String authorization);\r
+}\r