Query history: Add swagger definitions (#50498)
* Query history: Add swagger definitions
* Update
* Remove changes in generated files
* Generate api files
* Add query history into api docs
* Add examples for commands
* Add missing parameters
* Generate api-spec and api-merged
* Fix linting
* Fix showing of example of queries
* Revert "Fix showing of example of queries"
This reverts commit b1eb073fbe.
* Update
* Update
This commit is contained in:
@@ -25,6 +25,7 @@ func (s *QueryHistoryService) registerAPIEndpoints() {
|
||||
})
|
||||
}
|
||||
|
||||
// createHandler handles POST /api/query-history
|
||||
func (s *QueryHistoryService) createHandler(c *models.ReqContext) response.Response {
|
||||
cmd := CreateQueryInQueryHistoryCommand{}
|
||||
if err := web.Bind(c.Req, &cmd); err != nil {
|
||||
@@ -39,6 +40,7 @@ func (s *QueryHistoryService) createHandler(c *models.ReqContext) response.Respo
|
||||
return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query})
|
||||
}
|
||||
|
||||
// searchHandler handles GET /api/query-history
|
||||
func (s *QueryHistoryService) searchHandler(c *models.ReqContext) response.Response {
|
||||
timeRange := legacydata.NewDataTimeRange(c.Query("from"), c.Query("to"))
|
||||
|
||||
@@ -61,6 +63,7 @@ func (s *QueryHistoryService) searchHandler(c *models.ReqContext) response.Respo
|
||||
return response.JSON(http.StatusOK, QueryHistorySearchResponse{Result: result})
|
||||
}
|
||||
|
||||
// deleteHandler handles DELETE /api/query-history/:uid
|
||||
func (s *QueryHistoryService) deleteHandler(c *models.ReqContext) response.Response {
|
||||
queryUID := web.Params(c.Req)[":uid"]
|
||||
if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) {
|
||||
@@ -72,12 +75,13 @@ func (s *QueryHistoryService) deleteHandler(c *models.ReqContext) response.Respo
|
||||
return response.Error(http.StatusInternalServerError, "Failed to delete query from query history", err)
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusOK, DeleteQueryFromQueryHistoryResponse{
|
||||
return response.JSON(http.StatusOK, QueryHistoryDeleteQueryResponse{
|
||||
Message: "Query deleted",
|
||||
ID: id,
|
||||
})
|
||||
}
|
||||
|
||||
// patchCommentHandler handles PATCH /api/query-history/:uid
|
||||
func (s *QueryHistoryService) patchCommentHandler(c *models.ReqContext) response.Response {
|
||||
queryUID := web.Params(c.Req)[":uid"]
|
||||
if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) {
|
||||
@@ -97,6 +101,7 @@ func (s *QueryHistoryService) patchCommentHandler(c *models.ReqContext) response
|
||||
return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query})
|
||||
}
|
||||
|
||||
// starHandler handles POST /api/query-history/star/:uid
|
||||
func (s *QueryHistoryService) starHandler(c *models.ReqContext) response.Response {
|
||||
queryUID := web.Params(c.Req)[":uid"]
|
||||
if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) {
|
||||
@@ -111,6 +116,7 @@ func (s *QueryHistoryService) starHandler(c *models.ReqContext) response.Respons
|
||||
return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query})
|
||||
}
|
||||
|
||||
// starHandler handles DELETE /api/query-history/star/:uid
|
||||
func (s *QueryHistoryService) unstarHandler(c *models.ReqContext) response.Response {
|
||||
queryUID := web.Params(c.Req)[":uid"]
|
||||
if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) {
|
||||
@@ -125,6 +131,7 @@ func (s *QueryHistoryService) unstarHandler(c *models.ReqContext) response.Respo
|
||||
return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query})
|
||||
}
|
||||
|
||||
// starHandler handles POST /api/query-history/migrate
|
||||
func (s *QueryHistoryService) migrateHandler(c *models.ReqContext) response.Response {
|
||||
cmd := MigrateQueriesToQueryHistoryCommand{}
|
||||
if err := web.Bind(c.Req, &cmd); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user