1f883697ee12ef24913e9713637db1b70c28e3f0
[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 / ComponentMonitoringUploads.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.v3.oas.annotations.OpenAPIDefinition;
24 import io.swagger.v3.oas.annotations.Operation;
25 import io.swagger.v3.oas.annotations.Parameter;
26 import io.swagger.v3.oas.annotations.info.Info;
27 import io.swagger.v3.oas.annotations.media.ArraySchema;
28 import io.swagger.v3.oas.annotations.media.Content;
29 import io.swagger.v3.oas.annotations.media.Schema;
30 import io.swagger.v3.oas.annotations.responses.ApiResponse;
31 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
32 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
33 import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto;
34 import org.springframework.validation.annotation.Validated;
35
36 import javax.validation.constraints.NotNull;
37 import javax.ws.rs.*;
38 import javax.ws.rs.core.MediaType;
39 import javax.ws.rs.core.Response;
40
41 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
42 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
43
44 @Path(
45     "/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/uploads/")
46 @Produces(MediaType.APPLICATION_JSON)
47 @Consumes(MediaType.APPLICATION_JSON)
48 @OpenAPIDefinition(info = @Info(title = "Vendor Software Product Component Uploads"))
49 @Validated
50 public interface ComponentMonitoringUploads extends VspEntities {
51   @POST
52   @Path("types/{type}/")
53   @Consumes(MediaType.MULTIPART_FORM_DATA)
54   @Operation(description = "Upload file for component by type")
55   Response upload(@Multipart("upload") Attachment attachment,
56                   @Parameter(description = "Vendor software product Id") @PathParam("vspId")
57                       String vspId,
58                   @Parameter(description = "Vendor software product version Id")
59                   @PathParam("versionId") String versionId,
60                   @Parameter(description = "Component Id") @PathParam("componentId") String
61                       componentId,
62                   @Parameter(description = "Upload Type") @PathParam("type") String type,
63                   @NotNull(message = USER_MISSING_ERROR_MSG)
64                   @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception;
65
66   @DELETE
67   @Path("types/{type}")
68   @Operation(description = "Delete file uploaded for component")
69   Response delete(
70       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
71       @Parameter(description = "Vendor software product version Id") @PathParam("versionId")
72           String versionId,
73       @Parameter(description = "Component Id") @PathParam("componentId") String componentId,
74       @Parameter(description = "Upload Type") @PathParam("type") String type,
75       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
76       throws Exception;
77
78   @GET
79   @Path("")
80   @Operation(description = "Get the filenames of uploaded files by type", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =MonitoringUploadStatusDto.class)))))
81   Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
82                 @Parameter(description = "Vendor software product version Id") @PathParam("versionId")
83                     String versionId,
84                 @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
85                     String componentId,
86                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
87                     String user);
88 }