2 * In Samsung Ukraine R&D Center (SRK under a contract between)
3 * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 package com.samsung.samserver.web.rest.controller;
8 import com.samsung.samserver.web.rest.service.*;
9 import com.samsung.samserver.web.rest.errors.UserServiceError;
10 import com.samsung.samserver.web.rest.service.vm.*;
11 import org.springframework.data.domain.Pageable;
12 import org.springframework.http.*;
13 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*;
15 import javax.validation.Valid;
16 import java.util.List;
19 * Rest Interface for dashboard.
21 * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
24 @RequestMapping("/dashboard")
25 public interface IRestDashboard {
28 * GET /devices : get all the devices.
30 * @return the ResponseEntity with status 200 (OK) and the list of devices in body
32 @ApiOperation(value = "get all devices", notes = "The “get all devices” operation is used to obtain all registered devices.")
33 @ApiResponses(value = {
34 @ApiResponse(code = 200, message = "OK. Request executed successfully."),
35 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
36 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
38 @RequestMapping(value ="/devices", method = RequestMethod.GET)
39 @ResponseStatus(HttpStatus.OK)
40 public ResponseEntity<List<UIDevice>> getAllDevices(Pageable pageable);
46 * @return the ResponseEntity with status 200 (OK) and JWT
48 @ApiOperation(value = "login", notes = "The “login” operation is used to authenticate user and receive JWT token.")
49 @ApiResponses(value = {
50 @ApiResponse(code = 200, message = "OK. Login was successful."),
51 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
52 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
54 @RequestMapping(value ="/auth/login", method = RequestMethod.POST)
55 @ResponseStatus(HttpStatus.OK)
56 public ResponseEntity<UserJWTService.JWTToken> login(
57 @Valid @ApiParam(value = "Login Data", required = true) @RequestBody UILogin uiLogin);
61 * POST request register the user.
63 * @param uiRegistration the managed user View Model
64 * @throws UserServiceError.InvalidPasswordException 400 (Bad Request) if the password is incorrect
65 * @throws UserServiceError.EmailAlreadyUsedException 400 (Bad Request) if the email is already used
66 * @throws UserServiceError.LoginAlreadyUsedException 400 (Bad Request) if the login is already used
68 @ApiOperation(value = "register", notes = "The “register” operation is used to register new user.")
69 @ApiResponses(value = {
70 @ApiResponse(code = 201, message = "Register was successful. New User was created."),
71 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
72 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
74 @RequestMapping(value ="/auth/register", method = RequestMethod.POST)
75 @ResponseStatus(HttpStatus.CREATED)
76 public void registerAccount(
77 @Valid @ApiParam(value = "Managed User", required = true) @RequestBody UIRegistration uiRegistration);
81 * DELETE request logout
83 * @return the ResponseEntity with status 200 (OK)
85 @ApiOperation(value = "logout", notes = "The “logout” operation is used to logout user.")
86 @ApiResponses(value = {
87 @ApiResponse(code = 200, message = "OK. Logout was successful."),
88 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
89 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
91 @RequestMapping(value ="/auth/logout", method = RequestMethod.DELETE)
92 @ResponseStatus(HttpStatus.OK)
93 public ResponseEntity<Void> logout();
97 * PUT /devices/update : Updates an existing devices.
99 * @param uiDeviceUpdate list the device info to update
100 * @return the ResponseEntity with status 200 (OK)
101 * or with status 400 (Bad Request) if the uiDeviceUpdate is not valid
103 @ApiOperation(value = "devices update", notes = "The “devices update” operation is used to update devices.")
104 @ApiResponses(value = {
105 @ApiResponse(code = 200, message = "OK. All updates was successfully."),
106 @ApiResponse(code = 204, message = "No Content. All updates was unsuccessfully."),
107 @ApiResponse(code = 206, message = "Partial Content. Part updates was successfully."),
108 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
109 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
111 @RequestMapping(value ="/devices/update", method = RequestMethod.PUT)
112 public ResponseEntity<List<UIDevice>> updateDevice(@Valid @RequestBody UIDeviceUpdate uiDeviceUpdate);
116 * POST Dashboard log.
118 * @param uiDashboardLog the ui dashboard log
119 * @return the ResponseEntity with status 200 (OK)
121 @RequestMapping(value ="/logs", method = RequestMethod.POST)
122 public ResponseEntity<Void> sendDashboardLogs(@Valid @RequestBody UIDashboardLog uiDashboardLog);
126 * PUT /policies/device : Update an device policies.
128 * @param uiPolicesUpdate list the ui policies to update device policies
129 * @return the ResponseEntity with status 200 (OK)
130 * or with status 400 (Bad Request) if the uiPolicesUpdate is not valid
132 @ApiOperation(value = "device policy update", notes = "The “device policy update” operation is used to update device policy.")
133 @ApiResponses(value = {
134 @ApiResponse(code = 200, message = "OK. All updates was successfully."),
135 @ApiResponse(code = 204, message = "No Content. All updates was unsuccessfully."),
136 @ApiResponse(code = 206, message = "Partial Content. Part updates was successfully."),
137 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
138 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
140 @RequestMapping(value ="/policies/device", method = RequestMethod.PUT)
141 public ResponseEntity<List<UIPolicies.UIPolicy>> updateDevicePolicies(
142 @ApiParam(value = "device id", required = true) @RequestParam(value = "id") Long id, @Valid @RequestBody UIPoliciesUpdate uiPolicesUpdate);
146 * GET /policies : get all the polices.
148 * @return the ResponseEntity with status 200 (OK) and the list of polices
150 @ApiOperation(value = "get all polices", notes = "The “get all polices” operation is used to obtain all polices.")
151 @ApiResponses(value = {
152 @ApiResponse(code = 200, message = "OK. Request executed successfully."),
153 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
154 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
156 @RequestMapping(value ="/policies", method = RequestMethod.GET)
157 @ResponseStatus(HttpStatus.OK)
158 public ResponseEntity<List<UIPolicies>> getAllPolices();
162 * GET /policies/device?id : get the device polices.
164 * @param id the id of the device
165 * @return the ResponseEntity with status 200 (OK) and the list of polices
167 @ApiOperation(value = "get device polices", notes = "The “get device polices” operation is used to obtain device polices.")
168 @ApiResponses(value = {
169 @ApiResponse(code = 200, message = "OK. Request executed successfully."),
170 @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
171 @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
173 @RequestMapping(value ="/policies/device", method = RequestMethod.GET)
174 @ResponseStatus(HttpStatus.OK)
175 public ResponseEntity<List<UIPolicies>> getDevicePolices(
176 @ApiParam(value = "device id", required = true) @RequestParam(value = "id") Long id);