re base code
[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.annotations.Api;
24 import io.swagger.annotations.ApiOperation;
25 import io.swagger.annotations.ApiParam;
26 import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto;
27 import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus;
28 import org.springframework.validation.annotation.Validated;
29
30 import javax.validation.constraints.NotNull;
31 import javax.ws.rs.*;
32 import javax.ws.rs.core.MediaType;
33 import javax.ws.rs.core.Response;
34 import java.lang.reflect.InvocationTargetException;
35 import java.util.UUID;
36
37 import static org.openecomp.sdcrests.common.RestConstants.*;
38
39 @Path("/v1.0/notifications")
40 @Produces(MediaType.APPLICATION_JSON)
41 @Consumes(MediaType.APPLICATION_JSON)
42 @Api(value = "Notifications")
43 @Validated
44 public interface Notifications {
45   String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT";
46   String END_OF_PAGE_QUERY_PARAM = "END_OF_PAGE_EVENT_ID";
47
48   @GET
49   @ApiOperation(value = "Retrive all user notifications",
50       response = NotificationsStatusDto.class,
51       responseContainer = "List")
52   Response getNotifications(
53       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user,
54       @QueryParam(LAST_DELIVERED_QUERY_PARAM) UUID lastDelvered,
55       @QueryParam(END_OF_PAGE_QUERY_PARAM) UUID endOfPage);
56
57   @PUT
58   @Path("/{notificationId}")
59   @ApiOperation(value = "Mark notification as read",
60       response = UpdateNotificationResponseStatus.class)
61   Response markAsRead(
62       @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId,
63       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
64       throws InvocationTargetException, IllegalAccessException;
65
66   @PUT
67   @Path("/last-seen/{notificationId}")
68   @ApiOperation(value = "Update Last Seen Notification",
69       response = UpdateNotificationResponseStatus.class)
70   Response updateLastSeenNotification(
71       @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId,
72       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
73       throws InvocationTargetException, IllegalAccessException;
74
75   @GET
76   @Path("/worker")
77   @ApiOperation(value = "Retrive user not delivered notifications",
78       response = NotificationsStatusDto.class,
79       responseContainer = "List")
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 }