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 / VendorSoftwareProducts.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
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.PackageInfoDto;
33 import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
34 import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
35 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto;
36 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto;
37 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
38 import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson;
39 import org.springframework.validation.annotation.Validated;
40
41 import java.io.File;
42 import java.io.IOException;
43 import java.io.InputStream;
44 import javax.validation.Valid;
45 import javax.validation.constraints.NotNull;
46 import javax.validation.constraints.Pattern;
47 import javax.ws.rs.Consumes;
48 import javax.ws.rs.DELETE;
49 import javax.ws.rs.GET;
50 import javax.ws.rs.HeaderParam;
51 import javax.ws.rs.POST;
52 import javax.ws.rs.PUT;
53 import javax.ws.rs.Path;
54 import javax.ws.rs.PathParam;
55 import javax.ws.rs.Produces;
56 import javax.ws.rs.QueryParam;
57 import javax.ws.rs.core.MediaType;
58 import javax.ws.rs.core.Response;
59
60
61 @Path("/v1.0/vendor-software-products")
62 @Produces(MediaType.APPLICATION_JSON)
63 @Consumes(MediaType.APPLICATION_JSON)
64 @Api(value = "Vendor Software Products")
65 @Validated
66 public interface VendorSoftwareProducts {
67
68   @POST
69   @Path("/")
70   @ApiOperation(value = "Create a new vendor software product",
71       response = VspCreationDto.class)
72   Response createNewVsp(@Valid VspDescriptionDto vspDescriptionDto,
73                         @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
74                             String user);
75
76   @GET
77   @Path("/")
78   @ApiOperation(value = "Get list of vendor software products and their description",
79       responseContainer = "List")
80   Response getVspList(@ApiParam(
81       value = "Currently supported values: 'Final' - only vendor software products with final "
82           + "version will be return - with their latest final version")
83                       @QueryParam("versionFilter") String versionFilter,
84                       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
85                           String user);
86
87   @GET
88   @Path("/packages")
89   @ApiOperation(value = "Get list of translated CSAR files details",
90       response = PackageInfoDto.class,
91       responseContainer = "List")
92   Response listPackages(@ApiParam("Category") @QueryParam("category") String category,
93                         @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory,
94                         @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
95                             String user);
96
97   @GET
98   @Path("/{vspId}")
99   @ApiOperation(value = "Get details of a vendor software product")
100   Response getVspDetails(@PathParam("vspId") String vspId,
101                          @Pattern(regexp = Version.VERSION_REGEX,
102                              message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version")
103                              String version,
104                          @NotNull(message = USER_MISSING_ERROR_MSG)
105                          @HeaderParam(USER_HEADER_PARAM) String user);
106
107   @PUT
108   @Path("/{vspId}")
109   @ApiOperation(value = "Update an existing vendor software product")
110   Response updateVsp(@PathParam("vspId") String vspId, @Valid VspDescriptionDto vspDescriptionDto,
111                      @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
112                          String user);
113
114   @DELETE
115   @Path("/{vspId}")
116   @ApiOperation(value = "Deletes vendor software product by given id")
117   Response deleteVsp(@PathParam("vspId") String vspId,
118                      @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
119                          String user);
120
121   @POST
122   @Path("{vspId}/upload")
123   @Consumes(MediaType.MULTIPART_FORM_DATA)
124   @ApiOperation(value = "Uploads a HEAT package to translate",
125       response = UploadFileResponseDto.class)
126   Response uploadFile(@PathParam("vspId") String vspId,
127                       @Multipart("upload") InputStream heatFileToUpload,
128                       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
129                           String user);
130
131   @GET
132   @Path("/{vspId}/downloadHeat")
133   @Produces(MediaType.APPLICATION_OCTET_STREAM)
134   @ApiOperation(value = "Get uploaded HEAT file",
135       notes = "Downloads the latest HEAT package",
136       response = File.class)
137   Response getLatestHeatPackage(@PathParam("vspId") String vspId,
138                                 /*@NotNull(message = USER_MISSING_ERROR_MSG)*/
139                                 @HeaderParam(USER_HEADER_PARAM) String user);
140
141
142   @PUT
143   @Path("/{vspId}/actions")
144   @ApiOperation(value = "Actions on a vendor software product",
145       notes = "Performs one of the following actions on a vendor software product: |"
146           + "Checkout: Locks it for edits by other users. Only the locking user sees the edited "
147           + "version.|"
148           + "Undo_Checkout: Unlocks it and deletes the edits that were done.|"
149           + "Checkin: Unlocks it and activates the edited version to all users.| "
150           + "Submit: Finalize its active version.|"
151           + "Create_Package: Creates a CSAR zip file.|")
152   /*@ApiResponses(value = {
153             @ApiResponse(code = 200, message = "Action succeeded"),
154             @ApiResponse(code = 417, message = "Validation before submit has failed",
155             response = ValidationResponseDto.class)})*/
156   Response actOnVendorSoftwareProduct(@PathParam("vspId") String vspId,
157                                       VersionSoftwareProductActionRequestDto request,
158                                       @NotNull(message = USER_MISSING_ERROR_MSG)
159                                       @HeaderParam(USER_HEADER_PARAM) String user)
160       throws IOException;
161
162   @GET
163   @Path("/packages/{vspId}")
164   @Produces(MediaType.APPLICATION_OCTET_STREAM)
165   @ApiOperation(value = "Get translated CSAR file",
166       notes = "Exports translated file to a zip file",
167       response = File.class)
168   Response getTranslatedFile(@PathParam("vspId") String vspId,
169                              @Pattern(regexp = Version.VERSION_REGEX,
170                                  message = Version.VERSION_STRING_VIOLATION_MSG)
171                              @QueryParam("version") String version,
172                              /*@NotNull(message = USER_MISSING_ERROR_MSG)*/
173                              @HeaderParam(USER_HEADER_PARAM) String user);
174
175   @GET
176   @Path("/{vspId}/questionnaire")
177   @ApiOperation(value = "Get vendor software product questionnaire",
178       response = QuestionnaireResponseDto.class)
179   Response getQuestionnaire(@PathParam("vspId") String vspId,
180                             @Pattern(regexp = Version.VERSION_REGEX,
181                                 message = Version.VERSION_STRING_VIOLATION_MSG)
182                             @QueryParam("version") String version,
183                             @NotNull(message = USER_MISSING_ERROR_MSG)
184                             @HeaderParam(USER_HEADER_PARAM) String user);
185
186   @PUT
187   @Path("/{vspId}/questionnaire")
188   @ApiOperation(value = "Update vendor software product questionnaire")
189   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
190                                @PathParam("vspId") String vspId,
191                                @NotNull(message = USER_MISSING_ERROR_MSG)
192                                @HeaderParam(USER_HEADER_PARAM) String user);
193 }