< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateRerunTriggerInstanceRequest(...)-0%100%
RerunTriggerInstanceAsync()-0%0%
RerunTriggerInstance(...)-0%0%
CreateQueryTriggerRunsByWorkspaceRequest(...)-0%100%
QueryTriggerRunsByWorkspaceAsync()-0%0%
QueryTriggerRunsByWorkspace(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\TriggerRunRestClient.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 TriggerRunRestClient
 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 TriggerRunRestClient. </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 TriggerRunRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string 
 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 CreateRerunTriggerInstanceRequest(string triggerName, string runId)
 50        {
 051            var message = _pipeline.CreateMessage();
 052            var request = message.Request;
 053            request.Method = RequestMethod.Post;
 054            var uri = new RawRequestUriBuilder();
 055            uri.AppendRaw(endpoint, false);
 056            uri.AppendPath("/triggers/", false);
 057            uri.AppendPath(triggerName, true);
 058            uri.AppendPath("/triggerRuns/", false);
 059            uri.AppendPath(runId, true);
 060            uri.AppendPath("/rerun", false);
 061            uri.AppendQuery("api-version", apiVersion, true);
 062            request.Uri = uri;
 063            return message;
 64        }
 65
 66        /// <summary> Rerun single trigger instance by runId. </summary>
 67        /// <param name="triggerName"> The trigger name. </param>
 68        /// <param name="runId"> The pipeline run identifier. </param>
 69        /// <param name="cancellationToken"> The cancellation token to use. </param>
 70        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> or <paramref name="runId"/> is null.
 71        public async Task<Response> RerunTriggerInstanceAsync(string triggerName, string runId, CancellationToken cancel
 72        {
 073            if (triggerName == null)
 74            {
 075                throw new ArgumentNullException(nameof(triggerName));
 76            }
 077            if (runId == null)
 78            {
 079                throw new ArgumentNullException(nameof(runId));
 80            }
 81
 082            using var message = CreateRerunTriggerInstanceRequest(triggerName, runId);
 083            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 084            switch (message.Response.Status)
 85            {
 86                case 200:
 087                    return message.Response;
 88                default:
 089                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 90            }
 091        }
 92
 93        /// <summary> Rerun single trigger instance by runId. </summary>
 94        /// <param name="triggerName"> The trigger name. </param>
 95        /// <param name="runId"> The pipeline run identifier. </param>
 96        /// <param name="cancellationToken"> The cancellation token to use. </param>
 97        /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> or <paramref name="runId"/> is null.
 98        public Response RerunTriggerInstance(string triggerName, string runId, CancellationToken cancellationToken = def
 99        {
 0100            if (triggerName == null)
 101            {
 0102                throw new ArgumentNullException(nameof(triggerName));
 103            }
 0104            if (runId == null)
 105            {
 0106                throw new ArgumentNullException(nameof(runId));
 107            }
 108
 0109            using var message = CreateRerunTriggerInstanceRequest(triggerName, runId);
 0110            _pipeline.Send(message, cancellationToken);
 0111            switch (message.Response.Status)
 112            {
 113                case 200:
 0114                    return message.Response;
 115                default:
 0116                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 117            }
 0118        }
 119
 120        internal HttpMessage CreateQueryTriggerRunsByWorkspaceRequest(RunFilterParameters filterParameters)
 121        {
 0122            var message = _pipeline.CreateMessage();
 0123            var request = message.Request;
 0124            request.Method = RequestMethod.Post;
 0125            var uri = new RawRequestUriBuilder();
 0126            uri.AppendRaw(endpoint, false);
 0127            uri.AppendPath("/queryTriggerRuns", false);
 0128            uri.AppendQuery("api-version", apiVersion, true);
 0129            request.Uri = uri;
 0130            request.Headers.Add("Content-Type", "application/json");
 0131            var content = new Utf8JsonRequestContent();
 0132            content.JsonWriter.WriteObjectValue(filterParameters);
 0133            request.Content = content;
 0134            return message;
 135        }
 136
 137        /// <summary> Query trigger runs. </summary>
 138        /// <param name="filterParameters"> Parameters to filter the pipeline run. </param>
 139        /// <param name="cancellationToken"> The cancellation token to use. </param>
 140        /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception>
 141        public async Task<Response<TriggerRunsQueryResponse>> QueryTriggerRunsByWorkspaceAsync(RunFilterParameters filte
 142        {
 0143            if (filterParameters == null)
 144            {
 0145                throw new ArgumentNullException(nameof(filterParameters));
 146            }
 147
 0148            using var message = CreateQueryTriggerRunsByWorkspaceRequest(filterParameters);
 0149            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0150            switch (message.Response.Status)
 151            {
 152                case 200:
 153                    {
 154                        TriggerRunsQueryResponse value = default;
 0155                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0156                        value = TriggerRunsQueryResponse.DeserializeTriggerRunsQueryResponse(document.RootElement);
 0157                        return Response.FromValue(value, message.Response);
 158                    }
 159                default:
 0160                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 161            }
 0162        }
 163
 164        /// <summary> Query trigger runs. </summary>
 165        /// <param name="filterParameters"> Parameters to filter the pipeline run. </param>
 166        /// <param name="cancellationToken"> The cancellation token to use. </param>
 167        /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception>
 168        public Response<TriggerRunsQueryResponse> QueryTriggerRunsByWorkspace(RunFilterParameters filterParameters, Canc
 169        {
 0170            if (filterParameters == null)
 171            {
 0172                throw new ArgumentNullException(nameof(filterParameters));
 173            }
 174
 0175            using var message = CreateQueryTriggerRunsByWorkspaceRequest(filterParameters);
 0176            _pipeline.Send(message, cancellationToken);
 0177            switch (message.Response.Status)
 178            {
 179                case 200:
 180                    {
 181                        TriggerRunsQueryResponse value = default;
 0182                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0183                        value = TriggerRunsQueryResponse.DeserializeTriggerRunsQueryResponse(document.RootElement);
 0184                        return Response.FromValue(value, message.Response);
 185                    }
 186                default:
 0187                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 188            }
 0189        }
 190    }
 191}