3bc68a7e53b931829e75fbeaedd2a18bbc02d022
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-software-products-rest / vendor-software-products-rest-services / src / main / java / org / openecomp / sdcrests / vsp / rest / ComponentProcesses.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdcrests.vsp.rest;
22
23 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
24 import io.swagger.v3.oas.annotations.Operation;
25 import io.swagger.v3.oas.annotations.Parameter;
26 import io.swagger.v3.oas.annotations.info.Info;
27 import io.swagger.v3.oas.annotations.media.ArraySchema;
28 import io.swagger.v3.oas.annotations.media.Content;
29 import io.swagger.v3.oas.annotations.media.Schema;
30 import io.swagger.v3.oas.annotations.responses.ApiResponse;
31 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
32 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
33 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto;
34 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto;
35 import org.springframework.validation.annotation.Validated;
36
37 import javax.validation.Valid;
38 import javax.validation.constraints.NotNull;
39 import javax.ws.rs.*;
40 import javax.ws.rs.core.MediaType;
41 import javax.ws.rs.core.Response;
42
43 import java.util.List;
44
45 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
46 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
47
48 @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/processes")
49 @Produces(MediaType.APPLICATION_JSON)
50 @Consumes(MediaType.APPLICATION_JSON)
51 @OpenAPIDefinition(info =  @Info(title = "Vendor Software Product Component Processes"))
52 @Validated
53 public interface ComponentProcesses extends VspEntities {
54   @GET
55   @Path("/")
56   @Operation(description = "List vendor software product component processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class)))))
57   Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
58                 @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
59                 @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
60                     String componentId,
61                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
62                     String user);
63
64   @DELETE
65   @Path("/")
66   @Operation(description = "Delete vendor software product processes",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class))))
67   Response deleteList(
68       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
69       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
70       @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
71           String componentId,
72       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
73
74   @POST
75   @Path("/")
76   @Operation(description = "Create a vendor software product process")
77   Response create(@Valid ProcessRequestDto request,
78                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
79                   @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
80                   @Parameter(description = "Vendor software product component Id")
81                   @PathParam("componentId") String componentId,
82                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
83                       String user);
84
85   @GET
86   @Path("/{processId}")
87   @Operation(description = "Get vendor software product process",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class))))
88   Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
89                @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
90                @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
91                    String componentId,
92                @Parameter(description = "Vendor software product process Id") @PathParam("processId")
93                    String processId,
94                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
95                    String user);
96
97   @DELETE
98   @Path("/{processId}")
99   @Operation(description = "Delete vendor software product process")
100   Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
101                   @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
102                   @Parameter(description = "Vendor software product component Id")
103                   @PathParam("componentId") String componentId,
104                   @Parameter(description = "Vendor software product process Id") @PathParam("processId")
105                       String processId,
106                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
107                       String user);
108
109   @PUT
110   @Path("/{processId}")
111   @Operation(description = "Update vendor software product process")
112   Response update(@Valid ProcessRequestDto request,
113                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
114                   @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
115                   @Parameter(description = "Vendor software product component Id")
116                   @PathParam("componentId") String componentId,
117                   @Parameter(description = "Vendor software product process Id") @PathParam("processId")
118                       String processId,
119                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
120                       String user);
121
122   @GET
123   @Path("/{processId}/upload")
124   @Produces(MediaType.APPLICATION_OCTET_STREAM)
125   @Operation(description = "Get vendor software product process uploaded file")
126   Response getUploadedFile(
127       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
128       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
129       @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
130           String componentId,
131       @Parameter(description = "Vendor software product process Id") @PathParam("processId")
132           String processId,
133       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
134
135   @DELETE
136   @Path("/{processId}/upload")
137   @Operation(description = "Delete vendor software product process uploaded file")
138   Response deleteUploadedFile(
139       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
140       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
141       @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
142           String componentId,
143       @Parameter(description = "Vendor software product process Id") @PathParam("processId")
144           String processId,
145       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
146
147   @POST
148   @Path("/{processId}/upload")
149   @Consumes(MediaType.MULTIPART_FORM_DATA)
150   @Operation(description = "Update vendor software product process upload")
151   Response uploadFile(@Multipart("upload") Attachment attachment,
152                       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
153                       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
154                       @Parameter(description = "Vendor software product component Id")
155                       @PathParam("componentId") String componentId,
156                       @Parameter(description = "Vendor software product process Id")
157                       @PathParam("processId") String processId,
158                       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
159                           String user);
160 }