Skip to content

Commit

Permalink
Merge pull request #2796 from actiontech/2028-2
Browse files Browse the repository at this point in the history
api definition: tips, backup max rows, etc.
  • Loading branch information
iwanghc authored Dec 4, 2024
2 parents 6ce6c9e + 631cba8 commit 1397c54
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 24 deletions.
2 changes: 2 additions & 0 deletions sqle/api/controller/v1/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ type BackupSqlData struct {
OriginTaskId uint `json:"origin_task_id"`
BackupSqls []string `json:"backup_sqls"`
BackupStrategy string `json:"backup_strategy" enums:"none,manual,reverse_sql,original_row"`
BackupStatus string `json:"backup_status" enums:"waiting_for_execution,executing,failed,succeed"`
BackupResult string `json:"backup_result"`
InstanceName string `json:"instance_name"`
InstanceId string `json:"instance_id"`
ExecStatus string `json:"exec_status"`
Expand Down
15 changes: 8 additions & 7 deletions sqle/api/controller/v1/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,14 @@ type InstanceTipReqV1 struct {
}

type InstanceTipResV1 struct {
ID string `json:"instance_id"`
Name string `json:"instance_name"`
Type string `json:"instance_type"`
WorkflowTemplateId uint32 `json:"workflow_template_id"`
Host string `json:"host"`
Port string `json:"port"`
EnableBackup bool `json:"enable_backup"`
ID string `json:"instance_id"`
Name string `json:"instance_name"`
Type string `json:"instance_type"`
WorkflowTemplateId uint32 `json:"workflow_template_id"`
Host string `json:"host"`
Port string `json:"port"`
EnableBackup bool `json:"enable_backup"`
SupportedBackupStrategy []string `json:"supported_backup_strategy" enums:"none,manual,reverse_sql,original_row"`
}

type GetInstanceTipsResV1 struct {
Expand Down
4 changes: 2 additions & 2 deletions sqle/api/controller/v1/system_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ type ModuleStatusRes struct {
}

// @Summary 查询系统功能支持情况信息
// @Description get module status for modulealities in the system
// @Description get module status for module in the system
// @Id getSystemModuleStatus
// @Tags system
// @Security ApiKeyAuth
// @Param db_type query string false "db type" Enums(MySQL,Oracle,TiDB,OceanBase For MySQL,PostgreSQL,DB2,SQL Server)
// @Param module_name query string false "module name" Enums(execute_sql_file_mode,sql_optimization)
// @Param module_name query string false "module name" Enums(execute_sql_file_mode,sql_optimization,backup)
// @Success 200 {object} v1.GetModuleStatusResV1
// @router /v1/system/module_status [get]
func GetSystemModuleStatus(c echo.Context) error {
Expand Down
21 changes: 12 additions & 9 deletions sqle/api/controller/v1/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ import (
var ErrTooManyDataSource = errors.New(errors.DataConflict, fmt.Errorf("the number of data sources must be less than %v", MaximumDataSourceNum))

type CreateAuditTaskReqV1 struct {
InstanceName string `json:"instance_name" form:"instance_name" example:"inst_1" valid:"required"`
InstanceSchema string `json:"instance_schema" form:"instance_schema" example:"db1"`
Sql string `json:"sql" form:"sql" example:"alter table tb1 drop columns c1"`
ExecMode string `json:"exec_mode" form:"exec_mode" enums:"sql_file,sqls"`
EnableBackup bool `json:"enable_backup" form:"enable_backup"`
FileOrderMethod string `json:"file_order_method" form:"file_order_method"`
InstanceName string `json:"instance_name" form:"instance_name" example:"inst_1" valid:"required"`
InstanceSchema string `json:"instance_schema" form:"instance_schema" example:"db1"`
Sql string `json:"sql" form:"sql" example:"alter table tb1 drop columns c1"`
ExecMode string `json:"exec_mode" form:"exec_mode" enums:"sql_file,sqls"`
EnableBackup bool `json:"enable_backup" form:"enable_backup"`
BackupMaxRows *uint64 `json:"backup_max_rows,omitempty"`
FileOrderMethod string `json:"file_order_method" form:"file_order_method"`
}

type GetAuditTaskResV1 struct {
Expand All @@ -64,6 +65,7 @@ type AuditTaskResV1 struct {
FileOrderMethod string `json:"file_order_method,omitempty"`
ExecMode string `json:"exec_mode,omitempty"`
EnableBackup bool `json:"enable_backup"`
BackupMaxRows uint64 `json:"backup_max_rows,omitempty"`
BackupConflictWithInstance bool `json:"backup_conflict_with_instance"` // 当数据源备份开启,工单备份关闭,则需要提示审核人工单备份策略与数据源备份策略不一致
AuditFiles []AuditFileResp `json:"audit_files,omitempty"`
}
Expand Down Expand Up @@ -953,9 +955,10 @@ func CreateAuditTasksGroupV1(c echo.Context) error {
}

type AuditTaskGroupReqV1 struct {
TaskGroupId uint `json:"task_group_id" form:"task_group_id" valid:"required"`
Sql string `json:"sql" form:"sql" example:"alter table tb1 drop columns c1"`
EnableBackup bool `json:"enable_backup" form:"enable_backup"`
TaskGroupId uint `json:"task_group_id" form:"task_group_id" valid:"required"`
Sql string `json:"sql" form:"sql" example:"alter table tb1 drop columns c1"`
EnableBackup bool `json:"enable_backup" form:"enable_backup"`
BackupMaxRows *uint64 `json:"backup_max_rows,omitempty"`
}

type AuditTaskGroupRes struct {
Expand Down
2 changes: 2 additions & 0 deletions sqle/api/controller/v2/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type AuditTaskSQLResV2 struct {
SQLType string `json:"sql_type"`
BackupStrategy string `json:"backup_strategy" enums:"none,manual,reverse_sql,original_row"`
BackupStrategyTip string `json:"backup_strategy_tip"`
BackupStatus string `json:"backup_status" enums:"waiting_for_execution,executing,failed,succeed"`
BackupResult string `json:"backup_result"`
AssociatedRollbackWorkflows []*AssociatedRollbackWorkflow `json:"associated_rollback_workflows"`
}

Expand Down
47 changes: 45 additions & 2 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8977,7 +8977,7 @@ var doc = `{
"ApiKeyAuth": []
}
],
"description": "get module status for modulealities in the system",
"description": "get module status for module in the system",
"tags": [
"system"
],
Expand All @@ -9002,7 +9002,8 @@ var doc = `{
{
"enum": [
"execute_sql_file_mode",
"sql_optimization"
"sql_optimization",
"backup"
],
"type": "string",
"description": "module name",
Expand Down Expand Up @@ -11642,6 +11643,9 @@ var doc = `{
"description": "当数据源备份开启,工单备份关闭,则需要提示审核人工单备份策略与数据源备份策略不一致",
"type": "boolean"
},
"backup_max_rows": {
"type": "integer"
},
"enable_backup": {
"type": "boolean"
},
Expand Down Expand Up @@ -11789,12 +11793,24 @@ var doc = `{
"v1.BackupSqlData": {
"type": "object",
"properties": {
"backup_result": {
"type": "string"
},
"backup_sqls": {
"type": "array",
"items": {
"type": "string"
}
},
"backup_status": {
"type": "string",
"enum": [
"waiting_for_execution",
"executing",
"failed",
"succeed"
]
},
"backup_strategy": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -12122,6 +12138,9 @@ var doc = `{
"v1.CreateAuditTaskReqV1": {
"type": "object",
"properties": {
"backup_max_rows": {
"type": "integer"
},
"enable_backup": {
"type": "boolean"
},
Expand Down Expand Up @@ -15476,6 +15495,18 @@ var doc = `{
"port": {
"type": "string"
},
"supported_backup_strategy": {
"type": "array",
"items": {
"type": "string",
"enum": [
"none",
"manual",
"reverse_sql",
"original_row"
]
}
},
"workflow_template_id": {
"type": "integer"
}
Expand Down Expand Up @@ -18820,6 +18851,18 @@ var doc = `{
"audit_status": {
"type": "string"
},
"backup_result": {
"type": "string"
},
"backup_status": {
"type": "string",
"enum": [
"waiting_for_execution",
"executing",
"failed",
"succeed"
]
},
"backup_strategy": {
"type": "string",
"enum": [
Expand Down
47 changes: 45 additions & 2 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8961,7 +8961,7 @@
"ApiKeyAuth": []
}
],
"description": "get module status for modulealities in the system",
"description": "get module status for module in the system",
"tags": [
"system"
],
Expand All @@ -8986,7 +8986,8 @@
{
"enum": [
"execute_sql_file_mode",
"sql_optimization"
"sql_optimization",
"backup"
],
"type": "string",
"description": "module name",
Expand Down Expand Up @@ -11626,6 +11627,9 @@
"description": "当数据源备份开启,工单备份关闭,则需要提示审核人工单备份策略与数据源备份策略不一致",
"type": "boolean"
},
"backup_max_rows": {
"type": "integer"
},
"enable_backup": {
"type": "boolean"
},
Expand Down Expand Up @@ -11773,12 +11777,24 @@
"v1.BackupSqlData": {
"type": "object",
"properties": {
"backup_result": {
"type": "string"
},
"backup_sqls": {
"type": "array",
"items": {
"type": "string"
}
},
"backup_status": {
"type": "string",
"enum": [
"waiting_for_execution",
"executing",
"failed",
"succeed"
]
},
"backup_strategy": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -12106,6 +12122,9 @@
"v1.CreateAuditTaskReqV1": {
"type": "object",
"properties": {
"backup_max_rows": {
"type": "integer"
},
"enable_backup": {
"type": "boolean"
},
Expand Down Expand Up @@ -15460,6 +15479,18 @@
"port": {
"type": "string"
},
"supported_backup_strategy": {
"type": "array",
"items": {
"type": "string",
"enum": [
"none",
"manual",
"reverse_sql",
"original_row"
]
}
},
"workflow_template_id": {
"type": "integer"
}
Expand Down Expand Up @@ -18804,6 +18835,18 @@
"audit_status": {
"type": "string"
},
"backup_result": {
"type": "string"
},
"backup_status": {
"type": "string",
"enum": [
"waiting_for_execution",
"executing",
"failed",
"succeed"
]
},
"backup_strategy": {
"type": "string",
"enum": [
Expand Down
34 changes: 33 additions & 1 deletion sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ definitions:
backup_conflict_with_instance:
description: 当数据源备份开启,工单备份关闭,则需要提示审核人工单备份策略与数据源备份策略不一致
type: boolean
backup_max_rows:
type: integer
enable_backup:
type: boolean
exec_end_time:
Expand Down Expand Up @@ -491,10 +493,19 @@ definitions:
type: object
v1.BackupSqlData:
properties:
backup_result:
type: string
backup_sqls:
items:
type: string
type: array
backup_status:
enum:
- waiting_for_execution
- executing
- failed
- succeed
type: string
backup_strategy:
enum:
- none
Expand Down Expand Up @@ -716,6 +727,8 @@ definitions:
type: object
v1.CreateAuditTaskReqV1:
properties:
backup_max_rows:
type: integer
enable_backup:
type: boolean
exec_mode:
Expand Down Expand Up @@ -3027,6 +3040,15 @@ definitions:
type: string
port:
type: string
supported_backup_strategy:
items:
enum:
- none
- manual
- reverse_sql
- original_row
type: string
type: array
workflow_template_id:
type: integer
type: object
Expand Down Expand Up @@ -5295,6 +5317,15 @@ definitions:
type: array
audit_status:
type: string
backup_result:
type: string
backup_status:
enum:
- waiting_for_execution
- executing
- failed
- succeed
type: string
backup_strategy:
enum:
- none
Expand Down Expand Up @@ -11793,7 +11824,7 @@ paths:
- system
/v1/system/module_status:
get:
description: get module status for modulealities in the system
description: get module status for module in the system
operationId: getSystemModuleStatus
parameters:
- description: db type
Expand All @@ -11812,6 +11843,7 @@ paths:
enum:
- execute_sql_file_mode
- sql_optimization
- backup
in: query
name: module_name
type: string
Expand Down
Loading

0 comments on commit 1397c54

Please sign in to comment.