Skip to content

Commit

Permalink
Merge pull request #265 from actiontech/feat-import-db-service-api
Browse files Browse the repository at this point in the history
update api for importing db services and testing db services connection
  • Loading branch information
sjjian authored Jun 12, 2024
2 parents 0275735 + e7d4fbf commit 869f368
Show file tree
Hide file tree
Showing 6 changed files with 666 additions and 116 deletions.
23 changes: 21 additions & 2 deletions api/dms/service/v1/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ type ListDBServiceTipsReply struct {
base.GenericResp
}

// swagger:parameters ImportDBServicesOfOneProject
type ImportDBServiceReq struct {
// swagger:parameters ImportDBServicesOfOneProjectCheck
type ImportDBServicesOfOneProjectCheckReq struct {
// project id
// Required: true
// in:path
Expand All @@ -283,3 +283,22 @@ type ImportDBServiceReq struct {
// swagger:file
DBServicesFile *bytes.Buffer `json:"db_services_file"`
}

// swagger:model ImportDBServicesCheckReply
type ImportDBServicesCheckReply struct {
// db services
Data []*DBService `json:"data"`
// Generic reply
base.GenericResp
}

// swagger:parameters ImportDBServicesOfOneProject
type ImportDBServicesOfOneProjectReq struct {
// project id
// Required: true
// in:path
ProjectUid string `param:"project_uid" json:"project_uid" validate:"required"`
// new db services
// in:body
DBServices []DBService `json:"db_services" validate:"required"`
}
69 changes: 65 additions & 4 deletions api/dms/service/v1/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ type GetImportDBServicesTemplateReply struct {
File []byte
}

// swagger:parameters ImportDBServicesOfProjects
type ImportDBServicesReq struct {
// swagger:parameters ImportDBServicesOfProjectsCheck
type ImportDBServicesOfProjectsCheckReq struct {
// DBServices file.
//
// in: formData
Expand All @@ -221,9 +221,70 @@ type ImportDBServicesReq struct {
DBServicesFile *bytes.Buffer `json:"db_services_file"`
}

// swagger:response ImportDBServicesReply only when produces text/csv
type ImportDBServicesReply struct {
// swagger:response ImportDBServicesCheckCsvReply
type ImportDBServicesCheckCsvReply struct {
// swagger:file
// in: body
File []byte
}

// swagger:parameters ImportDBServicesOfProjects
type ImportDBServicesOfProjectsReq struct {
// new db services
// in:body
DBServices []DBService `json:"db_services" validate:"required"`
}

type CheckDbsConnectable struct {
// DB Service name
// Required: true
// example: mysql_1
Name string `json:"name" example:"mysql_1" validate:"required"`
// DB Service type
// Required: true
// example: MySQL
DBType string `json:"db_type" example:"mysql" validate:"required"`
// DB Service admin user
// Required: true
// example: root
User string `json:"user" example:"root" valid:"required"`
// DB Service host
// Required: true
// example: 127.0.0.1
Host string `json:"host" example:"10.10.10.10" valid:"required,ip_addr|uri|hostname|hostname_rfc1123"`
// DB Service port
// Required: true
// example: 3306
Port string `json:"port" example:"3306" valid:"required,port"`
// DB Service admin password
// Required: true
// example: 123456
Password string `json:"password" example:"123456"`
// DB Service Custom connection parameters
// Required: false
AdditionalParams []*dmsCommonV1.AdditionalParam `json:"additional_params" from:"additional_params"`
}

// swagger:parameters DBServicesConnection
type DBServiceConnectionReq struct {
// check db_service is connectable
// in:body
DBServices []CheckDbsConnectable `json:"db_services"`
}

type DBServicesConnectionItem struct {
// Successful connection num
SuccessfulNum int `json:"successful_num"`
// Failed connection num
FailedNum int `json:"failed_num"`
// Failed DBServices name
FailedNames []string `json:"failed_names"`
}

// swagger:response DBServicesConnectionReply
type DBServicesConnectionReply struct {
// Generic reply
base.GenericResp
// connection result
Data []*DBServicesConnectionItem `json:"data"`
}
Loading

0 comments on commit 869f368

Please sign in to comment.