| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Analytics.Synapse.Artifacts.Models; |
| | 14 | | using Azure.Core; |
| | 15 | | using Azure.Core.Pipeline; |
| | 16 | |
|
| | 17 | | namespace Azure.Analytics.Synapse.Artifacts |
| | 18 | | { |
| | 19 | | internal partial class TriggerRestClient |
| | 20 | | { |
| | 21 | | private string endpoint; |
| | 22 | | private string apiVersion; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of TriggerRestClient. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse |
| | 30 | | /// <param name="apiVersion"> Api Version. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="apiVersion"/> is nul |
| 0 | 32 | | public TriggerRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string api |
| | 33 | | { |
| 0 | 34 | | if (endpoint == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(endpoint)); |
| | 37 | | } |
| 0 | 38 | | if (apiVersion == null) |
| | 39 | | { |
| 0 | 40 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 41 | | } |
| | 42 | |
|
| 0 | 43 | | this.endpoint = endpoint; |
| 0 | 44 | | this.apiVersion = apiVersion; |
| 0 | 45 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 46 | | _pipeline = pipeline; |
| 0 | 47 | | } |
| | 48 | |
|
| | 49 | | internal HttpMessage CreateGetTriggersByWorkspaceRequest() |
| | 50 | | { |
| 0 | 51 | | var message = _pipeline.CreateMessage(); |
| 0 | 52 | | var request = message.Request; |
| 0 | 53 | | request.Method = RequestMethod.Get; |
| 0 | 54 | | var uri = new RawRequestUriBuilder(); |
| 0 | 55 | | uri.AppendRaw(endpoint, false); |
| 0 | 56 | | uri.AppendPath("/triggers", false); |
| 0 | 57 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 58 | | request.Uri = uri; |
| 0 | 59 | | return message; |
| | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> Lists triggers. </summary> |
| | 63 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 64 | | public async Task<Response<TriggerListResponse>> GetTriggersByWorkspaceAsync(CancellationToken cancellationToken |
| | 65 | | { |
| 0 | 66 | | using var message = CreateGetTriggersByWorkspaceRequest(); |
| 0 | 67 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 68 | | switch (message.Response.Status) |
| | 69 | | { |
| | 70 | | case 200: |
| | 71 | | { |
| | 72 | | TriggerListResponse value = default; |
| 0 | 73 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 74 | | value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement); |
| 0 | 75 | | return Response.FromValue(value, message.Response); |
| | 76 | | } |
| | 77 | | default: |
| 0 | 78 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 79 | | } |
| 0 | 80 | | } |
| | 81 | |
|
| | 82 | | /// <summary> Lists triggers. </summary> |
| | 83 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 84 | | public Response<TriggerListResponse> GetTriggersByWorkspace(CancellationToken cancellationToken = default) |
| | 85 | | { |
| 0 | 86 | | using var message = CreateGetTriggersByWorkspaceRequest(); |
| 0 | 87 | | _pipeline.Send(message, cancellationToken); |
| 0 | 88 | | switch (message.Response.Status) |
| | 89 | | { |
| | 90 | | case 200: |
| | 91 | | { |
| | 92 | | TriggerListResponse value = default; |
| 0 | 93 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 94 | | value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement); |
| 0 | 95 | | return Response.FromValue(value, message.Response); |
| | 96 | | } |
| | 97 | | default: |
| 0 | 98 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 99 | | } |
| 0 | 100 | | } |
| | 101 | |
|
| | 102 | | internal HttpMessage CreateCreateOrUpdateTriggerRequest(string triggerName, TriggerResource trigger, string ifMa |
| | 103 | | { |
| 0 | 104 | | var message = _pipeline.CreateMessage(); |
| 0 | 105 | | var request = message.Request; |
| 0 | 106 | | request.Method = RequestMethod.Put; |
| 0 | 107 | | var uri = new RawRequestUriBuilder(); |
| 0 | 108 | | uri.AppendRaw(endpoint, false); |
| 0 | 109 | | uri.AppendPath("/triggers/", false); |
| 0 | 110 | | uri.AppendPath(triggerName, true); |
| 0 | 111 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 112 | | request.Uri = uri; |
| 0 | 113 | | if (ifMatch != null) |
| | 114 | | { |
| 0 | 115 | | request.Headers.Add("If-Match", ifMatch); |
| | 116 | | } |
| 0 | 117 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 118 | | var content = new Utf8JsonRequestContent(); |
| 0 | 119 | | content.JsonWriter.WriteObjectValue(trigger); |
| 0 | 120 | | request.Content = content; |
| 0 | 121 | | return message; |
| | 122 | | } |
| | 123 | |
|
| | 124 | | /// <summary> Creates or updates a trigger. </summary> |
| | 125 | | /// <param name="triggerName"> The trigger name. </param> |
| | 126 | | /// <param name="trigger"> Trigger resource definition. </param> |
| | 127 | | /// <param name="ifMatch"> ETag of the trigger entity. Should only be specified for update, for which it should |
| | 128 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 129 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> or <paramref name="trigger"/> is nul |
| | 130 | | public async Task<Response<TriggerResource>> CreateOrUpdateTriggerAsync(string triggerName, TriggerResource trig |
| | 131 | | { |
| 0 | 132 | | if (triggerName == null) |
| | 133 | | { |
| 0 | 134 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 135 | | } |
| 0 | 136 | | if (trigger == null) |
| | 137 | | { |
| 0 | 138 | | throw new ArgumentNullException(nameof(trigger)); |
| | 139 | | } |
| | 140 | |
|
| 0 | 141 | | using var message = CreateCreateOrUpdateTriggerRequest(triggerName, trigger, ifMatch); |
| 0 | 142 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 143 | | switch (message.Response.Status) |
| | 144 | | { |
| | 145 | | case 200: |
| | 146 | | { |
| | 147 | | TriggerResource value = default; |
| 0 | 148 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 149 | | value = TriggerResource.DeserializeTriggerResource(document.RootElement); |
| 0 | 150 | | return Response.FromValue(value, message.Response); |
| | 151 | | } |
| | 152 | | default: |
| 0 | 153 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 154 | | } |
| 0 | 155 | | } |
| | 156 | |
|
| | 157 | | /// <summary> Creates or updates a trigger. </summary> |
| | 158 | | /// <param name="triggerName"> The trigger name. </param> |
| | 159 | | /// <param name="trigger"> Trigger resource definition. </param> |
| | 160 | | /// <param name="ifMatch"> ETag of the trigger entity. Should only be specified for update, for which it should |
| | 161 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 162 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> or <paramref name="trigger"/> is nul |
| | 163 | | public Response<TriggerResource> CreateOrUpdateTrigger(string triggerName, TriggerResource trigger, string ifMat |
| | 164 | | { |
| 0 | 165 | | if (triggerName == null) |
| | 166 | | { |
| 0 | 167 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 168 | | } |
| 0 | 169 | | if (trigger == null) |
| | 170 | | { |
| 0 | 171 | | throw new ArgumentNullException(nameof(trigger)); |
| | 172 | | } |
| | 173 | |
|
| 0 | 174 | | using var message = CreateCreateOrUpdateTriggerRequest(triggerName, trigger, ifMatch); |
| 0 | 175 | | _pipeline.Send(message, cancellationToken); |
| 0 | 176 | | switch (message.Response.Status) |
| | 177 | | { |
| | 178 | | case 200: |
| | 179 | | { |
| | 180 | | TriggerResource value = default; |
| 0 | 181 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 182 | | value = TriggerResource.DeserializeTriggerResource(document.RootElement); |
| 0 | 183 | | return Response.FromValue(value, message.Response); |
| | 184 | | } |
| | 185 | | default: |
| 0 | 186 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 187 | | } |
| 0 | 188 | | } |
| | 189 | |
|
| | 190 | | internal HttpMessage CreateGetTriggerRequest(string triggerName, string ifNoneMatch) |
| | 191 | | { |
| 0 | 192 | | var message = _pipeline.CreateMessage(); |
| 0 | 193 | | var request = message.Request; |
| 0 | 194 | | request.Method = RequestMethod.Get; |
| 0 | 195 | | var uri = new RawRequestUriBuilder(); |
| 0 | 196 | | uri.AppendRaw(endpoint, false); |
| 0 | 197 | | uri.AppendPath("/triggers/", false); |
| 0 | 198 | | uri.AppendPath(triggerName, true); |
| 0 | 199 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 200 | | request.Uri = uri; |
| 0 | 201 | | if (ifNoneMatch != null) |
| | 202 | | { |
| 0 | 203 | | request.Headers.Add("If-None-Match", ifNoneMatch); |
| | 204 | | } |
| 0 | 205 | | return message; |
| | 206 | | } |
| | 207 | |
|
| | 208 | | /// <summary> Gets a trigger. </summary> |
| | 209 | | /// <param name="triggerName"> The trigger name. </param> |
| | 210 | | /// <param name="ifNoneMatch"> ETag of the trigger entity. Should only be specified for get. If the ETag matches |
| | 211 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 212 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 213 | | public async Task<Response<TriggerResource>> GetTriggerAsync(string triggerName, string ifNoneMatch = null, Canc |
| | 214 | | { |
| 0 | 215 | | if (triggerName == null) |
| | 216 | | { |
| 0 | 217 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 218 | | } |
| | 219 | |
|
| 0 | 220 | | using var message = CreateGetTriggerRequest(triggerName, ifNoneMatch); |
| 0 | 221 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 222 | | switch (message.Response.Status) |
| | 223 | | { |
| | 224 | | case 200: |
| | 225 | | { |
| | 226 | | TriggerResource value = default; |
| 0 | 227 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 228 | | value = TriggerResource.DeserializeTriggerResource(document.RootElement); |
| 0 | 229 | | return Response.FromValue(value, message.Response); |
| | 230 | | } |
| | 231 | | case 304: |
| 0 | 232 | | return Response.FromValue<TriggerResource>(null, message.Response); |
| | 233 | | default: |
| 0 | 234 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 235 | | } |
| 0 | 236 | | } |
| | 237 | |
|
| | 238 | | /// <summary> Gets a trigger. </summary> |
| | 239 | | /// <param name="triggerName"> The trigger name. </param> |
| | 240 | | /// <param name="ifNoneMatch"> ETag of the trigger entity. Should only be specified for get. If the ETag matches |
| | 241 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 242 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 243 | | public Response<TriggerResource> GetTrigger(string triggerName, string ifNoneMatch = null, CancellationToken can |
| | 244 | | { |
| 0 | 245 | | if (triggerName == null) |
| | 246 | | { |
| 0 | 247 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 248 | | } |
| | 249 | |
|
| 0 | 250 | | using var message = CreateGetTriggerRequest(triggerName, ifNoneMatch); |
| 0 | 251 | | _pipeline.Send(message, cancellationToken); |
| 0 | 252 | | switch (message.Response.Status) |
| | 253 | | { |
| | 254 | | case 200: |
| | 255 | | { |
| | 256 | | TriggerResource value = default; |
| 0 | 257 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 258 | | value = TriggerResource.DeserializeTriggerResource(document.RootElement); |
| 0 | 259 | | return Response.FromValue(value, message.Response); |
| | 260 | | } |
| | 261 | | case 304: |
| 0 | 262 | | return Response.FromValue<TriggerResource>(null, message.Response); |
| | 263 | | default: |
| 0 | 264 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 265 | | } |
| 0 | 266 | | } |
| | 267 | |
|
| | 268 | | internal HttpMessage CreateDeleteTriggerRequest(string triggerName) |
| | 269 | | { |
| 0 | 270 | | var message = _pipeline.CreateMessage(); |
| 0 | 271 | | var request = message.Request; |
| 0 | 272 | | request.Method = RequestMethod.Delete; |
| 0 | 273 | | var uri = new RawRequestUriBuilder(); |
| 0 | 274 | | uri.AppendRaw(endpoint, false); |
| 0 | 275 | | uri.AppendPath("/triggers/", false); |
| 0 | 276 | | uri.AppendPath(triggerName, true); |
| 0 | 277 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 278 | | request.Uri = uri; |
| 0 | 279 | | return message; |
| | 280 | | } |
| | 281 | |
|
| | 282 | | /// <summary> Deletes a trigger. </summary> |
| | 283 | | /// <param name="triggerName"> The trigger name. </param> |
| | 284 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 285 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 286 | | public async Task<Response> DeleteTriggerAsync(string triggerName, CancellationToken cancellationToken = default |
| | 287 | | { |
| 0 | 288 | | if (triggerName == null) |
| | 289 | | { |
| 0 | 290 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 291 | | } |
| | 292 | |
|
| 0 | 293 | | using var message = CreateDeleteTriggerRequest(triggerName); |
| 0 | 294 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 295 | | switch (message.Response.Status) |
| | 296 | | { |
| | 297 | | case 200: |
| | 298 | | case 204: |
| 0 | 299 | | return message.Response; |
| | 300 | | default: |
| 0 | 301 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 302 | | } |
| 0 | 303 | | } |
| | 304 | |
|
| | 305 | | /// <summary> Deletes a trigger. </summary> |
| | 306 | | /// <param name="triggerName"> The trigger name. </param> |
| | 307 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 308 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 309 | | public Response DeleteTrigger(string triggerName, CancellationToken cancellationToken = default) |
| | 310 | | { |
| 0 | 311 | | if (triggerName == null) |
| | 312 | | { |
| 0 | 313 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 314 | | } |
| | 315 | |
|
| 0 | 316 | | using var message = CreateDeleteTriggerRequest(triggerName); |
| 0 | 317 | | _pipeline.Send(message, cancellationToken); |
| 0 | 318 | | switch (message.Response.Status) |
| | 319 | | { |
| | 320 | | case 200: |
| | 321 | | case 204: |
| 0 | 322 | | return message.Response; |
| | 323 | | default: |
| 0 | 324 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 325 | | } |
| 0 | 326 | | } |
| | 327 | |
|
| | 328 | | internal HttpMessage CreateSubscribeTriggerToEventsRequest(string triggerName) |
| | 329 | | { |
| 0 | 330 | | var message = _pipeline.CreateMessage(); |
| 0 | 331 | | var request = message.Request; |
| 0 | 332 | | request.Method = RequestMethod.Post; |
| 0 | 333 | | var uri = new RawRequestUriBuilder(); |
| 0 | 334 | | uri.AppendRaw(endpoint, false); |
| 0 | 335 | | uri.AppendPath("/triggers/", false); |
| 0 | 336 | | uri.AppendPath(triggerName, true); |
| 0 | 337 | | uri.AppendPath("/subscribeToEvents", false); |
| 0 | 338 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 339 | | request.Uri = uri; |
| 0 | 340 | | return message; |
| | 341 | | } |
| | 342 | |
|
| | 343 | | /// <summary> Subscribe event trigger to events. </summary> |
| | 344 | | /// <param name="triggerName"> The trigger name. </param> |
| | 345 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 346 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 347 | | public async Task<Response> SubscribeTriggerToEventsAsync(string triggerName, CancellationToken cancellationToke |
| | 348 | | { |
| 0 | 349 | | if (triggerName == null) |
| | 350 | | { |
| 0 | 351 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 352 | | } |
| | 353 | |
|
| 0 | 354 | | using var message = CreateSubscribeTriggerToEventsRequest(triggerName); |
| 0 | 355 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 356 | | switch (message.Response.Status) |
| | 357 | | { |
| | 358 | | case 200: |
| | 359 | | case 202: |
| 0 | 360 | | return message.Response; |
| | 361 | | default: |
| 0 | 362 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 363 | | } |
| 0 | 364 | | } |
| | 365 | |
|
| | 366 | | /// <summary> Subscribe event trigger to events. </summary> |
| | 367 | | /// <param name="triggerName"> The trigger name. </param> |
| | 368 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 369 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 370 | | public Response SubscribeTriggerToEvents(string triggerName, CancellationToken cancellationToken = default) |
| | 371 | | { |
| 0 | 372 | | if (triggerName == null) |
| | 373 | | { |
| 0 | 374 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 375 | | } |
| | 376 | |
|
| 0 | 377 | | using var message = CreateSubscribeTriggerToEventsRequest(triggerName); |
| 0 | 378 | | _pipeline.Send(message, cancellationToken); |
| 0 | 379 | | switch (message.Response.Status) |
| | 380 | | { |
| | 381 | | case 200: |
| | 382 | | case 202: |
| 0 | 383 | | return message.Response; |
| | 384 | | default: |
| 0 | 385 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 386 | | } |
| 0 | 387 | | } |
| | 388 | |
|
| | 389 | | internal HttpMessage CreateGetEventSubscriptionStatusRequest(string triggerName) |
| | 390 | | { |
| 0 | 391 | | var message = _pipeline.CreateMessage(); |
| 0 | 392 | | var request = message.Request; |
| 0 | 393 | | request.Method = RequestMethod.Post; |
| 0 | 394 | | var uri = new RawRequestUriBuilder(); |
| 0 | 395 | | uri.AppendRaw(endpoint, false); |
| 0 | 396 | | uri.AppendPath("/triggers/", false); |
| 0 | 397 | | uri.AppendPath(triggerName, true); |
| 0 | 398 | | uri.AppendPath("/getEventSubscriptionStatus", false); |
| 0 | 399 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 400 | | request.Uri = uri; |
| 0 | 401 | | return message; |
| | 402 | | } |
| | 403 | |
|
| | 404 | | /// <summary> Get a trigger's event subscription status. </summary> |
| | 405 | | /// <param name="triggerName"> The trigger name. </param> |
| | 406 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 407 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 408 | | public async Task<Response<TriggerSubscriptionOperationStatus>> GetEventSubscriptionStatusAsync(string triggerNa |
| | 409 | | { |
| 0 | 410 | | if (triggerName == null) |
| | 411 | | { |
| 0 | 412 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 413 | | } |
| | 414 | |
|
| 0 | 415 | | using var message = CreateGetEventSubscriptionStatusRequest(triggerName); |
| 0 | 416 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 417 | | switch (message.Response.Status) |
| | 418 | | { |
| | 419 | | case 200: |
| | 420 | | { |
| | 421 | | TriggerSubscriptionOperationStatus value = default; |
| 0 | 422 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 423 | | value = TriggerSubscriptionOperationStatus.DeserializeTriggerSubscriptionOperationStatus(documen |
| 0 | 424 | | return Response.FromValue(value, message.Response); |
| | 425 | | } |
| | 426 | | default: |
| 0 | 427 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 428 | | } |
| 0 | 429 | | } |
| | 430 | |
|
| | 431 | | /// <summary> Get a trigger's event subscription status. </summary> |
| | 432 | | /// <param name="triggerName"> The trigger name. </param> |
| | 433 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 434 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 435 | | public Response<TriggerSubscriptionOperationStatus> GetEventSubscriptionStatus(string triggerName, CancellationT |
| | 436 | | { |
| 0 | 437 | | if (triggerName == null) |
| | 438 | | { |
| 0 | 439 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 440 | | } |
| | 441 | |
|
| 0 | 442 | | using var message = CreateGetEventSubscriptionStatusRequest(triggerName); |
| 0 | 443 | | _pipeline.Send(message, cancellationToken); |
| 0 | 444 | | switch (message.Response.Status) |
| | 445 | | { |
| | 446 | | case 200: |
| | 447 | | { |
| | 448 | | TriggerSubscriptionOperationStatus value = default; |
| 0 | 449 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 450 | | value = TriggerSubscriptionOperationStatus.DeserializeTriggerSubscriptionOperationStatus(documen |
| 0 | 451 | | return Response.FromValue(value, message.Response); |
| | 452 | | } |
| | 453 | | default: |
| 0 | 454 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 455 | | } |
| 0 | 456 | | } |
| | 457 | |
|
| | 458 | | internal HttpMessage CreateUnsubscribeTriggerFromEventsRequest(string triggerName) |
| | 459 | | { |
| 0 | 460 | | var message = _pipeline.CreateMessage(); |
| 0 | 461 | | var request = message.Request; |
| 0 | 462 | | request.Method = RequestMethod.Post; |
| 0 | 463 | | var uri = new RawRequestUriBuilder(); |
| 0 | 464 | | uri.AppendRaw(endpoint, false); |
| 0 | 465 | | uri.AppendPath("/triggers/", false); |
| 0 | 466 | | uri.AppendPath(triggerName, true); |
| 0 | 467 | | uri.AppendPath("/unsubscribeFromEvents", false); |
| 0 | 468 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 469 | | request.Uri = uri; |
| 0 | 470 | | return message; |
| | 471 | | } |
| | 472 | |
|
| | 473 | | /// <summary> Unsubscribe event trigger from events. </summary> |
| | 474 | | /// <param name="triggerName"> The trigger name. </param> |
| | 475 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 476 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 477 | | public async Task<Response> UnsubscribeTriggerFromEventsAsync(string triggerName, CancellationToken cancellation |
| | 478 | | { |
| 0 | 479 | | if (triggerName == null) |
| | 480 | | { |
| 0 | 481 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 482 | | } |
| | 483 | |
|
| 0 | 484 | | using var message = CreateUnsubscribeTriggerFromEventsRequest(triggerName); |
| 0 | 485 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 486 | | switch (message.Response.Status) |
| | 487 | | { |
| | 488 | | case 200: |
| | 489 | | case 202: |
| 0 | 490 | | return message.Response; |
| | 491 | | default: |
| 0 | 492 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 493 | | } |
| 0 | 494 | | } |
| | 495 | |
|
| | 496 | | /// <summary> Unsubscribe event trigger from events. </summary> |
| | 497 | | /// <param name="triggerName"> The trigger name. </param> |
| | 498 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 499 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 500 | | public Response UnsubscribeTriggerFromEvents(string triggerName, CancellationToken cancellationToken = default) |
| | 501 | | { |
| 0 | 502 | | if (triggerName == null) |
| | 503 | | { |
| 0 | 504 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 505 | | } |
| | 506 | |
|
| 0 | 507 | | using var message = CreateUnsubscribeTriggerFromEventsRequest(triggerName); |
| 0 | 508 | | _pipeline.Send(message, cancellationToken); |
| 0 | 509 | | switch (message.Response.Status) |
| | 510 | | { |
| | 511 | | case 200: |
| | 512 | | case 202: |
| 0 | 513 | | return message.Response; |
| | 514 | | default: |
| 0 | 515 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 516 | | } |
| 0 | 517 | | } |
| | 518 | |
|
| | 519 | | internal HttpMessage CreateStartTriggerRequest(string triggerName) |
| | 520 | | { |
| 0 | 521 | | var message = _pipeline.CreateMessage(); |
| 0 | 522 | | var request = message.Request; |
| 0 | 523 | | request.Method = RequestMethod.Post; |
| 0 | 524 | | var uri = new RawRequestUriBuilder(); |
| 0 | 525 | | uri.AppendRaw(endpoint, false); |
| 0 | 526 | | uri.AppendPath("/triggers/", false); |
| 0 | 527 | | uri.AppendPath(triggerName, true); |
| 0 | 528 | | uri.AppendPath("/start", false); |
| 0 | 529 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 530 | | request.Uri = uri; |
| 0 | 531 | | return message; |
| | 532 | | } |
| | 533 | |
|
| | 534 | | /// <summary> Starts a trigger. </summary> |
| | 535 | | /// <param name="triggerName"> The trigger name. </param> |
| | 536 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 537 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 538 | | public async Task<Response> StartTriggerAsync(string triggerName, CancellationToken cancellationToken = default) |
| | 539 | | { |
| 0 | 540 | | if (triggerName == null) |
| | 541 | | { |
| 0 | 542 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 543 | | } |
| | 544 | |
|
| 0 | 545 | | using var message = CreateStartTriggerRequest(triggerName); |
| 0 | 546 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 547 | | switch (message.Response.Status) |
| | 548 | | { |
| | 549 | | case 200: |
| 0 | 550 | | return message.Response; |
| | 551 | | default: |
| 0 | 552 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 553 | | } |
| 0 | 554 | | } |
| | 555 | |
|
| | 556 | | /// <summary> Starts a trigger. </summary> |
| | 557 | | /// <param name="triggerName"> The trigger name. </param> |
| | 558 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 559 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 560 | | public Response StartTrigger(string triggerName, CancellationToken cancellationToken = default) |
| | 561 | | { |
| 0 | 562 | | if (triggerName == null) |
| | 563 | | { |
| 0 | 564 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 565 | | } |
| | 566 | |
|
| 0 | 567 | | using var message = CreateStartTriggerRequest(triggerName); |
| 0 | 568 | | _pipeline.Send(message, cancellationToken); |
| 0 | 569 | | switch (message.Response.Status) |
| | 570 | | { |
| | 571 | | case 200: |
| 0 | 572 | | return message.Response; |
| | 573 | | default: |
| 0 | 574 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 575 | | } |
| 0 | 576 | | } |
| | 577 | |
|
| | 578 | | internal HttpMessage CreateStopTriggerRequest(string triggerName) |
| | 579 | | { |
| 0 | 580 | | var message = _pipeline.CreateMessage(); |
| 0 | 581 | | var request = message.Request; |
| 0 | 582 | | request.Method = RequestMethod.Post; |
| 0 | 583 | | var uri = new RawRequestUriBuilder(); |
| 0 | 584 | | uri.AppendRaw(endpoint, false); |
| 0 | 585 | | uri.AppendPath("/triggers/", false); |
| 0 | 586 | | uri.AppendPath(triggerName, true); |
| 0 | 587 | | uri.AppendPath("/stop", false); |
| 0 | 588 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 589 | | request.Uri = uri; |
| 0 | 590 | | return message; |
| | 591 | | } |
| | 592 | |
|
| | 593 | | /// <summary> Stops a trigger. </summary> |
| | 594 | | /// <param name="triggerName"> The trigger name. </param> |
| | 595 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 596 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 597 | | public async Task<Response> StopTriggerAsync(string triggerName, CancellationToken cancellationToken = default) |
| | 598 | | { |
| 0 | 599 | | if (triggerName == null) |
| | 600 | | { |
| 0 | 601 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 602 | | } |
| | 603 | |
|
| 0 | 604 | | using var message = CreateStopTriggerRequest(triggerName); |
| 0 | 605 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 606 | | switch (message.Response.Status) |
| | 607 | | { |
| | 608 | | case 200: |
| 0 | 609 | | return message.Response; |
| | 610 | | default: |
| 0 | 611 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 612 | | } |
| 0 | 613 | | } |
| | 614 | |
|
| | 615 | | /// <summary> Stops a trigger. </summary> |
| | 616 | | /// <param name="triggerName"> The trigger name. </param> |
| | 617 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 618 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception> |
| | 619 | | public Response StopTrigger(string triggerName, CancellationToken cancellationToken = default) |
| | 620 | | { |
| 0 | 621 | | if (triggerName == null) |
| | 622 | | { |
| 0 | 623 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 624 | | } |
| | 625 | |
|
| 0 | 626 | | using var message = CreateStopTriggerRequest(triggerName); |
| 0 | 627 | | _pipeline.Send(message, cancellationToken); |
| 0 | 628 | | switch (message.Response.Status) |
| | 629 | | { |
| | 630 | | case 200: |
| 0 | 631 | | return message.Response; |
| | 632 | | default: |
| 0 | 633 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 634 | | } |
| 0 | 635 | | } |
| | 636 | |
|
| | 637 | | internal HttpMessage CreateGetTriggersByWorkspaceNextPageRequest(string nextLink) |
| | 638 | | { |
| 0 | 639 | | var message = _pipeline.CreateMessage(); |
| 0 | 640 | | var request = message.Request; |
| 0 | 641 | | request.Method = RequestMethod.Get; |
| 0 | 642 | | var uri = new RawRequestUriBuilder(); |
| 0 | 643 | | uri.AppendRaw(endpoint, false); |
| 0 | 644 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 645 | | request.Uri = uri; |
| 0 | 646 | | return message; |
| | 647 | | } |
| | 648 | |
|
| | 649 | | /// <summary> Lists triggers. </summary> |
| | 650 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 651 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 652 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 653 | | public async Task<Response<TriggerListResponse>> GetTriggersByWorkspaceNextPageAsync(string nextLink, Cancellati |
| | 654 | | { |
| 0 | 655 | | if (nextLink == null) |
| | 656 | | { |
| 0 | 657 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 658 | | } |
| | 659 | |
|
| 0 | 660 | | using var message = CreateGetTriggersByWorkspaceNextPageRequest(nextLink); |
| 0 | 661 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 662 | | switch (message.Response.Status) |
| | 663 | | { |
| | 664 | | case 200: |
| | 665 | | { |
| | 666 | | TriggerListResponse value = default; |
| 0 | 667 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 668 | | value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement); |
| 0 | 669 | | return Response.FromValue(value, message.Response); |
| | 670 | | } |
| | 671 | | default: |
| 0 | 672 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 673 | | } |
| 0 | 674 | | } |
| | 675 | |
|
| | 676 | | /// <summary> Lists triggers. </summary> |
| | 677 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 678 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 679 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 680 | | public Response<TriggerListResponse> GetTriggersByWorkspaceNextPage(string nextLink, CancellationToken cancellat |
| | 681 | | { |
| 0 | 682 | | if (nextLink == null) |
| | 683 | | { |
| 0 | 684 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 685 | | } |
| | 686 | |
|
| 0 | 687 | | using var message = CreateGetTriggersByWorkspaceNextPageRequest(nextLink); |
| 0 | 688 | | _pipeline.Send(message, cancellationToken); |
| 0 | 689 | | switch (message.Response.Status) |
| | 690 | | { |
| | 691 | | case 200: |
| | 692 | | { |
| | 693 | | TriggerListResponse value = default; |
| 0 | 694 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 695 | | value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement); |
| 0 | 696 | | return Response.FromValue(value, message.Response); |
| | 697 | | } |
| | 698 | | default: |
| 0 | 699 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 700 | | } |
| 0 | 701 | | } |
| | 702 | | } |
| | 703 | | } |