Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:rule template api define #2588

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions sqle/api/controller/v1/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,10 @@ func GetProjectRuleTemplateTips(c echo.Context) error {
return getRuleTemplateTips(c, projectUid, req.FilterDBType)
}

type ParseProjectRuleTemplateFileReqV1 struct {
FileType string `json:"file_type" form:"file_type" enums:"csv,json" valid:"required,oneof=csv json"`
}

type ParseProjectRuleTemplateFileResV1 struct {
controller.BaseRes
Data ParseProjectRuleTemplateFileResDataV1 `json:"data"`
Expand All @@ -1212,8 +1216,10 @@ type ParseProjectRuleTemplateFileResDataV1 struct {
// @Tags rule_template
// @Accept mpfd
// @Security ApiKeyAuth
// @Param file_type formData string true "file type" Enums(csv,json)
// @Param rule_template_file formData file true "SQLE rule template file"
// @Success 200 {object} v1.ParseProjectRuleTemplateFileResV1
// @Success 400 file 1 "return error file"
// @router /v1/rule_templates/parse [post]
func ParseProjectRuleTemplateFile(c echo.Context) error {
// 读取+解析文件
Expand All @@ -1237,11 +1243,35 @@ func ParseProjectRuleTemplateFile(c echo.Context) error {
})
}

type GetRuleTemplateFileReqV1 struct {
InstanceType string `json:"instance_type" query:"instance_type" valid:"required"`
FileType string `json:"file_type" query:"file_type" enums:"csv,json" valid:"required,oneof=csv json"`
}

// GetRuleTemplateFile
// @Summary 获取规则模板文件
// @Description get rule template file
// @Id getRuleTemplateFileV1
// @Tags rule_template
// @Security ApiKeyAuth
// @Param instance_type query string true "instance type"
// @Param file_type query string true "file type" Enums(csv,json)
// @Success 200 file 1 "sqle rule template file"
// @router /v1/import_rule_template [get]
func GetRuleTemplateFile(c echo.Context) error {
return nil
}

type ExportRuleTemplateFileReqV1 struct {
ExportType string `json:"export_type" query:"export_type" enums:"csv,json" valid:"required,oneof=csv json"`
}

// ExportRuleTemplateFile
// @Summary 导出全局规则模板
// @Description export rule template
// @Id exportRuleTemplateV1
// @Tags rule_template
// @Param export_type query string true "export type" Enums(csv,json)
// @Param rule_template_name path string true "rule template name"
// @Security ApiKeyAuth
// @Success 200 file 1 "sqle rule template file"
Expand All @@ -1251,13 +1281,18 @@ func ExportRuleTemplateFile(c echo.Context) error {
return exportRuleTemplateFile(c, model.ProjectIdForGlobalRuleTemplate, templateName)
}

type ExportProjectRuleTemplateFileReqV1 struct {
ExportType string `json:"export_type" query:"export_type" enums:"csv,json" valid:"required,oneof=csv json"`
}

// ExportProjectRuleTemplateFile
// @Summary 导出项目规则模板
// @Description export rule template in a project
// @Id exportProjectRuleTemplateV1
// @Tags rule_template
// @Param project_name path string true "project name"
// @Param rule_template_name path string true "rule template name"
// @Param export_type query string true "export type" Enums(csv,json)
// @Security ApiKeyAuth
// @Success 200 file 1 "sqle rule template file"
// @router /v1/projects/{project_name}/rule_templates/{rule_template_name}/export [get]
Expand Down
82 changes: 82 additions & 0 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,49 @@ var doc = `{
}
}
},
"/v1/import_rule_template": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get rule template file",
"tags": [
"rule_template"
],
"summary": "获取规则模板文件",
"operationId": "getRuleTemplateFileV1",
"parameters": [
{
"type": "string",
"description": "instance type",
"name": "instance_type",
"in": "query",
"required": true
},
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "file type",
"name": "file_type",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "sqle rule template file",
"schema": {
"type": "file"
}
}
}
}
},
"/v1/operation_records": {
"get": {
"security": [
Expand Down Expand Up @@ -3991,6 +4034,17 @@ var doc = `{
"name": "rule_template_name",
"in": "path",
"required": true
},
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "export type",
"name": "export_type",
"in": "query",
"required": true
}
],
"responses": {
Expand Down Expand Up @@ -7021,6 +7075,17 @@ var doc = `{
"summary": "解析规则模板文件",
"operationId": "importProjectRuleTemplateV1",
"parameters": [
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "file type",
"name": "file_type",
"in": "formData",
"required": true
},
{
"type": "file",
"description": "SQLE rule template file",
Expand All @@ -7035,6 +7100,12 @@ var doc = `{
"schema": {
"$ref": "#/definitions/v1.ParseProjectRuleTemplateFileResV1"
}
},
"400": {
"description": "return error file",
"schema": {
"type": "file"
}
}
}
}
Expand Down Expand Up @@ -7204,6 +7275,17 @@ var doc = `{
"summary": "导出全局规则模板",
"operationId": "exportRuleTemplateV1",
"parameters": [
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "export type",
"name": "export_type",
"in": "query",
"required": true
},
{
"type": "string",
"description": "rule template name",
Expand Down
82 changes: 82 additions & 0 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,49 @@
}
}
},
"/v1/import_rule_template": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get rule template file",
"tags": [
"rule_template"
],
"summary": "获取规则模板文件",
"operationId": "getRuleTemplateFileV1",
"parameters": [
{
"type": "string",
"description": "instance type",
"name": "instance_type",
"in": "query",
"required": true
},
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "file type",
"name": "file_type",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "sqle rule template file",
"schema": {
"type": "file"
}
}
}
}
},
"/v1/operation_records": {
"get": {
"security": [
Expand Down Expand Up @@ -3975,6 +4018,17 @@
"name": "rule_template_name",
"in": "path",
"required": true
},
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "export type",
"name": "export_type",
"in": "query",
"required": true
}
],
"responses": {
Expand Down Expand Up @@ -7005,6 +7059,17 @@
"summary": "解析规则模板文件",
"operationId": "importProjectRuleTemplateV1",
"parameters": [
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "file type",
"name": "file_type",
"in": "formData",
"required": true
},
{
"type": "file",
"description": "SQLE rule template file",
Expand All @@ -7019,6 +7084,12 @@
"schema": {
"$ref": "#/definitions/v1.ParseProjectRuleTemplateFileResV1"
}
},
"400": {
"description": "return error file",
"schema": {
"type": "file"
}
}
}
}
Expand Down Expand Up @@ -7188,6 +7259,17 @@
"summary": "导出全局规则模板",
"operationId": "exportRuleTemplateV1",
"parameters": [
{
"enum": [
"csv",
"json"
],
"type": "string",
"description": "export type",
"name": "export_type",
"in": "query",
"required": true
},
{
"type": "string",
"description": "rule template name",
Expand Down
Loading
Loading