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