2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdcrests.vsp.rest;
23 import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM;
24 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
26 import io.swagger.annotations.Api;
27 import io.swagger.annotations.ApiOperation;
28 import io.swagger.annotations.ApiParam;
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;
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;
61 @Path("/v1.0/vendor-software-products")
62 @Produces(MediaType.APPLICATION_JSON)
63 @Consumes(MediaType.APPLICATION_JSON)
64 @Api(value = "Vendor Software Products")
66 public interface VendorSoftwareProducts {
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)
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)
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)
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")
104 @NotNull(message = USER_MISSING_ERROR_MSG)
105 @HeaderParam(USER_HEADER_PARAM) String user);
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)
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)
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)
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);
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 "
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)
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);
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);
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);