Skip to content

Commit

Permalink
Merge pull request #261 from actiontech/feat-db-services-import
Browse files Browse the repository at this point in the history
数据源批量导入接口定义
  • Loading branch information
ColdWaterLW authored Jun 5, 2024
2 parents 0f21f13 + f92cf62 commit 617bbd3
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 0 deletions.
24 changes: 24 additions & 0 deletions api/dms/service/v1/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,27 @@ type ProjectTips struct {
IsFixedBusiness bool `json:"is_fixed_business"`
Business []string `json:"business"`
}

// swagger:response GetImportDBServicesTemplateReply
type GetImportDBServicesTemplateReply struct {
// swagger:file
// in: body
File []byte
}

// swagger:parameters ImportDBServicesOfOneProject ImportDBServicesOfProjects
type ImportDBServicesReq struct {
// DBServices file.
//
// in: formData
//
// swagger:file
DBServicesFile *bytes.Buffer `json:"db_services_file"`
}

// swagger:response ImportDBServicesReply only when produces text/csv
type ImportDBServicesReply struct {
// swagger:file
// in: body
File []byte
}
104 changes: 104 additions & 0 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,62 @@
}
}
},
"/v1/dms/projects/import_db_services": {
"post": {
"description": "Import DBServices",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json",
"text/csv"
],
"tags": [
"dms"
],
"operationId": "ImportDBServicesOfProjects",
"parameters": [
{
"type": "file",
"x-go-name": "DBServicesFile",
"description": "DBServices file.",
"name": "db_services_file",
"in": "formData"
}
],
"responses": {
"200": {
"$ref": "#/responses/ImportDBServicesReply"
},
"default": {
"description": "GenericResp",
"schema": {
"$ref": "#/definitions/GenericResp"
}
}
}
}
},
"/v1/dms/projects/import_db_services_template": {
"get": {
"tags": [
"dms"
],
"summary": "Get import DBServices template.",
"operationId": "GetImportDBServicesTemplate",
"responses": {
"200": {
"$ref": "#/responses/GetImportDBServicesTemplateReply"
},
"default": {
"description": "GenericResp",
"schema": {
"$ref": "#/definitions/GenericResp"
}
}
}
}
},
"/v1/dms/projects/import_template": {
"get": {
"tags": [
Expand Down Expand Up @@ -2619,6 +2675,42 @@
}
}
},
"/v1/dms/projects/{project_uid}/db_services/import": {
"post": {
"description": "Import DBServices",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json",
"text/csv"
],
"tags": [
"dms"
],
"operationId": "ImportDBServicesOfOneProject",
"parameters": [
{
"type": "file",
"x-go-name": "DBServicesFile",
"description": "DBServices file.",
"name": "db_services_file",
"in": "formData"
}
],
"responses": {
"200": {
"$ref": "#/responses/ImportDBServicesReply"
},
"default": {
"description": "GenericResp",
"schema": {
"$ref": "#/definitions/GenericResp"
}
}
}
}
},
"/v1/dms/projects/{project_uid}/db_services/tips": {
"get": {
"tags": [
Expand Down Expand Up @@ -9116,6 +9208,12 @@
}
}
},
"GetImportDBServicesTemplateReply": {
"description": "",
"schema": {
"type": "file"
}
},
"GetImportProjectsTemplateReply": {
"description": "",
"schema": {
Expand All @@ -9133,6 +9231,12 @@
"schema": {
"type": "file"
}
},
"ImportDBServicesReply": {
"description": "",
"schema": {
"type": "file"
}
}
},
"securityDefinitions": {
Expand Down
73 changes: 73 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5668,6 +5668,32 @@ paths:
summary: List db service tip.
tags:
- dms
/v1/dms/projects/{project_uid}/db_services/import:
post:
consumes:
- multipart/form-data
produces:
- application/json
- text/csv
description: Import DBServices
operationId: ImportDBServicesOfOneProject
parameters:
- description: DBServices file.
in: formData
name: db_services_file
type: file
x-go-name: DBServicesFile
responses:
default:
description: GenericResp
schema:
$ref: '#/definitions/GenericResp'
"200":
description: ImportDBServicesReply only when produces text/csv
schema:
$ref: '#/responses/ImportDBServicesReply'
tags:
- dms
/v1/dms/projects/{project_uid}/member_groups:
get:
operationId: ListMemberGroups
Expand Down Expand Up @@ -6163,6 +6189,45 @@ paths:
summary: Get project tips.
tags:
- dms
/v1/dms/projects/import_db_services_template:
get:
operationId: GetImportDBServicesTemplate
responses:
"200":
$ref: '#/responses/GetImportDBServicesTemplateReply'
default:
description: GenericResp
schema:
$ref: '#/definitions/GenericResp'
summary: Get import projects template.
tags:
- dms
/v1/dms/projects/import_db_services:
post:
consumes:
- multipart/form-data
produces:
- application/json
- text/csv
description: Import DBServices
operationId: ImportDBServicesOfProjects
parameters:
- description: DBServices file.
in: formData
name: db_services_file
type: file
x-go-name: DBServicesFile
responses:
default:
description: GenericResp
schema:
$ref: '#/definitions/GenericResp'
"200":
description: ImportDBServicesReply only when produces text/csv
schema:
$ref: '#/responses/ImportDBServicesReply'
tags:
- dms
/v1/dms/proxy:
post:
operationId: RegisterDMSProxyTarget
Expand Down Expand Up @@ -6734,6 +6799,14 @@ responses:
message:
description: message
type: string
GetImportDBServicesTemplateReply:
description: ""
schema:
type: file
ImportDBServicesReply:
description: ""
schema:
type: file
GetImportProjectsTemplateReply:
description: ""
schema:
Expand Down
47 changes: 47 additions & 0 deletions internal/apiserver/service/dms_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,53 @@ func (a *DMSController) GetProjectTips(c echo.Context) error {
return NewOkRespWithReply(c, reply)
}

// swagger:route GET /v1/dms/projects/import_db_services_template dms GetImportDBServicesTemplate
//
// Get import DBServices template.
//
// responses:
// 200: GetImportDBServicesTemplateReply
// default: body:GenericResp
func (a *DMSController) GetImportDBServicesTemplate(c echo.Context) error {
return nil
}

// swagger:route POST /v1/dms/projects/import_db_services dms ImportDBServicesOfProjects
//
// Import DBServices
//
// Consumes:
// - multipart/form-data
//
// Produces:
// - application/json
// - text/csv
//
// responses:
// default: body:GenericResp
// 200: ImportDBServicesReply
func (a *DMSController) ImportDBServicesOfProjects(c echo.Context) error {
return nil
}

// swagger:route POST /v1/dms/projects/{project_uid}/db_services/import dms ImportDBServicesOfOneProject
//
// Import DBServices
//
// Consumes:
// - multipart/form-data
//
// Produces:
// - application/json
// - text/csv
//
// responses:
// default: body:GenericResp
// 200: ImportDBServicesReply
func (a *DMSController) ImportDBServicesOfOneProject(c echo.Context) error {
return nil
}

// swagger:route POST /v1/dms/proxy dms RegisterDMSProxyTarget
//
// Register dms proxy target.
Expand Down
3 changes: 3 additions & 0 deletions internal/apiserver/service/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (s *APIServer) initRouter() error {
dbServiceV1.PUT("/:db_service_uid", s.DMSController.UpdateDBService)
dbServiceV1.POST("/connection", s.DMSController.CheckDBServiceIsConnectable)
dbServiceV1.POST("/:db_service_uid/connection", s.DMSController.CheckDBServiceIsConnectableById)
dbServiceV1.POST("/import", s.DMSController.ImportDBServicesOfOneProject)

DatabaseSourceServiceV1 := v1.Group("/dms/projects/:project_uid/database_source_services")
DatabaseSourceServiceV1.GET("/tips", s.DMSController.ListDatabaseSourceServiceTips)
Expand Down Expand Up @@ -109,6 +110,8 @@ func (s *APIServer) initRouter() error {
projectV1.POST("/preview_import", s.DMSController.PreviewImportProjects)
projectV1.GET("/export", s.DMSController.ExportProjects)
projectV1.GET("/tips", s.DMSController.GetProjectTips)
projectV1.GET("/import_db_services_template", s.DMSController.GetImportDBServicesTemplate)
projectV1.POST("/import_db_services", s.DMSController.ImportDBServicesOfProjects)

// oauth2 interface does not require login authentication
oauth2V1 := v1.Group("/dms/oauth2")
Expand Down

0 comments on commit 617bbd3

Please sign in to comment.