Skip to content

Commit 38c7ae7

Browse files
committed
refactor: update GetParameterValueForWatch to accept a watch flag and adjust templates accordingly
1 parent 43780e8 commit 38c7ae7

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/LibKubernetesGenerator/ParamHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void RegisterHelper(ScriptObject scriptObject)
2323
scriptObject.Import(nameof(GetModelCtorParam), new Func<JsonSchema, string>(GetModelCtorParam));
2424
scriptObject.Import(nameof(IfParamContains), IfParamContains);
2525
scriptObject.Import(nameof(FilterParameters), FilterParameters);
26-
scriptObject.Import(nameof(GetParameterValueForWatch), new Func<OpenApiParameter, string>(GetParameterValueForWatch));
26+
scriptObject.Import(nameof(GetParameterValueForWatch), new Func<OpenApiParameter, bool, string>(GetParameterValueForWatch));
2727
}
2828

2929
public static bool IfParamContains(OpenApiOperation operation, string name)
@@ -47,11 +47,11 @@ public static IEnumerable<OpenApiParameter> FilterParameters(OpenApiOperation op
4747
return operation.Parameters.Where(p => p.Name != excludeParam);
4848
}
4949

50-
public string GetParameterValueForWatch(OpenApiParameter parameter)
50+
public string GetParameterValueForWatch(OpenApiParameter parameter, bool watch)
5151
{
5252
if (parameter.Name == "watch")
5353
{
54-
return "true";
54+
return watch ? "true" : "false";
5555
}
5656
else
5757
{

src/LibKubernetesGenerator/templates/Client.cs.template

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public partial class {{name}}Client : ResourceClient
3838
{{if IfReturnType api.operation "stream"}}
3939
var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
4040
{{ for parameter in api.operation.parameters}}
41-
{{GetParameterValueForWatch parameter}},
41+
{{GetParameterValueForWatch parameter false}},
4242
{{end}}
4343
null,
4444
cancellationToken);
@@ -48,7 +48,7 @@ public partial class {{name}}Client : ResourceClient
4848
{{if IfReturnType api.operation "obj"}}
4949
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
5050
{{ for parameter in api.operation.parameters}}
51-
{{GetParameterValueForWatch parameter}},
51+
{{GetParameterValueForWatch parameter false}},
5252
{{end}}
5353
null,
5454
cancellationToken).ConfigureAwait(false))
@@ -59,7 +59,7 @@ public partial class {{name}}Client : ResourceClient
5959
{{if IfReturnType api.operation "void"}}
6060
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
6161
{{ for parameter in api.operation.parameters}}
62-
{{GetParameterValueForWatch parameter}},
62+
{{GetParameterValueForWatch parameter false}},
6363
{{end}}
6464
null,
6565
cancellationToken).ConfigureAwait(false))
@@ -88,7 +88,7 @@ public partial class {{name}}Client : ResourceClient
8888
{
8989
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
9090
{{ for parameter in api.operation.parameters}}
91-
{{GetParameterValueForWatch parameter}},
91+
{{GetParameterValueForWatch parameter false}},
9292
{{end}}
9393
null,
9494
cancellationToken).ConfigureAwait(false))
@@ -122,7 +122,7 @@ public partial class {{name}}Client : ResourceClient
122122

123123
var responseTask = Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
124124
{{ for parameter in api.operation.parameters}}
125-
{{GetParameterValueForWatch parameter}},
125+
{{GetParameterValueForWatch parameter true}},
126126
{{ end }}
127127
null,
128128
CancellationToken.None);
@@ -150,7 +150,7 @@ public partial class {{name}}Client : ResourceClient
150150
{
151151
var responseTask = Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
152152
{{ for parameter in api.operation.parameters}}
153-
{{GetParameterValueForWatch parameter}},
153+
{{GetParameterValueForWatch parameter true}},
154154
{{ end }}
155155
null,
156156
cancellationToken);

src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static partial class {{name}}OperationsExtensions
9191
{{if IfReturnType api.operation "stream"}}
9292
var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
9393
{{ for parameter in api.operation.parameters}}
94-
{{GetParameterValueForWatch parameter}},
94+
{{GetParameterValueForWatch parameter false}},
9595
{{end}}
9696
null,
9797
cancellationToken);
@@ -101,7 +101,7 @@ public static partial class {{name}}OperationsExtensions
101101
{{if IfReturnType api.operation "obj"}}
102102
using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
103103
{{ for parameter in api.operation.parameters}}
104-
{{GetParameterValueForWatch parameter}},
104+
{{GetParameterValueForWatch parameter false}},
105105
{{end}}
106106
null,
107107
cancellationToken).ConfigureAwait(false))
@@ -112,7 +112,7 @@ public static partial class {{name}}OperationsExtensions
112112
{{if IfReturnType api.operation "void"}}
113113
using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
114114
{{ for parameter in api.operation.parameters}}
115-
{{GetParameterValueForWatch parameter}},
115+
{{GetParameterValueForWatch parameter false}},
116116
{{end}}
117117
null,
118118
cancellationToken).ConfigureAwait(false))
@@ -145,7 +145,7 @@ public static partial class {{name}}OperationsExtensions
145145
{
146146
using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
147147
{{ for parameter in api.operation.parameters}}
148-
{{GetParameterValueForWatch parameter}},
148+
{{GetParameterValueForWatch parameter false}},
149149
{{end}}
150150
null,
151151
cancellationToken).ConfigureAwait(false))
@@ -184,7 +184,7 @@ public static Watcher<{{GetReturnType api.operation "T"}}> Watch{{GetOperationId
184184

185185
var responseTask = operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
186186
{{ for parameter in api.operation.parameters}}
187-
{{GetParameterValueForWatch parameter}},
187+
{{GetParameterValueForWatch parameter true}},
188188
{{end}}
189189
null,
190190
CancellationToken.None);
@@ -216,7 +216,7 @@ public static IAsyncEnumerable<(WatchEventType, {{GetReturnType api.operation "T
216216
{
217217
var responseTask = operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
218218
{{ for parameter in api.operation.parameters}}
219-
{{GetParameterValueForWatch parameter}},
219+
{{GetParameterValueForWatch parameter true}},
220220
{{end}}
221221
null,
222222
cancellationToken);

0 commit comments

Comments
 (0)