refactor(frontend): services/api 迁至 src/api,http 迁至 utils/request
对齐 Vue 后台惯例: - src/api/ 域 API(原 services/api) - src/utils/request.ts HTTP 封装(原 services/http.ts) - src/utils/export.ts 客户端导出工具 - src/utils/index.ts 工具统一出口 全局导入改为 @/api 与 @/utils/request,tsc + build 通过。
This commit is contained in:
1 parent
9bf35b369c
commit
d19a03d427
145 files changed
+156
-142
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// 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`),
|
||||
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 }),
|
||||
};
|
||||
Reference in new issue
Block a user