< Summary

Class:Azure.Analytics.Synapse.Artifacts.TriggerRestClient
Assembly:Azure.Analytics.Synapse.Artifacts
File(s):C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\TriggerRestClient.cs
Covered lines:0
Uncovered lines:302
Coverable lines:302
Total lines:703
Line coverage:0% (0 of 302)
Covered branches:0
Total branches:104
Branch coverage:0% (0 of 104)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateGetTriggersByWorkspaceRequest()-0%100%
GetTriggersByWorkspaceAsync()-0%0%
GetTriggersByWorkspace(...)-0%0%
CreateCreateOrUpdateTriggerRequest(...)-0%0%
CreateOrUpdateTriggerAsync()-0%0%
CreateOrUpdateTrigger(...)-0%0%
CreateGetTriggerRequest(...)-0%0%
GetTriggerAsync()-0%0%
GetTrigger(...)-0%0%
CreateDeleteTriggerRequest(...)-0%100%
DeleteTriggerAsync()-0%0%
DeleteTrigger(...)-0%0%
CreateSubscribeTriggerToEventsRequest(...)-0%100%
SubscribeTriggerToEventsAsync()-0%0%
SubscribeTriggerToEvents(...)-0%0%
CreateGetEventSubscriptionStatusRequest(...)-0%100%
GetEventSubscriptionStatusAsync()-0%0%
GetEventSubscriptionStatus(...)-0%0%
CreateUnsubscribeTriggerFromEventsRequest(...)-0%100%
UnsubscribeTriggerFromEventsAsync()-0%0%
UnsubscribeTriggerFromEvents(...)-0%0%
CreateStartTriggerRequest(...)-0%100%
StartTriggerAsync()-0%0%
StartTrigger(...)-0%0%
CreateStopTriggerRequest(...)-0%100%
StopTriggerAsync()-0%0%
StopTrigger(...)-0%0%
CreateGetTriggersByWorkspaceNextPageRequest(...)-0%100%
GetTriggersByWorkspaceNextPageAsync()-0%0%
GetTriggersByWorkspaceNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\TriggerRestClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Analytics.Synapse.Artifacts.Models;
 14using Azure.Core;
 15using Azure.Core.Pipeline;
 16
 17namespace 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
 032        public TriggerRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string api
 33        {
 034            if (endpoint == null)
 35            {
 036                throw new ArgumentNullException(nameof(endpoint));
 37            }
 038            if (apiVersion == null)
 39            {
 040                throw new ArgumentNullException(nameof(apiVersion));
 41            }
 42
 043            this.endpoint = endpoint;
 044            this.apiVersion = apiVersion;
 045            _clientDiagnostics = clientDiagnostics;
 046            _pipeline = pipeline;
 047        }
 48
 49        internal HttpMessage CreateGetTriggersByWorkspaceRequest()
 50        {
 051            var message = _pipeline.CreateMessage();
 052            var request = message.Request;
 053            request.Method = RequestMethod.Get;
 054            var uri = new RawRequestUriBuilder();
 055            uri.AppendRaw(endpoint, false);
 056            uri.AppendPath("/triggers", false);
 057            uri.AppendQuery("api-version", apiVersion, true);
 058            request.Uri = uri;
 059            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        {
 066            using var message = CreateGetTriggersByWorkspaceRequest();
 067            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 068            switch (message.Response.Status)
 69            {
 70                case 200:
 71                    {
 72                        TriggerListResponse value = default;
 073                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 074                        value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement);
 075                        return Response.FromValue(value, message.Response);
 76                    }
 77                default:
 078                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 79            }
 080        }
 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        {
 086            using var message = CreateGetTriggersByWorkspaceRequest();
 087            _pipeline.Send(message, cancellationToken);
 088            switch (message.Response.Status)
 89            {
 90                case 200:
 91                    {
 92                        TriggerListResponse value = default;
 093                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 094                        value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement);
 095                        return Response.FromValue(value, message.Response);
 96                    }
 97                default:
 098                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 99            }
 0100        }
 101
 102        internal HttpMessage CreateCreateOrUpdateTriggerRequest(string triggerName, TriggerResource trigger, string ifMa
 103        {
 0104            var message = _pipeline.CreateMessage();
 0105            var request = message.Request;
 0106            request.Method = RequestMethod.Put;
 0107            var uri = new RawRequestUriBuilder();
 0108            uri.AppendRaw(endpoint, false);
 0109            uri.AppendPath("/triggers/", false);
 0110            uri.AppendPath(triggerName, true);
 0111            uri.AppendQuery("api-version", apiVersion, true);
 0112            request.Uri = uri;
 0113            if (ifMatch != null)
 114            {
 0115                request.Headers.Add("If-Match", ifMatch);
 116            }
 0117            request.Headers.Add("Content-Type", "application/json");
 0118            var content = new Utf8JsonRequestContent();
 0119            content.JsonWriter.WriteObjectValue(trigger);
 0120            request.Content = content;
 0121            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        {
 0132            if (triggerName == null)
 133            {
 0134                throw new ArgumentNullException(nameof(triggerName));
 135            }
 0136            if (trigger == null)
 137            {
 0138                throw new ArgumentNullException(nameof(trigger));
 139            }
 140
 0141            using var message = CreateCreateOrUpdateTriggerRequest(triggerName, trigger, ifMatch);
 0142            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0143            switch (message.Response.Status)
 144            {
 145                case 200:
 146                    {
 147                        TriggerResource value = default;
 0148                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0149                        value = TriggerResource.DeserializeTriggerResource(document.RootElement);
 0150                        return Response.FromValue(value, message.Response);
 151                    }
 152                default:
 0153                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 154            }
 0155        }
 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        {
 0165            if (triggerName == null)
 166            {
 0167                throw new ArgumentNullException(nameof(triggerName));
 168            }
 0169            if (trigger == null)
 170            {
 0171                throw new ArgumentNullException(nameof(trigger));
 172            }
 173
 0174            using var message = CreateCreateOrUpdateTriggerRequest(triggerName, trigger, ifMatch);
 0175            _pipeline.Send(message, cancellationToken);
 0176            switch (message.Response.Status)
 177            {
 178                case 200:
 179                    {
 180                        TriggerResource value = default;
 0181                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0182                        value = TriggerResource.DeserializeTriggerResource(document.RootElement);
 0183                        return Response.FromValue(value, message.Response);
 184                    }
 185                default:
 0186                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 187            }
 0188        }
 189
 190        internal HttpMessage CreateGetTriggerRequest(string triggerName, string ifNoneMatch)
 191        {
 0192            var message = _pipeline.CreateMessage();
 0193            var request = message.Request;
 0194            request.Method = RequestMethod.Get;
 0195            var uri = new RawRequestUriBuilder();
 0196            uri.AppendRaw(endpoint, false);
 0197            uri.AppendPath("/triggers/", false);
 0198            uri.AppendPath(triggerName, true);
 0199            uri.AppendQuery("api-version", apiVersion, true);
 0200            request.Uri = uri;
 0201            if (ifNoneMatch != null)
 202            {
 0203                request.Headers.Add("If-None-Match", ifNoneMatch);
 204            }
 0205            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        {
 0215            if (triggerName == null)
 216            {
 0217                throw new ArgumentNullException(nameof(triggerName));
 218            }
 219
 0220            using var message = CreateGetTriggerRequest(triggerName, ifNoneMatch);
 0221            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0222            switch (message.Response.Status)
 223            {
 224                case 200:
 225                    {
 226                        TriggerResource value = default;
 0227                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0228                        value = TriggerResource.DeserializeTriggerResource(document.RootElement);
 0229                        return Response.FromValue(value, message.Response);
 230                    }
 231                case 304:
 0232                    return Response.FromValue<TriggerResource>(null, message.Response);
 233                default:
 0234                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 235            }
 0236        }
 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        {
 0245            if (triggerName == null)
 246            {
 0247                throw new ArgumentNullException(nameof(triggerName));
 248            }
 249
 0250            using var message = CreateGetTriggerRequest(triggerName, ifNoneMatch);
 0251            _pipeline.Send(message, cancellationToken);
 0252            switch (message.Response.Status)
 253            {
 254                case 200:
 255                    {
 256                        TriggerResource value = default;
 0257                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0258                        value = TriggerResource.DeserializeTriggerResource(document.RootElement);
 0259                        return Response.FromValue(value, message.Response);
 260                    }
 261                case 304:
 0262                    return Response.FromValue<TriggerResource>(null, message.Response);
 263                default:
 0264                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 265            }
 0266        }
 267
 268        internal HttpMessage CreateDeleteTriggerRequest(string triggerName)
 269        {
 0270            var message = _pipeline.CreateMessage();
 0271            var request = message.Request;
 0272            request.Method = RequestMethod.Delete;
 0273            var uri = new RawRequestUriBuilder();
 0274            uri.AppendRaw(endpoint, false);
 0275            uri.AppendPath("/triggers/", false);
 0276            uri.AppendPath(triggerName, true);
 0277            uri.AppendQuery("api-version", apiVersion, true);
 0278            request.Uri = uri;
 0279            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        {
 0288            if (triggerName == null)
 289            {
 0290                throw new ArgumentNullException(nameof(triggerName));
 291            }
 292
 0293            using var message = CreateDeleteTriggerRequest(triggerName);
 0294            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0295            switch (message.Response.Status)
 296            {
 297                case 200:
 298                case 204:
 0299                    return message.Response;
 300                default:
 0301                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 302            }
 0303        }
 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        {
 0311            if (triggerName == null)
 312            {
 0313                throw new ArgumentNullException(nameof(triggerName));
 314            }
 315
 0316            using var message = CreateDeleteTriggerRequest(triggerName);
 0317            _pipeline.Send(message, cancellationToken);
 0318            switch (message.Response.Status)
 319            {
 320                case 200:
 321                case 204:
 0322                    return message.Response;
 323                default:
 0324                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 325            }
 0326        }
 327
 328        internal HttpMessage CreateSubscribeTriggerToEventsRequest(string triggerName)
 329        {
 0330            var message = _pipeline.CreateMessage();
 0331            var request = message.Request;
 0332            request.Method = RequestMethod.Post;
 0333            var uri = new RawRequestUriBuilder();
 0334            uri.AppendRaw(endpoint, false);
 0335            uri.AppendPath("/triggers/", false);
 0336            uri.AppendPath(triggerName, true);
 0337            uri.AppendPath("/subscribeToEvents", false);
 0338            uri.AppendQuery("api-version", apiVersion, true);
 0339            request.Uri = uri;
 0340            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        {
 0349            if (triggerName == null)
 350            {
 0351                throw new ArgumentNullException(nameof(triggerName));
 352            }
 353
 0354            using var message = CreateSubscribeTriggerToEventsRequest(triggerName);
 0355            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0356            switch (message.Response.Status)
 357            {
 358                case 200:
 359                case 202:
 0360                    return message.Response;
 361                default:
 0362                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 363            }
 0364        }
 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        {
 0372            if (triggerName == null)
 373            {
 0374                throw new ArgumentNullException(nameof(triggerName));
 375            }
 376
 0377            using var message = CreateSubscribeTriggerToEventsRequest(triggerName);
 0378            _pipeline.Send(message, cancellationToken);
 0379            switch (message.Response.Status)
 380            {
 381                case 200:
 382                case 202:
 0383                    return message.Response;
 384                default:
 0385                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 386            }
 0387        }
 388
 389        internal HttpMessage CreateGetEventSubscriptionStatusRequest(string triggerName)
 390        {
 0391            var message = _pipeline.CreateMessage();
 0392            var request = message.Request;
 0393            request.Method = RequestMethod.Post;
 0394            var uri = new RawRequestUriBuilder();
 0395            uri.AppendRaw(endpoint, false);
 0396            uri.AppendPath("/triggers/", false);
 0397            uri.AppendPath(triggerName, true);
 0398            uri.AppendPath("/getEventSubscriptionStatus", false);
 0399            uri.AppendQuery("api-version", apiVersion, true);
 0400            request.Uri = uri;
 0401            return message;
 402        }
 403
 404        /// <summary> Get a trigger&apos;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        {
 0410            if (triggerName == null)
 411            {
 0412                throw new ArgumentNullException(nameof(triggerName));
 413            }
 414
 0415            using var message = CreateGetEventSubscriptionStatusRequest(triggerName);
 0416            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0417            switch (message.Response.Status)
 418            {
 419                case 200:
 420                    {
 421                        TriggerSubscriptionOperationStatus value = default;
 0422                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0423                        value = TriggerSubscriptionOperationStatus.DeserializeTriggerSubscriptionOperationStatus(documen
 0424                        return Response.FromValue(value, message.Response);
 425                    }
 426                default:
 0427                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 428            }
 0429        }
 430
 431        /// <summary> Get a trigger&apos;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        {
 0437            if (triggerName == null)
 438            {
 0439                throw new ArgumentNullException(nameof(triggerName));
 440            }
 441
 0442            using var message = CreateGetEventSubscriptionStatusRequest(triggerName);
 0443            _pipeline.Send(message, cancellationToken);
 0444            switch (message.Response.Status)
 445            {
 446                case 200:
 447                    {
 448                        TriggerSubscriptionOperationStatus value = default;
 0449                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0450                        value = TriggerSubscriptionOperationStatus.DeserializeTriggerSubscriptionOperationStatus(documen
 0451                        return Response.FromValue(value, message.Response);
 452                    }
 453                default:
 0454                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 455            }
 0456        }
 457
 458        internal HttpMessage CreateUnsubscribeTriggerFromEventsRequest(string triggerName)
 459        {
 0460            var message = _pipeline.CreateMessage();
 0461            var request = message.Request;
 0462            request.Method = RequestMethod.Post;
 0463            var uri = new RawRequestUriBuilder();
 0464            uri.AppendRaw(endpoint, false);
 0465            uri.AppendPath("/triggers/", false);
 0466            uri.AppendPath(triggerName, true);
 0467            uri.AppendPath("/unsubscribeFromEvents", false);
 0468            uri.AppendQuery("api-version", apiVersion, true);
 0469            request.Uri = uri;
 0470            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        {
 0479            if (triggerName == null)
 480            {
 0481                throw new ArgumentNullException(nameof(triggerName));
 482            }
 483
 0484            using var message = CreateUnsubscribeTriggerFromEventsRequest(triggerName);
 0485            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0486            switch (message.Response.Status)
 487            {
 488                case 200:
 489                case 202:
 0490                    return message.Response;
 491                default:
 0492                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 493            }
 0494        }
 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        {
 0502            if (triggerName == null)
 503            {
 0504                throw new ArgumentNullException(nameof(triggerName));
 505            }
 506
 0507            using var message = CreateUnsubscribeTriggerFromEventsRequest(triggerName);
 0508            _pipeline.Send(message, cancellationToken);
 0509            switch (message.Response.Status)
 510            {
 511                case 200:
 512                case 202:
 0513                    return message.Response;
 514                default:
 0515                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 516            }
 0517        }
 518
 519        internal HttpMessage CreateStartTriggerRequest(string triggerName)
 520        {
 0521            var message = _pipeline.CreateMessage();
 0522            var request = message.Request;
 0523            request.Method = RequestMethod.Post;
 0524            var uri = new RawRequestUriBuilder();
 0525            uri.AppendRaw(endpoint, false);
 0526            uri.AppendPath("/triggers/", false);
 0527            uri.AppendPath(triggerName, true);
 0528            uri.AppendPath("/start", false);
 0529            uri.AppendQuery("api-version", apiVersion, true);
 0530            request.Uri = uri;
 0531            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        {
 0540            if (triggerName == null)
 541            {
 0542                throw new ArgumentNullException(nameof(triggerName));
 543            }
 544
 0545            using var message = CreateStartTriggerRequest(triggerName);
 0546            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0547            switch (message.Response.Status)
 548            {
 549                case 200:
 0550                    return message.Response;
 551                default:
 0552                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 553            }
 0554        }
 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        {
 0562            if (triggerName == null)
 563            {
 0564                throw new ArgumentNullException(nameof(triggerName));
 565            }
 566
 0567            using var message = CreateStartTriggerRequest(triggerName);
 0568            _pipeline.Send(message, cancellationToken);
 0569            switch (message.Response.Status)
 570            {
 571                case 200:
 0572                    return message.Response;
 573                default:
 0574                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 575            }
 0576        }
 577
 578        internal HttpMessage CreateStopTriggerRequest(string triggerName)
 579        {
 0580            var message = _pipeline.CreateMessage();
 0581            var request = message.Request;
 0582            request.Method = RequestMethod.Post;
 0583            var uri = new RawRequestUriBuilder();
 0584            uri.AppendRaw(endpoint, false);
 0585            uri.AppendPath("/triggers/", false);
 0586            uri.AppendPath(triggerName, true);
 0587            uri.AppendPath("/stop", false);
 0588            uri.AppendQuery("api-version", apiVersion, true);
 0589            request.Uri = uri;
 0590            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        {
 0599            if (triggerName == null)
 600            {
 0601                throw new ArgumentNullException(nameof(triggerName));
 602            }
 603
 0604            using var message = CreateStopTriggerRequest(triggerName);
 0605            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0606            switch (message.Response.Status)
 607            {
 608                case 200:
 0609                    return message.Response;
 610                default:
 0611                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 612            }
 0613        }
 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        {
 0621            if (triggerName == null)
 622            {
 0623                throw new ArgumentNullException(nameof(triggerName));
 624            }
 625
 0626            using var message = CreateStopTriggerRequest(triggerName);
 0627            _pipeline.Send(message, cancellationToken);
 0628            switch (message.Response.Status)
 629            {
 630                case 200:
 0631                    return message.Response;
 632                default:
 0633                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 634            }
 0635        }
 636
 637        internal HttpMessage CreateGetTriggersByWorkspaceNextPageRequest(string nextLink)
 638        {
 0639            var message = _pipeline.CreateMessage();
 0640            var request = message.Request;
 0641            request.Method = RequestMethod.Get;
 0642            var uri = new RawRequestUriBuilder();
 0643            uri.AppendRaw(endpoint, false);
 0644            uri.AppendRawNextLink(nextLink, false);
 0645            request.Uri = uri;
 0646            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        {
 0655            if (nextLink == null)
 656            {
 0657                throw new ArgumentNullException(nameof(nextLink));
 658            }
 659
 0660            using var message = CreateGetTriggersByWorkspaceNextPageRequest(nextLink);
 0661            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0662            switch (message.Response.Status)
 663            {
 664                case 200:
 665                    {
 666                        TriggerListResponse value = default;
 0667                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0668                        value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement);
 0669                        return Response.FromValue(value, message.Response);
 670                    }
 671                default:
 0672                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 673            }
 0674        }
 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        {
 0682            if (nextLink == null)
 683            {
 0684                throw new ArgumentNullException(nameof(nextLink));
 685            }
 686
 0687            using var message = CreateGetTriggersByWorkspaceNextPageRequest(nextLink);
 0688            _pipeline.Send(message, cancellationToken);
 0689            switch (message.Response.Status)
 690            {
 691                case 200:
 692                    {
 693                        TriggerListResponse value = default;
 0694                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0695                        value = TriggerListResponse.DeserializeTriggerListResponse(document.RootElement);
 0696                        return Response.FromValue(value, message.Response);
 697                    }
 698                default:
 0699                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 700            }
 0701        }
 702    }
 703}