UNPKG

2.57 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};
21export declare type ListOptions = SelectorOptions;
22export interface WatchResult {
23 resourceVersion: number;
24 resyncRequired?: boolean;
25}
26export declare const patchKindStrategicMergePatch = "application/stategic-merge-patch+json";
27export declare const patchKindMergePatch = "application/merge-patch+json";
28export declare const patchKindJSONPatch = "application/json-patch+json";
29export declare type PatchKind = typeof patchKindStrategicMergePatch | typeof patchKindMergePatch | typeof patchKindJSONPatch;
30export interface IKubernetesRESTClient {
31 post<R = any>(url: string, body: any): Promise<R>;
32 put<R = any>(url: string, body: any): Promise<R>;
33 patch<R = any>(url: string, body: any, patchKind: PatchKind): Promise<R>;
34 delete<R = any>(url: string, opts?: DeleteOptions, queryParams?: {
35 [k: string]: string;
36 }, body?: any): Promise<R>;
37 get<R = any>(url: string, opts?: ListOptions): Promise<R | undefined>;
38 watch<R extends MetadataObject = MetadataObject>(url: string, onUpdate: (o: WatchEvent<R>) => any, onError: (err: any) => any, opts?: WatchOptions): Promise<WatchResult>;
39}
40export declare class KubernetesRESTClient implements IKubernetesRESTClient {
41 private config;
42 constructor(config: IKubernetesClientConfig);
43 private request;
44 post<R = any>(url: string, body: any): Promise<R>;
45 put<R = any>(url: string, body: any): Promise<R>;
46 patch<R = any>(url: string, body: any, patchKind: PatchKind): Promise<R>;
47 delete<R = any>(url: string, deleteOptions?: ListOptions, queryParams?: {
48 [k: string]: string;
49 }, body?: any): Promise<R>;
50 watch<R extends MetadataObject = MetadataObject>(url: string, onUpdate: (o: WatchEvent<R>) => any, onError: (err: any) => any, watchOpts?: WatchOptions): Promise<WatchResult>;
51 get<R = any>(url: string, listOptions?: ListOptions): Promise<R | undefined>;
52}
53
\No newline at end of file