1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/dashboard/client/api/endpoints/resource-quota.api.ts
Sebastian Malton b1ff34879a cleanup Lens repo with tighter linting
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
2020-07-09 17:00:23 -04:00

70 lines
1.6 KiB
TypeScript

import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface ResourceQuotaValues {
[quota: string]: string;
// Compute Resource Quota
"limits.cpu"?: string;
"limits.memory"?: string;
"requests.cpu"?: string;
"requests.memory"?: string;
// Storage Resource Quota
"requests.storage"?: string;
"persistentvolumeclaims"?: string;
// Object Count Quota
"count/pods"?: string;
"count/persistentvolumeclaims"?: string;
"count/services"?: string;
"count/secrets"?: string;
"count/configmaps"?: string;
"count/replicationcontrollers"?: string;
"count/deployments.apps"?: string;
"count/replicasets.apps"?: string;
"count/statefulsets.apps"?: string;
"count/jobs.batch"?: string;
"count/cronjobs.batch"?: string;
"count/deployments.extensions"?: string;
}
interface MatchExpression {
operator: string;
scopeName: string;
values: string[];
}
export class ResourceQuota extends KubeObject {
static kind = "ResourceQuota"
constructor(data: KubeJsonApiData) {
super(data);
this.spec = this.spec || {} as any;
}
spec: {
hard: ResourceQuotaValues;
scopeSelector?: {
matchExpressions: MatchExpression[];
};
}
status: {
hard: ResourceQuotaValues;
used: ResourceQuotaValues;
}
getScopeSelector(): MatchExpression[] {
return this.spec?.scopeSelector?.matchExpressions;
}
}
export const resourceQuotaApi = new KubeApi({
kind: ResourceQuota.kind,
apiBase: "/api/v1/resourcequotas",
isNamespaced: true,
objectConstructor: ResourceQuota,
});