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