@@ -17,10 +17,11 @@ public partial class {{name}}Client : ResourceClient
17
17
}
18
18
19
19
{{for api in apis }}
20
+ {{~ $filteredParams = FilterParameters api.operation "watch" ~}}
20
21
/// <summary>
21
22
/// {{ToXmlDoc api.operation.description}}
22
23
/// </summary>
23
- {{ for parameter in api.operation.parameters }}
24
+ {{ for parameter in $filteredParams }}
24
25
/// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
25
26
/// {{ToXmlDoc parameter.description}}
26
27
/// </param>
@@ -29,15 +30,15 @@ public partial class {{name}}Client : ResourceClient
29
30
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
30
31
/// </param>
31
32
public async Task{{GetReturnType api.operation "<>"}} {{GetActionName api.operation name "Async"}}(
32
- {{ for parameter in api.operation.parameters }}
33
+ {{ for parameter in $filteredParams }}
33
34
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
34
35
{{ end }}
35
36
CancellationToken cancellationToken = default(CancellationToken))
36
37
{
37
38
{{if IfReturnType api.operation "stream"}}
38
39
var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
39
40
{{ for parameter in api.operation.parameters}}
40
- {{GetDotNetNameOpenApiParameter parameter " false" }},
41
+ {{GetParameterValueForWatch parameter false}},
41
42
{{end}}
42
43
null,
43
44
cancellationToken);
@@ -47,7 +48,7 @@ public partial class {{name}}Client : ResourceClient
47
48
{{if IfReturnType api.operation "obj"}}
48
49
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
49
50
{{ for parameter in api.operation.parameters}}
50
- {{GetDotNetNameOpenApiParameter parameter " false" }},
51
+ {{GetParameterValueForWatch parameter false}},
51
52
{{end}}
52
53
null,
53
54
cancellationToken).ConfigureAwait(false))
@@ -58,7 +59,7 @@ public partial class {{name}}Client : ResourceClient
58
59
{{if IfReturnType api.operation "void"}}
59
60
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
60
61
{{ for parameter in api.operation.parameters}}
61
- {{GetDotNetNameOpenApiParameter parameter " false" }},
62
+ {{GetParameterValueForWatch parameter false}},
62
63
{{end}}
63
64
null,
64
65
cancellationToken).ConfigureAwait(false))
@@ -71,7 +72,7 @@ public partial class {{name}}Client : ResourceClient
71
72
/// <summary>
72
73
/// {{ToXmlDoc api.operation.description}}
73
74
/// </summary>
74
- {{ for parameter in api.operation.parameters }}
75
+ {{ for parameter in $filteredParams }}
75
76
/// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
76
77
/// {{ToXmlDoc parameter.description}}
77
78
/// </param>
@@ -80,14 +81,14 @@ public partial class {{name}}Client : ResourceClient
80
81
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
81
82
/// </param>
82
83
public async Task<T> {{GetActionName api.operation name "Async"}}<T>(
83
- {{ for parameter in api.operation.parameters }}
84
+ {{ for parameter in $filteredParams }}
84
85
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}},
85
86
{{ end }}
86
87
CancellationToken cancellationToken = default(CancellationToken))
87
88
{
88
89
using (var _result = await Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}<T>(
89
90
{{ for parameter in api.operation.parameters}}
90
- {{GetDotNetNameOpenApiParameter parameter " false" }},
91
+ {{GetParameterValueForWatch parameter false}},
91
92
{{end}}
92
93
null,
93
94
cancellationToken).ConfigureAwait(false))
@@ -96,5 +97,68 @@ public partial class {{name}}Client : ResourceClient
96
97
}
97
98
}
98
99
{{end}}
100
+
101
+ {{if IfParamContains api.operation "watch"}}
102
+ /// <summary>
103
+ /// Watch {{ToXmlDoc api.operation.description}}
104
+ /// </summary>
105
+ {{ for parameter in $filteredParams}}
106
+ /// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
107
+ /// {{ToXmlDoc parameter.description}}
108
+ /// </param>
109
+ {{ end }}
110
+ /// <param name="onEvent">Callback when any event raised from api server</param>
111
+ /// <param name="onError">Callback when any exception was caught during watching</param>
112
+ /// <param name="onClosed">Callback when the server closes the connection</param>
113
+ public Watcher<{{GetReturnType api.operation "T"}}> Watch{{GetActionName api.operation name ""}}(
114
+ {{ for parameter in $filteredParams}}
115
+ {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
116
+ {{ end }}
117
+ Action<WatchEventType, {{GetReturnType api.operation "T"}}> onEvent = null,
118
+ Action<Exception> onError = null,
119
+ Action onClosed = null)
120
+ {
121
+ if (onEvent == null) throw new ArgumentNullException(nameof(onEvent));
122
+
123
+ var responseTask = Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
124
+ {{ for parameter in api.operation.parameters}}
125
+ {{GetParameterValueForWatch parameter true}},
126
+ {{ end }}
127
+ null,
128
+ CancellationToken.None);
129
+
130
+ return responseTask.Watch<{{GetReturnType api.operation "T"}}, {{GetReturnType api.operation "TList"}}>(
131
+ onEvent, onError, onClosed);
132
+ }
133
+
134
+ /// <summary>
135
+ /// Watch {{ToXmlDoc api.operation.description}} as async enumerable
136
+ /// </summary>
137
+ {{ for parameter in $filteredParams}}
138
+ /// <param name="{{GetDotNetNameOpenApiParameter parameter "false"}}">
139
+ /// {{ToXmlDoc parameter.description}}
140
+ /// </param>
141
+ {{ end }}
142
+ /// <param name="onError">Callback when any exception was caught during watching</param>
143
+ /// <param name="cancellationToken">Cancellation token</param>
144
+ public IAsyncEnumerable<(WatchEventType, {{GetReturnType api.operation "T"}})> Watch{{GetActionName api.operation name "Async"}}(
145
+ {{ for parameter in $filteredParams}}
146
+ {{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
147
+ {{ end }}
148
+ Action<Exception> onError = null,
149
+ CancellationToken cancellationToken = default)
150
+ {
151
+ var responseTask = Client.{{group}}.{{GetOperationId api.operation "WithHttpMessagesAsync"}}(
152
+ {{ for parameter in api.operation.parameters}}
153
+ {{GetParameterValueForWatch parameter true}},
154
+ {{ end }}
155
+ null,
156
+ cancellationToken);
157
+
158
+ return responseTask.WatchAsync<{{GetReturnType api.operation "T"}}, {{GetReturnType api.operation "TList"}}>(
159
+ onError, cancellationToken);
160
+ }
99
161
{{end}}
100
- }
162
+
163
+ {{end}}
164
+ }
0 commit comments