@mittwald/kubernetes
Version:
Kubernetes client library
55 lines (54 loc) • 2.64 kB
TypeScript
import { IKubernetesClientConfig } from "./config";
import { Selector } from "./label";
import { MetadataObject } from "./types/meta";
import { DeleteOptions, WatchEvent } from "./types/meta/v1";
export declare type RequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
export interface SelectorOptions {
labelSelector?: Selector;
fieldSelector?: Selector;
}
export declare type MandatorySelectorOptions = {
labelSelector: Selector;
} | {
fieldSelector: Selector;
};
export declare type WatchOptions = SelectorOptions & {
resourceVersion?: number;
abortAfterErrorCount?: number;
resyncAfterIterations?: number;
onError?: (err: any) => void;
onEstablished?: () => void;
pingIntervalSeconds?: number;
};
export declare type ListOptions = SelectorOptions;
export interface WatchResult {
resourceVersion: number;
resyncRequired?: boolean;
}
export declare const patchKindStrategicMergePatch = "application/stategic-merge-patch+json";
export declare const patchKindMergePatch = "application/merge-patch+json";
export declare const patchKindJSONPatch = "application/json-patch+json";
export declare type PatchKind = typeof patchKindStrategicMergePatch | typeof patchKindMergePatch | typeof patchKindJSONPatch;
export interface IKubernetesRESTClient {
post<R = any>(url: string, body: any): Promise<R>;
put<R = any>(url: string, body: any): Promise<R>;
patch<R = any>(url: string, body: any, patchKind: PatchKind): Promise<R>;
delete<R = any>(url: string, opts?: DeleteOptions, queryParams?: {
[k: string]: string;
}, body?: any): Promise<R>;
get<R = any>(url: string, opts?: ListOptions): Promise<R | undefined>;
watch<R extends MetadataObject = MetadataObject>(url: string, onUpdate: (o: WatchEvent<R>) => any, onError: (err: any) => any, opts?: WatchOptions): Promise<WatchResult>;
}
export declare class KubernetesRESTClient implements IKubernetesRESTClient {
private readonly config;
constructor(config: IKubernetesClientConfig);
private request;
post<R = any>(url: string, body: any): Promise<R>;
put<R = any>(url: string, body: any): Promise<R>;
patch<R = any>(url: string, body: any, patchKind: PatchKind): Promise<R>;
delete<R = any>(url: string, deleteOptions?: ListOptions, queryParams?: {
[k: string]: string;
}, body?: any): Promise<R>;
watch<R extends MetadataObject = MetadataObject>(url: string, onUpdate: (o: WatchEvent<R>) => any, onError: (err: any) => any, watchOpts?: WatchOptions): Promise<WatchResult>;
get<R = any>(url: string, listOptions?: ListOptions): Promise<R | undefined>;
}