@@ -96,5 +96,69 @@ public partial class {{name}}Client : ResourceClient
96
96
}
97
97
}
98
98
{{end}}
99
+
100
+ {{if IfParamContains api.operation "watch"}}
101
+ {{~ $filteredParams = FilterParameters 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}},
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}},
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}}
162
+
163
+ {{end}}
100
164
}
0 commit comments