

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用者 API
<a name="Grafana-API-User"></a>

使用 使用者 API 與 Amazon Managed Grafana 工作區中的使用者搭配使用。

**注意**  
若要搭配 Amazon Managed Grafana 工作區使用 Grafana API，您必須擁有有效的 Grafana API 字符。您可以在 API 請求的 `Authorization` 欄位中包含此項目。如需如何建立權杖以驗證 API 呼叫的詳細資訊，請參閱 [使用字符進行驗證](authenticating-grafana-apis.md)。

## 取得使用者所屬的團隊
<a name="Grafana-API-User-teammember"></a>

```
GET /api/user/teams
```

**範例請求**

```
GET /api/user/teams HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```

**回應範例**

```
HTTP/1.1 200
Content-Type: application/json

[
  {
    "id": 1,
    "orgId": 1,
    "name": "MyTestTeam",
    "email": "",
    "avatarUrl": "\/avatar\/3f49c15916554246daa714b9bd0ee3",
    "memberCount": 1
  }
]
```

## 取得快照清單
<a name="Grafana-API-User-stardashboard"></a>

將實際使用者的指定儀表板設為 Star。

```
POST /api/user/stars/dashboard/:dashboardId
```

**範例請求**

```
POST /api/user/stars/dashboard/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```

**回應範例**

```
HTTP/1.1 200
Content-Type: application/json

{"message":"Dashboard starred!"}
```

## 取消顯示儀表板
<a name="Grafana-API-User-unstardashboard"></a>

刪除實際使用者的指定儀表板的星號。

```
DELETE /api/user/stars/dashboard/:dashboardId
```

**範例請求**

```
DELETE /api/user/stars/dashboard/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```

**回應範例**

```
HTTP/1.1 200
Content-Type: application/json

{"message":"Dashboard unstarred"}
```

## 取得實際使用者的身分驗證字符
<a name="Grafana-API-User-authtokens"></a>

```
GET /api/user/auth-tokens
```

**範例請求**

```
GET /api/user/auth-tokens HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```

**回應範例**

```
HTTP/1.1 200
Content-Type: application/json

[
  {
    "id": 361,
    "isActive": true,
    "clientIp": "127.0.0.1",
    "browser": "Chrome",
    "browserVersion": "72.0",
    "os": "Linux",
    "osVersion": "",
    "device": "Other",
    "createdAt": "2019-03-05T21:22:54+01:00",
    "seenAt": "2019-03-06T19:41:06+01:00"
  },
  {
    "id": 364,
    "isActive": false,
    "clientIp": "127.0.0.1",
    "browser": "Mobile Safari",
    "browserVersion": "11.0",
    "os": "iOS",
    "osVersion": "11.0",
    "device": "iPhone",
    "createdAt": "2019-03-06T19:41:19+01:00",
    "seenAt": "2019-03-06T19:41:21+01:00"
  }
]
```

## 撤銷實際使用者的身分驗證字符
<a name="Grafana-API-User-authtokens-revoke"></a>

```
POST /api/user/revoke-auth-token
```

撤銷實際使用者的指定身分驗證字符 （裝置）。已發行身分驗證字符 （裝置） 的使用者不會再登入，必須在下次活動時再次進行身分驗證。

**範例請求**

```
POST /api/user/revoke-auth-token HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

{
  "authTokenId": 364
}
```

**回應範例**

```
HTTP/1.1 200
Content-Type: application/json

{
  "message": "User auth token revoked"
}
```