diff --git a/internal/dashboard/business/oceanbase/obcluster.go b/internal/dashboard/business/oceanbase/obcluster.go index 09e2d246c..51aaa2d3a 100644 --- a/internal/dashboard/business/oceanbase/obcluster.go +++ b/internal/dashboard/business/oceanbase/obcluster.go @@ -85,17 +85,19 @@ func buildOBClusterOverview(ctx context.Context, obcluster *v1alpha1.OBCluster) } } return &response.OBClusterOverview{ - UID: string(obcluster.UID), - Namespace: obcluster.Namespace, - Name: obcluster.Name, - ClusterName: obcluster.Spec.ClusterName, - ClusterId: obcluster.Spec.ClusterId, + OBClusterMeta: response.OBClusterMeta{ + UID: string(obcluster.UID), + Namespace: obcluster.Namespace, + Name: obcluster.Name, + ClusterName: obcluster.Spec.ClusterName, + ClusterId: obcluster.Spec.ClusterId, + Mode: clusterMode, + }, Status: getStatisticStatus(obcluster), StatusDetail: obcluster.Status.Status, CreateTime: obcluster.ObjectMeta.CreationTimestamp.Unix(), Image: obcluster.Status.Image, Topology: topology, - Mode: clusterMode, }, nil } diff --git a/internal/dashboard/generated/bindata/bindata.go b/internal/dashboard/generated/bindata/bindata.go index a88284f76..d3fee295d 100644 --- a/internal/dashboard/generated/bindata/bindata.go +++ b/internal/dashboard/generated/bindata/bindata.go @@ -93,7 +93,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _internalAssetsCliTemplatesComponent_configYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\xcd\xb1\xca\xc2\x30\x10\x00\xe0\xbd\x4f\x71\xb4\x73\x8e\xfe\x99\x7e\xb2\x39\x74\x10\x44\xc1\x16\xd7\x72\x49\x0f\x5b\x48\x73\xe1\x12\xfa\xfc\xa2\xae\xee\x1f\x7c\x1d\x5c\x4e\xd3\x30\x4e\xf3\x63\xb8\x8f\xe7\xdb\xb5\x09\xb2\x67\x49\x9c\x6a\x71\x0d\x40\x60\xad\x66\xa7\x44\x4f\x56\x07\xad\x45\x8b\x76\x56\x8e\x4c\x85\xdb\x06\xa0\x83\x28\x81\xa2\xc9\x54\x57\x93\x55\x8e\xad\x6c\x92\x3e\xf6\xe8\xb1\x47\xfb\xff\x55\x12\x98\x92\xa7\xc2\x66\xa1\xb2\x7a\x21\x5d\x1c\xb4\x3d\x5a\xfc\x7b\x03\xf1\x46\x32\x2b\x55\xf9\xb1\xbc\x02\x00\x00\xff\xff\x85\x5e\xac\x0d\xa3\x00\x00\x00") +var _internalAssetsCliTemplatesComponent_configYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\xce\x31\xeb\xc2\x30\x10\x05\xf0\xbd\x9f\xe2\xc8\x7f\xce\x11\xf2\x5f\x24\x9b\x43\x07\x41\x14\x6c\x71\x2d\xd7\xf6\xb0\x85\x36\x17\x2e\xa1\x9f\x5f\x14\x07\x11\x5d\xdf\xfb\xf1\x78\x7f\x70\xdc\xb7\x75\xd3\x76\xd7\xfa\xd2\x1c\xce\xa7\x6a\x90\x35\x49\xe4\x58\x72\xa8\x00\x06\xd6\x62\x57\x8a\x74\x63\x0d\x60\x3c\x7a\xf4\x9d\xf2\xc2\x94\xd9\x54\x00\x8b\x0c\xb4\xd8\x44\x65\xb2\x49\x65\x9b\xf3\x2c\xf1\x29\x37\x87\x0e\xfd\xee\xb7\xb1\x23\x6f\x01\xcc\x4a\xb9\xb0\x3e\x98\xf4\x76\xa4\x3c\xf5\x42\x3a\x06\x30\x0e\xff\xd1\xbd\x72\x49\xac\x54\xe4\xeb\x83\xb7\xfa\x63\xf2\x1e\x00\x00\xff\xff\xfd\x32\xed\xc3\xdb\x00\x00\x00") func internalAssetsCliTemplatesComponent_configYamlBytes() ([]byte, error) { return bindataRead( @@ -108,7 +108,7 @@ func internalAssetsCliTemplatesComponent_configYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "internal/assets/cli-templates/component_config.yaml", size: 163, mode: os.FileMode(420), modTime: time.Unix(1725263522, 0)} + info := bindataFileInfo{name: "internal/assets/cli-templates/component_config.yaml", size: 219, mode: os.FileMode(420), modTime: time.Unix(1725453328, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/internal/dashboard/generated/swagger/docs.go b/internal/dashboard/generated/swagger/docs.go index 2761dd4d6..fe588ee98 100644 --- a/internal/dashboard/generated/swagger/docs.go +++ b/internal/dashboard/generated/swagger/docs.go @@ -2490,6 +2490,452 @@ const docTemplate = `{ } } }, + "/api/v1/inspection/policies": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "list inspection policies", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "list inspection policies", + "operationId": "ListInspectionPolicies", + "parameters": [ + { + "type": "string", + "description": "Namespace", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "description": "Object name", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "obcluster name", + "name": "obclusterName", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + }, + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "create or update inspection policy", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "create or update inspection policy", + "operationId": "CreateOrUpdateInspectionPolicy", + "parameters": [ + { + "description": "inspection policy", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/inspection.Policy" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/policies/{namespace}/{name}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get inspection policy", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "get inspection policy", + "operationId": "GetInspectionPolicy", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/policies/{namespace}/{name}/{scenario}": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "trigger inspection", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "trigger inspection", + "operationId": "TriggerInspection", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + }, + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "delete inspection policy", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "delete inspection policy", + "operationId": "DeleteInspectionPolicy", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/reports": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "list inspection reports", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "list inspection reports", + "operationId": "ListInspectionReports", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.ReportBriefInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/reports/{id}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get inspection report", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "get inspection report", + "operationId": "GetInspectionReport", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Report" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/login": { "post": { "description": "User login and return access token with cookie.", @@ -6750,6 +7196,211 @@ const docTemplate = `{ } } }, + "inspection.InspectionItem": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "results": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "inspection.InspectionScenario": { + "type": "string", + "enum": [ + "basic", + "performance" + ], + "x-enum-varnames": [ + "ScenarioBasic", + "ScenarioPerformance" + ] + }, + "inspection.InspectionScheduleConfig": { + "type": "object", + "required": [ + "scenario", + "scheduleExpr" + ], + "properties": { + "scenario": { + "$ref": "#/definitions/inspection.InspectionScenario" + }, + "scheduleExpr": { + "type": "string" + } + } + }, + "inspection.InspectionScheduleStatus": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-enum-varnames": [ + "ScheduleEnabled", + "ScheduleDisabled" + ] + }, + "inspection.JobStatus": { + "type": "string", + "enum": [ + "successful", + "failed" + ], + "x-enum-varnames": [ + "JobStatusSuccessful", + "JobStatusFailed" + ] + }, + "inspection.Policy": { + "type": "object", + "required": [ + "obCluster", + "status" + ], + "properties": { + "latestReports": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.ReportBriefInfo" + } + }, + "obCluster": { + "$ref": "#/definitions/response.OBClusterMeta" + }, + "scheduleConfig": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionScheduleConfig" + } + }, + "status": { + "$ref": "#/definitions/inspection.InspectionScheduleStatus" + } + } + }, + "inspection.Report": { + "type": "object", + "required": [ + "id", + "obCluster", + "resultStatistics", + "status" + ], + "properties": { + "finishTime": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "obCluster": { + "$ref": "#/definitions/response.OBClusterMeta" + }, + "resultDetail": { + "$ref": "#/definitions/inspection.ResultDetail" + }, + "resultStatistics": { + "$ref": "#/definitions/inspection.ResultStatistics" + }, + "scenario": { + "$ref": "#/definitions/inspection.InspectionScenario" + }, + "startTime": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/inspection.JobStatus" + } + } + }, + "inspection.ReportBriefInfo": { + "type": "object", + "required": [ + "id", + "obCluster", + "resultStatistics", + "status" + ], + "properties": { + "finishTime": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "obCluster": { + "$ref": "#/definitions/response.OBClusterMeta" + }, + "resultStatistics": { + "$ref": "#/definitions/inspection.ResultStatistics" + }, + "scenario": { + "$ref": "#/definitions/inspection.InspectionScenario" + }, + "startTime": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/inspection.JobStatus" + } + } + }, + "inspection.ResultDetail": { + "type": "object", + "properties": { + "criticalItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + }, + "failedItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + }, + "moderateItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + }, + "negligibleItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + } + } + }, + "inspection.ResultStatistics": { + "type": "object", + "properties": { + "criticalCount": { + "type": "integer" + }, + "failedCount": { + "type": "integer" + }, + "moderateCount": { + "type": "integer" + }, + "negligibleCount": { + "type": "integer" + } + } + }, "models.K8sEvent": { "type": "object", "properties": { @@ -8872,6 +9523,37 @@ const docTemplate = `{ } } }, + "response.OBClusterMeta": { + "type": "object", + "required": [ + "clusterId", + "clusterName", + "mode", + "name", + "namespace", + "uid" + ], + "properties": { + "clusterId": { + "type": "integer" + }, + "clusterName": { + "type": "string" + }, + "mode": { + "$ref": "#/definitions/common.ClusterMode" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, "response.OBClusterOverview": { "type": "object", "required": [ diff --git a/internal/dashboard/generated/swagger/swagger.json b/internal/dashboard/generated/swagger/swagger.json index 30a09986e..47b7f8b64 100644 --- a/internal/dashboard/generated/swagger/swagger.json +++ b/internal/dashboard/generated/swagger/swagger.json @@ -2483,6 +2483,452 @@ } } }, + "/api/v1/inspection/policies": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "list inspection policies", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "list inspection policies", + "operationId": "ListInspectionPolicies", + "parameters": [ + { + "type": "string", + "description": "Namespace", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "description": "Object name", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "obcluster name", + "name": "obclusterName", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + }, + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "create or update inspection policy", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "create or update inspection policy", + "operationId": "CreateOrUpdateInspectionPolicy", + "parameters": [ + { + "description": "inspection policy", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/inspection.Policy" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/policies/{namespace}/{name}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get inspection policy", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "get inspection policy", + "operationId": "GetInspectionPolicy", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/policies/{namespace}/{name}/{scenario}": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "trigger inspection", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "trigger inspection", + "operationId": "TriggerInspection", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + }, + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "delete inspection policy", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "delete inspection policy", + "operationId": "DeleteInspectionPolicy", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Policy" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/reports": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "list inspection reports", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "list inspection reports", + "operationId": "ListInspectionReports", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.ReportBriefInfo" + } + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, + "/api/v1/inspection/reports/{id}": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get inspection report", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Inspection" + ], + "summary": "get inspection report", + "operationId": "GetInspectionReport", + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/response.APIResponse" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/inspection.Report" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/login": { "post": { "description": "User login and return access token with cookie.", @@ -6743,6 +7189,211 @@ } } }, + "inspection.InspectionItem": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "results": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "inspection.InspectionScenario": { + "type": "string", + "enum": [ + "basic", + "performance" + ], + "x-enum-varnames": [ + "ScenarioBasic", + "ScenarioPerformance" + ] + }, + "inspection.InspectionScheduleConfig": { + "type": "object", + "required": [ + "scenario", + "scheduleExpr" + ], + "properties": { + "scenario": { + "$ref": "#/definitions/inspection.InspectionScenario" + }, + "scheduleExpr": { + "type": "string" + } + } + }, + "inspection.InspectionScheduleStatus": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-enum-varnames": [ + "ScheduleEnabled", + "ScheduleDisabled" + ] + }, + "inspection.JobStatus": { + "type": "string", + "enum": [ + "successful", + "failed" + ], + "x-enum-varnames": [ + "JobStatusSuccessful", + "JobStatusFailed" + ] + }, + "inspection.Policy": { + "type": "object", + "required": [ + "obCluster", + "status" + ], + "properties": { + "latestReports": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.ReportBriefInfo" + } + }, + "obCluster": { + "$ref": "#/definitions/response.OBClusterMeta" + }, + "scheduleConfig": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionScheduleConfig" + } + }, + "status": { + "$ref": "#/definitions/inspection.InspectionScheduleStatus" + } + } + }, + "inspection.Report": { + "type": "object", + "required": [ + "id", + "obCluster", + "resultStatistics", + "status" + ], + "properties": { + "finishTime": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "obCluster": { + "$ref": "#/definitions/response.OBClusterMeta" + }, + "resultDetail": { + "$ref": "#/definitions/inspection.ResultDetail" + }, + "resultStatistics": { + "$ref": "#/definitions/inspection.ResultStatistics" + }, + "scenario": { + "$ref": "#/definitions/inspection.InspectionScenario" + }, + "startTime": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/inspection.JobStatus" + } + } + }, + "inspection.ReportBriefInfo": { + "type": "object", + "required": [ + "id", + "obCluster", + "resultStatistics", + "status" + ], + "properties": { + "finishTime": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "obCluster": { + "$ref": "#/definitions/response.OBClusterMeta" + }, + "resultStatistics": { + "$ref": "#/definitions/inspection.ResultStatistics" + }, + "scenario": { + "$ref": "#/definitions/inspection.InspectionScenario" + }, + "startTime": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/inspection.JobStatus" + } + } + }, + "inspection.ResultDetail": { + "type": "object", + "properties": { + "criticalItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + }, + "failedItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + }, + "moderateItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + }, + "negligibleItems": { + "type": "array", + "items": { + "$ref": "#/definitions/inspection.InspectionItem" + } + } + } + }, + "inspection.ResultStatistics": { + "type": "object", + "properties": { + "criticalCount": { + "type": "integer" + }, + "failedCount": { + "type": "integer" + }, + "moderateCount": { + "type": "integer" + }, + "negligibleCount": { + "type": "integer" + } + } + }, "models.K8sEvent": { "type": "object", "properties": { @@ -8865,6 +9516,37 @@ } } }, + "response.OBClusterMeta": { + "type": "object", + "required": [ + "clusterId", + "clusterName", + "mode", + "name", + "namespace", + "uid" + ], + "properties": { + "clusterId": { + "type": "integer" + }, + "clusterName": { + "type": "string" + }, + "mode": { + "$ref": "#/definitions/common.ClusterMode" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "uid": { + "type": "string" + } + } + }, "response.OBClusterOverview": { "type": "object", "required": [ diff --git a/internal/dashboard/generated/swagger/swagger.yaml b/internal/dashboard/generated/swagger/swagger.yaml index 76b43c25a..2a45f8569 100644 --- a/internal/dashboard/generated/swagger/swagger.yaml +++ b/internal/dashboard/generated/swagger/swagger.yaml @@ -252,6 +252,145 @@ definitions: storageClass: type: string type: object + inspection.InspectionItem: + properties: + name: + type: string + results: + items: + type: string + type: array + required: + - name + type: object + inspection.InspectionScenario: + enum: + - basic + - performance + type: string + x-enum-varnames: + - ScenarioBasic + - ScenarioPerformance + inspection.InspectionScheduleConfig: + properties: + scenario: + $ref: '#/definitions/inspection.InspectionScenario' + scheduleExpr: + type: string + required: + - scenario + - scheduleExpr + type: object + inspection.InspectionScheduleStatus: + enum: + - enabled + - disabled + type: string + x-enum-varnames: + - ScheduleEnabled + - ScheduleDisabled + inspection.JobStatus: + enum: + - successful + - failed + type: string + x-enum-varnames: + - JobStatusSuccessful + - JobStatusFailed + inspection.Policy: + properties: + latestReports: + items: + $ref: '#/definitions/inspection.ReportBriefInfo' + type: array + obCluster: + $ref: '#/definitions/response.OBClusterMeta' + scheduleConfig: + items: + $ref: '#/definitions/inspection.InspectionScheduleConfig' + type: array + status: + $ref: '#/definitions/inspection.InspectionScheduleStatus' + required: + - obCluster + - status + type: object + inspection.Report: + properties: + finishTime: + type: integer + id: + type: string + obCluster: + $ref: '#/definitions/response.OBClusterMeta' + resultDetail: + $ref: '#/definitions/inspection.ResultDetail' + resultStatistics: + $ref: '#/definitions/inspection.ResultStatistics' + scenario: + $ref: '#/definitions/inspection.InspectionScenario' + startTime: + type: integer + status: + $ref: '#/definitions/inspection.JobStatus' + required: + - id + - obCluster + - resultStatistics + - status + type: object + inspection.ReportBriefInfo: + properties: + finishTime: + type: integer + id: + type: string + obCluster: + $ref: '#/definitions/response.OBClusterMeta' + resultStatistics: + $ref: '#/definitions/inspection.ResultStatistics' + scenario: + $ref: '#/definitions/inspection.InspectionScenario' + startTime: + type: integer + status: + $ref: '#/definitions/inspection.JobStatus' + required: + - id + - obCluster + - resultStatistics + - status + type: object + inspection.ResultDetail: + properties: + criticalItems: + items: + $ref: '#/definitions/inspection.InspectionItem' + type: array + failedItems: + items: + $ref: '#/definitions/inspection.InspectionItem' + type: array + moderateItems: + items: + $ref: '#/definitions/inspection.InspectionItem' + type: array + negligibleItems: + items: + $ref: '#/definitions/inspection.InspectionItem' + type: array + type: object + inspection.ResultStatistics: + properties: + criticalCount: + type: integer + failedCount: + type: integer + moderateCount: + type: integer + negligibleCount: + type: integer + type: object models.K8sEvent: properties: count: @@ -1729,6 +1868,28 @@ definitions: - topology - uid type: object + response.OBClusterMeta: + properties: + clusterId: + type: integer + clusterName: + type: string + mode: + $ref: '#/definitions/common.ClusterMode' + name: + type: string + namespace: + type: string + uid: + type: string + required: + - clusterId + - clusterName + - mode + - name + - namespace + - uid + type: object response.OBClusterOverview: properties: clusterId: @@ -4435,6 +4596,273 @@ paths: summary: Get process info tags: - Info + /api/v1/inspection/policies: + get: + consumes: + - application/json + description: list inspection policies + operationId: ListInspectionPolicies + parameters: + - description: Namespace + in: query + name: namespace + type: string + - description: Object name + in: query + name: name + type: string + - description: obcluster name + in: query + name: obclusterName + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.APIResponse' + - properties: + data: + items: + $ref: '#/definitions/inspection.Policy' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - ApiKeyAuth: [] + summary: list inspection policies + tags: + - Inspection + put: + consumes: + - application/json + description: create or update inspection policy + operationId: CreateOrUpdateInspectionPolicy + parameters: + - description: inspection policy + in: body + name: body + required: true + schema: + $ref: '#/definitions/inspection.Policy' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.APIResponse' + - properties: + data: + $ref: '#/definitions/inspection.Policy' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - ApiKeyAuth: [] + summary: create or update inspection policy + tags: + - Inspection + /api/v1/inspection/policies/{namespace}/{name}: + get: + consumes: + - application/json + description: get inspection policy + operationId: GetInspectionPolicy + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.APIResponse' + - properties: + data: + $ref: '#/definitions/inspection.Policy' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - ApiKeyAuth: [] + summary: get inspection policy + tags: + - Inspection + /api/v1/inspection/policies/{namespace}/{name}/{scenario}: + delete: + consumes: + - application/json + description: delete inspection policy + operationId: DeleteInspectionPolicy + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.APIResponse' + - properties: + data: + $ref: '#/definitions/inspection.Policy' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - ApiKeyAuth: [] + summary: delete inspection policy + tags: + - Inspection + post: + consumes: + - application/json + description: trigger inspection + operationId: TriggerInspection + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.APIResponse' + - properties: + data: + $ref: '#/definitions/inspection.Policy' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - ApiKeyAuth: [] + summary: trigger inspection + tags: + - Inspection + /api/v1/inspection/reports: + get: + consumes: + - application/json + description: list inspection reports + operationId: ListInspectionReports + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.APIResponse' + - properties: + data: + items: + $ref: '#/definitions/inspection.ReportBriefInfo' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - ApiKeyAuth: [] + summary: list inspection reports + tags: + - Inspection + /api/v1/inspection/reports/{id}: + get: + consumes: + - application/json + description: get inspection report + operationId: GetInspectionReport + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/response.APIResponse' + - properties: + data: + $ref: '#/definitions/inspection.Report' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - ApiKeyAuth: [] + summary: get inspection report + tags: + - Inspection /api/v1/login: post: consumes: diff --git a/internal/dashboard/handler/inspection_handler.go b/internal/dashboard/handler/inspection_handler.go new file mode 100644 index 000000000..cb6b72c8e --- /dev/null +++ b/internal/dashboard/handler/inspection_handler.go @@ -0,0 +1,136 @@ +/* +Copyright (c) 2023 OceanBase +ob-operator is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +package handler + +import ( + "github.com/gin-gonic/gin" + + "github.com/oceanbase/ob-operator/internal/dashboard/model/inspection" + "github.com/oceanbase/ob-operator/pkg/errors" +) + +// @ID ListInspectionPolicies +// @Summary list inspection policies +// @Description list inspection policies +// @Tags Inspection +// @Accept application/json +// @Produce application/json +// @Param namespace query string false "Namespace" string +// @Param name query string false "Object name" string +// @Param obclusterName query string false "obcluster name" string +// @Success 200 object response.APIResponse{data=[]inspection.Policy} +// @Failure 400 object response.APIResponse +// @Failure 401 object response.APIResponse +// @Failure 500 object response.APIResponse +// @Router /api/v1/inspection/policies [GET] +// @Security ApiKeyAuth +func ListInspectionPolicies(_ *gin.Context) ([]inspection.Policy, error) { + return nil, errors.NewNotImplemented("") +} + +// @ID CreateOrUpdateInspectionPolicy +// @Summary create or update inspection policy +// @Description create or update inspection policy +// @Tags Inspection +// @Accept application/json +// @Produce application/json +// @Param body body inspection.Policy true "inspection policy" +// @Success 200 object response.APIResponse{data=inspection.Policy} +// @Failure 400 object response.APIResponse +// @Failure 401 object response.APIResponse +// @Failure 500 object response.APIResponse +// @Router /api/v1/inspection/policies [PUT] +// @Security ApiKeyAuth +func CreateOrUpdateInspectionPolicy(_ *gin.Context) (*inspection.Policy, error) { + return nil, errors.NewNotImplemented("") +} + +// @ID GetInspectionPolicy +// @Summary get inspection policy +// @Description get inspection policy +// @Tags Inspection +// @Accept application/json +// @Produce application/json +// @Success 200 object response.APIResponse{data=inspection.Policy} +// @Failure 400 object response.APIResponse +// @Failure 401 object response.APIResponse +// @Failure 500 object response.APIResponse +// @Router /api/v1/inspection/policies/{namespace}/{name} [GET] +// @Security ApiKeyAuth +func GetInspectionPolicy(_ *gin.Context) (*inspection.Policy, error) { + return nil, errors.NewNotImplemented("") +} + +// @ID DeleteInspectionPolicy +// @Summary delete inspection policy +// @Description delete inspection policy +// @Tags Inspection +// @Accept application/json +// @Produce application/json +// @Success 200 object response.APIResponse{data=inspection.Policy} +// @Failure 400 object response.APIResponse +// @Failure 401 object response.APIResponse +// @Failure 500 object response.APIResponse +// @Router /api/v1/inspection/policies/{namespace}/{name}/{scenario} [DELETE] +// @Security ApiKeyAuth +func DeleteInspectionPolicy(_ *gin.Context) (*inspection.Policy, error) { + return nil, errors.NewNotImplemented("") +} + +// @ID TriggerInspection +// @Summary trigger inspection +// @Description trigger inspection +// @Tags Inspection +// @Accept application/json +// @Produce application/json +// @Success 200 object response.APIResponse{data=inspection.Policy} +// @Failure 400 object response.APIResponse +// @Failure 401 object response.APIResponse +// @Failure 500 object response.APIResponse +// @Router /api/v1/inspection/policies/{namespace}/{name}/{scenario} [POST] +// @Security ApiKeyAuth +func TriggerInspection(_ *gin.Context) (*inspection.Policy, error) { + return nil, errors.NewNotImplemented("") +} + +// @ID ListInspectionReports +// @Summary list inspection reports +// @Description list inspection reports +// @Tags Inspection +// @Accept application/json +// @Produce application/json +// @Success 200 object response.APIResponse{data=[]inspection.ReportBriefInfo} +// @Failure 400 object response.APIResponse +// @Failure 401 object response.APIResponse +// @Failure 500 object response.APIResponse +// @Router /api/v1/inspection/reports [GET] +// @Security ApiKeyAuth +func ListInspectionReports(_ *gin.Context) ([]inspection.ReportBriefInfo, error) { + return nil, errors.NewNotImplemented("") +} + +// @ID GetInspectionReport +// @Summary get inspection report +// @Description get inspection report +// @Tags Inspection +// @Accept application/json +// @Produce application/json +// @Success 200 object response.APIResponse{data=inspection.Report} +// @Failure 400 object response.APIResponse +// @Failure 401 object response.APIResponse +// @Failure 500 object response.APIResponse +// @Router /api/v1/inspection/reports/{id} [GET] +// @Security ApiKeyAuth +func GetInspectionReport(_ *gin.Context) (*inspection.Report, error) { + return nil, errors.NewNotImplemented("") +} diff --git a/internal/dashboard/model/inspection/job.go b/internal/dashboard/model/inspection/job.go new file mode 100644 index 000000000..d7ebef5fa --- /dev/null +++ b/internal/dashboard/model/inspection/job.go @@ -0,0 +1,22 @@ +/* +Copyright (c) 2023 OceanBase +ob-operator is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +package inspection + +type JobStatus string + +const ( + JobStatusSuccessful JobStatus = "successful" + JobStatusFailed JobStatus = "failed" + JobStatusRunning JobStatus = "running" + JobStatusPending JobStatus = "pending" +) diff --git a/internal/dashboard/model/inspection/policy.go b/internal/dashboard/model/inspection/policy.go new file mode 100644 index 000000000..f2206eb38 --- /dev/null +++ b/internal/dashboard/model/inspection/policy.go @@ -0,0 +1,43 @@ +/* +Copyright (c) 2023 OceanBase +ob-operator is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +package inspection + +import ( + "github.com/oceanbase/ob-operator/internal/dashboard/model/response" +) + +type InspectionScheduleStatus string + +const ( + ScheduleEnabled InspectionScheduleStatus = "enabled" + ScheduleDisabled InspectionScheduleStatus = "disabled" +) + +type InspectionScenario string + +const ( + ScenarioBasic InspectionScenario = "basic" + ScenarioPerformance InspectionScenario = "performance" +) + +type InspectionScheduleConfig struct { + Scenario InspectionScenario `json:"scenario" binding:"required"` + Crontab string `json:"crontab" binding:"required"` +} + +type Policy struct { + OBCluster response.OBClusterMeta `json:"obCluster" binding:"required"` + Status InspectionScheduleStatus `json:"status" binding:"required"` + ScheduleConfigs []InspectionScheduleConfig `json:"scheduleConfig,omitempty"` + LatestReports []ReportBriefInfo `json:"latestReports,omitempty"` +} diff --git a/internal/dashboard/model/inspection/report.go b/internal/dashboard/model/inspection/report.go new file mode 100644 index 000000000..4f3dae75f --- /dev/null +++ b/internal/dashboard/model/inspection/report.go @@ -0,0 +1,49 @@ +/* +Copyright (c) 2023 OceanBase +ob-operator is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +package inspection + +import "github.com/oceanbase/ob-operator/internal/dashboard/model/response" + +type ResultStatistics struct { + FailedCount int `json:"failedCount"` + CriticalCount int `json:"criticalCount"` + ModerateCount int `json:"moderateCount"` + NegligibleCount int `json:"negligibleCount"` +} + +type ReportBriefInfo struct { + Id string `json:"id" binding:"required"` + OBCluster response.OBClusterMeta `json:"obCluster" binding:"required"` + Scenario InspectionScenario `json:"scenario" binding:"required"` + ResultStatistics ResultStatistics `json:"resultStatistics" binding:"required"` + Status JobStatus `json:"status" binding:"required"` + StartTime int64 `json:"startTime,omitempty"` + FinishTime int64 `json:"finishTime,omitempty"` +} + +type InspectionItem struct { + Name string `json:"name" binding:"required"` + Results []string `json:"results,omitempty"` +} + +type ResultDetail struct { + CriticalItems []InspectionItem `json:"criticalItems,omitempty"` + ModerateItems []InspectionItem `json:"moderateItems,omitempty"` + NegligibleItems []InspectionItem `json:"negligibleItems,omitempty"` + FailedItems []InspectionItem `json:"failedItems,omitempty"` +} + +type Report struct { + ReportBriefInfo `json:",inline"` + ResultDetail ResultDetail `json:"resultDetail,omitempty"` +} diff --git a/internal/dashboard/model/response/obcluster.go b/internal/dashboard/model/response/obcluster.go index 122661e3b..fa9d9228d 100644 --- a/internal/dashboard/model/response/obcluster.go +++ b/internal/dashboard/model/response/obcluster.go @@ -51,19 +51,21 @@ type OBMetrics struct { DiskPercent int `json:"diskPercent" binding:"required"` } +type OBClusterMeta struct { + UID string `json:"uid" binding:"required"` + Name string `json:"name" binding:"required"` + Namespace string `json:"namespace" binding:"required"` + ClusterName string `json:"clusterName" binding:"required"` + ClusterId int64 `json:"clusterId" binding:"required"` + Mode common.ClusterMode `json:"mode" binding:"required"` +} type OBClusterOverview struct { - UID string `json:"uid" binding:"required"` - Name string `json:"name" binding:"required"` - Namespace string `json:"namespace" binding:"required"` - ClusterName string `json:"clusterName" binding:"required"` - ClusterId int64 `json:"clusterId" binding:"required"` - Status string `json:"status" binding:"required"` - StatusDetail string `json:"statusDetail" binding:"required"` - CreateTime int64 `json:"createTime" binding:"required"` - Image string `json:"image" binding:"required"` - Topology []OBZone `json:"topology" binding:"required"` - - Mode common.ClusterMode `json:"mode" binding:"required"` + OBClusterMeta `json:",inline"` + Status string `json:"status" binding:"required"` + StatusDetail string `json:"statusDetail" binding:"required"` + CreateTime int64 `json:"createTime" binding:"required"` + Image string `json:"image" binding:"required"` + Topology []OBZone `json:"topology" binding:"required"` } type OBCluster struct { diff --git a/internal/dashboard/router/router.go b/internal/dashboard/router/router.go index 51931a35a..c5366a9ae 100644 --- a/internal/dashboard/router/router.go +++ b/internal/dashboard/router/router.go @@ -84,5 +84,6 @@ func InitRoutes(router *gin.Engine) { v1.InitAlarmRoutes(v1Group) v1.InitOBProxyRoutes(v1Group) v1.InitAccessControlRoutes(v1Group) + v1.InitInspectionRoutes(v1Group) v1.InitSqlRoutes(v1Group) } diff --git a/internal/dashboard/router/v1/inspection_router.go b/internal/dashboard/router/v1/inspection_router.go new file mode 100644 index 000000000..a58246397 --- /dev/null +++ b/internal/dashboard/router/v1/inspection_router.go @@ -0,0 +1,29 @@ +/* +Copyright (c) 2023 OceanBase +ob-operator is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +*/ + +package v1 + +import ( + "github.com/gin-gonic/gin" + + acbiz "github.com/oceanbase/ob-operator/internal/dashboard/business/ac" + h "github.com/oceanbase/ob-operator/internal/dashboard/handler" +) + +func InitInspectionRoutes(g *gin.RouterGroup) { + g.GET("/inspection/policies", h.Wrap(h.ListInspectionPolicies, acbiz.PathGuard("obcluster", "*", "read"))) + g.PUT("/inspection/policies", h.Wrap(h.CreateOrUpdateInspectionPolicy, acbiz.PathGuard("obcluster", "*", "write"))) + g.DELETE("/inspection/policies/:namespace/:name/:scenario", h.Wrap(h.DeleteInspectionPolicy, acbiz.PathGuard("obcluster", "*", "write"))) + g.POST("/inspection/policies/:namespace/:name/:scenario/trigger", h.Wrap(h.TriggerInspection, acbiz.PathGuard("obcluster", "*", "write"))) + g.GET("/inspection/reports", h.Wrap(h.ListInspectionReports, acbiz.PathGuard("obcluster", "*", "read"))) + g.GET("/inspection/reports/:id", h.Wrap(h.GetInspectionReport, acbiz.PathGuard("obcluster", "*", "read"))) +}