60e269642e13fed0c6c440c26464b6af7bc983ba
[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 / OrchestrationTemplateCandidate.java
1 /*
2  * Copyright © 2016-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 package org.openecomp.sdcrests.vsp.rest;
18
19 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
20 import io.swagger.v3.oas.annotations.Operation;
21 import io.swagger.v3.oas.annotations.Parameter;
22 import io.swagger.v3.oas.annotations.info.Info;
23 import io.swagger.v3.oas.annotations.media.Content;
24 import io.swagger.v3.oas.annotations.media.Schema;
25 import io.swagger.v3.oas.annotations.responses.ApiResponse;
26 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
27 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
28 import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto;
29 import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
30 import org.springframework.validation.annotation.Validated;
31
32 import javax.validation.Valid;
33 import javax.validation.constraints.NotNull;
34 import javax.ws.rs.*;
35 import javax.ws.rs.core.MediaType;
36 import javax.ws.rs.core.Response;
37 import java.io.File;
38 import java.io.IOException;
39 import java.lang.reflect.InvocationTargetException;
40
41 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
42 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
43
44 @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/orchestration-template-candidate")
45 @Produces(MediaType.APPLICATION_JSON)
46 @Consumes(MediaType.APPLICATION_JSON)
47 @OpenAPIDefinition(info = @Info(title = "Orchestration Template Candidate"))
48 @Validated
49 public interface OrchestrationTemplateCandidate extends VspEntities {
50
51   @POST
52   @Path("/")
53   @Consumes(MediaType.MULTIPART_FORM_DATA)
54   Response upload(
55       @PathParam("vspId") String vspId,
56       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
57       @Multipart("upload") Attachment fileToUpload,
58       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
59
60   @GET
61   @Path("/")
62   @Produces(MediaType.APPLICATION_OCTET_STREAM)
63   @Operation(description = "Get uploaded Network Package file",
64       summary = "Downloads in uploaded Network Package file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =File.class))))
65   Response get(
66       @PathParam("vspId") String vspId,
67       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
68       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
69       throws IOException;
70
71   @DELETE
72   @Path("/")
73   @Operation(description = "Delete orchestration template candidate file and its files data structure")
74   Response abort(
75       @PathParam("vspId") String vspId,
76       @Parameter(description = "Version Id") @PathParam("versionId") String versionId)
77       throws Exception;
78
79   @PUT
80   @Path("/process")
81   @Operation(description = "process Orchestration Template Candidate",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =UploadFileResponseDto.class))))
82   Response process(
83       @PathParam("vspId") String vspId,
84       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
85       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
86       throws InvocationTargetException, IllegalAccessException;
87
88   @PUT
89   @Path("/manifest")
90   @Operation(description = "Update an existing vendor software product")
91   Response updateFilesDataStructure(
92       @PathParam("vspId") String vspId,
93       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
94       @Valid FileDataStructureDto fileDataStructureDto,
95       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
96       throws Exception;
97
98   @GET
99   @Path("/manifest")
100   @Operation(description = "Get uploaded HEAT file files data structure",
101       summary = "Downloads the latest HEAT package",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =FileDataStructureDto.class))))
102   Response getFilesDataStructure(
103       @PathParam("vspId") String vspId,
104       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
105       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
106       throws Exception;
107 }