Skip to content

Commit 05da1c4

Browse files
committed
Add ClientSet tests for Kubernetes pod operations
1 parent 47b8330 commit 05da1c4

File tree

6 files changed

+143
-31
lines changed

6 files changed

+143
-31
lines changed

src/LibKubernetesGenerator/GeneralNameHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public GeneralNameHelper(ClassNameHelper classNameHelper)
2121
public void RegisterHelper(ScriptObject scriptObject)
2222
{
2323
scriptObject.Import(nameof(GetInterfaceName), new Func<JsonSchema, string>(GetInterfaceName));
24-
scriptObject.Import(nameof(GetMethodName), new Func<OpenApiOperation, string, string>(GetMethodName));
25-
scriptObject.Import(nameof(GetActionTypeName), new Func<OpenApiOperationDescription, string, string, string>(GetActionTypeName));
24+
scriptObject.Import(nameof(GetOperationId), new Func<OpenApiOperation, string, string>(GetOperationId));
25+
scriptObject.Import(nameof(GetActionName), new Func<OpenApiOperationDescription, string, string, string>(GetActionName));
2626
scriptObject.Import(nameof(GetDotNetName), new Func<string, string, string>(GetDotNetName));
2727
scriptObject.Import(nameof(GetDotNetNameOpenApiParameter), new Func<OpenApiParameter, string, string>(GetDotNetNameOpenApiParameter));
2828
}
@@ -139,7 +139,7 @@ public string GetDotNetName(string jsonName, string style = "parameter")
139139
return jsonName.ToCamelCase();
140140
}
141141

142-
public static string GetMethodName(OpenApiOperation watchOperation, string suffix)
142+
public static string GetOperationId(OpenApiOperation watchOperation, string suffix)
143143
{
144144
var tag = watchOperation.Tags[0];
145145
tag = tag.Replace("_", string.Empty);
@@ -164,7 +164,7 @@ public static string GetMethodName(OpenApiOperation watchOperation, string suffi
164164
return methodName;
165165
}
166166

167-
public static string GetActionTypeName(OpenApiOperationDescription apiOperation, string resource, string suffix)
167+
public static string GetActionName(OpenApiOperationDescription apiOperation, string resource, string suffix)
168168
{
169169
var actionType = apiOperation.Operation?.ExtensionData?["x-kubernetes-action"] as string;
170170

src/LibKubernetesGenerator/templates/Client.cs.template

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public partial class {{name}}Client : ResourceClient
2828
/// <param name="cancellationToken">
2929
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
3030
/// </param>
31-
public async Task{{GetReturnType api.operation "<>"}} {{GetActionTypeName api name "Async"}}(
31+
public async Task{{GetReturnType api.operation "<>"}} {{GetActionName api name "Async"}}(
3232
{{ for parameter in api.operation.parameters}}
3333
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
3434
{{ end }}
3535
CancellationToken cancellationToken = default(CancellationToken))
3636
{
3737
{{if IfReturnType api.operation "stream"}}
38-
var _result = await Client.{{group}}.{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
38+
var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
3939
{{ for parameter in api.operation.parameters}}
4040
{{GetDotNetNameOpenApiParameter parameter "false"}},
4141
{{end}}
@@ -45,7 +45,7 @@ public partial class {{name}}Client : ResourceClient
4545
{{GetReturnType api.operation "_result.Body"}};
4646
{{end}}
4747
{{if IfReturnType api.operation "obj"}}
48-
using (var _result = await Client.{{group}}.{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
48+
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
4949
{{ for parameter in api.operation.parameters}}
5050
{{GetDotNetNameOpenApiParameter parameter "false"}},
5151
{{end}}
@@ -56,7 +56,7 @@ public partial class {{name}}Client : ResourceClient
5656
}
5757
{{end}}
5858
{{if IfReturnType api.operation "void"}}
59-
using (var _result = await Client.{{group}}.{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
59+
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
6060
{{ for parameter in api.operation.parameters}}
6161
{{GetDotNetNameOpenApiParameter parameter "false"}},
6262
{{end}}
@@ -79,13 +79,13 @@ public partial class {{name}}Client : ResourceClient
7979
/// <param name="cancellationToken">
8080
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
8181
/// </param>
82-
public async Task<T> {{GetActionTypeName api name "Async"}}<T>(
82+
public async Task<T> {{GetActionName api name "Async"}}<T>(
8383
{{ for parameter in api.operation.parameters}}
8484
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}},
8585
{{ end }}
8686
CancellationToken cancellationToken = default(CancellationToken))
8787
{
88-
using (var _result = await Client.{{group}}.{{GetMethodName api.operation "WithHttpMessagesAsync"}}<T>(
88+
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
8989
{{ for parameter in api.operation.parameters}}
9090
{{GetDotNetNameOpenApiParameter parameter "false"}},
9191
{{end}}

src/LibKubernetesGenerator/templates/IOperations.cs.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public partial interface I{{name}}Operations
2525
/// <param name="cancellationToken">
2626
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
2727
/// </param>
28-
Task<HttpOperationResponse{{GetReturnType api.operation "<>"}}> {{GetMethodName api.operation "WithHttpMessagesAsync"}}(
28+
Task<HttpOperationResponse{{GetReturnType api.operation "<>"}}> {{GetOperationId api.operation "WithHttpMessagesAsync"}}(
2929
{{ for parameter in api.operation.parameters}}
3030
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
3131
{{ end }}
@@ -47,7 +47,7 @@ public partial interface I{{name}}Operations
4747
/// <param name="cancellationToken">
4848
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
4949
/// </param>
50-
Task<HttpOperationResponse<T>> {{GetMethodName api.operation "WithHttpMessagesAsync"}}<T>(
50+
Task<HttpOperationResponse<T>> {{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
5151
{{ for parameter in api.operation.parameters}}
5252
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
5353
{{ end }}

src/LibKubernetesGenerator/templates/Operations.cs.template

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ public partial class AbstractKubernetes : I{{name}}Operations
1010
{
1111
{{for api in apis }}
1212
{{if IfReturnType api.operation "void"}}
13-
private async Task<HttpOperationResponse> I{{name}}Operations_{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
13+
private async Task<HttpOperationResponse> I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
1414
{{end}}
1515
{{if IfReturnType api.operation "obj"}}
16-
private async Task<HttpOperationResponse<T>> I{{name}}Operations_{{GetMethodName api.operation "WithHttpMessagesAsync"}}<T>(
16+
private async Task<HttpOperationResponse<T>> I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
1717
{{end}}
1818
{{if IfReturnType api.operation "stream"}}
19-
private async Task<HttpOperationResponse<Stream>> I{{name}}Operations_{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
19+
private async Task<HttpOperationResponse<Stream>> I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
2020
{{end}}
2121
{{ for parameter in api.operation.parameters}}
2222
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}},
@@ -90,31 +90,31 @@ public partial class AbstractKubernetes : I{{name}}Operations
9090
}
9191

9292
/// <inheritdoc/>
93-
async Task<HttpOperationResponse{{GetReturnType api.operation "<>"}}> I{{name}}Operations.{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
93+
async Task<HttpOperationResponse{{GetReturnType api.operation "<>"}}> I{{name}}Operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
9494
{{ for parameter in api.operation.parameters}}
9595
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}},
9696
{{end}}
9797
IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders,
9898
CancellationToken cancellationToken)
9999
{
100100
{{if IfReturnType api.operation "void"}}
101-
return await I{{name}}Operations_{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
101+
return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
102102
{{ for parameter in api.operation.parameters}}
103103
{{GetDotNetNameOpenApiParameter parameter "false"}},
104104
{{end}}
105105
customHeaders,
106106
cancellationToken).ConfigureAwait(false);
107107
{{end}}
108108
{{if IfReturnType api.operation "obj"}}
109-
return await I{{name}}Operations_{{GetMethodName api.operation "WithHttpMessagesAsync"}}{{GetReturnType api.operation "<>"}}(
109+
return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}{{GetReturnType api.operation "<>"}}(
110110
{{ for parameter in api.operation.parameters}}
111111
{{GetDotNetNameOpenApiParameter parameter "false"}},
112112
{{end}}
113113
customHeaders,
114114
cancellationToken).ConfigureAwait(false);
115115
{{end}}
116116
{{if IfReturnType api.operation "stream"}}
117-
return await I{{name}}Operations_{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
117+
return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
118118
{{ for parameter in api.operation.parameters}}
119119
{{GetDotNetNameOpenApiParameter parameter "false"}},
120120
{{end}}
@@ -125,14 +125,14 @@ public partial class AbstractKubernetes : I{{name}}Operations
125125

126126
{{if IfReturnType api.operation "object"}}
127127
/// <inheritdoc/>
128-
async Task<HttpOperationResponse<T>> I{{name}}Operations.{{GetMethodName api.operation "WithHttpMessagesAsync"}}<T>(
128+
async Task<HttpOperationResponse<T>> I{{name}}Operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
129129
{{ for parameter in api.operation.parameters}}
130130
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}},
131131
{{end}}
132132
IReadOnlyDictionary<string, IReadOnlyList<string>> customHeaders,
133133
CancellationToken cancellationToken)
134134
{
135-
return await I{{name}}Operations_{{GetMethodName api.operation "WithHttpMessagesAsync"}}<T>(
135+
return await I{{name}}Operations_{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
136136
{{ for parameter in api.operation.parameters}}
137137
{{GetDotNetNameOpenApiParameter parameter "false"}},
138138
{{end}}

src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public static partial class {{name}}OperationsExtensions
2323
/// {{ToXmlDoc api.description}}
2424
/// </param>
2525
{{ end }}
26-
public static {{GetReturnType api.operation "void"}} {{GetMethodName api.operation ""}}(
26+
public static {{GetReturnType api.operation "void"}} {{GetOperationId api.operation ""}}(
2727
this I{{name}}Operations operations
2828
{{ for parameter in api.operation.parameters}}
2929
,{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}
3030
{{end}}
3131
)
3232
{
33-
{{GetReturnType api.operation "return"}} operations.{{GetMethodName api.operation "Async"}}(
33+
{{GetReturnType api.operation "return"}} operations.{{GetOperationId api.operation "Async"}}(
3434
{{ for parameter in api.operation.parameters}}
3535
{{GetDotNetNameOpenApiParameter parameter "false"}},
3636
{{end}}
@@ -50,14 +50,14 @@ public static partial class {{name}}OperationsExtensions
5050
/// {{ToXmlDoc parameter.description}}
5151
/// </param>
5252
{{end}}
53-
public static T {{GetMethodName api.operation ""}}<T>(
53+
public static T {{GetOperationId api.operation ""}}<T>(
5454
this I{{name}}Operations operations
5555
{{ for parameter in api.operation.parameters}}
5656
,{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}}
5757
{{end}}
5858
)
5959
{
60-
return operations.{{GetMethodName api.operation "Async"}}<T>(
60+
return operations.{{GetOperationId api.operation "Async"}}<T>(
6161
{{ for parameter in api.operation.parameters}}
6262
{{GetDotNetNameOpenApiParameter parameter "false"}},
6363
{{end}}
@@ -80,15 +80,15 @@ public static partial class {{name}}OperationsExtensions
8080
/// <param name="cancellationToken">
8181
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
8282
/// </param>
83-
public static async Task{{GetReturnType api.operation "<>"}} {{GetMethodName api.operation "Async"}}(
83+
public static async Task{{GetReturnType api.operation "<>"}} {{GetOperationId api.operation "Async"}}(
8484
this I{{name}}Operations operations,
8585
{{ for parameter in api.operation.parameters}}
8686
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
8787
{{ end }}
8888
CancellationToken cancellationToken = default(CancellationToken))
8989
{
9090
{{if IfReturnType api.operation "stream"}}
91-
var _result = await operations.{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
91+
var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
9292
{{ for parameter in api.operation.parameters}}
9393
{{GetDotNetNameOpenApiParameter parameter "false"}},
9494
{{end}}
@@ -98,7 +98,7 @@ public static partial class {{name}}OperationsExtensions
9898
{{GetReturnType api.operation "_result.Body"}};
9999
{{end}}
100100
{{if IfReturnType api.operation "obj"}}
101-
using (var _result = await operations.{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
101+
using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
102102
{{ for parameter in api.operation.parameters}}
103103
{{GetDotNetNameOpenApiParameter parameter "false"}},
104104
{{end}}
@@ -109,7 +109,7 @@ public static partial class {{name}}OperationsExtensions
109109
}
110110
{{end}}
111111
{{if IfReturnType api.operation "void"}}
112-
using (var _result = await operations.{{GetMethodName api.operation "WithHttpMessagesAsync"}}(
112+
using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
113113
{{ for parameter in api.operation.parameters}}
114114
{{GetDotNetNameOpenApiParameter parameter "false"}},
115115
{{end}}
@@ -135,14 +135,14 @@ public static partial class {{name}}OperationsExtensions
135135
/// <param name="cancellationToken">
136136
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
137137
/// </param>
138-
public static async Task<T> {{GetMethodName api.operation "Async"}}<T>(
138+
public static async Task<T> {{GetOperationId api.operation "Async"}}<T>(
139139
this I{{name}}Operations operations,
140140
{{ for parameter in api.operation.parameters}}
141141
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
142142
{{ end }}
143143
CancellationToken cancellationToken = default(CancellationToken))
144144
{
145-
using (var _result = await operations.{{GetMethodName api.operation "WithHttpMessagesAsync"}}<T>(
145+
using (var _result = await operations.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
146146
{{ for parameter in api.operation.parameters}}
147147
{{GetDotNetNameOpenApiParameter parameter "false"}},
148148
{{end}}

0 commit comments

Comments
 (0)