f8af1536c5bd5114dc4afb1962813a604d0bd2ed
[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 / Processes.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}/processes")
49 @Produces(MediaType.APPLICATION_JSON)
50 @Consumes(MediaType.APPLICATION_JSON)
51 @OpenAPIDefinition(info = @Info(title = "Vendor Software Product Processes"))
52 @Validated
53 public interface Processes {
54   @GET
55   @Path("/")
56   @Operation(description = "List vendor software product 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                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
60                     String user);
61
62   @DELETE
63   @Path("/")
64   @Operation(description = "Delete vendor software product processes", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class))))
65   Response deleteList(
66       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
67       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
68       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
69
70   @POST
71   @Path("/")
72   @Operation(description = "Create a vendor software product process")
73   Response create(@Valid ProcessRequestDto request,
74                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
75                   @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
76                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
77                       String user);
78
79   @GET
80   @Path("/{processId}")
81   @Operation(description = "Get vendor software product process", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class))))
82   Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
83                @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
84                @Parameter(description = "Vendor software product process Id") @PathParam("processId")
85                    String processId,
86                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
87                    String user);
88
89   @DELETE
90   @Path("/{processId}")
91   @Operation(description = "Delete vendor software product process")
92   Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
93                   @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
94                   @Parameter(description = "Vendor software product process Id") @PathParam("processId")
95                       String processId,
96                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
97                       String user);
98
99   @PUT
100   @Path("/{processId}")
101   @Operation(description = "Update vendor software product process")
102   Response update(@Valid ProcessRequestDto request,
103                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
104                   @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
105                   @Parameter(description = "Vendor software product process Id") @PathParam("processId")
106                       String processId,
107                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
108                       String user);
109
110   @GET
111   @Path("/{processId}/upload")
112   @Produces(MediaType.APPLICATION_OCTET_STREAM)
113   @Operation(description = "Get vendor software product process uploaded file")
114   Response getUploadedFile(
115       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
116       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
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) String user);
120
121   @DELETE
122   @Path("/{processId}/upload")
123   @Operation(description = "Delete vendor software product process uploaded file")
124   Response deleteUploadedFile(
125       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
126       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
127       @Parameter(description = "Vendor software product process Id") @PathParam("processId")
128           String processId,
129       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
130
131   @POST
132   @Path("/{processId}/upload")
133   @Consumes(MediaType.MULTIPART_FORM_DATA)
134   @Operation(description = "Update vendor software product process upload")
135   Response uploadFile(@Multipart("upload") Attachment attachment,
136                       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
137                       @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId,
138                       @Parameter(description = "Vendor software product process Id")
139                       @PathParam("processId") String processId,
140                       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
141                           String user);
142 }