Publish swagger files for SDC APIs
[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.Operation;
20 import io.swagger.v3.oas.annotations.Parameter;
21 import io.swagger.v3.oas.annotations.info.Info;
22 import io.swagger.v3.oas.annotations.media.Content;
23 import io.swagger.v3.oas.annotations.media.Schema;
24 import io.swagger.v3.oas.annotations.responses.ApiResponse;
25 import io.swagger.v3.oas.annotations.tags.Tag;
26 import io.swagger.v3.oas.annotations.tags.Tags;
27 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
28 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
29 import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto;
30 import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
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.lang.reflect.InvocationTargetException;
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/{vspId}/versions/{versionId}/orchestration-template-candidate")
46 @Produces(MediaType.APPLICATION_JSON)
47 @Consumes(MediaType.APPLICATION_JSON)
48 @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Orchestration Template Candidate")})
49 @Validated
50 public interface OrchestrationTemplateCandidate extends VspEntities {
51
52   @POST
53   @Path("/")
54   @Consumes(MediaType.MULTIPART_FORM_DATA)
55   Response upload(
56       @PathParam("vspId") String vspId,
57       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
58       @Multipart("upload") Attachment fileToUpload,
59       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
60
61   @GET
62   @Path("/")
63   @Produces(MediaType.APPLICATION_OCTET_STREAM)
64   @Operation(description = "Get uploaded Network Package file",
65       summary = "Downloads in uploaded Network Package file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =File.class))))
66   Response get(
67       @PathParam("vspId") String vspId,
68       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
69       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
70       throws IOException;
71
72   @DELETE
73   @Path("/")
74   @Operation(description = "Delete orchestration template candidate file and its files data structure")
75   Response abort(
76       @PathParam("vspId") String vspId,
77       @Parameter(description = "Version Id") @PathParam("versionId") String versionId)
78       throws Exception;
79
80   @PUT
81   @Path("/process")
82   @Operation(description = "process Orchestration Template Candidate",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =UploadFileResponseDto.class))))
83   Response process(
84       @PathParam("vspId") String vspId,
85       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
86       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
87       throws InvocationTargetException, IllegalAccessException;
88
89   @PUT
90   @Path("/manifest")
91   @Operation(description = "Update an existing vendor software product")
92   Response updateFilesDataStructure(
93       @PathParam("vspId") String vspId,
94       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
95       @Valid FileDataStructureDto fileDataStructureDto,
96       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
97       throws Exception;
98
99   @GET
100   @Path("/manifest")
101   @Operation(description = "Get uploaded HEAT file files data structure",
102       summary = "Downloads the latest HEAT package",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =FileDataStructureDto.class))))
103   Response getFilesDataStructure(
104       @PathParam("vspId") String vspId,
105       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
106       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
107       throws Exception;
108 }