Library Elements API GET by name returns array (#44743)

* Library Elements API GET by name returns array

Making a GET request to the Library Elements HTTP API `api/library-elements/name/:name` will return an **array** of Library Element objects, but the documentation says it will return a Library Element object.

Example cURL POST request:
`curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer XXXXXXXXXXX" -d @request.json "https://my.grafana.net/api/library-elements/"`

request.json
```json
{
  "model": {},
  "kind": 1,
  "name": "testing description3",
  "uid": "basic3",
  "id": 12345,
  "version": 2
}
```

Example cURL GET request:
`curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer XXXXXXXX" -d @request "https://my/api/library-elements/name/testing description3"`

Example response:
```json
{
    "result": [
        {
            . . .
        }
    ]
}
```

* Library Elements API fix bracket spacing
This commit is contained in:
JM 2022-02-02 00:50:27 -08:00 committed by GitHub
parent ac90c8d68d
commit 925333bfa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -176,35 +176,37 @@ HTTP/1.1 200
Content-Type: application/json
{
"result": {
"id": 25,
"orgId": 1,
"folderId": 0,
"uid": "V--OrYHnz",
"name": "API docs Example",
"kind": 1,
"type": "text",
"description": "",
"model": {...},
"version": 1,
"meta": {
"folderName": "General",
"folderUid": "",
"connectedDashboards": 1,
"created": "2021-09-27T09:56:17+02:00",
"updated": "2021-09-27T09:56:17+02:00",
"createdBy": {
"id": 1,
"name": "admin",
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
},
"updatedBy": {
"id": 1,
"name": "admin",
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
}
}
}
"result": [
{
"id": 25,
"orgId": 1,
"folderId": 0,
"uid": "V--OrYHnz",
"name": "API docs Example",
"kind": 1,
"type": "text",
"description": "",
"model": {...},
"version": 1,
"meta": {
"folderName": "General",
"folderUid": "",
"connectedDashboards": 1,
"created": "2021-09-27T09:56:17+02:00",
"updated": "2021-09-27T09:56:17+02:00",
"createdBy": {
"id": 1,
"name": "admin",
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
},
"updatedBy": {
"id": 1,
"name": "admin",
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
}
}
}
]
}
```