Add collaboration feature
[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  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdcrests.vsp.rest;
22
23 import io.swagger.annotations.Api;
24 import io.swagger.annotations.ApiOperation;
25 import io.swagger.annotations.ApiParam;
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.Consumes;
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.core.MediaType;
43 import javax.ws.rs.core.Response;
44 import java.io.File;
45 import java.io.IOException;
46 import java.lang.reflect.InvocationTargetException;
47
48 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
49 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
50
51 @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/orchestration-template-candidate")
52 @Produces(MediaType.APPLICATION_JSON)
53 @Consumes(MediaType.APPLICATION_JSON)
54 @Api(value = "Orchestration Template Candidate")
55 @Validated
56 public interface OrchestrationTemplateCandidate extends VspEntities {
57
58   @POST
59   @Path("/")
60   @Consumes(MediaType.MULTIPART_FORM_DATA)
61   Response upload(
62       @PathParam("vspId") String vspId,
63       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
64       @Multipart("upload") Attachment fileToUpload,
65       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
66
67   @GET
68   @Path("/")
69   @Produces(MediaType.APPLICATION_OCTET_STREAM)
70   @ApiOperation(value = "Get uploaded candidate HEAT file",
71       notes = "Downloads in process candidate HEAT file",
72       response = File.class)
73   Response get(
74       @PathParam("vspId") String vspId,
75       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
76       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
77       throws IOException;
78
79   @PUT
80   @Path("/process")
81   @ApiOperation(value = "process Orchestration Template Candidate",
82       response = UploadFileResponseDto.class)
83   Response process(
84       @PathParam("vspId") String vspId,
85       @ApiParam(value = "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   @ApiOperation(value = "Update an existing vendor software product")
92   Response updateFilesDataStructure(
93       @PathParam("vspId") String vspId,
94       @ApiParam(value = "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   @ApiOperation(value = "Get uploaded HEAT file files data structure",
102       notes = "Downloads the latest HEAT package",
103       response = FileDataStructureDto.class)
104   Response getFilesDataStructure(
105       @PathParam("vspId") String vspId,
106       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
107       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
108       throws Exception;
109
110 }