re base code
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-software-products-rest / vnf-repository-rest-services / src / main / java / org / openecomp / sdcrests / vsp / rest / VnfPackageRepository.java
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
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.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
23 import org.springframework.validation.annotation.Validated;
24
25 import javax.validation.constraints.NotNull;
26 import javax.ws.rs.*;
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
29 import java.io.File;
30
31 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
32 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
33
34 @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/vnfrepository")
35 @Produces(MediaType.APPLICATION_JSON)
36 @Consumes(MediaType.APPLICATION_JSON)
37 @Api(value = "VNF Repository packages")
38 @Validated
39 public interface VnfPackageRepository extends VspEntities {
40
41     @GET
42     @Path("/vnfpackages")
43     @Produces(MediaType.APPLICATION_OCTET_STREAM)
44     @ApiOperation(value = "Get VNF packages from VNF Repository", notes = "Call VNF Repostory to get VNF package details", response = File.class)
45     Response getVnfPackages(@PathParam("vspId") String vspId,
46             @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
47             @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception;
48
49     @GET
50     @Path("/vnfpackage/{csarId}/download")
51     @Produces(MediaType.APPLICATION_OCTET_STREAM)
52     @ApiOperation(value = "Download VNF package from VNF Repository", notes = "Download VNF package from VNF repository and send to client", response = File.class)
53     Response downloadVnfPackage(@PathParam("vspId") String vspId,
54             @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
55             @PathParam("csarId") String csarId,
56             @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception;
57
58     @POST
59     @Path("/vnfpackage/{csarId}/import")
60     @Produces(MediaType.APPLICATION_JSON)
61     @ApiOperation(value = "Import VNF package from VNF Repository", notes = "Call VNF Repostory to download VNF package, validate it and send the response", response = UploadFileResponseDto.class)
62     Response importVnfPackage(@PathParam("vspId") String vspId,
63             @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
64             @PathParam("csarId") String csarId,
65             @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception;
66
67 }