-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1416 from jessun/issue-1411-api-def
feat: 新增 API 定义,升级了 audit_result 审核结果结构定义
- Loading branch information
Showing
7 changed files
with
1,110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package v2 | ||
|
||
import ( | ||
"github.com/labstack/echo/v4" | ||
|
||
"github.com/actiontech/sqle/sqle/api/controller" | ||
) | ||
|
||
type DirectAuditReqV2 struct { | ||
InstanceType string `json:"instance_type" form:"instance_type" example:"MySQL" valid:"required"` | ||
// 调用方不应该关心SQL是否被完美的拆分成独立的条目, 拆分SQL由SQLE实现 | ||
SQLContent string `json:"sql_content" form:"sql_content" example:"select * from t1; select * from t2;" valid:"required"` | ||
SQLType string `json:"sql_type" form:"sql_type" example:"sql" enums:"sql,mybatis," valid:"omitempty,oneof=sql mybatis"` | ||
} | ||
|
||
type AuditResDataV2 struct { | ||
AuditLevel string `json:"audit_level" enums:"normal,notice,warn,error,"` | ||
Score int32 `json:"score"` | ||
PassRate float64 `json:"pass_rate"` | ||
SQLResults []AuditSQLResV2 `json:"sql_results"` | ||
} | ||
|
||
type AuditSQLResV2 struct { | ||
Number uint `json:"number"` | ||
ExecSQL string `json:"exec_sql"` | ||
AuditResult []*AuditResult `json:"audit_result"` | ||
AuditLevel string `json:"audit_level"` | ||
} | ||
|
||
type DirectAuditResV2 struct { | ||
controller.BaseRes | ||
Data *AuditResDataV2 `json:"data"` | ||
} | ||
|
||
// @Summary 直接审核SQL | ||
// @Description Direct audit sql | ||
// @Id directAuditV2 | ||
// @Tags sql_audit | ||
// @Security ApiKeyAuth | ||
// @Param req body v2.DirectAuditReqV2 true "sqls that should be audited" | ||
// @Success 200 {object} v2.DirectAuditResV2 | ||
// @router /v2/sql_audit [post] | ||
func DirectAudit(c echo.Context) error { | ||
return controller.JSONNewNotImplementedErr(c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package v2 | ||
|
||
import ( | ||
"github.com/labstack/echo/v4" | ||
|
||
"github.com/actiontech/sqle/sqle/api/controller" | ||
) | ||
|
||
type GetAuditTaskSQLsReqV2 struct { | ||
FilterExecStatus string `json:"filter_exec_status" query:"filter_exec_status"` | ||
FilterAuditStatus string `json:"filter_audit_status" query:"filter_audit_status"` | ||
FilterAuditLevel string `json:"filter_audit_level" query:"filter_audit_level"` | ||
NoDuplicate bool `json:"no_duplicate" query:"no_duplicate"` | ||
PageIndex uint32 `json:"page_index" query:"page_index" valid:"required"` | ||
PageSize uint32 `json:"page_size" query:"page_size" valid:"required"` | ||
} | ||
|
||
type GetAuditTaskSQLsResV2 struct { | ||
controller.BaseRes | ||
Data []*AuditTaskSQLResV2 `json:"data"` | ||
TotalNums uint64 `json:"total_nums"` | ||
} | ||
|
||
type AuditTaskSQLResV2 struct { | ||
Number uint `json:"number"` | ||
ExecSQL string `json:"exec_sql"` | ||
AuditResult []*AuditResult `json:"audit_result"` | ||
AuditLevel string `json:"audit_level"` | ||
AuditStatus string `json:"audit_status"` | ||
ExecResult string `json:"exec_result"` | ||
ExecStatus string `json:"exec_status"` | ||
RollbackSQL string `json:"rollback_sql,omitempty"` | ||
Description string `json:"description"` | ||
} | ||
|
||
type AuditResult struct { | ||
Level string `json:"level"` | ||
Message string `json:"message"` | ||
RuleName string `json:"rule_name"` | ||
} | ||
|
||
// @Summary 获取指定扫描任务的SQLs信息 | ||
// @Description get information of all SQLs belong to the specified audit task | ||
// @Tags task | ||
// @Id getAuditTaskSQLsV2 | ||
// @Security ApiKeyAuth | ||
// @Param task_id path string true "task id" | ||
// @Param filter_exec_status query string false "filter: exec status of task sql" Enums(initialized,doing,succeeded,failed,manually_executed) | ||
// @Param filter_audit_status query string false "filter: audit status of task sql" Enums(initialized,doing,finished) | ||
// @Param filter_audit_level query string false "filter: audit level of task sql" Enums(normal,notice,warn,error) | ||
// @Param no_duplicate query boolean false "select unique (fingerprint and audit result) for task sql" | ||
// @Param page_index query string true "page index" | ||
// @Param page_size query string true "page size" | ||
// @Success 200 {object} v2.GetAuditTaskSQLsResV2 | ||
// @router /v2/tasks/audits/{task_id}/sqls [get] | ||
func GetTaskSQLs(c echo.Context) error { | ||
return controller.JSONNewNotImplementedErr(c) | ||
} |
Oops, something went wrong.