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