diff --git a/api/dms/service/v1/db_service.go b/api/dms/service/v1/db_service.go index 5e1afb3e..758326d3 100644 --- a/api/dms/service/v1/db_service.go +++ b/api/dms/service/v1/db_service.go @@ -284,12 +284,35 @@ type ImportDBServicesOfOneProjectCheckReq struct { DBServicesFile *bytes.Buffer `json:"db_services_file"` } -// swagger:model ImportDBServicesCheckReply -type ImportDBServicesCheckReply struct { - // db services - Data []*DBService `json:"data"` - // Generic reply - base.GenericResp +type ImportDBService struct { + // db service name + Name string `json:"name"` + // db service DB type + DBType string `json:"db_type"` + // db service host + Host string `json:"host"` + // db service port + Port string `json:"port"` + // db service admin user + User string `json:"user"` + // db service admin encrypted password + Password string `json:"password"` + // the db service business name + Business string `json:"business"` + // DB Service maintenance time + MaintenanceTimes []*dmsCommonV1.MaintenanceTime `json:"maintenance_times"` + // DB desc + Desc string `json:"desc"` + // DB source + Source string `json:"source"` + // DB project uid + ProjectUID string `json:"project_uid"` + // sqle config + SQLEConfig *dmsCommonV1.SQLEConfig `json:"sqle_config"` + // DB Service Custom connection parameters + AdditionalParams []*dmsCommonV1.AdditionalParam `json:"additional_params"` + // is enable masking + IsEnableMasking bool `json:"is_enable_masking"` } // swagger:parameters ImportDBServicesOfOneProject @@ -300,5 +323,13 @@ type ImportDBServicesOfOneProjectReq struct { ProjectUid string `param:"project_uid" json:"project_uid" validate:"required"` // new db services // in:body - DBServices []DBService `json:"db_services" validate:"required"` + DBServices []ImportDBService `json:"db_services" validate:"required"` +} + +// swagger:model ImportDBServicesCheckReply +type ImportDBServicesCheckReply struct { + // db services + Data []*ImportDBService `json:"data"` + // Generic reply + base.GenericResp } diff --git a/api/dms/service/v1/project.go b/api/dms/service/v1/project.go index 4ffdf171..130e87d0 100644 --- a/api/dms/service/v1/project.go +++ b/api/dms/service/v1/project.go @@ -120,6 +120,8 @@ type UnarchiveProjectReq struct { // swagger:parameters ImportProjects type ImportProjectsReq struct { + // import projects + // in:body Projects []*ImportProjects `json:"projects" validate:"required"` } @@ -232,7 +234,7 @@ type ImportDBServicesCheckCsvReply struct { type ImportDBServicesOfProjectsReq struct { // new db services // in:body - DBServices []DBService `json:"db_services" validate:"required"` + DBServices []ImportDBService `json:"db_services" validate:"required"` } type CheckDbsConnectable struct { @@ -281,10 +283,10 @@ type DBServicesConnectionItem struct { FailedNames []string `json:"failed_names"` } -// swagger:response DBServicesConnectionReply +// swagger:model DBServicesConnectionReply type DBServicesConnectionReply struct { // Generic reply base.GenericResp // connection result - Data []*DBServicesConnectionItem `json:"data"` + Data *DBServicesConnectionItem `json:"data"` } diff --git a/api/swagger.json b/api/swagger.json index f10a7c59..d678a8ad 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -1120,9 +1120,6 @@ "consumes": [ "application/json" ], - "produces": [ - "application/json" - ], "tags": [ "dms" ], @@ -1142,8 +1139,17 @@ } ], "responses": { + "200": { + "description": "DBServicesConnectionReply", + "schema": { + "$ref": "#/definitions/DBServicesConnectionReply" + } + }, "default": { - "$ref": "#/responses/DBServicesConnectionReply" + "description": "GenericResp", + "schema": { + "$ref": "#/definitions/GenericResp" + } } } } @@ -1204,13 +1210,16 @@ "operationId": "ImportProjects", "parameters": [ { - "type": "array", - "items": { - "$ref": "#/definitions/ImportProjects" - }, "x-go-name": "Projects", + "description": "import projects", "name": "projects", - "in": "query" + "in": "body", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ImportProjects" + } + } } ], "responses": { @@ -1251,12 +1260,18 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/DBService" + "$ref": "#/definitions/ImportDBService" } } } ], "responses": { + "200": { + "description": "GenericResp", + "schema": { + "$ref": "#/definitions/GenericResp" + } + }, "default": { "description": "GenericResp", "schema": { @@ -2752,9 +2767,6 @@ "consumes": [ "application/json" ], - "produces": [ - "application/json" - ], "tags": [ "dms" ], @@ -2776,12 +2788,18 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/DBService" + "$ref": "#/definitions/ImportDBService" } } } ], "responses": { + "200": { + "description": "GenericResp", + "schema": { + "$ref": "#/definitions/GenericResp" + } + }, "default": { "description": "GenericResp", "schema": { @@ -5300,6 +5318,26 @@ }, "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" }, + "DBServicesConnectionReply": { + "type": "object", + "properties": { + "code": { + "description": "code", + "type": "integer", + "format": "int64", + "x-go-name": "Code" + }, + "data": { + "$ref": "#/definitions/DBServicesConnectionItem" + }, + "message": { + "description": "message", + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, "DMSProxyTarget": { "description": "A dms proxy target", "type": "object", @@ -6217,15 +6255,14 @@ "$ref": "#/definitions/AccessTokenInfo" }, "authentication_type": { - "description": "user authentication type\nldap UserAuthenticationTypeLDAP\ndms UserAuthenticationTypeDMS\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", + "description": "user authentication type\nldap UserAuthenticationTypeLDAP\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", "type": "string", "enum": [ "ldap", - "dms", "oauth2", "unknown" ], - "x-go-enum-desc": "ldap UserAuthenticationTypeLDAP\ndms UserAuthenticationTypeDMS\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", + "x-go-enum-desc": "ldap UserAuthenticationTypeLDAP\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", "x-go-name": "AuthenticationType" }, "email": { @@ -6489,6 +6526,86 @@ }, "x-go-package": "github.com/actiontech/dms/pkg/dms-common/api/dms/v1" }, + "ImportDBService": { + "type": "object", + "properties": { + "additional_params": { + "description": "DB Service Custom connection parameters", + "type": "array", + "items": { + "$ref": "#/definitions/AdditionalParam" + }, + "x-go-name": "AdditionalParams" + }, + "business": { + "description": "the db service business name", + "type": "string", + "x-go-name": "Business" + }, + "db_type": { + "description": "db service DB type", + "type": "string", + "x-go-name": "DBType" + }, + "desc": { + "description": "DB desc", + "type": "string", + "x-go-name": "Desc" + }, + "host": { + "description": "db service host", + "type": "string", + "x-go-name": "Host" + }, + "is_enable_masking": { + "description": "is enable masking", + "type": "boolean", + "x-go-name": "IsEnableMasking" + }, + "maintenance_times": { + "description": "DB Service maintenance time", + "type": "array", + "items": { + "$ref": "#/definitions/MaintenanceTime" + }, + "x-go-name": "MaintenanceTimes" + }, + "name": { + "description": "db service name", + "type": "string", + "x-go-name": "Name" + }, + "password": { + "description": "db service admin encrypted password", + "type": "string", + "x-go-name": "Password" + }, + "port": { + "description": "db service port", + "type": "string", + "x-go-name": "Port" + }, + "project_uid": { + "description": "DB project uid", + "type": "string", + "x-go-name": "ProjectUID" + }, + "source": { + "description": "DB source", + "type": "string", + "x-go-name": "Source" + }, + "sqle_config": { + "$ref": "#/definitions/SQLEConfig" + }, + "user": { + "description": "db service admin user", + "type": "string", + "x-go-name": "User" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, "ImportDBServicesCheckReply": { "type": "object", "properties": { @@ -6502,7 +6619,7 @@ "description": "db services", "type": "array", "items": { - "$ref": "#/definitions/DBService" + "$ref": "#/definitions/ImportDBService" }, "x-go-name": "Data" }, @@ -7707,15 +7824,14 @@ "type": "object", "properties": { "authentication_type": { - "description": "user authentication type\nldap UserAuthenticationTypeLDAP\ndms UserAuthenticationTypeDMS\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", + "description": "user authentication type\nldap UserAuthenticationTypeLDAP\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", "type": "string", "enum": [ "ldap", - "dms", "oauth2", "unknown" ], - "x-go-enum-desc": "ldap UserAuthenticationTypeLDAP\ndms UserAuthenticationTypeDMS\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", + "x-go-enum-desc": "ldap UserAuthenticationTypeLDAP\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown", "x-go-name": "AuthenticationType" }, "email": { @@ -8719,7 +8835,7 @@ "x-go-name": "Uid" } }, - "x-go-package": "github.com/actiontech/dms/pkg/dms-common/api/dms/v1" + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" }, "UpdateCompanyNotice": { "description": "A companynotice", @@ -9403,27 +9519,6 @@ } }, "responses": { - "DBServicesConnectionReply": { - "description": "", - "headers": { - "code": { - "type": "integer", - "format": "int64", - "description": "code" - }, - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/DBServicesConnectionItem" - }, - "description": "connection result" - }, - "message": { - "type": "string", - "description": "message" - } - } - }, "DownloadDataExportTaskReply": { "description": "", "schema": { diff --git a/api/swagger.yaml b/api/swagger.yaml index 90f0278c..ee3833f4 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -712,6 +712,21 @@ definitions: x-go-name: SuccessfulNum type: object x-go-package: github.com/actiontech/dms/api/dms/service/v1 + DBServicesConnectionReply: + properties: + code: + description: code + format: int64 + type: integer + x-go-name: Code + data: + $ref: '#/definitions/DBServicesConnectionItem' + message: + description: message + type: string + x-go-name: Message + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 DMSProxyTarget: description: A dms proxy target properties: @@ -1422,18 +1437,15 @@ definitions: description: |- user authentication type ldap UserAuthenticationTypeLDAP - dms UserAuthenticationTypeDMS oauth2 UserAuthenticationTypeOAUTH2 unknown UserAuthenticationTypeUnknown enum: - ldap - - dms - oauth2 - unknown type: string x-go-enum-desc: |- ldap UserAuthenticationTypeLDAP - dms UserAuthenticationTypeDMS oauth2 UserAuthenticationTypeOAUTH2 unknown UserAuthenticationTypeUnknown x-go-name: AuthenticationType @@ -1642,6 +1654,68 @@ definitions: type: string type: object x-go-package: github.com/actiontech/dms/pkg/dms-common/api/dms/v1 + ImportDBService: + properties: + additional_params: + description: DB Service Custom connection parameters + items: + $ref: '#/definitions/AdditionalParam' + type: array + x-go-name: AdditionalParams + business: + description: the db service business name + type: string + x-go-name: Business + db_type: + description: db service DB type + type: string + x-go-name: DBType + desc: + description: DB desc + type: string + x-go-name: Desc + host: + description: db service host + type: string + x-go-name: Host + is_enable_masking: + description: is enable masking + type: boolean + x-go-name: IsEnableMasking + maintenance_times: + description: DB Service maintenance time + items: + $ref: '#/definitions/MaintenanceTime' + type: array + x-go-name: MaintenanceTimes + name: + description: db service name + type: string + x-go-name: Name + password: + description: db service admin encrypted password + type: string + x-go-name: Password + port: + description: db service port + type: string + x-go-name: Port + project_uid: + description: DB project uid + type: string + x-go-name: ProjectUID + source: + description: DB source + type: string + x-go-name: Source + sqle_config: + $ref: '#/definitions/SQLEConfig' + user: + description: db service admin user + type: string + x-go-name: User + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 ImportDBServicesCheckReply: properties: code: @@ -1652,7 +1726,7 @@ definitions: data: description: db services items: - $ref: '#/definitions/DBService' + $ref: '#/definitions/ImportDBService' type: array x-go-name: Data message: @@ -2599,18 +2673,15 @@ definitions: description: |- user authentication type ldap UserAuthenticationTypeLDAP - dms UserAuthenticationTypeDMS oauth2 UserAuthenticationTypeOAUTH2 unknown UserAuthenticationTypeUnknown enum: - ldap - - dms - oauth2 - unknown type: string x-go-enum-desc: |- ldap UserAuthenticationTypeLDAP - dms UserAuthenticationTypeDMS oauth2 UserAuthenticationTypeOAUTH2 unknown UserAuthenticationTypeUnknown x-go-name: AuthenticationType @@ -3437,7 +3508,7 @@ definitions: type: string x-go-name: Uid type: object - x-go-package: github.com/actiontech/dms/pkg/dms-common/api/dms/v1 + x-go-package: github.com/actiontech/dms/api/dms/service/v1 UpdateCompanyNotice: description: A companynotice properties: @@ -5738,12 +5809,14 @@ paths: name: db_services schema: items: - $ref: '#/definitions/DBService' + $ref: '#/definitions/ImportDBService' type: array x-go-name: DBServices - produces: - - application/json responses: + "200": + description: GenericResp + schema: + $ref: '#/definitions/GenericResp' default: description: GenericResp schema: @@ -6211,11 +6284,15 @@ paths: $ref: '#/definitions/CheckDbsConnectable' type: array x-go-name: DBServices - produces: - - application/json responses: + "200": + description: DBServicesConnectionReply + schema: + $ref: '#/definitions/DBServicesConnectionReply' default: - $ref: '#/responses/DBServicesConnectionReply' + description: GenericResp + schema: + $ref: '#/definitions/GenericResp' tags: - dms /v1/dms/projects/export: @@ -6257,11 +6334,13 @@ paths: description: Import projects operationId: ImportProjects parameters: - - in: query - items: - $ref: '#/definitions/ImportProjects' + - description: import projects + in: body name: projects - type: array + schema: + items: + $ref: '#/definitions/ImportProjects' + type: array x-go-name: Projects responses: "200": @@ -6286,12 +6365,16 @@ paths: name: db_services schema: items: - $ref: '#/definitions/DBService' + $ref: '#/definitions/ImportDBService' type: array x-go-name: DBServices produces: - application/json responses: + "200": + description: GenericResp + schema: + $ref: '#/definitions/GenericResp' default: description: GenericResp schema: @@ -6937,21 +7020,6 @@ paths: produces: - application/json responses: - DBServicesConnectionReply: - description: "" - headers: - code: - description: code - format: int64 - type: integer - data: - description: connection result - items: - $ref: '#/definitions/DBServicesConnectionItem' - type: array - message: - description: message - type: string DownloadDataExportTaskReply: description: "" schema: diff --git a/internal/apiserver/service/dms_controller.go b/internal/apiserver/service/dms_controller.go index 493489a6..c2ccd63a 100644 --- a/internal/apiserver/service/dms_controller.go +++ b/internal/apiserver/service/dms_controller.go @@ -1577,8 +1577,8 @@ func (a *DMSController) GetImportDBServicesTemplate(c echo.Context) error { // - text/csv // // responses: -// default: body:ImportDBServicesCheckReply // 200: ImportDBServicesCheckCsvReply +// default: body:ImportDBServicesCheckReply func (a *DMSController) ImportDBServicesOfOneProjectCheck(c echo.Context) error { return nil } @@ -1590,10 +1590,8 @@ func (a *DMSController) ImportDBServicesOfOneProjectCheck(c echo.Context) error // Consumes: // - application/json // -// Produces: -// - application/json -// // responses: +// 200: body:GenericResp // default: body:GenericResp func (a *DMSController) ImportDBServicesOfOneProject(c echo.Context) error { return nil @@ -1603,16 +1601,16 @@ func (a *DMSController) ImportDBServicesOfOneProject(c echo.Context) error { // // Import DBServices // -// Consumes: -// - multipart/form-data +// Consumes: +// - multipart/form-data // -// Produces: -// - application/json -// - text/csv +// Produces: +// - application/json +// - text/csv // // responses: -// default: body:ImportDBServicesCheckReply // 200: ImportDBServicesCheckCsvReply +// default: body:ImportDBServicesCheckReply func (a *DMSController) ImportDBServicesOfProjectsCheck(c echo.Context) error { return nil } @@ -1628,6 +1626,7 @@ func (a *DMSController) ImportDBServicesOfProjectsCheck(c echo.Context) error { // - application/json // // responses: +// 200: body:GenericResp // default: body:GenericResp func (a *DMSController) ImportDBServicesOfProjects(c echo.Context) error { return nil @@ -1640,11 +1639,9 @@ func (a *DMSController) ImportDBServicesOfProjects(c echo.Context) error { // Consumes: // - application/json // -// Produces: -// - application/json -// // responses: -// default: DBServicesConnectionReply +// 200: DBServicesConnectionReply +// default: body:GenericResp func (a *DMSController) DBServicesConnection(c echo.Context) error { return nil } @@ -2160,9 +2157,10 @@ func (d *DMSController) GetLicense(c echo.Context) error { } const ( - HardwareInfoFileName = "collected.infos" - LicenseFileParamKey = "license_file" - ProjectsFileParamKey = "projects_file" + HardwareInfoFileName = "collected.infos" + LicenseFileParamKey = "license_file" + ProjectsFileParamKey = "projects_file" + DBServicesFileParamKey = "db_services_file" ) // swagger:route GET /v1/dms/configurations/license/info dms GetLicenseInfo