2b4147229d39035809f2492be7ec87640c4492cb
[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.v3.oas.annotations.OpenAPIDefinition;
21 import io.swagger.v3.oas.annotations.Operation;
22 import io.swagger.v3.oas.annotations.Parameter;
23 import io.swagger.v3.oas.annotations.info.Info;
24 import io.swagger.v3.oas.annotations.media.ArraySchema;
25 import io.swagger.v3.oas.annotations.media.Content;
26 import io.swagger.v3.oas.annotations.media.Schema;
27 import io.swagger.v3.oas.annotations.responses.ApiResponse;
28 import org.openecomp.sdcrests.item.types.ItemCreationDto;
29 import org.openecomp.sdcrests.vendorsoftwareproducts.types.*;
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.*;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
38 import java.io.File;
39 import java.io.IOException;
40 import java.util.List;
41
42 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
43 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
44
45 @Path("/v1.0/vendor-software-products")
46 @Produces(MediaType.APPLICATION_JSON)
47 @Consumes(MediaType.APPLICATION_JSON)
48 @OpenAPIDefinition(info = @Info(title = "Vendor Software Products"))
49 @Validated
50 public interface VendorSoftwareProducts extends VspEntities {
51
52   @POST
53   @Path("/")
54   @Operation(description = "Create a new vendor software product",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemCreationDto.class))))
55   Response createVsp(@Valid VspRequestDto vspRequestDto,
56                      @NotNull(message = USER_MISSING_ERROR_MSG)
57                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
58
59   @GET
60   @Path("/")
61   @Operation(description = "Get list of vendor software products and their description",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspDetailsDto.class)))))
62   Response listVsps(@Parameter(description = "Filter to return only Vendor Software Products with at" +
63                     " least one version at this status. Currently supported values: 'Certified' , 'Draft'")
64                     @QueryParam("versionFilter") String versionStatus,
65                     @Parameter(description = "Filter to only return Vendor Software Products at this status." +
66                     "Currently supported values: 'ACTIVE' , 'ARCHIVED'." +
67                     "Default value = 'ACTIVE'.")
68                     @QueryParam("Status") String itemStatus,
69                     @NotNull(message = USER_MISSING_ERROR_MSG)
70                     @HeaderParam(USER_ID_HEADER_PARAM) String user);
71
72   @GET
73   @Path("/{vspId}/versions/{versionId}")
74   @Parameter(description = "Get details of a vendor software product")
75   Response getVsp(@PathParam("vspId") String vspId,
76                   @PathParam("versionId") String versionId,
77                   @NotNull(message = USER_MISSING_ERROR_MSG)
78                   @HeaderParam(USER_ID_HEADER_PARAM) String user);
79
80   @PUT
81   @Path("/{vspId}/versions/{versionId}")
82   @Parameter(description = "Update an existing vendor software product")
83   Response updateVsp(@PathParam("vspId") String vspId,
84                      @PathParam("versionId") String versionId,
85                      @Valid VspDescriptionDto vspDescriptionDto,
86                      @NotNull(message = USER_MISSING_ERROR_MSG)
87                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
88
89   @DELETE
90   @Path("/{vspId}")
91   @Parameter(description = "Deletes vendor software product by given id")
92   Response deleteVsp(@PathParam("vspId") String vspId,
93                      @NotNull(message = USER_MISSING_ERROR_MSG)
94                      @HeaderParam(USER_ID_HEADER_PARAM) String user);
95
96   @GET
97   @Path("/packages")
98   @Operation(description = "Get list of translated CSAR files details", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation=PackageInfoDto.class)))))
99   Response listPackages(@Parameter(description = "Vendor Software Product status filter. " +
100                         "Currently supported values: 'ACTIVE', 'ARCHIVED'")
101                         @QueryParam("Status") String status,
102                         @Parameter(description = "Category") @QueryParam("category") String category,
103                         @Parameter(description = "Sub-category") @QueryParam("subCategory") String subCategory,
104                         @NotNull(message = USER_MISSING_ERROR_MSG)
105                         @HeaderParam(USER_ID_HEADER_PARAM) String user);
106
107   @GET
108   @Path("/{vspId}/versions/{versionId}/orchestration-template")
109   @Produces(MediaType.APPLICATION_OCTET_STREAM)
110   @Operation(description = "Get Orchestration Template (HEAT) file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=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   @Operation(description = "Actions on a vendor software product",
126       summary = "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   @Operation(description = "Get translated CSAR file",
144       summary = "Exports translated file to a zip file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class))))
145   Response getTranslatedFile(@PathParam("vspId") String vspId,
146                              @QueryParam("versionId") String versionId,
147                              @HeaderParam(USER_ID_HEADER_PARAM) String user);
148
149   @GET
150   @Path("/{vspId}/versions/{versionId}/questionnaire")
151   @Operation(description = "Get vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=QuestionnaireResponseDto.class))))
152   Response getQuestionnaire(@PathParam("vspId") String vspId,
153                             @PathParam("versionId") String versionId,
154                             @NotNull(message = USER_MISSING_ERROR_MSG)
155                             @HeaderParam(USER_ID_HEADER_PARAM) String user);
156
157   @PUT
158   @Path("/{vspId}/versions/{versionId}/questionnaire")
159   @Operation(description = "Update vendor software product questionnaire")
160   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
161                                @PathParam("vspId") String vspId,
162                                @PathParam("versionId") String versionId,
163                                @NotNull(message = USER_MISSING_ERROR_MSG)
164                                @HeaderParam(USER_ID_HEADER_PARAM) String user);
165
166
167   @PUT
168   @Path("/{vspId}/versions/{versionId}/heal")
169   @Operation(description = "Checkout and heal vendor software product questionnaire",responses = @ApiResponse(content = @Content(schema = @Schema(implementation=QuestionnaireResponseDto.class))))
170   Response heal(@PathParam("vspId") String vspId,
171                 @PathParam("versionId") String versionId,
172                 @NotNull(message = USER_MISSING_ERROR_MSG)
173                 @HeaderParam(USER_ID_HEADER_PARAM) String user);
174
175
176   @GET
177   @Path("/{vspId}/versions/{versionId}/vspInformationArtifact")
178   @Produces(MediaType.TEXT_PLAIN)
179   @Operation(description = "Get vendor software product information artifact for specified version",responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class))))
180   Response getVspInformationArtifact(@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   @GET
186   @Path("/{vspId}/versions/{versionId}/compute-flavors")
187   @Operation(description = "Get list of vendor software product compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation=VspComputeDto.class)))))
188   Response listComputes(@Parameter(description = "Vendor software product Id")
189                         @PathParam("vspId") String vspId,
190                         @PathParam("versionId") String versionId,
191                         @NotNull(message = USER_MISSING_ERROR_MSG)
192                         @HeaderParam(USER_ID_HEADER_PARAM) String user);
193 }