< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateQueryPipelineRunsByWorkspaceRequest(...)-0%100%
QueryPipelineRunsByWorkspaceAsync()-0%0%
QueryPipelineRunsByWorkspace(...)-0%0%
CreateGetPipelineRunRequest(...)-0%100%
GetPipelineRunAsync()-0%0%
GetPipelineRun(...)-0%0%
CreateQueryActivityRunsRequest(...)-0%100%
QueryActivityRunsAsync()-0%0%
QueryActivityRuns(...)-0%0%
CreateCancelPipelineRunRequest(...)-0%0%
CancelPipelineRunAsync()-0%0%
CancelPipelineRun(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\PipelineRunRestClient.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 PipelineRunRestClient
 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 PipelineRunRestClient. </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 PipelineRunRestClient(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 CreateQueryPipelineRunsByWorkspaceRequest(RunFilterParameters filterParameters)
 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("/queryPipelineRuns", false);
 057            uri.AppendQuery("api-version", apiVersion, true);
 058            request.Uri = uri;
 059            request.Headers.Add("Content-Type", "application/json");
 060            var content = new Utf8JsonRequestContent();
 061            content.JsonWriter.WriteObjectValue(filterParameters);
 062            request.Content = content;
 063            return message;
 64        }
 65
 66        /// <summary> Query pipeline runs in the workspace based on input filter conditions. </summary>
 67        /// <param name="filterParameters"> Parameters to filter the pipeline run. </param>
 68        /// <param name="cancellationToken"> The cancellation token to use. </param>
 69        /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception>
 70        public async Task<Response<PipelineRunsQueryResponse>> QueryPipelineRunsByWorkspaceAsync(RunFilterParameters fil
 71        {
 072            if (filterParameters == null)
 73            {
 074                throw new ArgumentNullException(nameof(filterParameters));
 75            }
 76
 077            using var message = CreateQueryPipelineRunsByWorkspaceRequest(filterParameters);
 078            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 079            switch (message.Response.Status)
 80            {
 81                case 200:
 82                    {
 83                        PipelineRunsQueryResponse value = default;
 084                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 085                        value = PipelineRunsQueryResponse.DeserializePipelineRunsQueryResponse(document.RootElement);
 086                        return Response.FromValue(value, message.Response);
 87                    }
 88                default:
 089                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 90            }
 091        }
 92
 93        /// <summary> Query pipeline runs in the workspace based on input filter conditions. </summary>
 94        /// <param name="filterParameters"> Parameters to filter the pipeline run. </param>
 95        /// <param name="cancellationToken"> The cancellation token to use. </param>
 96        /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception>
 97        public Response<PipelineRunsQueryResponse> QueryPipelineRunsByWorkspace(RunFilterParameters filterParameters, Ca
 98        {
 099            if (filterParameters == null)
 100            {
 0101                throw new ArgumentNullException(nameof(filterParameters));
 102            }
 103
 0104            using var message = CreateQueryPipelineRunsByWorkspaceRequest(filterParameters);
 0105            _pipeline.Send(message, cancellationToken);
 0106            switch (message.Response.Status)
 107            {
 108                case 200:
 109                    {
 110                        PipelineRunsQueryResponse value = default;
 0111                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0112                        value = PipelineRunsQueryResponse.DeserializePipelineRunsQueryResponse(document.RootElement);
 0113                        return Response.FromValue(value, message.Response);
 114                    }
 115                default:
 0116                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 117            }
 0118        }
 119
 120        internal HttpMessage CreateGetPipelineRunRequest(string runId)
 121        {
 0122            var message = _pipeline.CreateMessage();
 0123            var request = message.Request;
 0124            request.Method = RequestMethod.Get;
 0125            var uri = new RawRequestUriBuilder();
 0126            uri.AppendRaw(endpoint, false);
 0127            uri.AppendPath("/pipelineruns/", false);
 0128            uri.AppendPath(runId, true);
 0129            uri.AppendQuery("api-version", apiVersion, true);
 0130            request.Uri = uri;
 0131            return message;
 132        }
 133
 134        /// <summary> Get a pipeline run by its run ID. </summary>
 135        /// <param name="runId"> The pipeline run identifier. </param>
 136        /// <param name="cancellationToken"> The cancellation token to use. </param>
 137        /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception>
 138        public async Task<Response<PipelineRun>> GetPipelineRunAsync(string runId, CancellationToken cancellationToken =
 139        {
 0140            if (runId == null)
 141            {
 0142                throw new ArgumentNullException(nameof(runId));
 143            }
 144
 0145            using var message = CreateGetPipelineRunRequest(runId);
 0146            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0147            switch (message.Response.Status)
 148            {
 149                case 200:
 150                    {
 151                        PipelineRun value = default;
 0152                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0153                        value = PipelineRun.DeserializePipelineRun(document.RootElement);
 0154                        return Response.FromValue(value, message.Response);
 155                    }
 156                default:
 0157                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 158            }
 0159        }
 160
 161        /// <summary> Get a pipeline run by its run ID. </summary>
 162        /// <param name="runId"> The pipeline run identifier. </param>
 163        /// <param name="cancellationToken"> The cancellation token to use. </param>
 164        /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception>
 165        public Response<PipelineRun> GetPipelineRun(string runId, CancellationToken cancellationToken = default)
 166        {
 0167            if (runId == null)
 168            {
 0169                throw new ArgumentNullException(nameof(runId));
 170            }
 171
 0172            using var message = CreateGetPipelineRunRequest(runId);
 0173            _pipeline.Send(message, cancellationToken);
 0174            switch (message.Response.Status)
 175            {
 176                case 200:
 177                    {
 178                        PipelineRun value = default;
 0179                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0180                        value = PipelineRun.DeserializePipelineRun(document.RootElement);
 0181                        return Response.FromValue(value, message.Response);
 182                    }
 183                default:
 0184                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 185            }
 0186        }
 187
 188        internal HttpMessage CreateQueryActivityRunsRequest(string pipelineName, string runId, RunFilterParameters filte
 189        {
 0190            var message = _pipeline.CreateMessage();
 0191            var request = message.Request;
 0192            request.Method = RequestMethod.Post;
 0193            var uri = new RawRequestUriBuilder();
 0194            uri.AppendRaw(endpoint, false);
 0195            uri.AppendPath("/pipelines/", false);
 0196            uri.AppendPath(pipelineName, true);
 0197            uri.AppendPath("/pipelineruns/", false);
 0198            uri.AppendPath(runId, true);
 0199            uri.AppendPath("/queryActivityruns", false);
 0200            uri.AppendQuery("api-version", apiVersion, true);
 0201            request.Uri = uri;
 0202            request.Headers.Add("Content-Type", "application/json");
 0203            var content = new Utf8JsonRequestContent();
 0204            content.JsonWriter.WriteObjectValue(filterParameters);
 0205            request.Content = content;
 0206            return message;
 207        }
 208
 209        /// <summary> Query activity runs based on input filter conditions. </summary>
 210        /// <param name="pipelineName"> The pipeline name. </param>
 211        /// <param name="runId"> The pipeline run identifier. </param>
 212        /// <param name="filterParameters"> Parameters to filter the activity runs. </param>
 213        /// <param name="cancellationToken"> The cancellation token to use. </param>
 214        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/>, <paramref name="runId"/>, or <para
 215        public async Task<Response<ActivityRunsQueryResponse>> QueryActivityRunsAsync(string pipelineName, string runId,
 216        {
 0217            if (pipelineName == null)
 218            {
 0219                throw new ArgumentNullException(nameof(pipelineName));
 220            }
 0221            if (runId == null)
 222            {
 0223                throw new ArgumentNullException(nameof(runId));
 224            }
 0225            if (filterParameters == null)
 226            {
 0227                throw new ArgumentNullException(nameof(filterParameters));
 228            }
 229
 0230            using var message = CreateQueryActivityRunsRequest(pipelineName, runId, filterParameters);
 0231            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0232            switch (message.Response.Status)
 233            {
 234                case 200:
 235                    {
 236                        ActivityRunsQueryResponse value = default;
 0237                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0238                        value = ActivityRunsQueryResponse.DeserializeActivityRunsQueryResponse(document.RootElement);
 0239                        return Response.FromValue(value, message.Response);
 240                    }
 241                default:
 0242                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 243            }
 0244        }
 245
 246        /// <summary> Query activity runs based on input filter conditions. </summary>
 247        /// <param name="pipelineName"> The pipeline name. </param>
 248        /// <param name="runId"> The pipeline run identifier. </param>
 249        /// <param name="filterParameters"> Parameters to filter the activity runs. </param>
 250        /// <param name="cancellationToken"> The cancellation token to use. </param>
 251        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/>, <paramref name="runId"/>, or <para
 252        public Response<ActivityRunsQueryResponse> QueryActivityRuns(string pipelineName, string runId, RunFilterParamet
 253        {
 0254            if (pipelineName == null)
 255            {
 0256                throw new ArgumentNullException(nameof(pipelineName));
 257            }
 0258            if (runId == null)
 259            {
 0260                throw new ArgumentNullException(nameof(runId));
 261            }
 0262            if (filterParameters == null)
 263            {
 0264                throw new ArgumentNullException(nameof(filterParameters));
 265            }
 266
 0267            using var message = CreateQueryActivityRunsRequest(pipelineName, runId, filterParameters);
 0268            _pipeline.Send(message, cancellationToken);
 0269            switch (message.Response.Status)
 270            {
 271                case 200:
 272                    {
 273                        ActivityRunsQueryResponse value = default;
 0274                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0275                        value = ActivityRunsQueryResponse.DeserializeActivityRunsQueryResponse(document.RootElement);
 0276                        return Response.FromValue(value, message.Response);
 277                    }
 278                default:
 0279                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 280            }
 0281        }
 282
 283        internal HttpMessage CreateCancelPipelineRunRequest(string runId, bool? isRecursive)
 284        {
 0285            var message = _pipeline.CreateMessage();
 0286            var request = message.Request;
 0287            request.Method = RequestMethod.Post;
 0288            var uri = new RawRequestUriBuilder();
 0289            uri.AppendRaw(endpoint, false);
 0290            uri.AppendPath("/pipelineruns/", false);
 0291            uri.AppendPath(runId, true);
 0292            uri.AppendPath("/cancel", false);
 0293            if (isRecursive != null)
 294            {
 0295                uri.AppendQuery("isRecursive", isRecursive.Value, true);
 296            }
 0297            uri.AppendQuery("api-version", apiVersion, true);
 0298            request.Uri = uri;
 0299            return message;
 300        }
 301
 302        /// <summary> Cancel a pipeline run by its run ID. </summary>
 303        /// <param name="runId"> The pipeline run identifier. </param>
 304        /// <param name="isRecursive"> If true, cancel all the Child pipelines that are triggered by the current pipelin
 305        /// <param name="cancellationToken"> The cancellation token to use. </param>
 306        /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception>
 307        public async Task<Response> CancelPipelineRunAsync(string runId, bool? isRecursive = null, CancellationToken can
 308        {
 0309            if (runId == null)
 310            {
 0311                throw new ArgumentNullException(nameof(runId));
 312            }
 313
 0314            using var message = CreateCancelPipelineRunRequest(runId, isRecursive);
 0315            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0316            switch (message.Response.Status)
 317            {
 318                case 200:
 0319                    return message.Response;
 320                default:
 0321                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 322            }
 0323        }
 324
 325        /// <summary> Cancel a pipeline run by its run ID. </summary>
 326        /// <param name="runId"> The pipeline run identifier. </param>
 327        /// <param name="isRecursive"> If true, cancel all the Child pipelines that are triggered by the current pipelin
 328        /// <param name="cancellationToken"> The cancellation token to use. </param>
 329        /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception>
 330        public Response CancelPipelineRun(string runId, bool? isRecursive = null, CancellationToken cancellationToken = 
 331        {
 0332            if (runId == null)
 333            {
 0334                throw new ArgumentNullException(nameof(runId));
 335            }
 336
 0337            using var message = CreateCancelPipelineRunRequest(runId, isRecursive);
 0338            _pipeline.Send(message, cancellationToken);
 0339            switch (message.Response.Status)
 340            {
 341                case 200:
 0342                    return message.Response;
 343                default:
 0344                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 345            }
 0346        }
 347    }
 348}