diff --git a/api/dms/service/v1/statistic.go b/api/dms/service/v1/statistic.go new file mode 100644 index 00000000..7b15fc43 --- /dev/null +++ b/api/dms/service/v1/statistic.go @@ -0,0 +1,50 @@ +package v1 + +import base "github.com/actiontech/dms/pkg/dms-common/api/base/v1" + +// swagger:parameters GetCBDbServiceStatistic +type GetCBDbServiceStatisticReq struct { + // project id + // Required: true + // in:path + ProjectUid string `param:"project_uid" json:"project_uid" validate:"required"` +} + +// swagger:model GetCBDbServiceStatisticReply +type GetCBDbServiceStatisticReply 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"` + Count int64 `json:"count"` +} + +// 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..bcf05e6c 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -3315,6 +3315,72 @@ } } }, + "/v1/dms/projects/{project_uid}/statistic/cb_db_services": { + "get": { + "tags": [ + "statistic" + ], + "summary": "Get cb db service statistic.", + "operationId": "GetCBDbServiceStatistic", + "parameters": [ + { + "type": "string", + "x-go-name": "ProjectUid", + "description": "project id", + "name": "project_uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GetCBDbServiceStatisticReply", + "schema": { + "$ref": "#/definitions/GetCBDbServiceStatisticReply" + } + }, + "default": { + "description": "GenericResp", + "schema": { + "$ref": "#/definitions/GenericResp" + } + } + } + } + }, + "/v1/dms/projects/{project_uid}/statistic/cb_operations": { + "get": { + "tags": [ + "statistic" + ], + "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,62 @@ }, "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": { + "count": { + "type": "integer", + "format": "int64", + "x-go-name": "Count" + }, + "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 +5463,30 @@ }, "x-go-package": "github.com/actiontech/dms/api/dms/service/v1" }, + "GetCBDbServiceStatisticReply": { + "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 +5497,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", @@ -8381,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", @@ -9062,19 +9245,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..94198f8b 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,47 @@ 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: + count: + format: int64 + type: integer + x-go-name: Count + 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 +954,24 @@ definitions: x-go-name: Message type: object x-go-package: github.com/actiontech/dms/api/dms/service/v1 + GetCBDbServiceStatisticReply: + 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 +980,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 @@ -3342,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: @@ -3866,15 +3952,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 +6105,50 @@ paths: summary: List member tips. tags: - dms + /v1/dms/projects/{project_uid}/statistic/cb_db_services: + get: + operationId: GetCBDbServiceStatistic + parameters: + - description: project id + in: path + name: project_uid + required: true + type: string + x-go-name: ProjectUid + responses: + "200": + description: GetCBDbServiceStatisticReply + schema: + $ref: '#/definitions/GetCBDbServiceStatisticReply' + default: + description: GenericResp + schema: + $ref: '#/definitions/GenericResp' + summary: Get cb db service statistic. + tags: + - statistic + /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: + - 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 7293f812..318b94d2 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_db_services statistic GetCBDbServiceStatistic +// +// Get cb db service statistic. +// +// responses: +// 200: body:GetCBDbServiceStatisticReply +// default: body:GenericResp +func (a *DMSController) GetCBDbServiceStatistic(c echo.Context) error { + return nil +} + +// swagger:route GET /v1/dms/projects/{project_uid}/statistic/cb_operations statistic 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..8b266f2d 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_db_services", s.DMSController.GetCBDbServiceStatistic) + 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()