UNPKG

6.91 kBJavaScriptView Raw
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5}) : (function(o, m, k, k2) {
6 if (k2 === undefined) k2 = k;
7 o[k2] = m[k];
8}));
9var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10 Object.defineProperty(o, "default", { enumerable: true, value: v });
11}) : function(o, v) {
12 o["default"] = v;
13});
14var __importStar = (this && this.__importStar) || function (mod) {
15 if (mod && mod.__esModule) return mod;
16 var result = {};
17 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18 __setModuleDefault(result, mod);
19 return result;
20};
21Object.defineProperty(exports, "__esModule", { value: true });
22exports.KubernetesAPI = void 0;
23const resource_1 = require("./resource");
24const resourceAppsV1beta1 = __importStar(require("./apis/apps/v1beta1"));
25const resourceExtensionsV1beta1 = __importStar(require("./apis/extensions/v1beta1"));
26const admregv1 = __importStar(require("./types/admissionregistration/v1"));
27const prom_client_1 = require("prom-client");
28class KubernetesAPI {
29 constructor(restClient, registry = prom_client_1.register) {
30 this.restClient = restClient;
31 this.registry = registry;
32 }
33 nc(apiBaseURL, resourceBaseURL) {
34 return new resource_1.NamespacedResourceClient(this.restClient, apiBaseURL, resourceBaseURL, this.registry);
35 }
36 c(apiBaseURL, resourceBaseURL) {
37 return new resource_1.ResourceClient(this.restClient, apiBaseURL, resourceBaseURL, this.registry);
38 }
39 extend(name, customResourceAPI) {
40 this[name] = () => customResourceAPI[name]();
41 return this;
42 }
43 admissionRegistration() {
44 return {
45 v1: () => ({
46 validatingWebhookConfigurations: () => this.c(`/apis/${admregv1.apiGroup}`, "/validatingwebhookconfigurations"),
47 }),
48 };
49 }
50 apiextensions() {
51 return {
52 v1beta1: () => ({
53 customResourceDefinitions: () => this.c("/apis/apiextensions.k8s.io/v1beta1", "/customresourcedefinitions"),
54 }),
55 v1: () => ({
56 customResourceDefinitions: () => this.c("/apis/apiextensions.k8s.io/v1", "/customresourcedefinitions"),
57 }),
58 };
59 }
60 certificates() {
61 return {
62 v1beta1: () => ({
63 certificateSigningRequests: () => this.c("/apis/certificates.k8s.io/v1beta1", "/certificatesigningrequests"),
64 }),
65 };
66 }
67 core() {
68 return {
69 v1: () => ({
70 configMaps: () => this.nc("/api/v1", "/configmaps"),
71 endpoints: () => this.nc("/api/v1", "/endpoints"),
72 namespaces: () => this.c("/api/v1", "/namespaces"),
73 nodes: () => this.c("/api/v1", "/nodes"),
74 pods: () => this.nc("/api/v1", "/pods"),
75 persistentVolumes: () => this.c("/api/v1", "/persistentvolumes"),
76 persistentVolumeClaims: () => this.nc("/api/v1", "/persistentvolumeclaims"),
77 services: () => {
78 const client = new resource_1.NamespacedResourceClient(this.restClient, "/api/v1", "/services", this.registry);
79 client.supportsCollectionDeletion = false;
80 return client;
81 },
82 secrets: () => this.nc("/api/v1", "/secrets"),
83 serviceAccounts: () => this.nc("/api/v1", "/serviceaccounts"),
84 }),
85 };
86 }
87 apps() {
88 return {
89 v1: () => ({
90 daemonSets: () => this.nc("/apis/apps/v1", "/daemonsets"),
91 deployments: () => this.nc("/apis/apps/v1", "/deployments"),
92 replicaSets: () => this.nc("/apis/apps/v1", "/replicasets"),
93 statefulSets: () => this.nc("/apis/apps/v1", "/statefulsets"),
94 }),
95 v1beta1: () => ({
96 deployments: () => new resourceAppsV1beta1.DeploymentResourceClient(this.restClient, this.registry),
97 statefulSets: () => new resourceAppsV1beta1.StatefulSetResourceClient(this.restClient, this.registry),
98 }),
99 };
100 }
101 batch() {
102 return {
103 v1: () => ({
104 jobs: () => this.nc("/apis/batch/v1", "/jobs"),
105 }),
106 v1beta1: () => ({
107 cronJobs: () => this.nc("/apis/batch/v1beta1", "/cronjobs"),
108 }),
109 };
110 }
111 extensions() {
112 return {
113 v1beta1: () => ({
114 daemonSets: () => this.nc("/apis/extensions/v1beta1", "/daemonsets"),
115 deployments: () => new resourceExtensionsV1beta1.DeploymentResourceClient(this.restClient, this.registry),
116 ingresses: () => this.nc("/apis/extensions/v1beta1", "/ingresses"),
117 networkPolicies: () => this.nc("/apis/extensions/v1beta1", "/networkpolicies"),
118 replicaSets: () => this.nc("/apis/extensions/v1beta1", "/replicasets"),
119 }),
120 };
121 }
122 rbac() {
123 return {
124 v1: () => ({
125 clusterRoles: () => new resource_1.ResourceClient(this.restClient, "/apis/rbac.authorization.k8s.io/v1", "/clusterroles", this.registry),
126 clusterRoleBindings: () => new resource_1.ResourceClient(this.restClient, "/apis/rbac.authorization.k8s.io/v1", "/clusterrolebindings", this.registry),
127 roles: () => new resource_1.NamespacedResourceClient(this.restClient, "/apis/rbac.authorization.k8s.io/v1", "/roles", this.registry),
128 roleBindings: () => new resource_1.NamespacedResourceClient(this.restClient, "/apis/rbac.authorization.k8s.io/v1", "/rolebindings", this.registry),
129 }),
130 v1beta1: () => ({
131 roles: () => new resource_1.NamespacedResourceClient(this.restClient, "/apis/rbac.authorization.k8s.io/v1beta1", "/roles", this.registry),
132 roleBindings: () => new resource_1.NamespacedResourceClient(this.restClient, "/apis/rbac.authorization.k8s.io/v1beta1", "/rolebindings", this.registry),
133 }),
134 };
135 }
136 policy() {
137 return {
138 v1beta1: () => ({
139 podDisruptionBudgets: () => new resource_1.NamespacedResourceClient(this.restClient, "/apis/policy/v1beta1", "/poddisruptionbudgets", this.registry),
140 }),
141 };
142 }
143 autoscaling() {
144 return {
145 v1: () => ({
146 horizontalPodAutoscalers: () => this.nc("/apis/autoscaling/v1", "/horizontalpodautoscalers"),
147 }),
148 };
149 }
150}
151exports.KubernetesAPI = KubernetesAPI;
152//# sourceMappingURL=api.js.map
\No newline at end of file