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