/
client.ex
784 lines (691 loc) · 25.3 KB
/
client.ex
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
defmodule K8s.Client do
@moduledoc """
An experimental k8s client.
Functions return `K8s.Operation`s that represent kubernetes operations.
To run operations pass them to: `run/2`, `run/3`, or `run/4`.
When specifying kinds the format should either be in the literal kubernetes kind name (eg `"ServiceAccount"`)
or the downcased version seen in kubectl (eg `"serviceaccount"`). A string or atom may be used.
## Examples
```elixir
"Deployment", "deployment", :Deployment, :deployment
"ServiceAccount", "serviceaccount", :ServiceAccount, :serviceaccount
"HorizontalPodAutoscaler", "horizontalpodautoscaler", :HorizontalPodAutoscaler, :horizontalpodautoscaler
```
`opts` to `K8s.Client.Runner` modules are HTTPoison HTTP option overrides.
"""
@type option :: {:name, String.t()} | {:namespace, binary() | :all}
@type options :: [option]
alias K8s.Operation
alias K8s.Client.Runner.{Async, Base, Stream, Wait, Watch}
@doc "alias of `K8s.Client.Runner.Base.run/2`"
defdelegate run(operation, cluster_name), to: Base
@doc "alias of `K8s.Client.Runner.Base.run/3`"
defdelegate run(operation, cluster_name, opts), to: Base
@doc "alias of `K8s.Client.Runner.Base.run/4`"
defdelegate run(operation, cluster_name, resource, opts), to: Base
@doc "alias of `K8s.Client.Runner.Async.run/3`"
defdelegate async(operations, cluster_name), to: Async, as: :run
@doc "alias of `K8s.Client.Runner.Async.run/3`"
defdelegate parallel(operations, cluster_name, opts), to: Async, as: :run
@doc "alias of `K8s.Client.Runner.Async.run/3`"
defdelegate async(operations, cluster_name, opts), to: Async, as: :run
@doc "alias of `K8s.Client.Runner.Wait.run/3`"
defdelegate wait_until(operation, cluster_name, opts), to: Wait, as: :run
@doc "alias of `K8s.Client.Runner.Watch.run/3`"
defdelegate watch(operation, cluster_name, opts), to: Watch, as: :run
@doc "alias of `K8s.Client.Runner.Watch.run/4`"
defdelegate watch(operation, cluster_name, rv, opts), to: Watch, as: :run
@doc "alias of `K8s.Client.Runner.Stream.run/2`"
defdelegate stream(operation, cluster_name), to: Stream, as: :run
@doc "alias of `K8s.Client.Runner.Stream.run/3`"
defdelegate stream(operation, cluster_name, opts), to: Stream, as: :run
@doc """
Returns a `GET` operation for a resource given a manifest. May be a partial manifest as long as it contains:
* apiVersion
* kind
* metadata.name
* metadata.namespace (if applicable)
[K8s Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/):
> Get will retrieve a specific resource object by name.
## Examples
Getting a pod
iex> pod = %{
...> "apiVersion" => "v1",
...> "kind" => "Pod",
...> "metadata" => %{"name" => "nginx-pod", "namespace" => "test"},
...> "spec" => %{"containers" => %{"image" => "nginx"}}
...> }
...> K8s.Client.get(pod)
%K8s.Operation{
method: :get,
verb: :get,
api_version: "v1",
name: "Pod",
path_params: [namespace: "test", name: "nginx-pod"],
}
"""
@spec get(map()) :: Operation.t()
def get(%{} = resource), do: Operation.build(:get, resource)
@doc """
Returns a `GET` operation for a resource by version, kind/resource type, name, and optionally namespace.
[K8s Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/):
> Get will retrieve a specific resource object by name.
## Examples
Get the nginx deployment in the default namespace:
iex> K8s.Client.get("apps/v1", "Deployment", namespace: "test", name: "nginx")
%K8s.Operation{
method: :get,
verb: :get,
api_version: "apps/v1",
name: "Deployment",
path_params: [namespace: "test", name: "nginx"]
}
Get the nginx deployment in the default namespace:
iex> K8s.Client.get("apps/v1", :deployment, namespace: "test", name: "nginx")
%K8s.Operation{
method: :get,
verb: :get,
api_version: "apps/v1",
name: :deployment,
path_params: [namespace: "test", name: "nginx"]}
Get the nginx deployment's status:
iex> K8s.Client.get("apps/v1", "deployments/status", namespace: "test", name: "nginx")
%K8s.Operation{
method: :get,
verb: :get,
api_version: "apps/v1",
name: "deployments/status",
path_params: [namespace: "test", name: "nginx"]}
Get the nginx deployment's scale:
iex> K8s.Client.get("v1", "deployments/scale", namespace: "test", name: "nginx")
%K8s.Operation{
method: :get,
verb: :get,
api_version: "v1",
name: "deployments/scale",
path_params: [namespace: "test", name: "nginx"]}
"""
@spec get(binary, binary | atom, options | nil) :: Operation.t()
def get(api_version, kind, opts \\ []), do: Operation.build(:get, api_version, kind, opts)
@doc """
Returns a `GET` operation to list all resources by version, kind, and namespace.
Given the namespace `:all` as an atom, will perform a list across all namespaces.
[K8s Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/):
> List will retrieve all resource objects of a specific type within a namespace, and the results can be restricted to resources matching a selector query.
> List All Namespaces: Like List but retrieves resources across all namespaces.
## Examples
iex> K8s.Client.list("v1", "Pod", namespace: "default")
%K8s.Operation{
method: :get,
verb: :list,
api_version: "v1",
name: "Pod",
path_params: [namespace: "default"]
}
iex> K8s.Client.list("apps/v1", "Deployment", namespace: :all)
%K8s.Operation{
method: :get,
verb: :list_all_namespaces,
api_version: "apps/v1",
name: "Deployment",
path_params: []
}
"""
@spec list(binary, binary | atom, options | nil) :: Operation.t()
def list(api_version, kind, opts \\ [])
def list(api_version, kind, namespace: :all),
do: Operation.build(:list_all_namespaces, api_version, kind, [])
def list(api_version, kind, opts),
do: Operation.build(:list, api_version, kind, opts)
@doc """
Returns a `POST` `K8s.Operation` to create the given resource.
## Examples
iex> deployment = %{
...> "apiVersion" => "apps/v1",
...> "kind" => "Deployment",
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> },
...> "name" => "nginx",
...> "namespace" => "test"
...> },
...> "spec" => %{
...> "replicas" => 2,
...> "selector" => %{
...> "matchLabels" => %{
...> "app" => "nginx"
...> }
...> },
...> "template" => %{
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> }
...> },
...> "spec" => %{
...> "containers" => %{
...> "image" => "nginx",
...> "name" => "nginx"
...> }
...> }
...> }
...> }
...> }
...> K8s.Client.create(deployment)
%K8s.Operation{
method: :post,
path_params: [namespace: "test", name: "nginx"],
verb: :create,
api_version: "apps/v1",
name: "Deployment",
data: %{
"apiVersion" => "apps/v1",
"kind" => "Deployment",
"metadata" => %{
"labels" => %{
"app" => "nginx"
},
"name" => "nginx",
"namespace" => "test"
},
"spec" => %{
"replicas" => 2,
"selector" => %{
"matchLabels" => %{
"app" => "nginx"
}
},
"template" => %{
"metadata" => %{
"labels" => %{
"app" => "nginx"
}
},
"spec" => %{
"containers" => %{
"image" => "nginx",
"name" => "nginx"
}
}
}
}
}
}
"""
@spec create(map()) :: Operation.t()
def create(
%{
"apiVersion" => api_version,
"kind" => kind,
"metadata" => %{"namespace" => ns, "name" => name}
} = resource
) do
Operation.build(:create, api_version, kind, [namespace: ns, name: name], resource)
end
# Support for creating resources that are cluster-scoped, like Namespaces.
def create(
%{"apiVersion" => api_version, "kind" => kind, "metadata" => %{"name" => name}} = resource
) do
Operation.build(:create, api_version, kind, [name: name], resource)
end
@doc """
Returns a `POST` `K8s.Operation` to create the given subresource.
Used for creating subresources like `Scale` or `Eviction`.
## Examples
Eviction a pod
iex> eviction = %{
...> "apiVersion" => "policy/v1beta1",
...> "kind" => "Eviction",
...> "metadata" => %{
...> "name" => "nginx",
...> "namespace" => "default"
...> }
...> }
...> K8s.Client.create("v1", "pods/eviction", [namespace: "default", name: "nginx"], eviction)
%K8s.Operation{api_version: "v1", data: %{"apiVersion" => "policy/v1beta1", "kind" => "Eviction", "metadata" => %{"name" => "nginx", "namespace" => "default"}}, method: :post, name: "pods/eviction", path_params: [namespace: "default", name: "nginx"], verb: :create}
"""
@spec create(binary, binary | atom, Keyword.t(), map()) :: Operation.t()
def create(api_version, kind, path_params, subresource),
do: Operation.build(:create, api_version, kind, path_params, subresource)
@doc """
Returns a `POST` `K8s.Operation` to create the given subresource.
Used for creating subresources like `Scale` or `Eviction`.
## Examples
Eviction a pod
iex> pod = %{
...> "apiVersion" => "v1",
...> "kind" => "Pod",
...> "metadata" => %{
...> "name" => "nginx",
...> "namespace" => "default"
...> }
...> }
...> eviction = %{
...> "apiVersion" => "policy/v1beta1",
...> "kind" => "Eviction",
...> "metadata" => %{
...> "name" => "nginx",
...> "namespace" => "default"
...> }
...> }
...> K8s.Client.create(pod, eviction)
%K8s.Operation{api_version: "v1", data: %{"apiVersion" => "policy/v1beta1", "kind" => "Eviction", "metadata" => %{"name" => "nginx", "namespace" => "default"}}, method: :post, name: {"Pod", "Eviction"}, path_params: [namespace: "default", name: "nginx"], verb: :create}
"""
@spec create(map(), map()) :: Operation.t()
def create(
%{
"apiVersion" => api_version,
"kind" => kind,
"metadata" => %{"namespace" => ns, "name" => name}
},
%{"kind" => subkind} = subresource
) do
Operation.build(
:create,
api_version,
{kind, subkind},
[namespace: ns, name: name],
subresource
)
end
# Support for creating resources that are cluster-scoped, like Namespaces.
def create(
%{"apiVersion" => api_version, "kind" => kind, "metadata" => %{"name" => name}},
%{"kind" => subkind} = subresource
) do
Operation.build(:create, api_version, {kind, subkind}, [name: name], subresource)
end
@doc """
Returns a `PATCH` operation to patch the given resource.
[K8s Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/):
> Patch will apply a change to a specific field. How the change is merged is defined per field. Lists may either be replaced or merged. Merging lists will not preserve ordering.
> Patches will never cause optimistic locking failures, and the last write will win. Patches are recommended when the full state is not read before an update, or when failing on optimistic locking is undesirable. When patching complex types, arrays and maps, how the patch is applied is defined on a per-field basis and may either replace the field's current value, or merge the contents into the current value.
## Examples
iex> deployment = %{
...> "apiVersion" => "apps/v1",
...> "kind" => "Deployment",
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> },
...> "name" => "nginx",
...> "namespace" => "test"
...> },
...> "spec" => %{
...> "replicas" => 2,
...> "selector" => %{
...> "matchLabels" => %{
...> "app" => "nginx"
...> }
...> },
...> "template" => %{
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> }
...> },
...> "spec" => %{
...> "containers" => %{
...> "image" => "nginx",
...> "name" => "nginx"
...> }
...> }
...> }
...> }
...> }
...> K8s.Client.patch(deployment)
%K8s.Operation{
method: :patch,
verb: :patch,
api_version: "apps/v1",
name: "Deployment",
path_params: [namespace: "test", name: "nginx"],
data: %{
"apiVersion" => "apps/v1",
"kind" => "Deployment",
"metadata" => %{
"labels" => %{
"app" => "nginx"
},
"name" => "nginx",
"namespace" => "test"
},
"spec" => %{
"replicas" => 2,
"selector" => %{
"matchLabels" => %{
"app" => "nginx"
}
},
"template" => %{
"metadata" => %{
"labels" => %{
"app" => "nginx"
}
},
"spec" => %{
"containers" => %{
"image" => "nginx",
"name" => "nginx"
}
}
}
}
}
}
"""
@spec patch(map()) :: Operation.t()
def patch(%{} = resource), do: Operation.build(:patch, resource)
@doc """
Returns a `PATCH` operation to patch the given subresource given a resource's details and a subresource map.
"""
@spec patch(binary, binary | atom, Keyword.t(), map()) :: Operation.t()
def patch(api_version, kind, path_params, subresource),
do: Operation.build(:patch, api_version, kind, path_params, subresource)
@doc """
Returns a `PATCH` operation to patch the given subresource given a resource map and a subresource map.
"""
@spec patch(map(), map()) :: Operation.t()
def patch(
%{
"apiVersion" => api_version,
"kind" => kind,
"metadata" => %{"namespace" => ns, "name" => name}
},
%{"kind" => subkind} = subresource
) do
Operation.build(
:patch,
api_version,
{kind, subkind},
[namespace: ns, name: name],
subresource
)
end
@doc """
Returns a `PUT` operation to replace/update the given resource.
[K8s Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/):
> Replacing a resource object will update the resource by replacing the existing spec with the provided one. For read-then-write operations this is safe because an optimistic lock failure will occur if the resource was modified between the read and write. Note: The ResourceStatus will be ignored by the system and will not be updated. To update the status, one must invoke the specific status update operation.
> Note: Replacing a resource object may not result immediately in changes being propagated to downstream objects. For instance replacing a ConfigMap or Secret resource will not result in all Pods seeing the changes unless the Pods are restarted out of band.
## Examples
iex> deployment = %{
...> "apiVersion" => "apps/v1",
...> "kind" => "Deployment",
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> },
...> "name" => "nginx",
...> "namespace" => "test"
...> },
...> "spec" => %{
...> "replicas" => 2,
...> "selector" => %{
...> "matchLabels" => %{
...> "app" => "nginx"
...> }
...> },
...> "template" => %{
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> }
...> },
...> "spec" => %{
...> "containers" => %{
...> "image" => "nginx",
...> "name" => "nginx"
...> }
...> }
...> }
...> }
...> }
...> K8s.Client.update(deployment)
%K8s.Operation{
method: :put,
verb: :update,
api_version: "apps/v1",
name: "Deployment",
path_params: [namespace: "test", name: "nginx"],
data: %{
"apiVersion" => "apps/v1",
"kind" => "Deployment",
"metadata" => %{
"labels" => %{
"app" => "nginx"
},
"name" => "nginx",
"namespace" => "test"
},
"spec" => %{
"replicas" => 2,
"selector" => %{
"matchLabels" => %{
"app" => "nginx"
}
},
"template" => %{
"metadata" => %{
"labels" => %{
"app" => "nginx"
}
},
"spec" => %{
"containers" => %{
"image" => "nginx",
"name" => "nginx"
}
}
}
}
}
}
"""
@spec update(map()) :: Operation.t()
def update(%{} = resource), do: Operation.build(:update, resource)
@doc """
Returns a `PUT` operation to replace/update the given subresource given a resource's details and a subresource map.
Used for updating subresources like `Scale` or `Status`.
## Examples
Scaling a deployment
iex> scale = %{
...> "kind" => "Scale",
...> "apiVersion" => "apps/v1beta1",
...> "metadata" => %{
...> "name" => "nginx",
...> "namespace" => "default"
...> },
...> "spec" => %{
...> "replicas" => 3
...> }
...> }
...> K8s.Client.update("apps/v1", "deployments/scale", [namespace: "default", name: "nginx"], scale)
%K8s.Operation{api_version: "apps/v1", data: %{"apiVersion" => "apps/v1beta1", "kind" => "Scale", "metadata" => %{"name" => "nginx", "namespace" => "default"}, "spec" => %{"replicas" => 3}}, method: :put, name: "deployments/scale", path_params: [namespace: "default", name: "nginx"], verb: :update}
"""
@spec update(binary, binary | atom, Keyword.t(), map()) :: Operation.t()
def update(api_version, kind, path_params, subresource),
do: Operation.build(:update, api_version, kind, path_params, subresource)
@doc """
Returns a `PUT` operation to replace/update the given subresource given a resource map and a subresource map.
Used for updating subresources like `Scale` or `Status`.
## Examples
Scaling a deployment:
iex> deployment = %{
...> "apiVersion" => "apps/v1",
...> "kind" => "Deployment",
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> },
...> "name" => "nginx",
...> "namespace" => "test"
...> },
...> "spec" => %{
...> "replicas" => 2,
...> "selector" => %{
...> "matchLabels" => %{
...> "app" => "nginx"
...> }
...> },
...> "template" => %{
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> }
...> },
...> "spec" => %{
...> "containers" => %{
...> "image" => "nginx",
...> "name" => "nginx"
...> }
...> }
...> }
...> }
...> }
...> scale = %{
...> "kind" => "Scale",
...> "apiVersion" => "apps/v1beta1",
...> "metadata" => %{
...> "name" => "nginx",
...> "namespace" => "test"
...> },
...> "spec" => %{
...> "replicas" => 3
...> }
...> }
...> K8s.Client.update(deployment, scale)
%K8s.Operation{api_version: "apps/v1", method: :put, path_params: [namespace: "test", name: "nginx"], verb: :update, data: %{"apiVersion" => "apps/v1beta1", "kind" => "Scale", "metadata" => %{"name" => "nginx", "namespace" => "test"}, "spec" => %{"replicas" => 3}}, name: {"Deployment", "Scale"}}
"""
@spec update(map(), map()) :: Operation.t()
def update(
%{
"apiVersion" => api_version,
"kind" => kind,
"metadata" => %{"namespace" => ns, "name" => name}
},
%{"kind" => subkind} = subresource
) do
Operation.build(
:update,
api_version,
{kind, subkind},
[namespace: ns, name: name],
subresource
)
end
@doc """
Returns a `DELETE` operation for a resource by manifest. May be a partial manifest as long as it contains:
* apiVersion
* kind
* metadata.name
* metadata.namespace (if applicable)
[K8s Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/):
> Delete will delete a resource. Depending on the specific resource, child objects may or may not be garbage collected by the server. See notes on specific resource objects for details.
## Examples
iex> deployment = %{
...> "apiVersion" => "apps/v1",
...> "kind" => "Deployment",
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> },
...> "name" => "nginx",
...> "namespace" => "test"
...> },
...> "spec" => %{
...> "replicas" => 2,
...> "selector" => %{
...> "matchLabels" => %{
...> "app" => "nginx"
...> }
...> },
...> "template" => %{
...> "metadata" => %{
...> "labels" => %{
...> "app" => "nginx"
...> }
...> },
...> "spec" => %{
...> "containers" => %{
...> "image" => "nginx",
...> "name" => "nginx"
...> }
...> }
...> }
...> }
...> }
...> K8s.Client.delete(deployment)
%K8s.Operation{
method: :delete,
verb: :delete,
api_version: "apps/v1",
name: "Deployment",
path_params: [namespace: "test", name: "nginx"]
}
"""
@spec delete(map()) :: Operation.t()
def delete(%{} = resource), do: Operation.build(:delete, resource)
@doc """
Returns a `DELETE` operation for a resource by version, kind, name, and optionally namespace.
## Examples
iex> K8s.Client.delete("apps/v1", "Deployment", namespace: "test", name: "nginx")
%K8s.Operation{
method: :delete,
verb: :delete,
api_version: "apps/v1",
name: "Deployment",
path_params: [namespace: "test", name: "nginx"]
}
"""
@spec delete(binary, binary | atom, options | nil) :: Operation.t()
def delete(api_version, kind, opts), do: Operation.build(:delete, api_version, kind, opts)
@doc """
Returns a `DELETE` collection operation for all instances of a cluster scoped resource kind.
## Examples
iex> K8s.Client.delete_all("extensions/v1beta1", "PodSecurityPolicy")
%K8s.Operation{
method: :delete,
verb: :deletecollection,
api_version: "extensions/v1beta1",
name: "PodSecurityPolicy",
path_params: []
}
iex> K8s.Client.delete_all("storage.k8s.io/v1", "StorageClass")
%K8s.Operation{
method: :delete,
verb: :deletecollection,
api_version: "storage.k8s.io/v1",
name: "StorageClass",
path_params: []
}
"""
@spec delete_all(binary(), binary() | atom()) :: Operation.t()
def delete_all(api_version, kind) do
Operation.build(:deletecollection, api_version, kind, [])
end
@doc """
Returns a `DELETE` collection operation for all instances of a resource kind in a specific namespace.
## Examples
iex> K8s.Client.delete_all("apps/v1beta1", "ControllerRevision", namespace: "default")
%K8s.Operation{
method: :delete,
verb: :deletecollection,
api_version: "apps/v1beta1",
name: "ControllerRevision",
path_params: [namespace: "default"]
}
iex> K8s.Client.delete_all("apps/v1", "Deployment", namespace: "staging")
%K8s.Operation{
method: :delete,
verb: :deletecollection,
api_version: "apps/v1",
name: "Deployment",
path_params: [namespace: "staging"]
}
"""
@spec delete_all(binary(), binary() | atom(), namespace: binary()) :: Operation.t()
def delete_all(api_version, kind, namespace: namespace) do
Operation.build(:deletecollection, api_version, kind, namespace: namespace)
end
end