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