diff --git a/pkg/services/queryhistory/models.go b/pkg/services/queryhistory/models.go index e4e5e78c1bf..617912e7fd8 100644 --- a/pkg/services/queryhistory/models.go +++ b/pkg/services/queryhistory/models.go @@ -12,6 +12,8 @@ var ( ErrQueryAlreadyStarred = errors.New("query was already starred") ) +type Queries *simplejson.Json + // QueryHistory is the model for query history definitions type QueryHistory struct { ID int64 `xorm:"pk autoincr 'id'"` @@ -21,7 +23,7 @@ type QueryHistory struct { CreatedBy int64 CreatedAt int64 Comment string - Queries *simplejson.Json + Queries Queries } // QueryHistory is the model for query history star definitions @@ -43,13 +45,13 @@ type SearchInQueryHistoryQuery struct { } type QueryHistoryDTO struct { - UID string `json:"uid" xorm:"uid"` - DatasourceUID string `json:"datasourceUid" xorm:"datasource_uid"` - CreatedBy int64 `json:"createdBy"` - CreatedAt int64 `json:"createdAt"` - Comment string `json:"comment"` - Queries *simplejson.Json `json:"queries"` - Starred bool `json:"starred"` + UID string `json:"uid" xorm:"uid"` + DatasourceUID string `json:"datasourceUid" xorm:"datasource_uid"` + CreatedBy int64 `json:"createdBy"` + CreatedAt int64 `json:"createdAt"` + Comment string `json:"comment"` + Queries Queries `json:"queries"` + Starred bool `json:"starred"` } // QueryHistoryResponse is a response struct for QueryHistoryDTO @@ -75,11 +77,11 @@ type QueryHistoryDeleteQueryResponse struct { } type QueryToMigrate struct { - DatasourceUID string `json:"datasourceUid"` - Queries *simplejson.Json `json:"queries"` - CreatedAt int64 `json:"createdAt"` - Comment string `json:"comment"` - Starred bool `json:"starred"` + DatasourceUID string `json:"datasourceUid"` + Queries Queries `json:"queries"` + CreatedAt int64 `json:"createdAt"` + Comment string `json:"comment"` + Starred bool `json:"starred"` } type QueryHistoryMigrationResponse struct { @@ -97,7 +99,7 @@ type CreateQueryInQueryHistoryCommand struct { // The JSON model of queries. // required: true // example: [ { "datasourceUid": "PE1C5CBDA0504A6A3", "queries": [ { "refId": "A", "key": "Q-87fed8e3-62ba-4eb2-8d2a-4129979bb4de-0", "scenarioId": "csv_content", "datasource": { "type": "testdata", "uid": "PD8C576611E62080A" } } ], "starred": false, "createdAt": 1643630762, "comment": "debugging" } ] - Queries *simplejson.Json `json:"queries"` + Queries Queries `json:"queries"` } // PatchQueryCommentInQueryHistoryCommand is the command for updating comment for query in query history diff --git a/public/api-merged.json b/public/api-merged.json index dc04b92cfad..aeed9f7f229 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -489,6 +489,13 @@ "summary": "Add a user role assignment.", "operationId": "addUserRole", "parameters": [ + { + "type": "integer", + "format": "int64", + "name": "user_id", + "in": "path", + "required": true + }, { "name": "body", "in": "body", @@ -496,13 +503,6 @@ "schema": { "$ref": "#/definitions/AddUserRoleCommand" } - }, - { - "type": "integer", - "format": "int64", - "name": "user_id", - "in": "path", - "required": true } ], "responses": { @@ -528,6 +528,13 @@ "summary": "Remove a user role assignment.", "operationId": "removeUserRole", "parameters": [ + { + "type": "integer", + "format": "int64", + "name": "user_id", + "in": "path", + "required": true + }, { "type": "string", "name": "roleUID", @@ -539,13 +546,6 @@ "description": "A flag indicating if the assignment is global or not. If set to false, the default org ID of the authenticated user will be used from the request to remove assignment.", "name": "global", "in": "query" - }, - { - "type": "integer", - "format": "int64", - "name": "user_id", - "in": "path", - "required": true } ], "responses": { @@ -5837,7 +5837,7 @@ { "type": "integer", "format": "int64", - "description": "Limit the number of returned results ", + "description": "Limit the number of returned results", "name": "limit", "in": "query" }, @@ -9412,7 +9412,8 @@ "example": "PE1C5CBDA0504A6A3" }, "queries": { - "$ref": "#/definitions/Json" + "description": "The JSON model of queries.", + "example": "[ { \"datasourceUid\": \"PE1C5CBDA0504A6A3\", \"queries\": [ { \"refId\": \"A\", \"key\": \"Q-87fed8e3-62ba-4eb2-8d2a-4129979bb4de-0\", \"scenarioId\": \"csv_content\", \"datasource\": { \"type\": \"testdata\", \"uid\": \"PD8C576611E62080A\" } } ], \"starred\": false, \"createdAt\": 1643630762, \"comment\": \"debugging\" } ]" } } }, @@ -13013,9 +13014,7 @@ "datasourceUid": { "type": "string" }, - "queries": { - "$ref": "#/definitions/Json" - }, + "queries": {}, "starred": { "type": "boolean" }, @@ -13199,9 +13198,7 @@ "datasourceUid": { "type": "string" }, - "queries": { - "$ref": "#/definitions/Json" - }, + "queries": {}, "starred": { "type": "boolean" } diff --git a/public/api-spec.json b/public/api-spec.json index 067de4ca625..01c28e83fd4 100644 --- a/public/api-spec.json +++ b/public/api-spec.json @@ -489,6 +489,13 @@ "summary": "Add a user role assignment.", "operationId": "addUserRole", "parameters": [ + { + "type": "integer", + "format": "int64", + "name": "user_id", + "in": "path", + "required": true + }, { "name": "body", "in": "body", @@ -496,13 +503,6 @@ "schema": { "$ref": "#/definitions/AddUserRoleCommand" } - }, - { - "type": "integer", - "format": "int64", - "name": "user_id", - "in": "path", - "required": true } ], "responses": { @@ -528,6 +528,13 @@ "summary": "Remove a user role assignment.", "operationId": "removeUserRole", "parameters": [ + { + "type": "integer", + "format": "int64", + "name": "user_id", + "in": "path", + "required": true + }, { "type": "string", "name": "roleUID", @@ -539,13 +546,6 @@ "description": "A flag indicating if the assignment is global or not. If set to false, the default org ID of the authenticated user will be used from the request to remove assignment.", "name": "global", "in": "query" - }, - { - "type": "integer", - "format": "int64", - "name": "user_id", - "in": "path", - "required": true } ], "responses": { @@ -5837,7 +5837,7 @@ { "type": "integer", "format": "int64", - "description": "Limit the number of returned results ", + "description": "Limit the number of returned results", "name": "limit", "in": "query" }, @@ -9157,7 +9157,8 @@ "example": "PE1C5CBDA0504A6A3" }, "queries": { - "$ref": "#/definitions/Json" + "description": "The JSON model of queries.", + "example": "[ { \"datasourceUid\": \"PE1C5CBDA0504A6A3\", \"queries\": [ { \"refId\": \"A\", \"key\": \"Q-87fed8e3-62ba-4eb2-8d2a-4129979bb4de-0\", \"scenarioId\": \"csv_content\", \"datasource\": { \"type\": \"testdata\", \"uid\": \"PD8C576611E62080A\" } } ], \"starred\": false, \"createdAt\": 1643630762, \"comment\": \"debugging\" } ]" } } }, @@ -11174,9 +11175,7 @@ "datasourceUid": { "type": "string" }, - "queries": { - "$ref": "#/definitions/Json" - }, + "queries": {}, "starred": { "type": "boolean" }, @@ -11360,9 +11359,7 @@ "datasourceUid": { "type": "string" }, - "queries": { - "$ref": "#/definitions/Json" - }, + "queries": {}, "starred": { "type": "boolean" }