Publish swagger files for SDC APIs
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / notifications-rest / notifications-rest-services / src / main / java / org / openecomp / sdcrests / notifications / rest / services / Notifications.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.notifications.rest.services;
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.notifications.types.NotificationsStatusDto;
33 import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus;
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 import java.lang.reflect.InvocationTargetException;
41 import java.util.UUID;
42
43 import static org.openecomp.sdcrests.common.RestConstants.*;
44
45 @Path("/v1.0/notifications")
46 @Produces(MediaType.APPLICATION_JSON)
47 @Consumes(MediaType.APPLICATION_JSON)
48 @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Notifications")})
49 @Validated
50 public interface Notifications {
51   String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT";
52   String END_OF_PAGE_QUERY_PARAM = "END_OF_PAGE_EVENT_ID";
53
54   @GET
55   @Operation(description = "Retrieve all user notifications", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = NotificationsStatusDto.class)))))
56   Response getNotifications(
57       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user,
58       @QueryParam(LAST_DELIVERED_QUERY_PARAM) UUID lastDelvered,
59       @QueryParam(END_OF_PAGE_QUERY_PARAM) UUID endOfPage);
60
61   @PUT
62   @Path("/{notificationId}")
63   @Operation(description = "Mark notification as read", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UpdateNotificationResponseStatus.class))))
64   Response markAsRead(
65       @Parameter(description = "Notification Id") @PathParam("notificationId") String notificationId,
66       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
67       throws InvocationTargetException, IllegalAccessException;
68
69   @PUT
70   @Path("/last-seen/{notificationId}")
71   @Operation(description = "Update Last Seen Notification", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UpdateNotificationResponseStatus.class))))
72   Response updateLastSeenNotification(
73       @Parameter(description = "Notification Id") @PathParam("notificationId") String notificationId,
74       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
75       throws InvocationTargetException, IllegalAccessException;
76
77   @GET
78   @Path("/worker")
79   @Operation(description = "Retrive user not delivered notifications",responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = NotificationsStatusDto.class)))))
80   Response getNewNotificationsByOwnerId(
81       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user,
82       @QueryParam(LAST_DELIVERED_QUERY_PARAM) String eventId,
83       @QueryParam(LIMIT_QUERY_PARAM) String limit);
84
85 }