- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器 - 新增 log_datasource.go model - 新增 monitor/log-center.ts API 模块 - 新增 LogCenter 前端组件及页面 - 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等) - 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件 - 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等) - 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等) - 更新静态资源 (index.html + 新 JS/CSS bundle) - 删除废弃静态资源文件
51 lines
3.2 KiB
TypeScript
51 lines
3.2 KiB
TypeScript
// Kubernetes 命名空间资源 / YAML / 事件 / 容量 API // Logan.Li
|
|
|
|
import { http } from '@/utils/request';
|
|
|
|
export const resourceApi = {
|
|
getNamespaceServices: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/services`),
|
|
getNamespaceIngresses: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/ingresses`),
|
|
// 获取 IngressClass 列表,用于 Ingress 可视化编辑的下拉选择 // Logan.Li
|
|
getIngressClasses: async (clusterCode: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/ingressclasses`),
|
|
getNamespaceConfigMaps: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/configmaps`),
|
|
getNamespaceSecrets: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/secrets`),
|
|
getPVCs: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/pvcs`),
|
|
deletePVC: async (clusterCode: string, namespace: string, name: string) =>
|
|
http.delete(`/kubernetes/${clusterCode}/namespace/${namespace}/pvcs/${name}`),
|
|
getServiceAccounts: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/serviceaccounts`),
|
|
getRoles: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/roles`),
|
|
getRoleBindings: async (clusterCode: string, namespace: string) =>
|
|
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/rolebindings`),
|
|
getResourceYaml: async (clusterCode: string, namespace: string, resource: string, name: string) =>
|
|
http.getRaw(`/kubernetes/${clusterCode}/namespace/${namespace}/${resource}/${name}/yaml`),
|
|
updateResourceYaml: async (clusterCode: string, namespace: string, resource: string, name: string, yaml: string) =>
|
|
http.putRaw(`/kubernetes/${clusterCode}/namespace/${namespace}/${resource}/${name}/yaml`, yaml, 'application/yaml'),
|
|
deleteResourceYaml: async (clusterCode: string, namespace: string, resource: string, name: string) =>
|
|
http.delete(`/kubernetes/${clusterCode}/namespace/${namespace}/${resource}/${name}/yaml`),
|
|
getEvents: async (clusterCode: string, namespace?: string, type?: string) => {
|
|
const params: Record<string, string> = {};
|
|
if (namespace) params.namespace = namespace;
|
|
if (type) params.type = type;
|
|
return http.get(`/kubernetes/${clusterCode}/events`, params);
|
|
},
|
|
getEventsSummary: async (clusterCode: string, namespace?: string, hours?: number) => {
|
|
const params: Record<string, string | number> = {};
|
|
if (namespace) params.namespace = namespace;
|
|
if (hours) params.hours = hours;
|
|
return http.get(`/kubernetes/${clusterCode}/events/summary`, params);
|
|
},
|
|
getCapacity: async (clusterCode: string, namespace?: string) => {
|
|
const params = namespace ? { namespace } : undefined;
|
|
return http.get(`/kubernetes/${clusterCode}/capacity`, params);
|
|
},
|
|
applyYAML: async (clusterCode: string, yaml: string) =>
|
|
http.post(`/kubernetes/${clusterCode}/yaml/apply`, { yaml }),
|
|
}; |