[SECARSP-111] +Auth API [SECARSP-115 +Get Devices]
[platform/core/security/suspicious-activity-monitor.git] / server / src / main / java / com / samsung / samserver / web / rest / controller / IRestDashboard.java
1 /*
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.
5  */
6 package com.samsung.samserver.web.rest.controller;
7
8 import com.samsung.samserver.domain.Device;
9 import com.samsung.samserver.web.rest.service.AccountService;
10 import com.samsung.samserver.web.rest.service.UserJWTService;
11 import org.springframework.http.HttpStatus;
12 import org.springframework.http.ResponseEntity;
13 import org.springframework.web.bind.annotation.*;
14 import io.swagger.annotations.*;
15
16 import javax.validation.Valid;
17 import java.util.List;
18 import com.samsung.samserver.web.rest.errors.UserServiceError;
19
20 /**
21  * Rest Interface for dashboard.
22  *
23  * @author <A HREF="mailto:m.dalakov@samsung.com">Mykhailo Dalakov</A>
24  * @version 1.0
25  */
26 @RequestMapping("/dashboard")
27 public interface IRestDashboard {
28
29     /**
30      * GET  /devices : get all the devices.
31      *
32      * @return the ResponseEntity with status 200 (OK) and the list of devices in body
33      */
34     @ApiOperation(value = "getAllDevices", notes = "The “getAllDevices” operation is used to obtain all registered devices.")
35     @ApiResponses(value = {
36             @ApiResponse(code = 200, message = "OK. Request executed successfully."),
37             @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
38             @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
39     })
40     @RequestMapping(value ="/devices", method = RequestMethod.GET)
41     public List<Device> getAllDevices();
42
43
44     /**
45      * POST request login
46      *
47      * @return the ResponseEntity with status 200 (OK) and JWT
48      */
49     @ApiOperation(value = "login", notes = "The “login” operation is used to authenticate user and receive JWT token.")
50     @ApiResponses(value = {
51             @ApiResponse(code = 200, message = "OK. Login was successful."),
52             @ApiResponse(code = 400, message = "Bad Request. The reason is contained in the tags “errorKey”, “message”, “title”"),
53             @ApiResponse(code = 500, message = "Internal server error. The user has to repeat action.")
54     })
55     @RequestMapping(value ="/auth/login", method = RequestMethod.POST)
56     public ResponseEntity<UserJWTService.JWTToken> login(
57             @Valid @ApiParam(value = "Login Data", required = true) @RequestBody UserJWTService.LoginVM loginVM);
58
59
60     /**
61      * POST request register the user.
62      *
63      * @param managedUserVM 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
67      */
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.")
73     })
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 AccountService.ManagedUserVM managedUserVM);
78
79
80 }