From bdf7db2ca0053855ca26171092ea3f5152918f78 Mon Sep 17 00:00:00 2001 From: taolx0 Date: Tue, 4 Jun 2024 16:05:40 +0800 Subject: [PATCH 1/2] feat:Data Object Usage and Overview of Data Object Usage --- api/dms/service/v1/statistic.go | 49 +++++ api/swagger.json | 193 +++++++++++++++++-- api/swagger.yaml | 137 ++++++++++++- internal/apiserver/service/dms_controller.go | 22 +++ internal/apiserver/service/router.go | 4 + 5 files changed, 381 insertions(+), 24 deletions(-) create mode 100644 api/dms/service/v1/statistic.go diff --git a/api/dms/service/v1/statistic.go b/api/dms/service/v1/statistic.go new file mode 100644 index 00000000..af6dc8bb --- /dev/null +++ b/api/dms/service/v1/statistic.go @@ -0,0 +1,49 @@ +package v1 + +import base "github.com/actiontech/dms/pkg/dms-common/api/base/v1" + +// swagger:parameters GetCBInstanceStatistic +type GetCBInstanceStatisticReq struct { + // project id + // Required: true + // in:path + ProjectUid string `param:"project_uid" json:"project_uid" validate:"required"` +} + +// swagger:model GetCBInstanceStatisticReply +type GetCBInstanceStatisticReply struct { + // Generic reply + base.GenericResp + Data []*CbDbServiceStatistic `json:"data"` +} + +type CbDbServiceStatistic struct { + Name string `json:"name"` + Count int64 `json:"count"` + Content []*CbDbServiceStatisticContent `json:"content"` +} + +type CbDbServiceStatisticContent struct { + Schema string `json:"schema"` + Table string `json:"table"` +} + +// swagger:parameters GetCBOperationStatistic +type GetCBOperationStatisticReq struct { + // project id + // Required: true + // in:path + ProjectUid string `param:"project_uid" json:"project_uid" validate:"required"` +} + +// swagger:model GetCBOperationStatisticReply +type GetCBOperationStatisticReply struct { + // Generic reply + base.GenericResp + Data []*CbOperationStatistic `json:"data"` +} + +type CbOperationStatistic struct { + OperationType string `json:"operation_type"` + OperationCount int64 `json:"operation_count"` +} diff --git a/api/swagger.json b/api/swagger.json index b9c771e9..ce8ed200 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -3315,6 +3315,72 @@ } } }, + "/v1/dms/projects/{project_uid}/statistic/cb_instances": { + "get": { + "tags": [ + "dms" + ], + "summary": "Get cb instance statistic.", + "operationId": "GetCBInstanceStatistic", + "parameters": [ + { + "type": "string", + "x-go-name": "ProjectUid", + "description": "project id", + "name": "project_uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GetCBInstanceStatisticReply", + "schema": { + "$ref": "#/definitions/GetCBInstanceStatisticReply" + } + }, + "default": { + "description": "GenericResp", + "schema": { + "$ref": "#/definitions/GenericResp" + } + } + } + } + }, + "/v1/dms/projects/{project_uid}/statistic/cb_operations": { + "get": { + "tags": [ + "dms" + ], + "summary": "Get cb operation statistic.", + "operationId": "GetCBOperationStatistic", + "parameters": [ + { + "type": "string", + "x-go-name": "ProjectUid", + "description": "project id", + "name": "project_uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GetCBOperationStatisticReply", + "schema": { + "$ref": "#/definitions/GetCBOperationStatisticReply" + } + }, + "default": { + "description": "GenericResp", + "schema": { + "$ref": "#/definitions/GenericResp" + } + } + } + } + }, "/v1/dms/projects/{project_uid}/unarchive": { "put": { "tags": [ @@ -4738,6 +4804,19 @@ }, "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" }, + "CBOperationLogTips": { + "type": "object", + "properties": { + "exec_result": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "ExecResult" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, "CancelDataExportWorkflowPayload": { "type": "object", "required": [ @@ -4754,6 +4833,57 @@ }, "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" }, + "CbDbServiceStatistic": { + "type": "object", + "properties": { + "content": { + "type": "array", + "items": { + "$ref": "#/definitions/CbDbServiceStatisticContent" + }, + "x-go-name": "Content" + }, + "count": { + "type": "integer", + "format": "int64", + "x-go-name": "Count" + }, + "name": { + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, + "CbDbServiceStatisticContent": { + "type": "object", + "properties": { + "schema": { + "type": "string", + "x-go-name": "Schema" + }, + "table": { + "type": "string", + "x-go-name": "Table" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, + "CbOperationStatistic": { + "type": "object", + "properties": { + "operation_count": { + "type": "integer", + "format": "int64", + "x-go-name": "OperationCount" + }, + "operation_type": { + "type": "string", + "x-go-name": "OperationType" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, "CheckDBServiceIsConnectableReply": { "type": "object", "properties": { @@ -5328,6 +5458,30 @@ }, "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" }, + "GetCBInstanceStatisticReply": { + "type": "object", + "properties": { + "code": { + "description": "code", + "type": "integer", + "format": "int64", + "x-go-name": "Code" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/CbDbServiceStatistic" + }, + "x-go-name": "Data" + }, + "message": { + "description": "message", + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, "GetCBOperationLogTipsReply": { "type": "object", "properties": { @@ -5338,7 +5492,31 @@ "x-go-name": "Code" }, "data": { - "$ref": "#/definitions/cBOperationLogTips" + "$ref": "#/definitions/CBOperationLogTips" + }, + "message": { + "description": "message", + "type": "string", + "x-go-name": "Message" + } + }, + "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" + }, + "GetCBOperationStatisticReply": { + "type": "object", + "properties": { + "code": { + "description": "code", + "type": "integer", + "format": "int64", + "x-go-name": "Code" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/CbOperationStatistic" + }, + "x-go-name": "Data" }, "message": { "description": "message", @@ -9062,19 +9240,6 @@ } }, "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" - }, - "cBOperationLogTips": { - "type": "object", - "properties": { - "exec_result": { - "type": "array", - "items": { - "type": "string" - }, - "x-go-name": "ExecResult" - } - }, - "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" } }, "responses": { diff --git a/api/swagger.yaml b/api/swagger.yaml index 74c2a968..7488f59e 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -443,6 +443,15 @@ definitions: x-go-name: UID type: object x-go-package: github.com/actiontech/dms/api/dms/service/v1 + CBOperationLogTips: + properties: + exec_result: + items: + type: string + type: array + x-go-name: ExecResult + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 CancelDataExportWorkflowPayload: properties: data_export_workflow_uids: @@ -454,6 +463,43 @@ definitions: - data_export_workflow_uids type: object x-go-package: github.com/actiontech/dms/api/dms/service/v1 + CbDbServiceStatistic: + properties: + content: + items: + $ref: '#/definitions/CbDbServiceStatisticContent' + type: array + x-go-name: Content + count: + format: int64 + type: integer + x-go-name: Count + name: + type: string + x-go-name: Name + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 + CbDbServiceStatisticContent: + properties: + schema: + type: string + x-go-name: Schema + table: + type: string + x-go-name: Table + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 + CbOperationStatistic: + properties: + operation_count: + format: int64 + type: integer + x-go-name: OperationCount + operation_type: + type: string + x-go-name: OperationType + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 CheckDBServiceIsConnectableReply: properties: code: @@ -904,6 +950,24 @@ definitions: x-go-name: Message type: object x-go-package: github.com/actiontech/dms/api/dms/service/v1 + GetCBInstanceStatisticReply: + properties: + code: + description: code + format: int64 + type: integer + x-go-name: Code + data: + items: + $ref: '#/definitions/CbDbServiceStatistic' + type: array + x-go-name: Data + message: + description: message + type: string + x-go-name: Message + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 GetCBOperationLogTipsReply: properties: code: @@ -912,7 +976,25 @@ definitions: type: integer x-go-name: Code data: - $ref: '#/definitions/cBOperationLogTips' + $ref: '#/definitions/CBOperationLogTips' + message: + description: message + type: string + x-go-name: Message + type: object + x-go-package: github.com/actiontech/dms/api/dms/service/v1 + GetCBOperationStatisticReply: + properties: + code: + description: code + format: int64 + type: integer + x-go-name: Code + data: + items: + $ref: '#/definitions/CbOperationStatistic' + type: array + x-go-name: Data message: description: message type: string @@ -3866,15 +3948,6 @@ definitions: x-go-name: Type type: object x-go-package: github.com/actiontech/dms/api/dms/service/v1 - cBOperationLogTips: - properties: - exec_result: - items: - type: string - type: array - x-go-name: ExecResult - type: object - x-go-package: github.com/actiontech/dms/api/dms/service/v1 info: description: Documentation of our dms API. title: dms api. @@ -6028,6 +6101,50 @@ paths: summary: List member tips. tags: - dms + /v1/dms/projects/{project_uid}/statistic/cb_instances: + get: + operationId: GetCBInstanceStatistic + parameters: + - description: project id + in: path + name: project_uid + required: true + type: string + x-go-name: ProjectUid + responses: + "200": + description: GetCBInstanceStatisticReply + schema: + $ref: '#/definitions/GetCBInstanceStatisticReply' + default: + description: GenericResp + schema: + $ref: '#/definitions/GenericResp' + summary: Get cb instance statistic. + tags: + - dms + /v1/dms/projects/{project_uid}/statistic/cb_operations: + get: + operationId: GetCBOperationStatistic + parameters: + - description: project id + in: path + name: project_uid + required: true + type: string + x-go-name: ProjectUid + responses: + "200": + description: GetCBOperationStatisticReply + schema: + $ref: '#/definitions/GetCBOperationStatisticReply' + default: + description: GenericResp + schema: + $ref: '#/definitions/GenericResp' + summary: Get cb operation statistic. + tags: + - dms /v1/dms/projects/{project_uid}/unarchive: put: operationId: UnarchiveProject diff --git a/internal/apiserver/service/dms_controller.go b/internal/apiserver/service/dms_controller.go index 7293f812..9969e9be 100644 --- a/internal/apiserver/service/dms_controller.go +++ b/internal/apiserver/service/dms_controller.go @@ -2636,3 +2636,25 @@ func (a *DMSController) GetCBOperationLogTips(c echo.Context) error { return NewOkRespWithReply(c, reply) } + +// swagger:route GET /v1/dms/projects/{project_uid}/statistic/cb_instances dms GetCBInstanceStatistic +// +// Get cb instance statistic. +// +// responses: +// 200: body:GetCBInstanceStatisticReply +// default: body:GenericResp +func (a *DMSController) GetCBInstanceStatistic(c echo.Context) error { + return nil +} + +// swagger:route GET /v1/dms/projects/{project_uid}/statistic/cb_operations dms GetCBOperationStatistic +// +// Get cb operation statistic. +// +// responses: +// 200: body:GetCBOperationStatisticReply +// default: body:GenericResp +func (a *DMSController) GetCBOperationStatistic(c echo.Context) error { + return nil +} diff --git a/internal/apiserver/service/router.go b/internal/apiserver/service/router.go index a66aa1a0..e25276a4 100644 --- a/internal/apiserver/service/router.go +++ b/internal/apiserver/service/router.go @@ -177,6 +177,10 @@ func (s *APIServer) initRouter() error { maskingV1 := v1.Group("/dms/masking") maskingV1.GET("/rules", s.DMSController.ListMaskingRules) + statisticRouter := v1.Group("/dms/projects/:project_uid/statistic") + statisticRouter.GET("/cb_instances", s.DMSController.GetCBInstanceStatistic) + statisticRouter.GET("/cb_operations", s.DMSController.GetCBOperationStatistic) + if s.CloudbeaverController.CloudbeaverService.CloudbeaverUsecase.IsCloudbeaverConfigured() { cloudbeaverV1 := s.echo.Group(s.CloudbeaverController.CloudbeaverService.CloudbeaverUsecase.GetRootUri()) targets, err := s.CloudbeaverController.CloudbeaverService.ProxyUsecase.GetCloudbeaverProxyTarget() From b829a8fa39f1bc5dda4b9a64a35fe8eeed3c8eea Mon Sep 17 00:00:00 2001 From: taolx0 Date: Tue, 4 Jun 2024 17:59:28 +0800 Subject: [PATCH 2/2] fix:change instance to dbservice fix:change instance to db service --- api/dms/service/v1/statistic.go | 9 ++++---- api/swagger.json | 23 ++++++++++++-------- api/swagger.yaml | 22 +++++++++++-------- internal/apiserver/service/dms_controller.go | 10 ++++----- internal/apiserver/service/router.go | 2 +- 5 files changed, 38 insertions(+), 28 deletions(-) diff --git a/api/dms/service/v1/statistic.go b/api/dms/service/v1/statistic.go index af6dc8bb..7b15fc43 100644 --- a/api/dms/service/v1/statistic.go +++ b/api/dms/service/v1/statistic.go @@ -2,16 +2,16 @@ package v1 import base "github.com/actiontech/dms/pkg/dms-common/api/base/v1" -// swagger:parameters GetCBInstanceStatistic -type GetCBInstanceStatisticReq struct { +// swagger:parameters GetCBDbServiceStatistic +type GetCBDbServiceStatisticReq struct { // project id // Required: true // in:path ProjectUid string `param:"project_uid" json:"project_uid" validate:"required"` } -// swagger:model GetCBInstanceStatisticReply -type GetCBInstanceStatisticReply struct { +// swagger:model GetCBDbServiceStatisticReply +type GetCBDbServiceStatisticReply struct { // Generic reply base.GenericResp Data []*CbDbServiceStatistic `json:"data"` @@ -26,6 +26,7 @@ type CbDbServiceStatistic struct { type CbDbServiceStatisticContent struct { Schema string `json:"schema"` Table string `json:"table"` + Count int64 `json:"count"` } // swagger:parameters GetCBOperationStatistic diff --git a/api/swagger.json b/api/swagger.json index ce8ed200..bcf05e6c 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -3315,13 +3315,13 @@ } } }, - "/v1/dms/projects/{project_uid}/statistic/cb_instances": { + "/v1/dms/projects/{project_uid}/statistic/cb_db_services": { "get": { "tags": [ - "dms" + "statistic" ], - "summary": "Get cb instance statistic.", - "operationId": "GetCBInstanceStatistic", + "summary": "Get cb db service statistic.", + "operationId": "GetCBDbServiceStatistic", "parameters": [ { "type": "string", @@ -3334,9 +3334,9 @@ ], "responses": { "200": { - "description": "GetCBInstanceStatisticReply", + "description": "GetCBDbServiceStatisticReply", "schema": { - "$ref": "#/definitions/GetCBInstanceStatisticReply" + "$ref": "#/definitions/GetCBDbServiceStatisticReply" } }, "default": { @@ -3351,7 +3351,7 @@ "/v1/dms/projects/{project_uid}/statistic/cb_operations": { "get": { "tags": [ - "dms" + "statistic" ], "summary": "Get cb operation statistic.", "operationId": "GetCBOperationStatistic", @@ -4858,6 +4858,11 @@ "CbDbServiceStatisticContent": { "type": "object", "properties": { + "count": { + "type": "integer", + "format": "int64", + "x-go-name": "Count" + }, "schema": { "type": "string", "x-go-name": "Schema" @@ -5458,7 +5463,7 @@ }, "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" }, - "GetCBInstanceStatisticReply": { + "GetCBDbServiceStatisticReply": { "type": "object", "properties": { "code": { @@ -8559,7 +8564,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", diff --git a/api/swagger.yaml b/api/swagger.yaml index 7488f59e..94198f8b 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -481,6 +481,10 @@ definitions: x-go-package: github.com/actiontech/dms/api/dms/service/v1 CbDbServiceStatisticContent: properties: + count: + format: int64 + type: integer + x-go-name: Count schema: type: string x-go-name: Schema @@ -950,7 +954,7 @@ definitions: x-go-name: Message type: object x-go-package: github.com/actiontech/dms/api/dms/service/v1 - GetCBInstanceStatisticReply: + GetCBDbServiceStatisticReply: properties: code: description: code @@ -3424,7 +3428,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: @@ -6101,9 +6105,9 @@ paths: summary: List member tips. tags: - dms - /v1/dms/projects/{project_uid}/statistic/cb_instances: + /v1/dms/projects/{project_uid}/statistic/cb_db_services: get: - operationId: GetCBInstanceStatistic + operationId: GetCBDbServiceStatistic parameters: - description: project id in: path @@ -6113,16 +6117,16 @@ paths: x-go-name: ProjectUid responses: "200": - description: GetCBInstanceStatisticReply + description: GetCBDbServiceStatisticReply schema: - $ref: '#/definitions/GetCBInstanceStatisticReply' + $ref: '#/definitions/GetCBDbServiceStatisticReply' default: description: GenericResp schema: $ref: '#/definitions/GenericResp' - summary: Get cb instance statistic. + summary: Get cb db service statistic. tags: - - dms + - statistic /v1/dms/projects/{project_uid}/statistic/cb_operations: get: operationId: GetCBOperationStatistic @@ -6144,7 +6148,7 @@ paths: $ref: '#/definitions/GenericResp' summary: Get cb operation statistic. tags: - - dms + - statistic /v1/dms/projects/{project_uid}/unarchive: put: operationId: UnarchiveProject diff --git a/internal/apiserver/service/dms_controller.go b/internal/apiserver/service/dms_controller.go index 9969e9be..318b94d2 100644 --- a/internal/apiserver/service/dms_controller.go +++ b/internal/apiserver/service/dms_controller.go @@ -2637,18 +2637,18 @@ func (a *DMSController) GetCBOperationLogTips(c echo.Context) error { return NewOkRespWithReply(c, reply) } -// swagger:route GET /v1/dms/projects/{project_uid}/statistic/cb_instances dms GetCBInstanceStatistic +// swagger:route GET /v1/dms/projects/{project_uid}/statistic/cb_db_services statistic GetCBDbServiceStatistic // -// Get cb instance statistic. +// Get cb db service statistic. // // responses: -// 200: body:GetCBInstanceStatisticReply +// 200: body:GetCBDbServiceStatisticReply // default: body:GenericResp -func (a *DMSController) GetCBInstanceStatistic(c echo.Context) error { +func (a *DMSController) GetCBDbServiceStatistic(c echo.Context) error { return nil } -// swagger:route GET /v1/dms/projects/{project_uid}/statistic/cb_operations dms GetCBOperationStatistic +// swagger:route GET /v1/dms/projects/{project_uid}/statistic/cb_operations statistic GetCBOperationStatistic // // Get cb operation statistic. // diff --git a/internal/apiserver/service/router.go b/internal/apiserver/service/router.go index e25276a4..8b266f2d 100644 --- a/internal/apiserver/service/router.go +++ b/internal/apiserver/service/router.go @@ -178,7 +178,7 @@ func (s *APIServer) initRouter() error { maskingV1.GET("/rules", s.DMSController.ListMaskingRules) statisticRouter := v1.Group("/dms/projects/:project_uid/statistic") - statisticRouter.GET("/cb_instances", s.DMSController.GetCBInstanceStatistic) + statisticRouter.GET("/cb_db_services", s.DMSController.GetCBDbServiceStatistic) statisticRouter.GET("/cb_operations", s.DMSController.GetCBOperationStatistic) if s.CloudbeaverController.CloudbeaverService.CloudbeaverUsecase.IsCloudbeaverConfigured() {