UNPKG

2.63 kBTypeScriptView Raw
1import { IKubernetesClientConfig } from "./config";
2import { Selector } from "./label";
3import { MetadataObject } from "./types/meta";
4import { DeleteOptions, WatchEvent } from "./types/meta/v1";
5export declare type RequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
6export declare type SelectorOptions = {
7 labelSelector?: Selector;
8 fieldSelector?: Selector;
9};
10export declare type MandatorySelectorOptions = {
11 labelSelector: Selector;
12} | {
13 fieldSelector: Selector;
14};
15export declare type WatchOptions = SelectorOptions & {
16 resourceVersion?: number;
17 abortAfterErrorCount?: number;
18 resyncAfterIterations?: number;
19 onError?: (err: any) => void;
20 onEstablished?: () => void;
21 pingIntervalSeconds?: number;
22};
23export declare type ListOptions = SelectorOptions;
24export interface WatchResult {
25 resourceVersion: number;
26 resyncRequired?: boolean;
27}
28export declare const patchKindStrategicMergePatch = "application/stategic-merge-patch+json";
29export declare const patchKindMergePatch = "application/merge-patch+json";
30export declare const patchKindJSONPatch = "application/json-patch+json";
31export declare type PatchKind = typeof patchKindStrategicMergePatch | typeof patchKindMergePatch | typeof patchKindJSONPatch;
32export interface IKubernetesRESTClient {
33 post<R = any>(url: string, body: any): Promise<R>;
34 put<R = any>(url: string, body: any): Promise<R>;
35 patch<R = any>(url: string, body: any, patchKind: PatchKind): Promise<R>;
36 delete<R = any>(url: string, opts?: DeleteOptions, queryParams?: {
37 [k: string]: string;
38 }, body?: any): Promise<R>;
39 get<R = any>(url: string, opts?: ListOptions): Promise<R | undefined>;
40 watch<R extends MetadataObject = MetadataObject>(url: string, onUpdate: (o: WatchEvent<R>) => any, onError: (err: any) => any, opts?: WatchOptions): Promise<WatchResult>;
41}
42export declare class KubernetesRESTClient implements IKubernetesRESTClient {
43 private config;
44 constructor(config: IKubernetesClientConfig);
45 private request;
46 post<R = any>(url: string, body: any): Promise<R>;
47 put<R = any>(url: string, body: any): Promise<R>;
48 patch<R = any>(url: string, body: any, patchKind: PatchKind): Promise<R>;
49 delete<R = any>(url: string, deleteOptions?: ListOptions, queryParams?: {
50 [k: string]: string;
51 }, body?: any): Promise<R>;
52 watch<R extends MetadataObject = MetadataObject>(url: string, onUpdate: (o: WatchEvent<R>) => any, onError: (err: any) => any, watchOpts?: WatchOptions): Promise<WatchResult>;
53 get<R = any>(url: string, listOptions?: ListOptions): Promise<R | undefined>;
54}
55
\No newline at end of file