diff --git a/docs/sources/http_api/user.md b/docs/sources/http_api/user.md index 6f849947416..9b759330489 100644 --- a/docs/sources/http_api/user.md +++ b/docs/sources/http_api/user.md @@ -13,7 +13,7 @@ parent = "http_api" ## Search Users -`GET /api/users` +`GET /api/users?perpage=10&page=1` **Example Request**: @@ -22,6 +22,8 @@ parent = "http_api" Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk +Default value for the `perpage` parameter is `1000` and for the `page` parameter is `1`. + **Example Response**: HTTP/1.1 200 @@ -44,6 +46,45 @@ parent = "http_api" } ] +## Search Users with Paging + +`GET /api/users/search?perpage=10&page=1` + +**Example Request**: + + GET /api/users/search?perpage=10&page=1 HTTP/1.1 + Accept: application/json + Content-Type: application/json + Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk + +Default value for the `perpage` parameter is `1000` and for the `page` parameter is `1`. The `totalCount` field in the response can be used for pagination of the user list E.g. if `totalCount` is equal to 100 users and the `perpage` parameter is set to 10 then there are 10 pages of users. + +**Example Response**: + + HTTP/1.1 200 + Content-Type: application/json + { + "totalCount": 2, + "users": [ + { + "id": 1, + "name": "Admin", + "login": "admin", + "email": "admin@mygraf.com", + "isAdmin": true + }, + { + "id": 2, + "name": "User", + "login": "user", + "email": "user@mygraf.com", + "isAdmin": false + } + ], + "page": 1, + "perPage": 10 + } + ## Get single user by Id `GET /api/users/:id` diff --git a/pkg/api/user.go b/pkg/api/user.go index 9a978503761..8dd6daab4bc 100644 --- a/pkg/api/user.go +++ b/pkg/api/user.go @@ -218,7 +218,7 @@ func SearchUsers(c *middleware.Context) Response { return Json(200, query.Result.Users) } -// GET /api/paged-users +// GET /api/search func SearchUsersWithPaging(c *middleware.Context) Response { query, err := searchUser(c) if err != nil {