mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 08:18:10 -05:00
API: Add by UID routes for data sources (#29884)
- also add Get by UID+OrgID to datasource cache - Refactor backend commands for Delete and Get to be unified
This commit is contained in:
@@ -31,6 +31,7 @@ Content-Type: application/json
|
||||
{
|
||||
"id": 1,
|
||||
"orgId": 1,
|
||||
"uid": "H8joYFVGz"
|
||||
"name": "datasource_elastic",
|
||||
"type": "elasticsearch",
|
||||
"typeLogoUrl": "public/app/plugins/datasource/elasticsearch/img/elasticsearch.svg",
|
||||
@@ -74,6 +75,53 @@ Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"uid": "kLtEtcRGk",
|
||||
"orgId": 1,
|
||||
"name": "test_datasource",
|
||||
"type": "graphite",
|
||||
"typeLogoUrl": "",
|
||||
"access": "proxy",
|
||||
"url": "http://mydatasource.com",
|
||||
"password": "",
|
||||
"user": "",
|
||||
"database": "",
|
||||
"basicAuth": false,
|
||||
"basicAuthUser": "",
|
||||
"basicAuthPassword": "",
|
||||
"withCredentials": false,
|
||||
"isDefault": false,
|
||||
"jsonData": {
|
||||
"graphiteType": "default",
|
||||
"graphiteVersion": "1.1"
|
||||
},
|
||||
"secureJsonFields": {},
|
||||
"version": 1,
|
||||
"readOnly": false
|
||||
}
|
||||
```
|
||||
|
||||
## Get a single data source by UID
|
||||
|
||||
`GET /api/datasources/uid/:uid`
|
||||
|
||||
**Example request:**
|
||||
|
||||
```http
|
||||
GET /api/datasources/uid/kLtEtcRGk HTTP/1.1
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"uid": "kLtEtcRGk",
|
||||
"orgId": 1,
|
||||
"name": "test_datasource",
|
||||
"type": "graphite",
|
||||
@@ -119,6 +167,7 @@ Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"uid": "kLtEtcRGk",
|
||||
"orgId": 1,
|
||||
"name": "test_datasource",
|
||||
"type": "graphite",
|
||||
@@ -396,6 +445,28 @@ Content-Type: application/json
|
||||
{"message":"Data source deleted"}
|
||||
```
|
||||
|
||||
## Delete an existing data source by UID
|
||||
|
||||
`DELETE /api/datasources/uid/:uid`
|
||||
|
||||
**Example request:**
|
||||
|
||||
```http
|
||||
DELETE /api/datasources/uid/kLtEtcRGk HTTP/1.1
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||
```
|
||||
|
||||
**Example response**:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
|
||||
{"message":"Data source deleted"}
|
||||
```
|
||||
|
||||
## Delete an existing data source by name
|
||||
|
||||
`DELETE /api/datasources/name/:datasourceName`
|
||||
|
||||
Reference in New Issue
Block a user