push addional code
[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 static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM;
24 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
25
26 import io.swagger.annotations.Api;
27 import io.swagger.annotations.ApiOperation;
28 import io.swagger.annotations.ApiParam;
29 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
30 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
31 import org.openecomp.sdc.versioning.dao.types.Version;
32 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto;
33 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto;
34
35 import org.springframework.validation.annotation.Validated;
36
37 import javax.validation.Valid;
38 import javax.validation.constraints.NotNull;
39 import javax.validation.constraints.Pattern;
40 import javax.ws.rs.Consumes;
41 import javax.ws.rs.DELETE;
42 import javax.ws.rs.GET;
43 import javax.ws.rs.HeaderParam;
44 import javax.ws.rs.POST;
45 import javax.ws.rs.PUT;
46 import javax.ws.rs.Path;
47 import javax.ws.rs.PathParam;
48 import javax.ws.rs.Produces;
49 import javax.ws.rs.QueryParam;
50 import javax.ws.rs.core.MediaType;
51 import javax.ws.rs.core.Response;
52
53 @Path("/v1.0/vendor-software-products/{vspId}/processes")
54 @Produces(MediaType.APPLICATION_JSON)
55 @Consumes(MediaType.APPLICATION_JSON)
56 @Api(value = "Vendor Software Product Processes")
57 @Validated
58 public interface Processes {
59   @GET
60   @Path("/")
61   @ApiOperation(value = "List vendor software product processes",
62       response = ProcessEntityDto.class,
63       responseContainer = "List")
64   Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
65                 @Pattern(regexp = Version.VERSION_REGEX,
66                     message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version")
67                     String version,
68                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
69                     String user);
70
71   @DELETE
72   @Path("/")
73   @ApiOperation(value = "Delete vendor software product processes",
74       responseContainer = "List")
75   Response deleteList(
76       @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
77       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user);
78
79   @POST
80   @Path("/")
81   @ApiOperation(value = "Create a vendor software product process")
82   Response create(@Valid ProcessRequestDto request,
83                   @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
84                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
85                       String user);
86
87   @GET
88   @Path("/{processId}")
89   @ApiOperation(value = "Get vendor software product process",
90       response = ProcessEntityDto.class)
91   Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
92                @ApiParam(value = "Vendor software product process Id") @PathParam("processId")
93                    String processId,
94                @Pattern(regexp = Version.VERSION_REGEX,
95                    message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version")
96                    String version,
97                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
98                    String user);
99
100   @DELETE
101   @Path("/{processId}")
102   @ApiOperation(value = "Delete vendor software product process")
103   Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
104                   @ApiParam(value = "Vendor software product process Id") @PathParam("processId")
105                       String processId,
106                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
107                       String user);
108
109   @PUT
110   @Path("/{processId}")
111   @ApiOperation(value = "Update vendor software product process")
112   Response update(@Valid ProcessRequestDto request,
113                   @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
114                   @ApiParam(value = "Vendor software product process Id") @PathParam("processId")
115                       String processId,
116                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
117                       String user);
118
119   @GET
120   @Path("/{processId}/upload")
121   @Produces(MediaType.APPLICATION_OCTET_STREAM)
122   @ApiOperation(value = "Get vendor software product process uploaded file")
123   Response getUploadedFile(
124       @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
125       @ApiParam(value = "Vendor software product process Id") @PathParam("processId")
126           String processId,
127       @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG)
128       @QueryParam("version") String version,
129       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user);
130
131   @DELETE
132   @Path("/{processId}/upload")
133   @ApiOperation(value = "Delete vendor software product process uploaded file")
134   Response deleteUploadedFile(
135       @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
136       @ApiParam(value = "Vendor software product process Id") @PathParam("processId")
137           String processId,
138       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user);
139
140   @POST
141   @Path("/{processId}/upload")
142   @Consumes(MediaType.MULTIPART_FORM_DATA)
143   @ApiOperation(value = "Update vendor software product process upload")
144   Response uploadFile(@Multipart("upload") Attachment attachment,
145                       @ApiParam(value = "Vendor software product Id") @PathParam("vspId")
146                           String vspId,
147                       @ApiParam(value = "Vendor software product process Id")
148                       @PathParam("processId") String processId,
149                       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
150                           String user);
151 }