本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
首选项 API
使用首选项 API 在 Amazon Managed Grafana 工作区中处理用户首选项。
键:
-
theme:有效值为
light、dark或使用默认主题的空字符串。 -
home DashboardId — 最喜欢的仪表板
:id的数字。默认值是 0。 -
timezone:有效值为
utc、browser或使用默认值的空字符串。
省略键会导致当前值被系统默认值替换。
注意
要在您的亚马逊托管 Grafana 工作空间中使用 Grafana API,您必须拥有有效的服务账户令牌。您可以将其包含在 API 请求的 Authorization 字段中。
获取当前用户首选项
GET /api/user/preferences
示例请求
GET /api/user/preferences HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
响应示例
HTTP/1.1 200 Content-Type: application/json {"theme":"","homeDashboardId":0,"timezone":""}
更新当前用户首选项
PUT /api/user/preferences
示例请求
PUT /api/user/preferences HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk { "theme": "", "homeDashboardId":0, "timezone":"utc" }
响应示例
HTTP/1.1 200 Content-Type: text/plain; charset=utf-8 {"message":"Preferences updated"}
获取当前组织首选项
GET /api/org/preferences
示例请求
GET /api/org/preferences HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
响应示例
HTTP/1.1 200 Content-Type: application/json {"theme":"","homeDashboardId":0,"timezone":""}
更新当前组织首选项
PUT /api/org/preferences
示例请求
PUT /api/org/preferences HTTP/1.1 Accept: application/json Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk { "theme": "", "homeDashboardId":0, "timezone":"utc" }
响应示例
HTTP/1.1 200 Content-Type: text/plain; charset=utf-8 {"message":"Preferences updated"}