Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d92beeee
Unverified
Commit
d92beeee
authored
Dec 04, 2020
by
Agnès Toulet
Committed by
GitHub
Dec 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: add ID to snapshot API responses (#29600)
* API: add ID to snapshot API responses * API: update snapshot tests
parent
bb45f5fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
7 deletions
+22
-7
docs/sources/http_api/snapshot.md
+5
-5
pkg/api/dashboard_snapshot.go
+9
-2
pkg/api/dashboard_snapshot_test.go
+8
-0
No files found.
docs/sources/http_api/snapshot.md
View file @
d92beeee
...
...
@@ -68,7 +68,8 @@ JSON Body schema:
"deleteKey":"XXXXXXX",
"deleteUrl":"myurl/api/snapshots-delete/XXXXXXX",
"key":"YYYYYYY",
"url":"myurl/dashboard/snapshot/YYYYYYY"
"url":"myurl/dashboard/snapshot/YYYYYYY",
"id": 1,
}
```
...
...
@@ -192,7 +193,7 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
HTTP/1.1 200
Content-Type: application/json
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches."}
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches."
, "id": 1
}
```
## Delete Snapshot by deleteKey
...
...
@@ -214,5 +215,5 @@ Accept: application/json
HTTP/1.1 200
Content-Type: application/json
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches."}
```
\ No newline at end of file
{"message":"Snapshot deleted. It might take an hour before it's cleared from any CDN caches.", "id": 1}
```
pkg/api/dashboard_snapshot.go
View file @
d92beeee
...
...
@@ -132,6 +132,7 @@ func CreateDashboardSnapshot(c *models.ReqContext, cmd models.CreateDashboardSna
"deleteKey"
:
cmd
.
DeleteKey
,
"url"
:
url
,
"deleteUrl"
:
setting
.
ToAbsUrl
(
"api/snapshots-delete/"
+
cmd
.
DeleteKey
),
"id"
:
cmd
.
Result
.
Id
,
})
}
...
...
@@ -223,7 +224,10 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) Response {
return
Error
(
500
,
"Failed to delete dashboard snapshot"
,
err
)
}
return
JSON
(
200
,
util
.
DynMap
{
"message"
:
"Snapshot deleted. It might take an hour before it's cleared from any CDN caches."
})
return
JSON
(
200
,
util
.
DynMap
{
"message"
:
"Snapshot deleted. It might take an hour before it's cleared from any CDN caches."
,
"id"
:
query
.
Result
.
Id
,
})
}
// DELETE /api/snapshots/:key
...
...
@@ -269,7 +273,10 @@ func DeleteDashboardSnapshot(c *models.ReqContext) Response {
return
Error
(
500
,
"Failed to delete dashboard snapshot"
,
err
)
}
return
JSON
(
200
,
util
.
DynMap
{
"message"
:
"Snapshot deleted. It might take an hour before it's cleared from any CDN caches."
})
return
JSON
(
200
,
util
.
DynMap
{
"message"
:
"Snapshot deleted. It might take an hour before it's cleared from any CDN caches."
,
"id"
:
query
.
Result
.
Id
,
})
}
// GET /api/dashboard/snapshots
...
...
pkg/api/dashboard_snapshot_test.go
View file @
d92beeee
...
...
@@ -109,6 +109,7 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
require
.
NoError
(
t
,
err
)
assert
.
True
(
t
,
strings
.
HasPrefix
(
respJSON
.
Get
(
"message"
)
.
MustString
(),
"Snapshot deleted"
))
assert
.
Equal
(
t
,
1
,
respJSON
.
Get
(
"id"
)
.
MustInt
())
assert
.
Equal
(
t
,
http
.
MethodGet
,
externalRequest
.
Method
)
assert
.
Equal
(
t
,
ts
.
URL
,
fmt
.
Sprintf
(
"http://%s"
,
externalRequest
.
Host
))
...
...
@@ -141,6 +142,7 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
require
.
NoError
(
t
,
err
)
assert
.
True
(
t
,
strings
.
HasPrefix
(
respJSON
.
Get
(
"message"
)
.
MustString
(),
"Snapshot deleted"
))
assert
.
Equal
(
t
,
1
,
respJSON
.
Get
(
"id"
)
.
MustInt
())
assert
.
Equal
(
t
,
ts
.
URL
,
fmt
.
Sprintf
(
"http://%s"
,
externalRequest
.
Host
))
assert
.
Equal
(
t
,
"/"
,
externalRequest
.
URL
.
EscapedPath
())
})
...
...
@@ -163,6 +165,7 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
require
.
NoError
(
t
,
err
)
assert
.
True
(
t
,
strings
.
HasPrefix
(
respJSON
.
Get
(
"message"
)
.
MustString
(),
"Snapshot deleted"
))
assert
.
Equal
(
t
,
1
,
respJSON
.
Get
(
"id"
)
.
MustInt
())
})
})
...
...
@@ -186,6 +189,11 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
require
.
NoError
(
t
,
writeErr
)
assert
.
Equal
(
t
,
200
,
sc
.
resp
.
Code
)
respJSON
,
err
:=
simplejson
.
NewJson
(
sc
.
resp
.
Body
.
Bytes
())
require
.
NoError
(
t
,
err
)
assert
.
True
(
t
,
strings
.
HasPrefix
(
respJSON
.
Get
(
"message"
)
.
MustString
(),
"Snapshot deleted"
))
assert
.
Equal
(
t
,
1
,
respJSON
.
Get
(
"id"
)
.
MustInt
())
})
loggedInUserScenarioWithRole
(
t
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment