328c96254fe42b4ecd10fc35df8e10e9bc7d6f56
[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 package org.openecomp.sdcrests.vsp.rest;
17
18 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
19 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
20
21 import io.swagger.v3.oas.annotations.Operation;
22 import io.swagger.v3.oas.annotations.Parameter;
23 import io.swagger.v3.oas.annotations.media.ArraySchema;
24 import io.swagger.v3.oas.annotations.media.Content;
25 import io.swagger.v3.oas.annotations.media.Schema;
26 import io.swagger.v3.oas.annotations.responses.ApiResponse;
27 import io.swagger.v3.oas.annotations.tags.Tag;
28 import io.swagger.v3.oas.annotations.tags.Tags;
29 import java.io.File;
30 import java.io.IOException;
31 import javax.validation.Valid;
32 import javax.validation.constraints.NotNull;
33 import javax.ws.rs.Consumes;
34 import javax.ws.rs.DELETE;
35 import javax.ws.rs.GET;
36 import javax.ws.rs.HeaderParam;
37 import javax.ws.rs.POST;
38 import javax.ws.rs.PUT;
39 import javax.ws.rs.Path;
40 import javax.ws.rs.PathParam;
41 import javax.ws.rs.Produces;
42 import javax.ws.rs.QueryParam;
43 import javax.ws.rs.core.MediaType;
44 import javax.ws.rs.core.Response;
45 import org.openecomp.sdcrests.item.types.ItemCreationDto;
46 import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto;
47 import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
48 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto;
49 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
50 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
51 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
52 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspRequestDto;
53 import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson;
54 import org.springframework.validation.annotation.Validated;
55
56 @Path("/v1.0/vendor-software-products")
57 @Produces(MediaType.APPLICATION_JSON)
58 @Consumes(MediaType.APPLICATION_JSON)
59 @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Products")})
60 @Validated
61 public interface VendorSoftwareProducts extends VspEntities {
62
63     @POST
64     @Path("/")
65     @Operation(description = "Create a new vendor software product", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemCreationDto.class))))
66     Response createVsp(@Valid VspRequestDto vspRequestDto, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
67
68     @GET
69     @Path("/")
70     @Operation(description = "Get list of vendor software products and their description", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspDetailsDto.class)))))
71     Response listVsps(@Parameter(description = "Filter to return only Vendor Software Products with at"
72         + " least one version at this status. Currently supported values: 'Certified' , 'Draft'") @QueryParam("versionFilter") String versionStatus,
73                       @Parameter(description = "Filter to only return Vendor Software Products at this status."
74                           + "Currently supported values: 'ACTIVE' , 'ARCHIVED'."
75                           + "Default value = 'ACTIVE'.") @QueryParam("Status") String itemStatus,
76                       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
77
78     @GET
79     @Path("/{vspId}/versions/{versionId}")
80     @Parameter(description = "Get details of a vendor software product")
81     Response getVsp(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId,
82                     @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
83
84     @PUT
85     @Path("/{vspId}/versions/{versionId}")
86     @Parameter(description = "Update an existing vendor software product")
87     Response updateVsp(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, @Valid VspDescriptionDto vspDescriptionDto,
88                        @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
89
90     @DELETE
91     @Path("/{vspId}")
92     @Parameter(description = "Deletes vendor software product by given id")
93     Response deleteVsp(@PathParam("vspId") String vspId, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
94
95     @GET
96     @Path("/packages")
97     @Operation(description = "Get list of translated CSAR files details", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = PackageInfoDto.class)))))
98     Response listPackages(@Parameter(description = "Vendor Software Product status filter. "
99         + "Currently supported values: 'ACTIVE', 'ARCHIVED'") @QueryParam("Status") String status,
100                           @Parameter(description = "Category") @QueryParam("category") String category,
101                           @Parameter(description = "Sub-category") @QueryParam("subCategory") String subCategory,
102                           @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
103
104     @GET
105     @Path("/{vspId}/versions/{versionId}/orchestration-template")
106     @Produces(MediaType.APPLICATION_OCTET_STREAM)
107     @Operation(description = "Get Orchestration Template (HEAT) file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class))))
108     Response getOrchestrationTemplate(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId,
109                                       @HeaderParam(USER_ID_HEADER_PARAM) String user);
110
111     @GET
112     @Path("/validation-vsp")
113     Response getValidationVsp(@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception;
114
115     @PUT
116     @Path("/{vspId}/versions/{versionId}/actions")
117     @Operation(description = "Actions on a vendor software product", summary = "Performs one of the following actions on a vendor software product: |"
118         + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " + "version.|"
119         + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" + "Checkin: Unlocks it and activates the edited version to all users.| "
120         + "Submit: Finalize its active version.|" + "Create_Package: Creates a CSAR zip file.|")
121     Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, @PathParam("vspId") String vspId,
122                                         @PathParam("versionId") String versionId,
123                                         @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException;
124
125     @GET
126     @Path("/packages/{vspId}")
127     @Produces(MediaType.APPLICATION_OCTET_STREAM)
128     @Operation(description = "Get translated CSAR file", summary = "Exports translated file to a zip file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class))))
129     Response getTranslatedFile(@PathParam("vspId") String vspId, @QueryParam("versionId") String versionId,
130                                @HeaderParam(USER_ID_HEADER_PARAM) String user);
131
132     @GET
133     @Path("/{vspId}/versions/{versionId}/questionnaire")
134     @Operation(description = "Get vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class))))
135     Response getQuestionnaire(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId,
136                               @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
137
138     @PUT
139     @Path("/{vspId}/versions/{versionId}/questionnaire")
140     @Operation(description = "Update vendor software product questionnaire")
141     Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @PathParam("vspId") String vspId,
142                                  @PathParam("versionId") String versionId,
143                                  @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
144
145     @PUT
146     @Path("/{vspId}/versions/{versionId}/heal")
147     @Operation(description = "Checkout and heal vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class))))
148     Response heal(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId,
149                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
150
151     @GET
152     @Path("/{vspId}/versions/{versionId}/vspInformationArtifact")
153     @Produces(MediaType.TEXT_PLAIN)
154     @Operation(description = "Get vendor software product information artifact for specified version", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class))))
155     Response getVspInformationArtifact(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId,
156                                        @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
157
158     @GET
159     @Path("/{vspId}/versions/{versionId}/compute-flavors")
160     @Operation(description = "Get list of vendor software product compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspComputeDto.class)))))
161     Response listComputes(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
162                           @PathParam("versionId") String versionId,
163                           @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
164 }