Publish swagger files for SDC APIs
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / item-rest / item-rest-services / src / main / java / org / openecomp / sdcrests / item / rest / Versions.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.item.rest;
22
23 import io.swagger.v3.oas.annotations.Operation;
24 import io.swagger.v3.oas.annotations.Parameter;
25 import io.swagger.v3.oas.annotations.info.Info;
26 import io.swagger.v3.oas.annotations.media.ArraySchema;
27 import io.swagger.v3.oas.annotations.media.Content;
28 import io.swagger.v3.oas.annotations.media.Schema;
29 import io.swagger.v3.oas.annotations.responses.ApiResponse;
30 import io.swagger.v3.oas.annotations.tags.Tag;
31 import io.swagger.v3.oas.annotations.tags.Tags;
32 import org.openecomp.sdcrests.item.types.*;
33 import org.springframework.validation.annotation.Validated;
34
35 import javax.validation.constraints.NotNull;
36 import javax.ws.rs.*;
37 import javax.ws.rs.core.MediaType;
38 import javax.ws.rs.core.Response;
39
40 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
41 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
42
43 @Path("/v1.0/items/{itemId}/versions")
44 @Produces(MediaType.APPLICATION_JSON)
45 @Consumes(MediaType.APPLICATION_JSON)
46 @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Item Versions")})
47 @Validated
48 public interface Versions {
49
50   @GET
51   @Path("/")
52   @Operation(description = "Lists item versions", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = VersionDto.class)))))
53   Response list(@PathParam("itemId") String itemId,
54                 @NotNull(message = USER_MISSING_ERROR_MSG)
55                 @HeaderParam(USER_ID_HEADER_PARAM) String user);
56
57   @POST
58   @Path("/{versionId}")
59   @Operation(description = "Creates a new item version")
60   Response create(VersionRequestDto request,
61                   @PathParam("itemId") String itemId,
62                   @PathParam("versionId") String versionId,
63                   @NotNull(message = USER_MISSING_ERROR_MSG)
64                   @HeaderParam(USER_ID_HEADER_PARAM) String user);
65
66   @GET
67   @Path("/{versionId}")
68   @Operation(description = "Gets item version", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = VersionDto.class))))
69   Response get(@PathParam("itemId") String itemId,
70                @PathParam("versionId") String versionId,
71                @NotNull(message = USER_MISSING_ERROR_MSG)
72                @HeaderParam(USER_ID_HEADER_PARAM) String user);
73
74   @GET
75   @Path("/{versionId}/activity-logs")
76   @Operation(description = "Gets item version activity log", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ActivityLogDto.class)))))
77   Response getActivityLog(@Parameter(description = "Item Id") @PathParam("itemId") String itemId,
78                           @Parameter( description = "Version Id") @PathParam("versionId") String versionId,
79                           @NotNull(message = USER_MISSING_ERROR_MSG)
80                           @HeaderParam(USER_ID_HEADER_PARAM) String user);
81
82   @GET
83   @Path("/{versionId}/revisions")
84   @Operation(description = "Gets item version revisions", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ActivityLogDto.class)))))
85   Response listRevisions(@PathParam("itemId") String itemId,
86                          @PathParam("versionId") String versionId,
87                          @NotNull(message = USER_MISSING_ERROR_MSG)
88                @HeaderParam(USER_ID_HEADER_PARAM) String user);
89
90   @PUT
91   @Path("/{versionId}/actions")
92   @Operation(description = "Acts on item version")
93   Response actOn(VersionActionRequestDto request,
94                  @PathParam("itemId") String itemId,
95                  @PathParam("versionId") String versionId,
96                  @NotNull(message = USER_MISSING_ERROR_MSG)
97                  @HeaderParam(USER_ID_HEADER_PARAM) String user);
98 }