mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 03:52:17 +08:00
Docs: update users API (#23570)
* Docs: update users api * Apply suggestions from code review Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:

committed by
GitHub

parent
28543e11ba
commit
19f03e593c
@ -38,14 +38,22 @@ Content-Type: application/json
|
|||||||
|
|
||||||
`GET /api/users/search?perpage=10&page=1&query=mygraf`
|
`GET /api/users/search?perpage=10&page=1&query=mygraf`
|
||||||
|
|
||||||
**Example Request**:
|
**Example Request**:
|
||||||
|
|
||||||
|
```http
|
||||||
|
GET /api/users/search?perpage=10&page=1&query=mygraf HTTP/1.1
|
||||||
|
Accept: application/json
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Basic YWRtaW46YWRtaW4=
|
Authorization: Basic YWRtaW46YWRtaW4=
|
||||||
```
|
```
|
||||||
|
|
||||||
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. The `query` parameter is optional and it will return results where the query value is contained in one of the `name`, `login` or `email` fields. Query values with spaces need to be URL encoded e.g. `query=Jane%20Doe`.
|
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. The `query` parameter is optional and it will return results where the query value is contained in one of the `name`, `login` or `email` fields. Query values with spaces need to be URL encoded e.g. `query=Jane%20Doe`.
|
||||||
|
|
||||||
```
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
||||||
|
|
||||||
|
**Example Response**:
|
||||||
|
|
||||||
|
```http
|
||||||
HTTP/1.1 200
|
HTTP/1.1 200
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
{
|
{
|
||||||
@ -80,14 +88,22 @@ Content-Type: application/json
|
|||||||
**Example Request using the email as option**:
|
**Example Request using the email as option**:
|
||||||
|
|
||||||
```http
|
```http
|
||||||
|
GET /api/users/lookup?loginOrEmail=user@mygraf.com HTTP/1.1
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||||
|
```
|
||||||
|
|
||||||
**Example Request using the username as option**:
|
**Example Request using the username as option**:
|
||||||
|
|
||||||
```http
|
```http
|
||||||
GET /api/users/lookup?loginOrEmail=admin HTTP/1.1
|
GET /api/users/lookup?loginOrEmail=admin HTTP/1.1
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
```http
|
Content-Type: application/json
|
||||||
|
Authorization: Basic YWRtaW46YWRtaW4=
|
||||||
|
```
|
||||||
|
|
||||||
|
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
||||||
|
|
||||||
**Example Response**:
|
**Example Response**:
|
||||||
|
|
||||||
@ -127,7 +143,8 @@ Content-Type: application/json
|
|||||||
|
|
||||||
**Example Request**:
|
**Example Request**:
|
||||||
|
|
||||||
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
```http
|
||||||
|
GET /api/users/1/orgs HTTP/1.1
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Basic YWRtaW46YWRtaW4=
|
Authorization: Basic YWRtaW46YWRtaW4=
|
||||||
@ -173,7 +190,8 @@ Content-Type: application/json
|
|||||||
|
|
||||||
`GET /api/user`
|
`GET /api/user`
|
||||||
|
|
||||||
Requires basic authentication and that the authenticated user is a Grafana Admin.
|
**Example Request**:
|
||||||
|
|
||||||
```http
|
```http
|
||||||
GET /api/user HTTP/1.1
|
GET /api/user HTTP/1.1
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
@ -294,12 +312,19 @@ HTTP/1.1 200
|
|||||||
|
|
||||||
## Teams that the actual User is member of
|
## Teams that the actual User is member of
|
||||||
|
|
||||||
|
`GET /api/user/teams`
|
||||||
|
|
||||||
Return a list of all teams that the current user is member of.
|
Return a list of all teams that the current user is member of.
|
||||||
|
|
||||||
**Example Request**:
|
**Example Request**:
|
||||||
|
|
||||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
```http
|
||||||
|
GET /api/user/teams HTTP/1.1
|
||||||
|
Accept: application/json
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||||
|
```
|
||||||
|
|
||||||
**Example Response**:
|
**Example Response**:
|
||||||
|
|
||||||
```http
|
```http
|
||||||
|
Reference in New Issue
Block a user