< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%100%
.ctor(...)-0%100%
.ctor(...)-0%100%
get_RestClient()-0%100%
.ctor(...)-0%100%
.ctor()-0%100%
.ctor(...)-0%100%
CreateOrUpdateTriggerAsync()-0%100%
CreateOrUpdateTrigger(...)-0%100%
GetTriggerAsync()-0%100%
GetTrigger(...)-0%100%
DeleteTriggerAsync()-0%100%
DeleteTrigger(...)-0%100%
GetEventSubscriptionStatusAsync()-0%100%
GetEventSubscriptionStatus(...)-0%100%
<GetTriggersByWorkspaceAsync()-0%100%
<GetTriggersByWorkspaceAsync()-0%100%
GetTriggersByWorkspaceAsync(...)-0%100%
GetTriggersByWorkspace(...)-0%100%
StartSubscribeTriggerToEventsAsync()-0%0%
StartSubscribeTriggerToEvents(...)-0%0%
StartUnsubscribeTriggerFromEventsAsync()-0%0%
StartUnsubscribeTriggerFromEvents(...)-0%0%
StartStartTriggerAsync()-0%0%
StartStartTrigger(...)-0%0%
StartStopTriggerAsync()-0%0%
StartStopTrigger(...)-0%0%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using Azure.Core;
 6using Azure.Core.Pipeline;
 7
 8namespace Azure.Analytics.Synapse.Artifacts
 9{
 10    public partial class TriggerClient
 11    {
 12        /// <summary>
 13        /// Initializes a new instance of the <see cref="TriggerClient"/>.
 14        /// </summary>
 15        public TriggerClient(Uri endpoint, TokenCredential credential)
 016            : this(endpoint, credential, ArtifactsClientOptions.Default)
 17        {
 018        }
 19
 20        /// <summary>
 21        /// Initializes a new instance of the <see cref="TriggerClient"/>.
 22        /// </summary>
 23        public TriggerClient(Uri endpoint, TokenCredential credential, ArtifactsClientOptions options)
 024            : this(new ClientDiagnostics(options),
 025                  SynapseClientPipeline.Build(options, credential),
 026                  endpoint.ToString(),
 027                  options.VersionString)
 28        {
 029        }
 30    }
 31}

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\TriggerClient.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.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Analytics.Synapse.Artifacts.Models;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15
 016namespace Azure.Analytics.Synapse.Artifacts
 17{
 018    /// <summary> The Trigger service client. </summary>
 19    public partial class TriggerClient
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 023        internal TriggerRestClient RestClient { get; }
 024        /// <summary> Initializes a new instance of TriggerClient for mocking. </summary>
 025        protected TriggerClient()
 026        {
 027        }
 28        /// <summary> Initializes a new instance of TriggerClient. </summary>
 029        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 30        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 31        /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse
 32        /// <param name="apiVersion"> Api Version. </param>
 033        internal TriggerClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string apiVe
 34        {
 035            RestClient = new TriggerRestClient(clientDiagnostics, pipeline, endpoint, apiVersion);
 036            _clientDiagnostics = clientDiagnostics;
 037            _pipeline = pipeline;
 038        }
 39
 40        /// <summary> Creates or updates a trigger. </summary>
 41        /// <param name="triggerName"> The trigger name. </param>
 42        /// <param name="trigger"> Trigger resource definition. </param>
 43        /// <param name="ifMatch"> ETag of the trigger entity.  Should only be specified for update, for which it should
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<TriggerResource>> CreateOrUpdateTriggerAsync(string triggerName, TriggerResou
 46        {
 047            using var scope = _clientDiagnostics.CreateScope("TriggerClient.CreateOrUpdateTrigger");
 048            scope.Start();
 49            try
 50            {
 051                return await RestClient.CreateOrUpdateTriggerAsync(triggerName, trigger, ifMatch, cancellationToken).Con
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 058        }
 59
 60        /// <summary> Creates or updates a trigger. </summary>
 61        /// <param name="triggerName"> The trigger name. </param>
 62        /// <param name="trigger"> Trigger resource definition. </param>
 63        /// <param name="ifMatch"> ETag of the trigger entity.  Should only be specified for update, for which it should
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<TriggerResource> CreateOrUpdateTrigger(string triggerName, TriggerResource trigger, stri
 66        {
 067            using var scope = _clientDiagnostics.CreateScope("TriggerClient.CreateOrUpdateTrigger");
 068            scope.Start();
 69            try
 70            {
 071                return RestClient.CreateOrUpdateTrigger(triggerName, trigger, ifMatch, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 078        }
 79
 80        /// <summary> Gets a trigger. </summary>
 81        /// <param name="triggerName"> The trigger name. </param>
 82        /// <param name="ifNoneMatch"> ETag of the trigger entity. Should only be specified for get. If the ETag matches
 83        /// <param name="cancellationToken"> The cancellation token to use. </param>
 84        public virtual async Task<Response<TriggerResource>> GetTriggerAsync(string triggerName, string ifNoneMatch = nu
 85        {
 086            using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetTrigger");
 087            scope.Start();
 88            try
 89            {
 090                return await RestClient.GetTriggerAsync(triggerName, ifNoneMatch, cancellationToken).ConfigureAwait(fals
 91            }
 092            catch (Exception e)
 93            {
 094                scope.Failed(e);
 095                throw;
 96            }
 097        }
 98
 99        /// <summary> Gets a trigger. </summary>
 100        /// <param name="triggerName"> The trigger name. </param>
 101        /// <param name="ifNoneMatch"> ETag of the trigger entity. Should only be specified for get. If the ETag matches
 102        /// <param name="cancellationToken"> The cancellation token to use. </param>
 103        public virtual Response<TriggerResource> GetTrigger(string triggerName, string ifNoneMatch = null, CancellationT
 104        {
 0105            using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetTrigger");
 0106            scope.Start();
 107            try
 108            {
 0109                return RestClient.GetTrigger(triggerName, ifNoneMatch, cancellationToken);
 110            }
 0111            catch (Exception e)
 112            {
 0113                scope.Failed(e);
 0114                throw;
 115            }
 0116        }
 117
 118        /// <summary> Deletes a trigger. </summary>
 119        /// <param name="triggerName"> The trigger name. </param>
 120        /// <param name="cancellationToken"> The cancellation token to use. </param>
 121        public virtual async Task<Response> DeleteTriggerAsync(string triggerName, CancellationToken cancellationToken =
 122        {
 0123            using var scope = _clientDiagnostics.CreateScope("TriggerClient.DeleteTrigger");
 0124            scope.Start();
 125            try
 126            {
 0127                return await RestClient.DeleteTriggerAsync(triggerName, cancellationToken).ConfigureAwait(false);
 128            }
 0129            catch (Exception e)
 130            {
 0131                scope.Failed(e);
 0132                throw;
 133            }
 0134        }
 135
 136        /// <summary> Deletes a trigger. </summary>
 137        /// <param name="triggerName"> The trigger name. </param>
 138        /// <param name="cancellationToken"> The cancellation token to use. </param>
 139        public virtual Response DeleteTrigger(string triggerName, CancellationToken cancellationToken = default)
 140        {
 0141            using var scope = _clientDiagnostics.CreateScope("TriggerClient.DeleteTrigger");
 0142            scope.Start();
 143            try
 144            {
 0145                return RestClient.DeleteTrigger(triggerName, cancellationToken);
 146            }
 0147            catch (Exception e)
 148            {
 0149                scope.Failed(e);
 0150                throw;
 151            }
 0152        }
 153
 154        /// <summary> Get a trigger&apos;s event subscription status. </summary>
 155        /// <param name="triggerName"> The trigger name. </param>
 156        /// <param name="cancellationToken"> The cancellation token to use. </param>
 157        public virtual async Task<Response<TriggerSubscriptionOperationStatus>> GetEventSubscriptionStatusAsync(string t
 158        {
 0159            using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetEventSubscriptionStatus");
 0160            scope.Start();
 161            try
 162            {
 0163                return await RestClient.GetEventSubscriptionStatusAsync(triggerName, cancellationToken).ConfigureAwait(f
 164            }
 0165            catch (Exception e)
 166            {
 0167                scope.Failed(e);
 0168                throw;
 169            }
 0170        }
 171
 172        /// <summary> Get a trigger&apos;s event subscription status. </summary>
 173        /// <param name="triggerName"> The trigger name. </param>
 174        /// <param name="cancellationToken"> The cancellation token to use. </param>
 175        public virtual Response<TriggerSubscriptionOperationStatus> GetEventSubscriptionStatus(string triggerName, Cance
 176        {
 0177            using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetEventSubscriptionStatus");
 0178            scope.Start();
 179            try
 180            {
 0181                return RestClient.GetEventSubscriptionStatus(triggerName, cancellationToken);
 182            }
 0183            catch (Exception e)
 184            {
 0185                scope.Failed(e);
 0186                throw;
 187            }
 0188        }
 189
 190        /// <summary> Lists triggers. </summary>
 191        /// <param name="cancellationToken"> The cancellation token to use. </param>
 192        public virtual AsyncPageable<TriggerResource> GetTriggersByWorkspaceAsync(CancellationToken cancellationToken = 
 193        {
 194            async Task<Page<TriggerResource>> FirstPageFunc(int? pageSizeHint)
 195            {
 0196                using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetTriggersByWorkspace");
 0197                scope.Start();
 198                try
 199                {
 0200                    var response = await RestClient.GetTriggersByWorkspaceAsync(cancellationToken).ConfigureAwait(false)
 0201                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 202                }
 0203                catch (Exception e)
 204                {
 0205                    scope.Failed(e);
 0206                    throw;
 207                }
 0208            }
 209            async Task<Page<TriggerResource>> NextPageFunc(string nextLink, int? pageSizeHint)
 210            {
 0211                using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetTriggersByWorkspace");
 0212                scope.Start();
 213                try
 214                {
 0215                    var response = await RestClient.GetTriggersByWorkspaceNextPageAsync(nextLink, cancellationToken).Con
 0216                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 217                }
 0218                catch (Exception e)
 219                {
 0220                    scope.Failed(e);
 0221                    throw;
 222                }
 0223            }
 0224            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 225        }
 226
 227        /// <summary> Lists triggers. </summary>
 228        /// <param name="cancellationToken"> The cancellation token to use. </param>
 229        public virtual Pageable<TriggerResource> GetTriggersByWorkspace(CancellationToken cancellationToken = default)
 230        {
 231            Page<TriggerResource> FirstPageFunc(int? pageSizeHint)
 232            {
 0233                using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetTriggersByWorkspace");
 0234                scope.Start();
 235                try
 236                {
 0237                    var response = RestClient.GetTriggersByWorkspace(cancellationToken);
 0238                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 239                }
 0240                catch (Exception e)
 241                {
 0242                    scope.Failed(e);
 0243                    throw;
 244                }
 0245            }
 246            Page<TriggerResource> NextPageFunc(string nextLink, int? pageSizeHint)
 247            {
 0248                using var scope = _clientDiagnostics.CreateScope("TriggerClient.GetTriggersByWorkspace");
 0249                scope.Start();
 250                try
 251                {
 0252                    var response = RestClient.GetTriggersByWorkspaceNextPage(nextLink, cancellationToken);
 0253                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 254                }
 0255                catch (Exception e)
 256                {
 0257                    scope.Failed(e);
 0258                    throw;
 259                }
 0260            }
 0261            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 262        }
 263
 264        /// <summary> Subscribe event trigger to events. </summary>
 265        /// <param name="triggerName"> The trigger name. </param>
 266        /// <param name="cancellationToken"> The cancellation token to use. </param>
 267        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 268        public virtual async Task<TriggerSubscribeTriggerToEventsOperation> StartSubscribeTriggerToEventsAsync(string tr
 269        {
 0270            if (triggerName == null)
 271            {
 0272                throw new ArgumentNullException(nameof(triggerName));
 273            }
 274
 0275            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartSubscribeTriggerToEvents");
 0276            scope.Start();
 277            try
 278            {
 0279                var originalResponse = await RestClient.SubscribeTriggerToEventsAsync(triggerName, cancellationToken).Co
 0280                return new TriggerSubscribeTriggerToEventsOperation(_clientDiagnostics, _pipeline, RestClient.CreateSubs
 281            }
 0282            catch (Exception e)
 283            {
 0284                scope.Failed(e);
 0285                throw;
 286            }
 0287        }
 288
 289        /// <summary> Subscribe event trigger to events. </summary>
 290        /// <param name="triggerName"> The trigger name. </param>
 291        /// <param name="cancellationToken"> The cancellation token to use. </param>
 292        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 293        public virtual TriggerSubscribeTriggerToEventsOperation StartSubscribeTriggerToEvents(string triggerName, Cancel
 294        {
 0295            if (triggerName == null)
 296            {
 0297                throw new ArgumentNullException(nameof(triggerName));
 298            }
 299
 0300            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartSubscribeTriggerToEvents");
 0301            scope.Start();
 302            try
 303            {
 0304                var originalResponse = RestClient.SubscribeTriggerToEvents(triggerName, cancellationToken);
 0305                return new TriggerSubscribeTriggerToEventsOperation(_clientDiagnostics, _pipeline, RestClient.CreateSubs
 306            }
 0307            catch (Exception e)
 308            {
 0309                scope.Failed(e);
 0310                throw;
 311            }
 0312        }
 313
 314        /// <summary> Unsubscribe event trigger from events. </summary>
 315        /// <param name="triggerName"> The trigger name. </param>
 316        /// <param name="cancellationToken"> The cancellation token to use. </param>
 317        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 318        public virtual async Task<TriggerUnsubscribeTriggerFromEventsOperation> StartUnsubscribeTriggerFromEventsAsync(s
 319        {
 0320            if (triggerName == null)
 321            {
 0322                throw new ArgumentNullException(nameof(triggerName));
 323            }
 324
 0325            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartUnsubscribeTriggerFromEvents");
 0326            scope.Start();
 327            try
 328            {
 0329                var originalResponse = await RestClient.UnsubscribeTriggerFromEventsAsync(triggerName, cancellationToken
 0330                return new TriggerUnsubscribeTriggerFromEventsOperation(_clientDiagnostics, _pipeline, RestClient.Create
 331            }
 0332            catch (Exception e)
 333            {
 0334                scope.Failed(e);
 0335                throw;
 336            }
 0337        }
 338
 339        /// <summary> Unsubscribe event trigger from events. </summary>
 340        /// <param name="triggerName"> The trigger name. </param>
 341        /// <param name="cancellationToken"> The cancellation token to use. </param>
 342        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 343        public virtual TriggerUnsubscribeTriggerFromEventsOperation StartUnsubscribeTriggerFromEvents(string triggerName
 344        {
 0345            if (triggerName == null)
 346            {
 0347                throw new ArgumentNullException(nameof(triggerName));
 348            }
 349
 0350            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartUnsubscribeTriggerFromEvents");
 0351            scope.Start();
 352            try
 353            {
 0354                var originalResponse = RestClient.UnsubscribeTriggerFromEvents(triggerName, cancellationToken);
 0355                return new TriggerUnsubscribeTriggerFromEventsOperation(_clientDiagnostics, _pipeline, RestClient.Create
 356            }
 0357            catch (Exception e)
 358            {
 0359                scope.Failed(e);
 0360                throw;
 361            }
 0362        }
 363
 364        /// <summary> Starts a trigger. </summary>
 365        /// <param name="triggerName"> The trigger name. </param>
 366        /// <param name="cancellationToken"> The cancellation token to use. </param>
 367        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 368        public virtual async Task<TriggerStartTriggerOperation> StartStartTriggerAsync(string triggerName, CancellationT
 369        {
 0370            if (triggerName == null)
 371            {
 0372                throw new ArgumentNullException(nameof(triggerName));
 373            }
 374
 0375            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartStartTrigger");
 0376            scope.Start();
 377            try
 378            {
 0379                var originalResponse = await RestClient.StartTriggerAsync(triggerName, cancellationToken).ConfigureAwait
 0380                return new TriggerStartTriggerOperation(_clientDiagnostics, _pipeline, RestClient.CreateStartTriggerRequ
 381            }
 0382            catch (Exception e)
 383            {
 0384                scope.Failed(e);
 0385                throw;
 386            }
 0387        }
 388
 389        /// <summary> Starts a trigger. </summary>
 390        /// <param name="triggerName"> The trigger name. </param>
 391        /// <param name="cancellationToken"> The cancellation token to use. </param>
 392        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 393        public virtual TriggerStartTriggerOperation StartStartTrigger(string triggerName, CancellationToken cancellation
 394        {
 0395            if (triggerName == null)
 396            {
 0397                throw new ArgumentNullException(nameof(triggerName));
 398            }
 399
 0400            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartStartTrigger");
 0401            scope.Start();
 402            try
 403            {
 0404                var originalResponse = RestClient.StartTrigger(triggerName, cancellationToken);
 0405                return new TriggerStartTriggerOperation(_clientDiagnostics, _pipeline, RestClient.CreateStartTriggerRequ
 406            }
 0407            catch (Exception e)
 408            {
 0409                scope.Failed(e);
 0410                throw;
 411            }
 0412        }
 413
 414        /// <summary> Stops a trigger. </summary>
 415        /// <param name="triggerName"> The trigger name. </param>
 416        /// <param name="cancellationToken"> The cancellation token to use. </param>
 417        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 418        public virtual async Task<TriggerStopTriggerOperation> StartStopTriggerAsync(string triggerName, CancellationTok
 419        {
 0420            if (triggerName == null)
 421            {
 0422                throw new ArgumentNullException(nameof(triggerName));
 423            }
 424
 0425            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartStopTrigger");
 0426            scope.Start();
 427            try
 428            {
 0429                var originalResponse = await RestClient.StopTriggerAsync(triggerName, cancellationToken).ConfigureAwait(
 0430                return new TriggerStopTriggerOperation(_clientDiagnostics, _pipeline, RestClient.CreateStopTriggerReques
 431            }
 0432            catch (Exception e)
 433            {
 0434                scope.Failed(e);
 0435                throw;
 436            }
 0437        }
 438
 439        /// <summary> Stops a trigger. </summary>
 440        /// <param name="triggerName"> The trigger name. </param>
 441        /// <param name="cancellationToken"> The cancellation token to use. </param>
 442        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> is null. </exception>
 443        public virtual TriggerStopTriggerOperation StartStopTrigger(string triggerName, CancellationToken cancellationTo
 444        {
 0445            if (triggerName == null)
 446            {
 0447                throw new ArgumentNullException(nameof(triggerName));
 448            }
 449
 0450            using var scope = _clientDiagnostics.CreateScope("TriggerClient.StartStopTrigger");
 0451            scope.Start();
 452            try
 453            {
 0454                var originalResponse = RestClient.StopTrigger(triggerName, cancellationToken);
 0455                return new TriggerStopTriggerOperation(_clientDiagnostics, _pipeline, RestClient.CreateStopTriggerReques
 456            }
 0457            catch (Exception e)
 458            {
 0459                scope.Failed(e);
 0460                throw;
 461            }
 0462        }
 463    }
 464}