diff --git a/charts/oceanbase-cluster/Chart.yaml b/charts/oceanbase-cluster/Chart.yaml index 7ce0dffdd..5a0579710 100644 --- a/charts/oceanbase-cluster/Chart.yaml +++ b/charts/oceanbase-cluster/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 4.2.1-sp.6-106000012024042515 +version: 4.3.1-sp.0-100000032024051615 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "4.2.1.6-106000012024042515" +appVersion: 4.3.1.0-100000032024051615 diff --git a/docsite/static/index.yaml b/docsite/static/index.yaml index 9f3fa1887..b6c0ed1f0 100644 --- a/docsite/static/index.yaml +++ b/docsite/static/index.yaml @@ -62,6 +62,16 @@ entries: - https://github.com/oceanbase/ob-operator/releases/download/ob-operator-2.0.0/ob-operator-2.0.0.tgz version: 2.0.0 oceanbase-cluster: + - apiVersion: v2 + appVersion: 4.3.1.0-100000032024051615 + created: "2024-05-22T11:22:39.758486099Z" + description: A Helm chart for Kubernetes to deploy OceanBase cluster + digest: 441c578f4bd226e4b84948f8843faefb4ac441ef0cc2ee2fbdab3530e0ceac47 + name: oceanbase-cluster + type: application + urls: + - https://github.com/oceanbase/ob-operator/releases/download/oceanbase-cluster-4.3.1-sp.0-100000032024051615/oceanbase-cluster-4.3.1-sp.0-100000032024051615.tgz + version: 4.3.1-sp.0-100000032024051615 - apiVersion: v2 appVersion: 4.3.0.1-100000242024032211 created: "2024-04-16T06:22:47.179508074Z" @@ -133,4 +143,4 @@ entries: urls: - https://github.com/oceanbase/ob-operator/releases/download/oceanbase-dashboard-0.1.0/oceanbase-dashboard-0.1.0.tgz version: 0.1.0 -generated: "2024-05-20T04:00:41.425046287Z" +generated: "2024-05-22T11:22:39.758544248Z" diff --git a/internal/dashboard/generated/swagger/docs.go b/internal/dashboard/generated/swagger/docs.go index dd32f3825..81705d1a1 100644 --- a/internal/dashboard/generated/swagger/docs.go +++ b/internal/dashboard/generated/swagger/docs.go @@ -2998,6 +2998,22 @@ const docTemplate = `{ ], "summary": "Get OBProxy", "operationId": "GetOBProxy", + "parameters": [ + { + "type": "string", + "description": "namespace of obproxy deployment", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of obproxy deployment", + "name": "name", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -3055,6 +3071,22 @@ const docTemplate = `{ ], "summary": "Delete OBProxy", "operationId": "DeleteOBProxy", + "parameters": [ + { + "type": "string", + "description": "namespace of obproxy deployment", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of obproxy deployment", + "name": "name", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -3121,6 +3153,20 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/obproxy.PatchOBProxyParam" } + }, + { + "type": "string", + "description": "namespace of obproxy deployment", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of obproxy deployment", + "name": "name", + "in": "path", + "required": true } ], "responses": { diff --git a/internal/dashboard/generated/swagger/swagger.json b/internal/dashboard/generated/swagger/swagger.json index 60f21f820..84d3c5625 100644 --- a/internal/dashboard/generated/swagger/swagger.json +++ b/internal/dashboard/generated/swagger/swagger.json @@ -2991,6 +2991,22 @@ ], "summary": "Get OBProxy", "operationId": "GetOBProxy", + "parameters": [ + { + "type": "string", + "description": "namespace of obproxy deployment", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of obproxy deployment", + "name": "name", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -3048,6 +3064,22 @@ ], "summary": "Delete OBProxy", "operationId": "DeleteOBProxy", + "parameters": [ + { + "type": "string", + "description": "namespace of obproxy deployment", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of obproxy deployment", + "name": "name", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -3114,6 +3146,20 @@ "schema": { "$ref": "#/definitions/obproxy.PatchOBProxyParam" } + }, + { + "type": "string", + "description": "namespace of obproxy deployment", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of obproxy deployment", + "name": "name", + "in": "path", + "required": true } ], "responses": { diff --git a/internal/dashboard/generated/swagger/swagger.yaml b/internal/dashboard/generated/swagger/swagger.yaml index bc43e9216..c6b562db4 100644 --- a/internal/dashboard/generated/swagger/swagger.yaml +++ b/internal/dashboard/generated/swagger/swagger.yaml @@ -4086,6 +4086,17 @@ paths: - application/json description: Delete OBProxy by namespace and name operationId: DeleteOBProxy + parameters: + - description: namespace of obproxy deployment + in: path + name: namespace + required: true + type: string + - description: name of obproxy deployment + in: path + name: name + required: true + type: string produces: - application/json responses: @@ -4120,6 +4131,17 @@ paths: - application/json description: Get OBProxy by namespace and name operationId: GetOBProxy + parameters: + - description: namespace of obproxy deployment + in: path + name: namespace + required: true + type: string + - description: name of obproxy deployment + in: path + name: name + required: true + type: string produces: - application/json responses: @@ -4161,6 +4183,16 @@ paths: required: true schema: $ref: '#/definitions/obproxy.PatchOBProxyParam' + - description: namespace of obproxy deployment + in: path + name: namespace + required: true + type: string + - description: name of obproxy deployment + in: path + name: name + required: true + type: string produces: - application/json responses: diff --git a/internal/dashboard/handler/obproxy_handler.go b/internal/dashboard/handler/obproxy_handler.go index ca297a8fd..781a93e5d 100644 --- a/internal/dashboard/handler/obproxy_handler.go +++ b/internal/dashboard/handler/obproxy_handler.go @@ -67,6 +67,8 @@ func CreateOBProxy(c *gin.Context) (*obproxy.OBProxy, error) { // @Tags OBProxy // @Accept application/json // @Produce application/json +// @Param namespace path string true "namespace of obproxy deployment" +// @Param name path string true "name of obproxy deployment" // @Success 200 object response.APIResponse{data=obproxy.OBProxy} // @Failure 400 object response.APIResponse // @Failure 401 object response.APIResponse @@ -89,6 +91,8 @@ func GetOBProxy(c *gin.Context) (*obproxy.OBProxy, error) { // @Accept application/json // @Produce application/json // @Param body body obproxy.PatchOBProxyParam true "Request body for patching obproxy" +// @Param namespace path string true "namespace of obproxy deployment" +// @Param name path string true "name of obproxy deployment" // @Success 200 object response.APIResponse{data=obproxy.OBProxy} // @Failure 400 object response.APIResponse // @Failure 401 object response.APIResponse @@ -115,6 +119,8 @@ func PatchOBProxy(c *gin.Context) (*obproxy.OBProxy, error) { // @Tags OBProxy // @Accept application/json // @Produce application/json +// @Param namespace path string true "namespace of obproxy deployment" +// @Param name path string true "name of obproxy deployment" // @Success 200 object response.APIResponse{data=obproxy.OBProxy} // @Failure 400 object response.APIResponse // @Failure 401 object response.APIResponse diff --git a/ui/config/config.ts b/ui/config/config.ts index 0156ffb17..50c89aa2d 100644 --- a/ui/config/config.ts +++ b/ui/config/config.ts @@ -9,7 +9,6 @@ export default defineConfig({ request: {}, favicons: ['/logo.png'], title: 'OceanBase Dashboard', - mock: false, layout: false, locale: { default: 'zh-CN', diff --git a/ui/mock/alertAPI.ts b/ui/mock/alertAPI.ts index a9982d981..8013661c3 100644 --- a/ui/mock/alertAPI.ts +++ b/ui/mock/alertAPI.ts @@ -129,4 +129,90 @@ export default { message: 'string', successful: true, }, + 'GET /api/v1/alarm/silence/silencers/string': { + data: { + comment: 'string', + createdBy: 'string', + endsAt: 1716282320833, + id: 'string', + instances: [ + { + obcluster: 'string', + observer: 'string', + obtenant: 'string', + obzone: 'string', + type: 'obcluster', + }, + ], + rules: ['string'], + matchers: [ + { + isRegex: true, + name: 'string', + value: 'string', + }, + ], + startsAt: 0, + status: { + state: 'active', + }, + updatedAt: 0, + }, + message: 'string', + successful: true, + }, + 'GET /api/v1/alarm/rule/rules/string': { + data: { + description: 'string', + duration: 0, + evaluationTime: 0, + health: 'unknown', + instanceType: 'obcluster', + keepFiringFor: 0, + labels: [ + { + key: 'string', + value: 'string', + }, + ], + lastError: 'string', + lastEvaluation: 0, + name: 'string', + query: 'string', + serverity: 'critical', + state: 'active', + summary: 'string', + type: 'builtin', + }, + message: 'string', + successful: true, + }, + 'GET /api/v1/alarm/receiver/receivers/string': { + data: { + config: 'string', + name: 'string', + type: 'discord', + }, + message: 'string', + successful: true, + }, + 'GET /api/v1/alarm/route/routes/string': { + data: { + aggregateLabels: ['string'], + groupInterval: 0, + groupWait: 0, + id: 'string', + matchers: [ + { + isRegex: true, + name: 'string', + value: 'string', + }, + ], + receiver: 'string', + repeatInterval: 0, + }, + message: 'string', + successful: true, + }, }; diff --git a/ui/src/api/generated/api.ts b/ui/src/api/generated/api.ts index b81e5d620..8cfbef3dd 100644 --- a/ui/src/api/generated/api.ts +++ b/ui/src/api/generated/api.ts @@ -390,6 +390,31 @@ export interface CreateOBCluster200Response { */ 'successful': boolean; } +/** + * + * @export + * @interface CreateOBPROXY200Response + */ +export interface CreateOBPROXY200Response { + /** + * + * @type {ObproxyOBProxy} + * @memberof CreateOBPROXY200Response + */ + 'data': ObproxyOBProxy; + /** + * + * @type {string} + * @memberof CreateOBPROXY200Response + */ + 'message': string; + /** + * + * @type {boolean} + * @memberof CreateOBPROXY200Response + */ + 'successful': boolean; +} /** * * @export @@ -940,6 +965,31 @@ export interface ListOBClusters200Response { */ 'successful': boolean; } +/** + * + * @export + * @interface ListOBProxies200Response + */ +export interface ListOBProxies200Response { + /** + * + * @type {Array} + * @memberof ListOBProxies200Response + */ + 'data': Array; + /** + * + * @type {string} + * @memberof ListOBProxies200Response + */ + 'message': string; + /** + * + * @type {boolean} + * @memberof ListOBProxies200Response + */ + 'successful': boolean; +} /** * * @export @@ -1746,6 +1796,307 @@ export interface ModelsStorageSpec { */ 'storageSize'?: number; } +/** + * + * @export + * @interface ObproxyCreateOBProxyParam + */ +export interface ObproxyCreateOBProxyParam { + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'image': string; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'namespace': string; + /** + * + * @type {ObproxyK8sObject} + * @memberof ObproxyCreateOBProxyParam + */ + 'obCluster': ObproxyK8sObject; + /** + * + * @type {Array} + * @memberof ObproxyCreateOBProxyParam + */ + 'parameters'?: Array; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'proxyClusterName': string; + /** + * Password should be encrypted + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'proxySysPassword': string; + /** + * + * @type {number} + * @memberof ObproxyCreateOBProxyParam + */ + 'replicas': number; + /** + * + * @type {CommonResourceSpec} + * @memberof ObproxyCreateOBProxyParam + */ + 'resource': CommonResourceSpec; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'serviceType': ObproxyCreateOBProxyParamServiceTypeEnum; +} + +export const ObproxyCreateOBProxyParamServiceTypeEnum = { + ClusterIP: 'ClusterIP', + NodePort: 'NodePort', + LoadBalancer: 'LoadBalancer', + ExternalName: 'ExternalName' +} as const; + +export type ObproxyCreateOBProxyParamServiceTypeEnum = typeof ObproxyCreateOBProxyParamServiceTypeEnum[keyof typeof ObproxyCreateOBProxyParamServiceTypeEnum]; + +/** + * + * @export + * @interface ObproxyK8sObject + */ +export interface ObproxyK8sObject { + /** + * + * @type {string} + * @memberof ObproxyK8sObject + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyK8sObject + */ + 'namespace': string; +} +/** + * + * @export + * @interface ObproxyOBProxy + */ +export interface ObproxyOBProxy { + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'creationTime': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'image': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'namespace': string; + /** + * + * @type {ObproxyK8sObject} + * @memberof ObproxyOBProxy + */ + 'obCluster': ObproxyK8sObject; + /** + * + * @type {Array} + * @memberof ObproxyOBProxy + */ + 'parameters': Array; + /** + * + * @type {Array} + * @memberof ObproxyOBProxy + */ + 'pods': Array; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'proxyClusterName': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'proxySysSecret': string; + /** + * + * @type {number} + * @memberof ObproxyOBProxy + */ + 'replicas': number; + /** + * + * @type {CommonResourceSpec} + * @memberof ObproxyOBProxy + */ + 'resource': CommonResourceSpec; + /** + * + * @type {ResponseK8sService} + * @memberof ObproxyOBProxy + */ + 'service': ResponseK8sService; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'serviceIp': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'status': string; +} +/** + * + * @export + * @interface ObproxyOBProxyOverview + */ +export interface ObproxyOBProxyOverview { + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'creationTime': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'image': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'namespace': string; + /** + * + * @type {ObproxyK8sObject} + * @memberof ObproxyOBProxyOverview + */ + 'obCluster': ObproxyK8sObject; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'proxyClusterName': string; + /** + * + * @type {number} + * @memberof ObproxyOBProxyOverview + */ + 'replicas': number; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'serviceIp': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'status': string; +} +/** + * + * @export + * @interface ObproxyPatchOBProxyParam + */ +export interface ObproxyPatchOBProxyParam { + /** + * + * @type {Array} + * @memberof ObproxyPatchOBProxyParam + */ + 'addedParameters'?: Array; + /** + * + * @type {Array} + * @memberof ObproxyPatchOBProxyParam + */ + 'deletedParameters'?: Array; + /** + * + * @type {string} + * @memberof ObproxyPatchOBProxyParam + */ + 'image'?: string; + /** + * + * @type {number} + * @memberof ObproxyPatchOBProxyParam + */ + 'replicas'?: number; + /** + * + * @type {CommonResourceSpec} + * @memberof ObproxyPatchOBProxyParam + */ + 'resource'?: CommonResourceSpec; + /** + * + * @type {string} + * @memberof ObproxyPatchOBProxyParam + */ + 'serviceType'?: ObproxyPatchOBProxyParamServiceTypeEnum; +} + +export const ObproxyPatchOBProxyParamServiceTypeEnum = { + ClusterIP: 'ClusterIP', + NodePort: 'NodePort', + LoadBalancer: 'LoadBalancer', + ExternalName: 'ExternalName' +} as const; + +export type ObproxyPatchOBProxyParamServiceTypeEnum = typeof ObproxyPatchOBProxyParamServiceTypeEnum[keyof typeof ObproxyPatchOBProxyParamServiceTypeEnum]; + /** * * @export @@ -2918,19 +3269,74 @@ export interface ResponseBackupPolicy { /** * * @export - * @interface ResponseDashboardInfo + * @interface ResponseContainerInfo */ -export interface ResponseDashboardInfo { +export interface ResponseContainerInfo { /** * * @type {string} - * @memberof ResponseDashboardInfo + * @memberof ResponseContainerInfo */ - 'appName': string; + 'image': string; /** * - * @type {string} - * @memberof ResponseDashboardInfo + * @type {CommonResourceSpec} + * @memberof ResponseContainerInfo + */ + 'limits': CommonResourceSpec; + /** + * + * @type {string} + * @memberof ResponseContainerInfo + */ + 'name': string; + /** + * + * @type {Array} + * @memberof ResponseContainerInfo + */ + 'ports': Array; + /** + * + * @type {boolean} + * @memberof ResponseContainerInfo + */ + 'ready': boolean; + /** + * + * @type {CommonResourceSpec} + * @memberof ResponseContainerInfo + */ + 'requests': CommonResourceSpec; + /** + * + * @type {number} + * @memberof ResponseContainerInfo + */ + 'restartCount': number; + /** + * + * @type {string} + * @memberof ResponseContainerInfo + */ + 'startTime': string; +} +/** + * + * @export + * @interface ResponseDashboardInfo + */ +export interface ResponseDashboardInfo { + /** + * + * @type {string} + * @memberof ResponseDashboardInfo + */ + 'appName': string; + /** + * + * @type {string} + * @memberof ResponseDashboardInfo */ 'publicKey': string; /** @@ -3173,6 +3579,135 @@ export interface ResponseK8sNodeResource { */ 'memoryUsed': number; } +/** + * + * @export + * @interface ResponseK8sPodInfo + */ +export interface ResponseK8sPodInfo { + /** + * + * @type {Array} + * @memberof ResponseK8sPodInfo + */ + 'containers': Array; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'message': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'name': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'namespace': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'nodeName': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'podIP': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'reason': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'startTime': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'status': string; +} +/** + * + * @export + * @interface ResponseK8sService + */ +export interface ResponseK8sService { + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'clusterIP'?: string; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'externalIP'?: string; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'name'?: string; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'namespace'?: string; + /** + * + * @type {Array} + * @memberof ResponseK8sService + */ + 'ports'?: Array; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'type'?: string; +} +/** + * + * @export + * @interface ResponseK8sServicePort + */ +export interface ResponseK8sServicePort { + /** + * + * @type {string} + * @memberof ResponseK8sServicePort + */ + 'name'?: string; + /** + * + * @type {number} + * @memberof ResponseK8sServicePort + */ + 'port'?: number; + /** + * + * @type {number} + * @memberof ResponseK8sServicePort + */ + 'targetPort'?: number; +} /** * * @export @@ -4766,7 +5301,7 @@ export interface SilenceSilencerParam { * @type {Array} * @memberof SilenceSilencerParam */ - 'instance': Array; + 'instances': Array; /** * * @type {Array} @@ -7961,6 +8496,438 @@ export class OBClusterApi extends BaseAPI { +/** + * OBProxyApi - axios parameter creator + * @export + */ +export const OBProxyApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createOBPROXY: async (body: ObproxyCreateOBProxyParam, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'body' is not null or undefined + assertParamExists('createOBPROXY', 'body', body) + const localVarPath = `/api/v1/obproxies`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteOBProxy: async (namespace: string, name: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'namespace' is not null or undefined + assertParamExists('deleteOBProxy', 'namespace', namespace) + // verify required parameter 'name' is not null or undefined + assertParamExists('deleteOBProxy', 'name', name) + const localVarPath = `/api/v1/obproxies/{namespace}/{name}` + .replace(`{${"namespace"}}`, encodeURIComponent(String(namespace))) + .replace(`{${"name"}}`, encodeURIComponent(String(name))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getOBProxy: async (namespace: string, name: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'namespace' is not null or undefined + assertParamExists('getOBProxy', 'namespace', namespace) + // verify required parameter 'name' is not null or undefined + assertParamExists('getOBProxy', 'name', name) + const localVarPath = `/api/v1/obproxies/{namespace}/{name}` + .replace(`{${"namespace"}}`, encodeURIComponent(String(namespace))) + .replace(`{${"name"}}`, encodeURIComponent(String(name))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listOBProxies: async (ns?: string, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/obproxies`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + if (ns !== undefined) { + localVarQueryParameter['ns'] = ns; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + patchOBProxy: async (namespace: string, name: string, body: ObproxyPatchOBProxyParam, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'namespace' is not null or undefined + assertParamExists('patchOBProxy', 'namespace', namespace) + // verify required parameter 'name' is not null or undefined + assertParamExists('patchOBProxy', 'name', name) + // verify required parameter 'body' is not null or undefined + assertParamExists('patchOBProxy', 'body', body) + const localVarPath = `/api/v1/obproxies/{namespace}/{name}` + .replace(`{${"namespace"}}`, encodeURIComponent(String(namespace))) + .replace(`{${"name"}}`, encodeURIComponent(String(name))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * OBProxyApi - functional programming interface + * @export + */ +export const OBProxyApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = OBProxyApiAxiosParamCreator(configuration) + return { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createOBPROXY(body: ObproxyCreateOBProxyParam, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createOBPROXY(body, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.createOBPROXY']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deleteOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deleteOBProxy(namespace, name, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.deleteOBProxy']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getOBProxy(namespace, name, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.getOBProxy']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async listOBProxies(ns?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.listOBProxies(ns, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.listOBProxies']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async patchOBProxy(namespace: string, name: string, body: ObproxyPatchOBProxyParam, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.patchOBProxy(namespace, name, body, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.patchOBProxy']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * OBProxyApi - factory interface + * @export + */ +export const OBProxyApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = OBProxyApiFp(configuration) + return { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createOBPROXY(body: ObproxyCreateOBProxyParam, options?: any): AxiosPromise { + return localVarFp.createOBPROXY(body, options).then((request) => request(axios, basePath)); + }, + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteOBProxy(namespace: string, name: string, options?: any): AxiosPromise { + return localVarFp.deleteOBProxy(namespace, name, options).then((request) => request(axios, basePath)); + }, + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getOBProxy(namespace: string, name: string, options?: any): AxiosPromise { + return localVarFp.getOBProxy(namespace, name, options).then((request) => request(axios, basePath)); + }, + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listOBProxies(ns?: string, options?: any): AxiosPromise { + return localVarFp.listOBProxies(ns, options).then((request) => request(axios, basePath)); + }, + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + patchOBProxy(namespace: string, name: string, body: ObproxyPatchOBProxyParam, options?: any): AxiosPromise { + return localVarFp.patchOBProxy(namespace, name, body, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * OBProxyApi - object-oriented interface + * @export + * @class OBProxyApi + * @extends {BaseAPI} + */ +export class OBProxyApi extends BaseAPI { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public createOBPROXY(body: ObproxyCreateOBProxyParam, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).createOBPROXY(body, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public deleteOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).deleteOBProxy(namespace, name, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public getOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).getOBProxy(namespace, name, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public listOBProxies(ns?: string, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).listOBProxies(ns, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public patchOBProxy(namespace: string, name: string, body: ObproxyPatchOBProxyParam, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).patchOBProxy(namespace, name, body, options).then((request) => request(this.axios, this.basePath)); + } +} + + + /** * OBTenantApi - axios parameter creator * @export diff --git a/ui/src/components/InputLabel/index.tsx b/ui/src/components/InputLabel/index.tsx index 570b6984d..cce9bb527 100644 --- a/ui/src/components/InputLabel/index.tsx +++ b/ui/src/components/InputLabel/index.tsx @@ -1,6 +1,6 @@ import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'; import { Button, Checkbox, Col, Form, Input, Popconfirm, Row } from 'antd'; -import styles from './index.less' +import styles from './index.less'; interface InputLabelProps { wrapFormName: string; @@ -8,6 +8,7 @@ interface InputLabelProps { valueFormName: string; regBoxFormName?: string; showDelete?: boolean; + maxCount?: number; } export default function InputLabel({ @@ -16,6 +17,7 @@ export default function InputLabel({ valueFormName, regBoxFormName, showDelete = true, + maxCount, }: InputLabelProps) { return ( @@ -24,12 +26,12 @@ export default function InputLabel({
{fields.map(({ key, name }, index) => ( - + - + @@ -43,7 +45,7 @@ export default function InputLabel({ )} {showDelete && fields.length > 1 && ( - + ))} - - - - - - - + {!maxCount || fields.length < maxCount ? ( + + + + + + + + ) : null}
); }} diff --git a/ui/src/pages/Alert/AlarmFilter/index.tsx b/ui/src/pages/Alert/AlarmFilter/index.tsx index 483607ee3..6c598bcba 100644 --- a/ui/src/pages/Alert/AlarmFilter/index.tsx +++ b/ui/src/pages/Alert/AlarmFilter/index.tsx @@ -10,8 +10,8 @@ import { useUpdateEffect } from 'ahooks'; import type { FormInstance } from 'antd'; import { Button, Col, DatePicker, Form, Input, Row, Select, Tag } from 'antd'; import { useEffect, useState } from 'react'; -import type { ServersList, TenantsList } from '../helper'; import { getSelectList } from '../helper'; +import { Alert } from '@/type/alert'; interface AlarmFilterProps { form: FormInstance; @@ -42,7 +42,7 @@ export default function AlarmFilter({ form, type }: AlarmFilterProps) { })); } if (type === 'obtenant') { - return (list as TenantsList[]).map((cluster) => ({ + return (list as Alert.TenantsList[]).map((cluster) => ({ label: {cluster.clusterName}, title: cluster.clusterName, options: cluster.tenants?.map((item) => ({ @@ -52,7 +52,7 @@ export default function AlarmFilter({ form, type }: AlarmFilterProps) { })); } if (type === 'observer') { - return (list as ServersList[]).map((cluster) => ({ + return (list as Alert.ServersList[]).map((cluster) => ({ label: {cluster.clusterName}, title: cluster.clusterName, options: cluster.servers?.map((item) => ({ diff --git a/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx b/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx index 4a4f5af7b..5caa4d01b 100644 --- a/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx +++ b/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx @@ -1,8 +1,10 @@ +import { alert } from '@/api'; import AlertDrawer from '@/components/AlertDrawer'; import InputLabel from '@/components/InputLabel'; +import { LEVER_OPTIONS_ALARM, SERVERITY_MAP } from '@/constants'; import { QuestionCircleOutlined } from '@ant-design/icons'; import type { DrawerProps } from 'antd'; -import { Col, Form, Input, InputNumber, Row, Select } from 'antd'; +import { Col, Form, Input, InputNumber, Row, Select, Tag } from 'antd'; import { useEffect } from 'react'; type AlertRuleDrawerProps = { @@ -25,9 +27,13 @@ export default function RuleDrawerForm({ useEffect(() => { if (ruleName) { - // Something to do + alert.getRule(ruleName).then(({ data, successful }) => { + if (successful) { + form.setFieldsValue({ ...data }); + } + }); } - }, []); + }, [ruleName]); return ( - - ({ + value: item.value, + label: ( + + {item.label} + + ), + }))} + placeholder="请选择" + /> @@ -90,7 +115,7 @@ export default function RuleDrawerForm({ }, ]} label="持续时间" - name={'description'} + name={'duration'} > diff --git a/ui/src/pages/Alert/Rules/index.tsx b/ui/src/pages/Alert/Rules/index.tsx index 888155fdf..835bf6490 100644 --- a/ui/src/pages/Alert/Rules/index.tsx +++ b/ui/src/pages/Alert/Rules/index.tsx @@ -14,6 +14,7 @@ const { Text } = Typography; export default function Rules() { const [form] = Form.useForm(); const { data: listRulesRes, refresh } = useRequest(alert.listRules); + const [editRuleName,setEditRuleName] = useState() const { run: deleteRule } = useRequest(alert.deleteRule, { onSuccess: ({ successful }) => { if (successful) { @@ -24,6 +25,11 @@ export default function Rules() { const [drawerOpen, setDrawerOpen] = useState(false); const listRules = listRulesRes?.data || []; + const editRule = (ruleName:string)=>{ + setEditRuleName(ruleName); + setDrawerOpen(true); + } + const columns: ColumnsType = [ { title: '告警规则名', @@ -66,7 +72,7 @@ export default function Rules() { dataIndex: 'action', render: (_, record) => ( <> -