6f72175175e50ff0b99ac2ee89838f6335a8fdee
[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.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.openecomp.sdcrests.item.types.*;
32 import org.springframework.validation.annotation.Validated;
33
34 import javax.validation.constraints.NotNull;
35 import javax.ws.rs.*;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
38
39 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
40 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
41
42 @Path("/v1.0/items/{itemId}/versions")
43 @Produces(MediaType.APPLICATION_JSON)
44 @Consumes(MediaType.APPLICATION_JSON)
45 @OpenAPIDefinition(info = @Info(title = "Item Versions"))
46 @Validated
47 public interface Versions {
48
49   @GET
50   @Path("/")
51   @Operation(description = "Lists item versions", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = VersionDto.class)))))
52   Response list(@PathParam("itemId") String itemId,
53                 @NotNull(message = USER_MISSING_ERROR_MSG)
54                 @HeaderParam(USER_ID_HEADER_PARAM) String user);
55
56   @POST
57   @Path("/{versionId}")
58   @Operation(description = "Creates a new item version")
59   Response create(VersionRequestDto request,
60                   @PathParam("itemId") String itemId,
61                   @PathParam("versionId") String versionId,
62                   @NotNull(message = USER_MISSING_ERROR_MSG)
63                   @HeaderParam(USER_ID_HEADER_PARAM) String user);
64
65   @GET
66   @Path("/{versionId}")
67   @Operation(description = "Gets item version", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = VersionDto.class))))
68   Response get(@PathParam("itemId") String itemId,
69                @PathParam("versionId") String versionId,
70                @NotNull(message = USER_MISSING_ERROR_MSG)
71                @HeaderParam(USER_ID_HEADER_PARAM) String user);
72
73   @GET
74   @Path("/{versionId}/activity-logs")
75   @Operation(description = "Gets item version activity log", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ActivityLogDto.class)))))
76   Response getActivityLog(@Parameter(description = "Item Id") @PathParam("itemId") String itemId,
77                           @Parameter( description = "Version Id") @PathParam("versionId") String versionId,
78                           @NotNull(message = USER_MISSING_ERROR_MSG)
79                           @HeaderParam(USER_ID_HEADER_PARAM) String user);
80
81   @GET
82   @Path("/{versionId}/revisions")
83   @Operation(description = "Gets item version revisions", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ActivityLogDto.class)))))
84   Response listRevisions(@PathParam("itemId") String itemId,
85                          @PathParam("versionId") String versionId,
86                          @NotNull(message = USER_MISSING_ERROR_MSG)
87                @HeaderParam(USER_ID_HEADER_PARAM) String user);
88
89   @PUT
90   @Path("/{versionId}/actions")
91   @Operation(description = "Acts on item version")
92   Response actOn(VersionActionRequestDto request,
93                  @PathParam("itemId") String itemId,
94                  @PathParam("versionId") String versionId,
95                  @NotNull(message = USER_MISSING_ERROR_MSG)
96                  @HeaderParam(USER_ID_HEADER_PARAM) String user);
97 }