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:
Kyle Brandt
2021-01-13 13:16:27 -05:00
committed by GitHub
parent d5cbb17666
commit 1c1a800bc0
18 changed files with 295 additions and 89 deletions

View File

@ -31,6 +31,7 @@ Content-Type: application/json
## Get a single data source by Id
`GET /api/datasources/:datasourceId`
**Example Request**:
@ -74,6 +75,53 @@ Content-Type: application/json
`GET /api/datasources/name/:name`
**Example Request**:
```http
GET /api/datasources/name/test_datasource HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
```
## Get data source Id by Name
`GET /api/datasources/id/:name`
**Example Request**:
```http
GET /api/datasources/id/test_datasource HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
```
## Create a data source
`POST /api/datasources`
**Example Graphite Request**:
```http
POST /api/datasources HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
@ -119,6 +167,7 @@ Content-Type: application/json
## Update an existing data source
`PUT /api/datasources/:datasourceId`
**Example Request**:
```http
@ -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`