diff --git a/api/dms/service/v1/project.go b/api/dms/service/v1/project.go index 5b5f6cb7..c5587ecf 100644 --- a/api/dms/service/v1/project.go +++ b/api/dms/service/v1/project.go @@ -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 +} diff --git a/api/swagger.json b/api/swagger.json index b9c771e9..0f9663a9 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -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": [ @@ -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": [ @@ -9116,6 +9208,12 @@ } } }, + "GetImportDBServicesTemplateReply": { + "description": "", + "schema": { + "type": "file" + } + }, "GetImportProjectsTemplateReply": { "description": "", "schema": { @@ -9133,6 +9231,12 @@ "schema": { "type": "file" } + }, + "ImportDBServicesReply": { + "description": "", + "schema": { + "type": "file" + } } }, "securityDefinitions": { diff --git a/api/swagger.yaml b/api/swagger.yaml index 74c2a968..fd7c547b 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -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 @@ -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 @@ -6734,6 +6799,14 @@ responses: message: description: message type: string + GetImportDBServicesTemplateReply: + description: "" + schema: + type: file + ImportDBServicesReply: + description: "" + schema: + type: file GetImportProjectsTemplateReply: description: "" schema: diff --git a/internal/apiserver/service/dms_controller.go b/internal/apiserver/service/dms_controller.go index 7293f812..50e79802 100644 --- a/internal/apiserver/service/dms_controller.go +++ b/internal/apiserver/service/dms_controller.go @@ -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. diff --git a/internal/apiserver/service/router.go b/internal/apiserver/service/router.go index a66aa1a0..a693b40e 100644 --- a/internal/apiserver/service/router.go +++ b/internal/apiserver/service/router.go @@ -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) @@ -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")