Skip to content

Commit

Permalink
Merge pull request #2166 from actiontech/issue-ee-1266-api
Browse files Browse the repository at this point in the history
sql analysis api define
  • Loading branch information
sjjian authored Dec 20, 2023
2 parents b725499 + dff48d4 commit 8dd9957
Show file tree
Hide file tree
Showing 5 changed files with 326 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config config.SqleConfi
v1Router.PATCH("/projects/:project_name/sql_manages/batch", v1.BatchUpdateSqlManage)
v1Router.GET("/projects/:project_name/sql_manages/exports", v1.ExportSqlManagesV1)
v1Router.GET("/projects/:project_name/sql_manages/rule_tips", v1.GetSqlManageRuleTips)
v1Router.GET("/projects/:project_name/sql_manages/:sql_manage_id/sql_analysis", v1.GetSqlManageSqlAnalysisV1)

// sql audit record
v1Router.POST("/projects/:project_name/sql_audit_records", v1.CreateSQLAuditRecord)
Expand Down
40 changes: 40 additions & 0 deletions sqle/api/controller/v1/sql_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,43 @@ type GetSqlManageRuleTipsResp struct {
func GetSqlManageRuleTips(c echo.Context) error {
return getSqlManageRuleTips(c)
}

type AffectRows struct {
Count int `json:"count"`
ErrMessage string `json:"err_message"`
}

type PerformanceStatistics struct {
AffectRows *AffectRows `json:"affect_rows"`
}

type TableMetas struct {
ErrMessage string `json:"err_message"`
Items []*TableMeta `json:"table_meta_items"`
}

type SqlAnalysis struct {
SQLExplain *SQLExplain `json:"sql_explain"`
TableMetas *TableMetas `json:"table_metas"`
PerformanceStatistics *PerformanceStatistics `json:"performance_statistics"`
}

type GetSqlManageSqlAnalysisResp struct {
controller.BaseRes
// V1版本不能引用V2版本的结构体,所以只能复制一份
Data *SqlAnalysis `json:"data"`
}

// GetSqlManageSqlAnalysisV1
// @Summary 获取SQL管控SQL分析
// @Description get sql manage analysis
// @Id GetSqlManageSqlAnalysisV1
// @Tags SqlManage
// @Param project_name path string true "project name"
// @Param sql_manage_id path string true "sql manage id"
// @Security ApiKeyAuth
// @Success 200 {object} GetSqlManageSqlAnalysisResp
// @Router /v1/projects/{project_name}/sql_manages/{sql_manage_id}/sql_analysis [get]
func GetSqlManageSqlAnalysisV1(c echo.Context) error {
return nil
}
107 changes: 107 additions & 0 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5093,6 +5093,45 @@ var doc = `{
}
}
},
"/v1/projects/{project_name}/sql_manages/{sql_manage_id}/sql_analysis": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get sql manage analysis",
"tags": [
"SqlManage"
],
"summary": "获取SQL管控SQL分析",
"operationId": "GetSqlManageSqlAnalysisV1",
"parameters": [
{
"type": "string",
"description": "project name",
"name": "project_name",
"in": "path",
"required": true
},
{
"type": "string",
"description": "sql manage id",
"name": "sql_manage_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetSqlManageSqlAnalysisResp"
}
}
}
}
},
"/v1/projects/{project_name}/statistic/audit_plans": {
"get": {
"security": [
Expand Down Expand Up @@ -10381,6 +10420,17 @@ var doc = `{
}
}
},
"v1.AffectRows": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"err_message": {
"type": "string"
}
}
},
"v1.AuditPlanCount": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -13305,6 +13355,23 @@ var doc = `{
}
}
},
"v1.GetSqlManageSqlAnalysisResp": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"example": 0
},
"data": {
"type": "object",
"$ref": "#/definitions/v1.SqlAnalysis"
},
"message": {
"type": "string",
"example": "ok"
}
}
},
"v1.GetSyncInstanceTaskListResV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -14562,6 +14629,15 @@ var doc = `{
}
}
},
"v1.PerformanceStatistics": {
"type": "object",
"properties": {
"affect_rows": {
"type": "object",
"$ref": "#/definitions/v1.AffectRows"
}
}
},
"v1.PersonaliseReqV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -15154,6 +15230,23 @@ var doc = `{
}
}
},
"v1.SqlAnalysis": {
"type": "object",
"properties": {
"performance_statistics": {
"type": "object",
"$ref": "#/definitions/v1.PerformanceStatistics"
},
"sql_explain": {
"type": "object",
"$ref": "#/definitions/v1.SQLExplain"
},
"table_metas": {
"type": "object",
"$ref": "#/definitions/v1.TableMetas"
}
}
},
"v1.SqlAnalysisResDataV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -15440,6 +15533,20 @@ var doc = `{
}
}
},
"v1.TableMetas": {
"type": "object",
"properties": {
"err_message": {
"type": "string"
},
"table_meta_items": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.TableMeta"
}
}
}
},
"v1.TestAuditPlanNotifyConfigResDataV1": {
"type": "object",
"properties": {
Expand Down
107 changes: 107 additions & 0 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5077,6 +5077,45 @@
}
}
},
"/v1/projects/{project_name}/sql_manages/{sql_manage_id}/sql_analysis": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get sql manage analysis",
"tags": [
"SqlManage"
],
"summary": "获取SQL管控SQL分析",
"operationId": "GetSqlManageSqlAnalysisV1",
"parameters": [
{
"type": "string",
"description": "project name",
"name": "project_name",
"in": "path",
"required": true
},
{
"type": "string",
"description": "sql manage id",
"name": "sql_manage_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetSqlManageSqlAnalysisResp"
}
}
}
}
},
"/v1/projects/{project_name}/statistic/audit_plans": {
"get": {
"security": [
Expand Down Expand Up @@ -10365,6 +10404,17 @@
}
}
},
"v1.AffectRows": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"err_message": {
"type": "string"
}
}
},
"v1.AuditPlanCount": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -13289,6 +13339,23 @@
}
}
},
"v1.GetSqlManageSqlAnalysisResp": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"example": 0
},
"data": {
"type": "object",
"$ref": "#/definitions/v1.SqlAnalysis"
},
"message": {
"type": "string",
"example": "ok"
}
}
},
"v1.GetSyncInstanceTaskListResV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -14546,6 +14613,15 @@
}
}
},
"v1.PerformanceStatistics": {
"type": "object",
"properties": {
"affect_rows": {
"type": "object",
"$ref": "#/definitions/v1.AffectRows"
}
}
},
"v1.PersonaliseReqV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -15138,6 +15214,23 @@
}
}
},
"v1.SqlAnalysis": {
"type": "object",
"properties": {
"performance_statistics": {
"type": "object",
"$ref": "#/definitions/v1.PerformanceStatistics"
},
"sql_explain": {
"type": "object",
"$ref": "#/definitions/v1.SQLExplain"
},
"table_metas": {
"type": "object",
"$ref": "#/definitions/v1.TableMetas"
}
}
},
"v1.SqlAnalysisResDataV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -15424,6 +15517,20 @@
}
}
},
"v1.TableMetas": {
"type": "object",
"properties": {
"err_message": {
"type": "string"
},
"table_meta_items": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.TableMeta"
}
}
}
},
"v1.TestAuditPlanNotifyConfigResDataV1": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit 8dd9957

Please sign in to comment.