-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperations.ts
144 lines (137 loc) · 6.75 KB
/
operations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
export interface NoOpts {
abortSignal?: AbortSignal;
};
export interface GetListOpts {
continue?: string;
fieldSelector?: string;
labelSelector?: string;
limit?: number;
resourceVersion?: string;
resourceVersionMatch?: "Exact" | "NotOlderThan";
sendInitialEvents?: boolean;
timeoutSeconds?: number;
abortSignal?: AbortSignal;
};
export function formatGetListOpts(opts: GetListOpts): URLSearchParams {
const query = new URLSearchParams;
if (opts["continue"] != null) query.append("continue", opts["continue"]);
if (opts["fieldSelector"] != null) query.append("fieldSelector", opts["fieldSelector"]);
if (opts["labelSelector"] != null) query.append("labelSelector", opts["labelSelector"]);
if (opts["limit"] != null) query.append("limit", String(opts["limit"]));
if (opts["resourceVersion"] != null) query.append("resourceVersion", opts["resourceVersion"]);
if (opts["resourceVersionMatch"] != null) query.append("resourceVersionMatch", opts["resourceVersionMatch"]);
if (opts["sendInitialEvents"] != null) query.append("sendInitialEvents", opts["sendInitialEvents"] ? '1' : '0');
if (opts["timeoutSeconds"] != null) query.append("timeoutSeconds", String(opts["timeoutSeconds"]));
return query;
}
export interface WatchListOpts {
allowWatchBookmarks?: boolean;
fieldSelector?: string;
labelSelector?: string;
resourceVersion?: string;
resourceVersionMatch?: "Exact" | "NotOlderThan";
sendInitialEvents?: boolean;
timeoutSeconds?: number;
abortSignal?: AbortSignal;
};
export function formatWatchListOpts(opts: WatchListOpts): URLSearchParams {
const query = new URLSearchParams([['watch', '1']]);
if (opts["allowWatchBookmarks"] != null) query.append("allowWatchBookmarks", opts["allowWatchBookmarks"] ? '1' : '0');
if (opts["fieldSelector"] != null) query.append("fieldSelector", opts["fieldSelector"]);
if (opts["labelSelector"] != null) query.append("labelSelector", opts["labelSelector"]);
if (opts["resourceVersion"] != null) query.append("resourceVersion", opts["resourceVersion"]);
if (opts["resourceVersionMatch"] != null) query.append("resourceVersionMatch", opts["resourceVersionMatch"]);
if (opts["sendInitialEvents"] != null) query.append("sendInitialEvents", opts["sendInitialEvents"] ? '1' : '0');
if (opts["timeoutSeconds"] != null) query.append("timeoutSeconds", String(opts["timeoutSeconds"]));
return query;
}
export interface PutOpts {
dryRun?: string;
fieldManager?: string;
fieldValidation?: string;
abortSignal?: AbortSignal;
};
export function formatPutOpts(opts: PutOpts): URLSearchParams {
const query = new URLSearchParams;
if (opts["dryRun"] != null) query.append("dryRun", opts["dryRun"]);
if (opts["fieldManager"] != null) query.append("fieldManager", opts["fieldManager"]);
if (opts["fieldValidation"] != null) query.append("fieldValidation", opts["fieldValidation"]);
return query;
}
export interface DeleteListOpts {
continue?: string;
dryRun?: string;
fieldSelector?: string;
gracePeriodSeconds?: number;
ignoreStoreReadErrorWithClusterBreakingPotential?: boolean;
labelSelector?: string;
limit?: number;
orphanDependents?: boolean;
propagationPolicy?: string;
resourceVersion?: string;
resourceVersionMatch?: "Exact" | "NotOlderThan";
sendInitialEvents?: boolean;
timeoutSeconds?: number;
abortSignal?: AbortSignal;
};
export function formatDeleteListOpts(opts: DeleteListOpts): URLSearchParams {
const query = new URLSearchParams;
if (opts["continue"] != null) query.append("continue", opts["continue"]);
if (opts["dryRun"] != null) query.append("dryRun", opts["dryRun"]);
if (opts["fieldSelector"] != null) query.append("fieldSelector", opts["fieldSelector"]);
if (opts["gracePeriodSeconds"] != null) query.append("gracePeriodSeconds", String(opts["gracePeriodSeconds"]));
if (opts["ignoreStoreReadErrorWithClusterBreakingPotential"] != null) query.append("ignoreStoreReadErrorWithClusterBreakingPotential", opts["ignoreStoreReadErrorWithClusterBreakingPotential"] ? '1' : '0');
if (opts["labelSelector"] != null) query.append("labelSelector", opts["labelSelector"]);
if (opts["limit"] != null) query.append("limit", String(opts["limit"]));
if (opts["orphanDependents"] != null) query.append("orphanDependents", opts["orphanDependents"] ? '1' : '0');
if (opts["propagationPolicy"] != null) query.append("propagationPolicy", opts["propagationPolicy"]);
if (opts["resourceVersion"] != null) query.append("resourceVersion", opts["resourceVersion"]);
if (opts["resourceVersionMatch"] != null) query.append("resourceVersionMatch", opts["resourceVersionMatch"]);
if (opts["sendInitialEvents"] != null) query.append("sendInitialEvents", opts["sendInitialEvents"] ? '1' : '0');
if (opts["timeoutSeconds"] != null) query.append("timeoutSeconds", String(opts["timeoutSeconds"]));
return query;
}
export interface PatchOpts {
dryRun?: string;
fieldManager?: string;
fieldValidation?: string;
force?: boolean;
abortSignal?: AbortSignal;
};
export function formatPatchOpts(opts: PatchOpts): URLSearchParams {
const query = new URLSearchParams;
if (opts["dryRun"] != null) query.append("dryRun", opts["dryRun"]);
if (opts["fieldManager"] != null) query.append("fieldManager", opts["fieldManager"]);
if (opts["fieldValidation"] != null) query.append("fieldValidation", opts["fieldValidation"]);
if (opts["force"] != null) query.append("force", opts["force"] ? '1' : '0');
return query;
}
// exact/export were fully gone in Kubernetes v1.21, so this struct isn't used anymore
export interface GetOpts {
exact?: boolean;
export?: boolean;
abortSignal?: AbortSignal;
};
export function formatGetOpts(opts: GetOpts): URLSearchParams {
const query = new URLSearchParams;
if (opts["exact"] != null) query.append("exact", opts["exact"] ? '1' : '0');
if (opts["export"] != null) query.append("export", opts["export"] ? '1' : '0');
return query;
}
export interface DeleteOpts {
dryRun?: string;
gracePeriodSeconds?: number;
ignoreStoreReadErrorWithClusterBreakingPotential?: boolean;
orphanDependents?: boolean;
propagationPolicy?: string;
abortSignal?: AbortSignal;
};
export function formatDeleteOpts(opts: DeleteOpts): URLSearchParams {
const query = new URLSearchParams;
if (opts["dryRun"] != null) query.append("dryRun", opts["dryRun"]);
if (opts["gracePeriodSeconds"] != null) query.append("gracePeriodSeconds", String(opts["gracePeriodSeconds"]));
if (opts["ignoreStoreReadErrorWithClusterBreakingPotential"] != null) query.append("ignoreStoreReadErrorWithClusterBreakingPotential", opts["ignoreStoreReadErrorWithClusterBreakingPotential"] ? '1' : '0');
if (opts["orphanDependents"] != null) query.append("orphanDependents", opts["orphanDependents"] ? '1' : '0');
if (opts["propagationPolicy"] != null) query.append("propagationPolicy", opts["propagationPolicy"]);
return query;
}