@@ -84,7 +84,8 @@ Task<IList<TEntity>> ListAsync(
84
84
/// <returns>A list of Kubernetes entities.</returns>
85
85
Task < IList < TEntity > > ListAsync (
86
86
string ? @namespace = null ,
87
- params LabelSelector [ ] labelSelectors ) ;
87
+ params LabelSelector [ ] labelSelectors )
88
+ => ListAsync ( @namespace , labelSelectors . ToExpression ( ) ) ;
88
89
89
90
/// <inheritdoc cref="ListAsync(string?,string?)"/>
90
91
IList < TEntity > List (
@@ -94,7 +95,8 @@ IList<TEntity> List(
94
95
/// <inheritdoc cref="ListAsync(string?,LabelSelector[])"/>
95
96
IList < TEntity > List (
96
97
string ? @namespace = null ,
97
- params LabelSelector [ ] labelSelectors ) ;
98
+ params LabelSelector [ ] labelSelectors )
99
+ => List ( @namespace , labelSelectors . ToExpression ( ) ) ;
98
100
99
101
/// <summary>
100
102
/// Create or Update a entity. This first fetches the entity from the Kubernetes API
@@ -108,22 +110,71 @@ IList<TEntity> List(
108
110
_ => await CreateAsync ( entity ) ,
109
111
} ;
110
112
111
- /// <inheritdoc cref="SaveAsync"/>
113
+ /// <summary>
114
+ /// Create or Update a list of entities. This first fetches each entity from the Kubernetes API
115
+ /// and if it does exist, updates the entity. Otherwise, the entity is created.
116
+ /// </summary>
117
+ /// <param name="entities">The entity list.</param>
118
+ /// <returns>The saved instances of the entities.</returns>
119
+ async Task < IEnumerable < TEntity > > SaveAsync ( IEnumerable < TEntity > entities ) =>
120
+ await Task . WhenAll ( entities . Select ( SaveAsync ) ) ;
121
+
122
+ /// <summary>
123
+ /// Create or Update a list of entities. This first fetches each entity from the Kubernetes API
124
+ /// and if it does exist, updates the entity. Otherwise, the entity is created.
125
+ /// </summary>
126
+ /// <param name="entities">The entity list.</param>
127
+ /// <returns>The saved instances of the entities.</returns>
128
+ async Task < IEnumerable < TEntity > > SaveAsync ( params TEntity [ ] entities ) =>
129
+ await Task . WhenAll ( entities . Select ( SaveAsync ) ) ;
130
+
131
+ /// <inheritdoc cref="SaveAsync(TEntity)"/>
112
132
TEntity Save ( TEntity entity ) => Get ( entity . Name ( ) , entity . Namespace ( ) ) switch
113
133
{
114
134
{ } e => Update ( entity . WithResourceVersion ( e ) ) ,
115
135
_ => Create ( entity ) ,
116
136
} ;
117
137
138
+ /// <inheritdoc cref="SaveAsync(IEnumerable{TEntity})"/>
139
+ IEnumerable < TEntity > Save ( IEnumerable < TEntity > entities ) => entities . Select ( Save ) ;
140
+
141
+ /// <inheritdoc cref="SaveAsync(IEnumerable{TEntity})"/>
142
+ IEnumerable < TEntity > Save ( params TEntity [ ] entities ) => entities . Select ( Save ) ;
143
+
118
144
/// <summary>
119
145
/// Create the given entity on the Kubernetes API.
120
146
/// </summary>
121
147
/// <param name="entity">The entity instance.</param>
122
148
/// <returns>The created instance of the entity.</returns>
123
149
Task < TEntity > CreateAsync ( TEntity entity ) ;
124
150
125
- /// <inheritdoc cref="CreateAsync"/>
126
- TEntity Create ( TEntity entity ) ;
151
+ /// <summary>
152
+ /// Create a list of entities on the Kubernetes API.
153
+ /// </summary>
154
+ /// <param name="entities">The entity list.</param>
155
+ /// <returns>The created instances of the entities.</returns>
156
+ async Task < IEnumerable < TEntity > > CreateAsync ( IEnumerable < TEntity > entities )
157
+ => await Task . WhenAll ( entities . Select ( CreateAsync ) ) ;
158
+
159
+ /// <summary>
160
+ /// Create a list of entities on the Kubernetes API.
161
+ /// </summary>
162
+ /// <param name="entities">The entity list.</param>
163
+ /// <returns>The created instances of the entities.</returns>
164
+ async Task < IEnumerable < TEntity > > CreateAsync ( params TEntity [ ] entities )
165
+ => await Task . WhenAll ( entities . Select ( CreateAsync ) ) ;
166
+
167
+ /// <inheritdoc cref="CreateAsync(TEntity)"/>
168
+ TEntity Create ( TEntity entity )
169
+ => CreateAsync ( entity ) . GetAwaiter ( ) . GetResult ( ) ;
170
+
171
+ /// <inheritdoc cref="CreateAsync(IEnumerable{TEntity})"/>
172
+ IEnumerable < TEntity > Create ( IEnumerable < TEntity > entities )
173
+ => entities . Select ( Create ) ;
174
+
175
+ /// <inheritdoc cref="CreateAsync(TEntity[])"/>
176
+ IEnumerable < TEntity > Create ( params TEntity [ ] entities )
177
+ => entities . Select ( Create ) ;
127
178
128
179
/// <summary>
129
180
/// Update the given entity on the Kubernetes API.
@@ -132,8 +183,33 @@ IList<TEntity> List(
132
183
/// <returns>The updated instance of the entity.</returns>
133
184
Task < TEntity > UpdateAsync ( TEntity entity ) ;
134
185
135
- /// <inheritdoc cref="UpdateAsync"/>
136
- TEntity Update ( TEntity entity ) ;
186
+ /// <summary>
187
+ /// Update a list of entities on the Kubernetes API.
188
+ /// </summary>
189
+ /// <param name="entities">An enumerable of entities.</param>
190
+ /// <returns>The updated instances of the entities.</returns>
191
+ async Task < IEnumerable < TEntity > > UpdateAsync ( IEnumerable < TEntity > entities )
192
+ => await Task . WhenAll ( entities . Select ( UpdateAsync ) ) ;
193
+
194
+ /// <summary>
195
+ /// Update a list of entities on the Kubernetes API.
196
+ /// </summary>
197
+ /// <param name="entities">An enumerable of entities.</param>
198
+ /// <returns>The updated instances of the entities.</returns>
199
+ async Task < IEnumerable < TEntity > > UpdateAsync ( params TEntity [ ] entities )
200
+ => await Task . WhenAll ( entities . Select ( UpdateAsync ) ) ;
201
+
202
+ /// <inheritdoc cref="UpdateAsync(TEntity)"/>
203
+ TEntity Update ( TEntity entity )
204
+ => UpdateAsync ( entity ) . GetAwaiter ( ) . GetResult ( ) ;
205
+
206
+ /// <inheritdoc cref="UpdateAsync(IEnumerable{TEntity})"/>
207
+ IEnumerable < TEntity > Update ( IEnumerable < TEntity > entities )
208
+ => entities . Select ( Update ) ;
209
+
210
+ /// <inheritdoc cref="UpdateAsync(TEntity[])"/>
211
+ IEnumerable < TEntity > Update ( params TEntity [ ] entities )
212
+ => entities . Select ( Update ) ;
137
213
138
214
/// <summary>
139
215
/// Update the status object of a given entity on the Kubernetes API.
@@ -147,15 +223,17 @@ IList<TEntity> List(
147
223
148
224
/// <inheritdoc cref="Delete(TEntity)"/>
149
225
/// <returns>A task that completes when the call was made.</returns>
150
- Task DeleteAsync ( TEntity entity ) ;
226
+ Task DeleteAsync ( TEntity entity ) => DeleteAsync ( entity . Name ( ) , entity . Namespace ( ) ) ;
151
227
152
228
/// <inheritdoc cref="Delete(IEnumerable{TEntity})"/>
153
229
/// <returns>A task that completes when the call was made.</returns>
154
- Task DeleteAsync ( IEnumerable < TEntity > entities ) ;
230
+ Task DeleteAsync ( IEnumerable < TEntity > entities )
231
+ => Task . WhenAll ( entities . Select ( DeleteAsync ) ) ;
155
232
156
233
/// <inheritdoc cref="Delete(TEntity[])"/>
157
234
/// <returns>A task that completes when the call was made.</returns>
158
- Task DeleteAsync ( params TEntity [ ] entities ) ;
235
+ Task DeleteAsync ( params TEntity [ ] entities )
236
+ => Task . WhenAll ( entities . Select ( DeleteAsync ) ) ;
159
237
160
238
/// <inheritdoc cref="Delete(string,string?)"/>
161
239
/// <returns>A task that completes when the call was made.</returns>
@@ -165,26 +243,39 @@ IList<TEntity> List(
165
243
/// Delete a given entity from the Kubernetes API.
166
244
/// </summary>
167
245
/// <param name="entity">The entity in question.</param>
168
- void Delete ( TEntity entity ) ;
246
+ void Delete ( TEntity entity ) => Delete ( entity . Name ( ) , entity . Namespace ( ) ) ;
169
247
170
248
/// <summary>
171
249
/// Delete a given list of entities from the Kubernetes API.
172
250
/// </summary>
173
251
/// <param name="entities">The entities in question.</param>
174
- void Delete ( IEnumerable < TEntity > entities ) ;
252
+ void Delete ( IEnumerable < TEntity > entities )
253
+ {
254
+ foreach ( var entity in entities )
255
+ {
256
+ Delete ( entity ) ;
257
+ }
258
+ }
175
259
176
260
/// <summary>
177
261
/// Delete a given list of entities from the Kubernetes API.
178
262
/// </summary>
179
263
/// <param name="entities">The entities in question.</param>
180
- void Delete ( params TEntity [ ] entities ) ;
264
+ void Delete ( params TEntity [ ] entities )
265
+ {
266
+ foreach ( var entity in entities )
267
+ {
268
+ Delete ( entity ) ;
269
+ }
270
+ }
181
271
182
272
/// <summary>
183
273
/// Delete a given entity by name from the Kubernetes API.
184
274
/// </summary>
185
275
/// <param name="name">The name of the entity.</param>
186
276
/// <param name="namespace">The optional namespace of the entity.</param>
187
- void Delete ( string name , string ? @namespace = null ) ;
277
+ void Delete ( string name , string ? @namespace = null )
278
+ => DeleteAsync ( name , @namespace ) . GetAwaiter ( ) . GetResult ( ) ;
188
279
189
280
/// <summary>
190
281
/// Create a entity watcher on the Kubernetes API.
@@ -209,7 +300,15 @@ Watcher<TEntity> Watch(
209
300
string ? @namespace = null ,
210
301
TimeSpan ? timeout = null ,
211
302
CancellationToken cancellationToken = default ,
212
- params LabelSelector [ ] labelSelectors ) ;
303
+ params LabelSelector [ ] labelSelectors )
304
+ => Watch (
305
+ onEvent ,
306
+ onError ,
307
+ onClose ,
308
+ @namespace ,
309
+ timeout ,
310
+ labelSelectors . ToExpression ( ) ,
311
+ cancellationToken ) ;
213
312
214
313
/// <summary>
215
314
/// Create a entity watcher on the Kubernetes API.
0 commit comments