Create new VSP, onboard from TOSCA file - UI
[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.sdc.vendorsoftwareproduct.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.io.InputStream;
47 import java.lang.reflect.InvocationTargetException;
48
49 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
50 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
51
52 @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/orchestration-template-candidate")
53 @Produces(MediaType.APPLICATION_JSON)
54 @Consumes(MediaType.APPLICATION_JSON)
55 @Api(value = "Orchestration Template Candidate")
56 @Validated
57 public interface OrchestrationTemplateCandidate extends VspEntities {
58
59   @POST
60   @Path("/")
61   @Consumes(MediaType.MULTIPART_FORM_DATA)
62   Response upload(
63       @PathParam("vspId") String vspId,
64       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
65       @Multipart("upload") Attachment fileToUpload,
66       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
67
68   @GET
69   @Path("/")
70   @Produces(MediaType.APPLICATION_OCTET_STREAM)
71   @ApiOperation(value = "Get uploaded candidate HEAT file",
72       notes = "Downloads in process candidate HEAT file",
73       response = File.class)
74   Response get(
75       @PathParam("vspId") String vspId,
76       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
77       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
78       throws IOException;
79
80   @PUT
81   @Path("/process")
82   @ApiOperation(value = "process Orchestration Template Candidate",
83       response = UploadFileResponseDto.class)
84   Response process(
85       @PathParam("vspId") String vspId,
86       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
87       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
88       throws InvocationTargetException, IllegalAccessException;
89
90   @PUT
91   @Path("/manifest")
92   @ApiOperation(value = "Update an existing vendor software product")
93   Response updateFilesDataStructure(
94       @PathParam("vspId") String vspId,
95       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
96       @Valid FileDataStructureDto fileDataStructureDto,
97       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
98       throws Exception;
99
100   @GET
101   @Path("/manifest")
102   @ApiOperation(value = "Get uploaded HEAT file files data structure",
103       notes = "Downloads the latest HEAT package",
104       response = FileDataStructureDto.class)
105   Response getFilesDataStructure(
106       @PathParam("vspId") String vspId,
107       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
108       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
109       throws Exception;
110
111 }