re base 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  * Copyright © 2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 package org.openecomp.sdcrests.vsp.rest;
19
20 import io.swagger.annotations.Api;
21 import io.swagger.annotations.ApiOperation;
22 import io.swagger.annotations.ApiParam;
23 import org.openecomp.sdcrests.item.types.ItemCreationDto;
24 import org.openecomp.sdcrests.vendorsoftwareproducts.types.*;
25 import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson;
26 import org.springframework.validation.annotation.Validated;
27
28 import javax.validation.Valid;
29 import javax.validation.constraints.NotNull;
30 import javax.ws.rs.*;
31 import javax.ws.rs.core.MediaType;
32 import javax.ws.rs.core.Response;
33 import java.io.File;
34 import java.io.IOException;
35
36 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
37 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
38
39 @Path("/v1.0/vendor-software-products")
40 @Produces(MediaType.APPLICATION_JSON)
41 @Consumes(MediaType.APPLICATION_JSON)
42 @Api(value = "Vendor Software Products")
43 @Validated
44 public interface VendorSoftwareProducts extends VspEntities {
45
46   @POST
47   @Path("/")
48   @ApiOperation(value = "Create a new vendor software product",
49       response = ItemCreationDto.class)
50   Response createVsp(@Valid VspRequestDto vspRequestDto,
51                      @NotNull(message = USER_MISSING_ERROR_MSG)
52                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
53
54   @GET
55   @Path("/")
56   @ApiOperation(value = "Get list of vendor software products and their description",
57       responseContainer = "List")
58   Response listVsps(@ApiParam(value = "Filter to return only Vendor Software Products with at" +
59                     " least one version at this status. Currently supported values: 'Certified' , 'Draft'")
60                     @QueryParam("versionFilter") String versionStatus,
61                     @ApiParam(value = "Filter to only return Vendor Software Products at this status." +
62                     "Currently supported values: 'ACTIVE' , 'ARCHIVED'." +
63                     "Default value = 'ACTIVE'.")
64                     @QueryParam("Status") String itemStatus,
65                     @NotNull(message = USER_MISSING_ERROR_MSG)
66                     @HeaderParam(USER_ID_HEADER_PARAM) String user);
67
68   @GET
69   @Path("/{vspId}/versions/{versionId}")
70   @ApiOperation(value = "Get details of a vendor software product")
71   Response getVsp(@PathParam("vspId") String vspId,
72                   @PathParam("versionId") String versionId,
73                   @NotNull(message = USER_MISSING_ERROR_MSG)
74                   @HeaderParam(USER_ID_HEADER_PARAM) String user);
75
76   @PUT
77   @Path("/{vspId}/versions/{versionId}")
78   @ApiOperation(value = "Update an existing vendor software product")
79   Response updateVsp(@PathParam("vspId") String vspId,
80                      @PathParam("versionId") String versionId,
81                      @Valid VspDescriptionDto vspDescriptionDto,
82                      @NotNull(message = USER_MISSING_ERROR_MSG)
83                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
84
85   @DELETE
86   @Path("/{vspId}")
87   @ApiOperation(value = "Deletes vendor software product by given id")
88   Response deleteVsp(@PathParam("vspId") String vspId,
89                      @NotNull(message = USER_MISSING_ERROR_MSG)
90                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
91
92   @GET
93   @Path("/packages")
94   @ApiOperation(value = "Get list of translated CSAR files details",
95       response = PackageInfoDto.class,
96       responseContainer = "List")
97   Response listPackages(@ApiParam("Vendor Software Product status filter. " +
98                         "Currently supported values: 'ACTIVE', 'ARCHIVED'")
99                         @QueryParam("Status") String status,
100                         @ApiParam("Category") @QueryParam("category") String category,
101                         @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory,
102                         @NotNull(message = USER_MISSING_ERROR_MSG)
103                         @HeaderParam(USER_ID_HEADER_PARAM) String user);
104
105   @GET
106   @Path("/{vspId}/versions/{versionId}/orchestration-template")
107   @Produces(MediaType.APPLICATION_OCTET_STREAM)
108   @ApiOperation(value = "Get Orchestration Template (HEAT) file",
109       notes = "Downloads the latest HEAT package",
110       response = File.class)
111   Response getOrchestrationTemplate(
112       @PathParam("vspId") String vspId,
113       @PathParam("versionId") String versionId,
114       @HeaderParam(USER_ID_HEADER_PARAM) String user);
115
116
117   @GET
118   @Path("/validation-vsp")
119   Response getValidationVsp(
120       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
121       throws Exception;
122
123   @PUT
124   @Path("/{vspId}/versions/{versionId}/actions")
125   @ApiOperation(value = "Actions on a vendor software product",
126       notes = "Performs one of the following actions on a vendor software product: |"
127           + "Checkout: Locks it for edits by other users. Only the locking user sees the edited "
128           + "version.|"
129           + "Undo_Checkout: Unlocks it and deletes the edits that were done.|"
130           + "Checkin: Unlocks it and activates the edited version to all users.| "
131           + "Submit: Finalize its active version.|"
132           + "Create_Package: Creates a CSAR zip file.|")
133   Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request,
134                                       @PathParam("vspId") String vspId,
135                                       @PathParam("versionId") String versionId,
136                                       @NotNull(message = USER_MISSING_ERROR_MSG)
137                                       @HeaderParam(USER_ID_HEADER_PARAM) String user)
138       throws IOException;
139
140   @GET
141   @Path("/packages/{vspId}")
142   @Produces(MediaType.APPLICATION_OCTET_STREAM)
143   @ApiOperation(value = "Get translated CSAR file",
144       notes = "Exports translated file to a zip file",
145       response = File.class)
146   Response getTranslatedFile(@PathParam("vspId") String vspId,
147                              @QueryParam("versionId") String versionId,
148                              @HeaderParam(USER_ID_HEADER_PARAM) String user);
149
150   @GET
151   @Path("/{vspId}/versions/{versionId}/questionnaire")
152   @ApiOperation(value = "Get vendor software product questionnaire",
153       response = QuestionnaireResponseDto.class)
154   Response getQuestionnaire(@PathParam("vspId") String vspId,
155                             @PathParam("versionId") String versionId,
156                             @NotNull(message = USER_MISSING_ERROR_MSG)
157                             @HeaderParam(USER_ID_HEADER_PARAM) String user);
158
159   @PUT
160   @Path("/{vspId}/versions/{versionId}/questionnaire")
161   @ApiOperation(value = "Update vendor software product questionnaire")
162   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
163                                @PathParam("vspId") String vspId,
164                                @PathParam("versionId") String versionId,
165                                @NotNull(message = USER_MISSING_ERROR_MSG)
166                                @HeaderParam(USER_ID_HEADER_PARAM) String user);
167
168
169   @PUT
170   @Path("/{vspId}/versions/{versionId}/heal")
171   @ApiOperation(value = "Checkout and heal vendor software product questionnaire",
172       response = QuestionnaireResponseDto.class)
173   Response heal(@PathParam("vspId") String vspId,
174                 @PathParam("versionId") String versionId,
175                 @NotNull(message = USER_MISSING_ERROR_MSG)
176                 @HeaderParam(USER_ID_HEADER_PARAM) String user);
177
178
179   @GET
180   @Path("/{vspId}/versions/{versionId}/vspInformationArtifact")
181   @Produces(MediaType.TEXT_PLAIN)
182   @ApiOperation(value = "Get vendor software product information artifact for specified version",
183       response = File.class)
184   Response getVspInformationArtifact(@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   @GET
190   @Path("/{vspId}/versions/{versionId}/compute-flavors")
191   @ApiOperation(value = "Get list of vendor software product compute-flavors",
192       response = VspComputeDto.class,
193       responseContainer = "List")
194   Response listComputes(@ApiParam(value = "Vendor software product Id")
195                         @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 }