diff --git a/sqle/api/controller/v1/rule.go b/sqle/api/controller/v1/rule.go index b08ca1535..7e5c5d5e6 100644 --- a/sqle/api/controller/v1/rule.go +++ b/sqle/api/controller/v1/rule.go @@ -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"` @@ -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 { // 读取+解析文件 @@ -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" @@ -1251,6 +1281,10 @@ 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 @@ -1258,6 +1292,7 @@ func ExportRuleTemplateFile(c echo.Context) error { // @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] diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index e3707eb89..73cf8c0a0 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -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": [ @@ -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": { @@ -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", @@ -7035,6 +7100,12 @@ var doc = `{ "schema": { "$ref": "#/definitions/v1.ParseProjectRuleTemplateFileResV1" } + }, + "400": { + "description": "return error file", + "schema": { + "type": "file" + } } } } @@ -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", diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 5efe6701c..ef7056e6a 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -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": [ @@ -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": { @@ -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", @@ -7019,6 +7084,12 @@ "schema": { "$ref": "#/definitions/v1.ParseProjectRuleTemplateFileResV1" } + }, + "400": { + "description": "return error file", + "schema": { + "type": "file" + } } } } @@ -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", diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 03c32eaaa..8753288da 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -5673,6 +5673,34 @@ paths: summary: 获取 dashboard 信息 tags: - dashboard + /v1/import_rule_template: + get: + description: get rule template file + operationId: getRuleTemplateFileV1 + parameters: + - description: instance type + in: query + name: instance_type + required: true + type: string + - description: file type + enum: + - csv + - json + in: query + name: file_type + required: true + type: string + responses: + "200": + description: sqle rule template file + schema: + type: file + security: + - ApiKeyAuth: [] + summary: 获取规则模板文件 + tags: + - rule_template /v1/operation_records: get: description: Get operation record list @@ -7674,6 +7702,14 @@ paths: name: rule_template_name required: true type: string + - description: export type + enum: + - csv + - json + in: query + name: export_type + required: true + type: string responses: "200": description: sqle rule template file @@ -9767,6 +9803,14 @@ paths: description: export rule template operationId: exportRuleTemplateV1 parameters: + - description: export type + enum: + - csv + - json + in: query + name: export_type + required: true + type: string - description: rule template name in: path name: rule_template_name @@ -9789,6 +9833,14 @@ paths: description: parse rule template operationId: importProjectRuleTemplateV1 parameters: + - description: file type + enum: + - csv + - json + in: formData + name: file_type + required: true + type: string - description: SQLE rule template file in: formData name: rule_template_file @@ -9799,6 +9851,10 @@ paths: description: OK schema: $ref: '#/definitions/v1.ParseProjectRuleTemplateFileResV1' + "400": + description: return error file + schema: + type: file security: - ApiKeyAuth: [] summary: 解析规则模板文件