[SDC] Onboarding 1710 rebase.
[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 io.swagger.annotations.Api;
24 import io.swagger.annotations.ApiOperation;
25 import io.swagger.annotations.ApiParam;
26 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
27 import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto;
28 import org.openecomp.sdc.versioning.dao.types.Version;
29 import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto;
30 import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
31 import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
32 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto;
33 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
34 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto;
35 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
36 import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson;
37 import org.springframework.validation.annotation.Validated;
38
39 import java.io.File;
40 import java.io.IOException;
41 import java.io.InputStream;
42 import java.lang.reflect.InvocationTargetException;
43 import javax.validation.Valid;
44 import javax.validation.constraints.NotNull;
45 import javax.validation.constraints.Pattern;
46 import javax.ws.rs.Consumes;
47 import javax.ws.rs.DELETE;
48 import javax.ws.rs.GET;
49 import javax.ws.rs.HeaderParam;
50 import javax.ws.rs.POST;
51 import javax.ws.rs.PUT;
52 import javax.ws.rs.Path;
53 import javax.ws.rs.PathParam;
54 import javax.ws.rs.Produces;
55 import javax.ws.rs.QueryParam;
56 import javax.ws.rs.core.MediaType;
57 import javax.ws.rs.core.Response;
58
59 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
60 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
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 extends VspEntities {
67
68   @POST
69   @Path("/")
70   @ApiOperation(value = "Create a new vendor software product",
71       response = VspCreationDto.class)
72   Response createVsp(@Valid VspDescriptionDto vspDescriptionDto,
73                      @NotNull(message = USER_MISSING_ERROR_MSG)
74                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
75
76   @GET
77   @Path("/")
78   @ApiOperation(value = "Get list of vendor software products and their description",
79       responseContainer = "List")
80   Response listVsps(@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)
85                     @HeaderParam(USER_ID_HEADER_PARAM) String user);
86
87
88   @GET
89   @Path("/{vspId}/versions/{versionId}")
90   @ApiOperation(value = "Get details of a vendor software product")
91   Response getVsp(@PathParam("vspId") String vspId,
92                   @PathParam("versionId") String versionId,
93                   @NotNull(message = USER_MISSING_ERROR_MSG)
94                   @HeaderParam(USER_ID_HEADER_PARAM) String user);
95
96   @PUT
97   @Path("/{vspId}/versions/{versionId}")
98   @ApiOperation(value = "Update an existing vendor software product")
99   Response updateVsp(@PathParam("vspId") String vspId,
100                      @PathParam("versionId") String versionId,
101                      @Valid VspDescriptionDto vspDescriptionDto,
102                      @NotNull(message = USER_MISSING_ERROR_MSG)
103                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
104
105   @DELETE
106   @Path("/{vspId}")
107   @ApiOperation(value = "Deletes vendor software product by given id")
108   Response deleteVsp(@PathParam("vspId") String vspId,
109                      @NotNull(message = USER_MISSING_ERROR_MSG)
110                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
111
112   @GET
113   @Path("/packages")
114   @ApiOperation(value = "Get list of translated CSAR files details",
115       response = PackageInfoDto.class,
116       responseContainer = "List")
117   Response listPackages(@ApiParam("Category") @QueryParam("category") String category,
118                         @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory,
119                         @NotNull(message = USER_MISSING_ERROR_MSG)
120                         @HeaderParam(USER_ID_HEADER_PARAM) String user);
121
122   @GET
123   @Path("/{vspId}/versions/{versionId}/orchestration-template")
124   @Produces(MediaType.APPLICATION_OCTET_STREAM)
125   @ApiOperation(value = "Get Orchestration Template (HEAT) file",
126       notes = "Downloads the latest HEAT package",
127       response = File.class)
128   Response getOrchestrationTemplate(
129       @PathParam("vspId") String vspId,
130       @PathParam("versionId") String versionId,
131       @HeaderParam(USER_ID_HEADER_PARAM) String user);
132
133
134   @GET
135   @Path("/validation-vsp")
136   Response getValidationVsp(
137       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
138       throws Exception;
139
140   @PUT
141   @Path("/{vspId}/versions/{versionId}/actions")
142   @ApiOperation(value = "Actions on a vendor software product",
143       notes = "Performs one of the following actions on a vendor software product: |"
144           + "Checkout: Locks it for edits by other users. Only the locking user sees the edited "
145           + "version.|"
146           + "Undo_Checkout: Unlocks it and deletes the edits that were done.|"
147           + "Checkin: Unlocks it and activates the edited version to all users.| "
148           + "Submit: Finalize its active version.|"
149           + "Create_Package: Creates a CSAR zip file.|")
150   Response actOnVendorSoftwareProduct(@PathParam("vspId") String vspId,
151                                       @PathParam("versionId") String versionId,
152                                       VersionSoftwareProductActionRequestDto request,
153                                       @NotNull(message = USER_MISSING_ERROR_MSG)
154                                       @HeaderParam(USER_ID_HEADER_PARAM) String user)
155       throws IOException;
156
157   @GET
158   @Path("/packages/{vspId}")
159   @Produces(MediaType.APPLICATION_OCTET_STREAM)
160   @ApiOperation(value = "Get translated CSAR file",
161       notes = "Exports translated file to a zip file",
162       response = File.class)
163   Response getTranslatedFile(@PathParam("vspId") String vspId,
164                              @QueryParam("versionId") String versionId,
165                              @HeaderParam(USER_ID_HEADER_PARAM) String user);
166
167   @GET
168   @Path("/{vspId}/versions/{versionId}/questionnaire")
169   @ApiOperation(value = "Get vendor software product questionnaire",
170       response = QuestionnaireResponseDto.class)
171   Response getQuestionnaire(@PathParam("vspId") String vspId,
172                             @PathParam("versionId") String versionId,
173                             @NotNull(message = USER_MISSING_ERROR_MSG)
174                             @HeaderParam(USER_ID_HEADER_PARAM) String user);
175
176   @PUT
177   @Path("/{vspId}/versions/{versionId}/questionnaire")
178   @ApiOperation(value = "Update vendor software product questionnaire")
179   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
180                                @PathParam("vspId") String vspId,
181                                @PathParam("versionId") String versionId,
182                                @NotNull(message = USER_MISSING_ERROR_MSG)
183                                @HeaderParam(USER_ID_HEADER_PARAM) String user);
184
185
186   @PUT
187   @Path("/{vspId}/versions/{versionId}/heal")
188   @ApiOperation(value = "Checkout and heal vendor software product questionnaire",
189       response = QuestionnaireResponseDto.class)
190   Response heal(@PathParam("vspId") String vspId,
191                 @PathParam("versionId") String versionId,
192                 @NotNull(message = USER_MISSING_ERROR_MSG)
193                 @HeaderParam(USER_ID_HEADER_PARAM) String user);
194
195
196   @GET
197   @Path("/{vspId}/versions/{versionId}/vspInformationArtifact")
198   @Produces(MediaType.TEXT_PLAIN)
199   @ApiOperation(value = "Get vendor software product information artifact for specified version",
200       response = File.class)
201   Response getVspInformationArtifact(@PathParam("vspId") String vspId,
202                                      @PathParam("versionId") String versionId,
203                                      @NotNull(message = USER_MISSING_ERROR_MSG)
204                                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
205
206   @GET
207   @Path("/{vspId}/versions/{versionId}/compute-flavors")
208   @ApiOperation(value = "Get list of vendor software product compute-flavors",
209       response = VspComputeDto.class,
210       responseContainer = "List")
211   Response listCompute(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String
212                            vspId,
213                        @PathParam("versionId") String versionId,
214                        @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
215                            String user);
216 }