@@ -9,11 +9,21 @@ sel(cnd::String...) = join(cnd, ", ")
9
9
10
10
_delopts (; kwargs... ) = Typedefs. MetaV1. DeleteOptions (; preconditions= Typedefs. MetaV1. Preconditions (; kwargs... ), kwargs... )
11
11
12
- function list (ctx:: KuberContext , O:: Symbol , name:: String ; namespace:: Union{String,Nothing} = ctx. namespace, kwargs... )
12
+ function _get_apictx (ctx:: KuberContext , O:: Symbol , apiversion:: Union{String,Nothing} )
13
+ if apiversion != = nothing
14
+ k = Kuber. api_group_type (apiversion)
15
+ apictx = k (ctx. client)
16
+ else
17
+ kapi = ctx. modelapi[O]
18
+ apictx = kapi. api (ctx. client)
19
+ end
20
+ apictx
21
+ end
22
+
23
+ function list (ctx:: KuberContext , O:: Symbol , name:: String , apiversion:: Union{String,Nothing} = nothing ; namespace:: Union{String,Nothing} = ctx. namespace, kwargs... )
13
24
isempty (ctx. apis) && set_api_versions! (ctx)
14
25
15
- kapi = ctx. modelapi[O]
16
- apictx = kapi. api (ctx. client)
26
+ apictx = _get_apictx (ctx, O, apiversion)
17
27
namespaced = (namespace != = nothing ) && ! isempty (namespace)
18
28
allnamespaces = namespaced && (namespace == " *" )
19
29
@@ -29,11 +39,10 @@ function list(ctx::KuberContext, O::Symbol, name::String; namespace::Union{Strin
29
39
end
30
40
end
31
41
32
- function list (ctx:: KuberContext , O:: Symbol ; namespace:: Union{String,Nothing} = ctx. namespace, kwargs... )
42
+ function list (ctx:: KuberContext , O:: Symbol , apiversion :: Union{String,Nothing} = nothing ; namespace:: Union{String,Nothing} = ctx. namespace, kwargs... )
33
43
isempty (ctx. apis) && set_api_versions! (ctx)
34
44
35
- kapi = ctx. modelapi[O]
36
- apictx = kapi. api (ctx. client)
45
+ apictx = _get_apictx (ctx, O, apiversion)
37
46
namespaced = (namespace != = nothing ) && ! isempty (namespace)
38
47
allnamespaces = namespaced && (namespace == " *" )
39
48
@@ -49,12 +58,10 @@ function list(ctx::KuberContext, O::Symbol; namespace::Union{String,Nothing}=ctx
49
58
end
50
59
end
51
60
52
- function get (ctx:: KuberContext , O:: Symbol , name:: String ; kwargs... )
61
+ function get (ctx:: KuberContext , O:: Symbol , name:: String , apiversion :: Union{String,Nothing} = nothing ; kwargs... )
53
62
isempty (ctx. apis) && set_api_versions! (ctx)
54
63
55
- kapi = ctx. modelapi[O]
56
- apictx = kapi. api (ctx. client)
57
-
64
+ apictx = _get_apictx (ctx, O, apiversion)
58
65
try
59
66
apicall = eval (Symbol (" read$O " ))
60
67
return apicall (apictx, name; kwargs... )
@@ -65,12 +72,10 @@ function get(ctx::KuberContext, O::Symbol, name::String; kwargs...)
65
72
end
66
73
end
67
74
68
- function get (ctx:: KuberContext , O:: Symbol ; label_selector= nothing , namespace:: Union{String,Nothing} = ctx. namespace)
75
+ function get (ctx:: KuberContext , O:: Symbol , apiversion :: Union{String,Nothing} = nothing ; label_selector= nothing , namespace:: Union{String,Nothing} = ctx. namespace)
69
76
isempty (ctx. apis) && set_api_versions! (ctx)
70
77
71
- kapi = ctx. modelapi[O]
72
- apictx = kapi. api (ctx. client)
73
-
78
+ apictx = _get_apictx (ctx, O, apiversion)
74
79
try
75
80
apiname = " list$O "
76
81
(namespace === nothing ) && (apiname *= " ForAllNamespaces" )
92
97
function put! (ctx:: KuberContext , O:: Symbol , d:: Dict{String,Any} )
93
98
isempty (ctx. apis) && set_api_versions! (ctx)
94
99
95
- if haskey (d, " apiVersion" )
96
- v = d[" apiVersion" ]
97
- k = Kuber. api_group_type (v)
98
- apictx = k (ctx. client)
99
- else
100
- kapi = ctx. modelapi[O]
101
- apictx = kapi. api (ctx. client)
102
- end
103
-
100
+ apictx = _get_apictx (ctx, O, get (d, " apiVersion" , nothing ))
104
101
try
105
102
apicall = eval (Symbol (" create$O " ))
106
103
return apicall (apictx, d)
@@ -115,14 +112,13 @@ function delete!(ctx::KuberContext, v::T; kwargs...) where {T<:SwaggerModel}
115
112
vjson = convert (Dict{String,Any}, v)
116
113
kind = vjson[" kind" ]
117
114
name = vjson[" metadata" ][" name" ]
118
- delete! (ctx, Symbol (kind), name; kwargs... )
115
+ delete! (ctx, Symbol (kind), name, get (vjson, " apiVersion " , nothing ) ; kwargs... )
119
116
end
120
117
121
- function delete! (ctx:: KuberContext , O:: Symbol , name:: String ; kwargs... )
118
+ function delete! (ctx:: KuberContext , O:: Symbol , name:: String , apiversion :: Union{String,Nothing} = nothing ; kwargs... )
122
119
isempty (ctx. apis) && set_api_versions! (ctx)
120
+ apictx = _get_apictx (ctx, O, apiversion)
123
121
124
- kapi = ctx. modelapi[O]
125
- apictx = kapi. api (ctx. client)
126
122
params = [apictx, name]
127
123
128
124
try
@@ -140,14 +136,13 @@ function update!(ctx::KuberContext, v::T, patch, patch_type) where {T<:SwaggerMo
140
136
vjson = convert (Dict{String,Any}, v)
141
137
kind = vjson[" kind" ]
142
138
name = vjson[" metadata" ][" name" ]
143
- update! (ctx, Symbol (kind), name, patch, patch_type)
139
+ update! (ctx, Symbol (kind), name, patch, patch_type, get (vjson, " apiVersion " , nothing ) )
144
140
end
145
141
146
- function update! (ctx:: KuberContext , O:: Symbol , name:: String , patch, patch_type)
142
+ function update! (ctx:: KuberContext , O:: Symbol , name:: String , patch, patch_type, apiversion :: Union{String,Nothing} = nothing )
147
143
isempty (ctx. apis) && set_api_versions! (ctx)
148
144
149
- kapi = ctx. modelapi[O]
150
- apictx = kapi. api (ctx. client)
145
+ apictx = _get_apictx (ctx, O, apiversion)
151
146
152
147
try
153
148
apicall = eval (Symbol (" patch$O " ))
0 commit comments