< Summary

Class:Azure.Analytics.Synapse.Artifacts.PipelineRestClient
Assembly:Azure.Analytics.Synapse.Artifacts
File(s):C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\PipelineRestClient.cs
Covered lines:58
Uncovered lines:151
Coverable lines:209
Total lines:497
Line coverage:27.7% (58 of 209)
Covered branches:9
Total branches:74
Branch coverage:12.1% (9 of 74)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
CreateGetPipelinesByWorkspaceRequest()-100%100%
GetPipelinesByWorkspaceAsync()-87.5%50%
GetPipelinesByWorkspace(...)-87.5%50%
CreateCreateOrUpdatePipelineRequest(...)-0%0%
CreateOrUpdatePipelineAsync()-0%0%
CreateOrUpdatePipeline(...)-0%0%
CreateGetPipelineRequest(...)-91.67%50%
GetPipelineAsync()-72.73%33.33%
GetPipeline(...)-72.73%33.33%
CreateDeletePipelineRequest(...)-0%100%
DeletePipelineAsync()-0%0%
DeletePipeline(...)-0%0%
CreateCreatePipelineRunRequest(...)-0%0%
CreatePipelineRunAsync()-0%0%
CreatePipelineRun(...)-0%0%
CreateGetPipelinesByWorkspaceNextPageRequest(...)-0%100%
GetPipelinesByWorkspaceNextPageAsync()-0%0%
GetPipelinesByWorkspaceNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\PipelineRestClient.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.Collections.Generic;
 10using System.Text.Json;
 11using System.Threading;
 12using System.Threading.Tasks;
 13using Azure;
 14using Azure.Analytics.Synapse.Artifacts.Models;
 15using Azure.Core;
 16using Azure.Core.Pipeline;
 17
 18namespace Azure.Analytics.Synapse.Artifacts
 19{
 20    internal partial class PipelineRestClient
 21    {
 22        private string endpoint;
 23        private string apiVersion;
 24        private ClientDiagnostics _clientDiagnostics;
 25        private HttpPipeline _pipeline;
 26
 27        /// <summary> Initializes a new instance of PipelineRestClient. </summary>
 28        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 29        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 30        /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse
 31        /// <param name="apiVersion"> Api Version. </param>
 32        /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="apiVersion"/> is nul
 833        public PipelineRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string ap
 34        {
 835            if (endpoint == null)
 36            {
 037                throw new ArgumentNullException(nameof(endpoint));
 38            }
 839            if (apiVersion == null)
 40            {
 041                throw new ArgumentNullException(nameof(apiVersion));
 42            }
 43
 844            this.endpoint = endpoint;
 845            this.apiVersion = apiVersion;
 846            _clientDiagnostics = clientDiagnostics;
 847            _pipeline = pipeline;
 848        }
 49
 50        internal HttpMessage CreateGetPipelinesByWorkspaceRequest()
 51        {
 452            var message = _pipeline.CreateMessage();
 453            var request = message.Request;
 454            request.Method = RequestMethod.Get;
 455            var uri = new RawRequestUriBuilder();
 456            uri.AppendRaw(endpoint, false);
 457            uri.AppendPath("/pipelines", false);
 458            uri.AppendQuery("api-version", apiVersion, true);
 459            request.Uri = uri;
 460            return message;
 61        }
 62
 63        /// <summary> Lists pipelines. </summary>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public async Task<Response<PipelineListResponse>> GetPipelinesByWorkspaceAsync(CancellationToken cancellationTok
 66        {
 267            using var message = CreateGetPipelinesByWorkspaceRequest();
 268            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 269            switch (message.Response.Status)
 70            {
 71                case 200:
 72                    {
 73                        PipelineListResponse value = default;
 274                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 275                        value = PipelineListResponse.DeserializePipelineListResponse(document.RootElement);
 276                        return Response.FromValue(value, message.Response);
 77                    }
 78                default:
 079                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 80            }
 281        }
 82
 83        /// <summary> Lists pipelines. </summary>
 84        /// <param name="cancellationToken"> The cancellation token to use. </param>
 85        public Response<PipelineListResponse> GetPipelinesByWorkspace(CancellationToken cancellationToken = default)
 86        {
 287            using var message = CreateGetPipelinesByWorkspaceRequest();
 288            _pipeline.Send(message, cancellationToken);
 289            switch (message.Response.Status)
 90            {
 91                case 200:
 92                    {
 93                        PipelineListResponse value = default;
 294                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 295                        value = PipelineListResponse.DeserializePipelineListResponse(document.RootElement);
 296                        return Response.FromValue(value, message.Response);
 97                    }
 98                default:
 099                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 100            }
 2101        }
 102
 103        internal HttpMessage CreateCreateOrUpdatePipelineRequest(string pipelineName, PipelineResource pipeline, string 
 104        {
 0105            var message = _pipeline.CreateMessage();
 0106            var request = message.Request;
 0107            request.Method = RequestMethod.Put;
 0108            var uri = new RawRequestUriBuilder();
 0109            uri.AppendRaw(endpoint, false);
 0110            uri.AppendPath("/pipelines/", false);
 0111            uri.AppendPath(pipelineName, true);
 0112            uri.AppendQuery("api-version", apiVersion, true);
 0113            request.Uri = uri;
 0114            if (ifMatch != null)
 115            {
 0116                request.Headers.Add("If-Match", ifMatch);
 117            }
 0118            request.Headers.Add("Content-Type", "application/json");
 0119            var content = new Utf8JsonRequestContent();
 0120            content.JsonWriter.WriteObjectValue(pipeline);
 0121            request.Content = content;
 0122            return message;
 123        }
 124
 125        /// <summary> Creates or updates a pipeline. </summary>
 126        /// <param name="pipelineName"> The pipeline name. </param>
 127        /// <param name="pipeline"> Pipeline resource definition. </param>
 128        /// <param name="ifMatch"> ETag of the pipeline entity.  Should only be specified for update, for which it shoul
 129        /// <param name="cancellationToken"> The cancellation token to use. </param>
 130        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> or <paramref name="pipeline"/> is n
 131        public async Task<Response<PipelineResource>> CreateOrUpdatePipelineAsync(string pipelineName, PipelineResource 
 132        {
 0133            if (pipelineName == null)
 134            {
 0135                throw new ArgumentNullException(nameof(pipelineName));
 136            }
 0137            if (pipeline == null)
 138            {
 0139                throw new ArgumentNullException(nameof(pipeline));
 140            }
 141
 0142            using var message = CreateCreateOrUpdatePipelineRequest(pipelineName, pipeline, ifMatch);
 0143            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0144            switch (message.Response.Status)
 145            {
 146                case 200:
 147                    {
 148                        PipelineResource value = default;
 0149                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0150                        value = PipelineResource.DeserializePipelineResource(document.RootElement);
 0151                        return Response.FromValue(value, message.Response);
 152                    }
 153                default:
 0154                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 155            }
 0156        }
 157
 158        /// <summary> Creates or updates a pipeline. </summary>
 159        /// <param name="pipelineName"> The pipeline name. </param>
 160        /// <param name="pipeline"> Pipeline resource definition. </param>
 161        /// <param name="ifMatch"> ETag of the pipeline entity.  Should only be specified for update, for which it shoul
 162        /// <param name="cancellationToken"> The cancellation token to use. </param>
 163        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> or <paramref name="pipeline"/> is n
 164        public Response<PipelineResource> CreateOrUpdatePipeline(string pipelineName, PipelineResource pipeline, string 
 165        {
 0166            if (pipelineName == null)
 167            {
 0168                throw new ArgumentNullException(nameof(pipelineName));
 169            }
 0170            if (pipeline == null)
 171            {
 0172                throw new ArgumentNullException(nameof(pipeline));
 173            }
 174
 0175            using var message = CreateCreateOrUpdatePipelineRequest(pipelineName, pipeline, ifMatch);
 0176            _pipeline.Send(message, cancellationToken);
 0177            switch (message.Response.Status)
 178            {
 179                case 200:
 180                    {
 181                        PipelineResource value = default;
 0182                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0183                        value = PipelineResource.DeserializePipelineResource(document.RootElement);
 0184                        return Response.FromValue(value, message.Response);
 185                    }
 186                default:
 0187                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 188            }
 0189        }
 190
 191        internal HttpMessage CreateGetPipelineRequest(string pipelineName, string ifNoneMatch)
 192        {
 4193            var message = _pipeline.CreateMessage();
 4194            var request = message.Request;
 4195            request.Method = RequestMethod.Get;
 4196            var uri = new RawRequestUriBuilder();
 4197            uri.AppendRaw(endpoint, false);
 4198            uri.AppendPath("/pipelines/", false);
 4199            uri.AppendPath(pipelineName, true);
 4200            uri.AppendQuery("api-version", apiVersion, true);
 4201            request.Uri = uri;
 4202            if (ifNoneMatch != null)
 203            {
 0204                request.Headers.Add("If-None-Match", ifNoneMatch);
 205            }
 4206            return message;
 207        }
 208
 209        /// <summary> Gets a pipeline. </summary>
 210        /// <param name="pipelineName"> The pipeline name. </param>
 211        /// <param name="ifNoneMatch"> ETag of the pipeline entity. Should only be specified for get. If the ETag matche
 212        /// <param name="cancellationToken"> The cancellation token to use. </param>
 213        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> is null. </exception>
 214        public async Task<Response<PipelineResource>> GetPipelineAsync(string pipelineName, string ifNoneMatch = null, C
 215        {
 2216            if (pipelineName == null)
 217            {
 0218                throw new ArgumentNullException(nameof(pipelineName));
 219            }
 220
 2221            using var message = CreateGetPipelineRequest(pipelineName, ifNoneMatch);
 2222            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2223            switch (message.Response.Status)
 224            {
 225                case 200:
 226                    {
 227                        PipelineResource value = default;
 2228                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2229                        value = PipelineResource.DeserializePipelineResource(document.RootElement);
 2230                        return Response.FromValue(value, message.Response);
 231                    }
 232                case 304:
 0233                    return Response.FromValue<PipelineResource>(null, message.Response);
 234                default:
 0235                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 236            }
 2237        }
 238
 239        /// <summary> Gets a pipeline. </summary>
 240        /// <param name="pipelineName"> The pipeline name. </param>
 241        /// <param name="ifNoneMatch"> ETag of the pipeline entity. Should only be specified for get. If the ETag matche
 242        /// <param name="cancellationToken"> The cancellation token to use. </param>
 243        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> is null. </exception>
 244        public Response<PipelineResource> GetPipeline(string pipelineName, string ifNoneMatch = null, CancellationToken 
 245        {
 2246            if (pipelineName == null)
 247            {
 0248                throw new ArgumentNullException(nameof(pipelineName));
 249            }
 250
 2251            using var message = CreateGetPipelineRequest(pipelineName, ifNoneMatch);
 2252            _pipeline.Send(message, cancellationToken);
 2253            switch (message.Response.Status)
 254            {
 255                case 200:
 256                    {
 257                        PipelineResource value = default;
 2258                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2259                        value = PipelineResource.DeserializePipelineResource(document.RootElement);
 2260                        return Response.FromValue(value, message.Response);
 261                    }
 262                case 304:
 0263                    return Response.FromValue<PipelineResource>(null, message.Response);
 264                default:
 0265                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 266            }
 2267        }
 268
 269        internal HttpMessage CreateDeletePipelineRequest(string pipelineName)
 270        {
 0271            var message = _pipeline.CreateMessage();
 0272            var request = message.Request;
 0273            request.Method = RequestMethod.Delete;
 0274            var uri = new RawRequestUriBuilder();
 0275            uri.AppendRaw(endpoint, false);
 0276            uri.AppendPath("/pipelines/", false);
 0277            uri.AppendPath(pipelineName, true);
 0278            uri.AppendQuery("api-version", apiVersion, true);
 0279            request.Uri = uri;
 0280            return message;
 281        }
 282
 283        /// <summary> Deletes a pipeline. </summary>
 284        /// <param name="pipelineName"> The pipeline name. </param>
 285        /// <param name="cancellationToken"> The cancellation token to use. </param>
 286        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> is null. </exception>
 287        public async Task<Response> DeletePipelineAsync(string pipelineName, CancellationToken cancellationToken = defau
 288        {
 0289            if (pipelineName == null)
 290            {
 0291                throw new ArgumentNullException(nameof(pipelineName));
 292            }
 293
 0294            using var message = CreateDeletePipelineRequest(pipelineName);
 0295            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0296            switch (message.Response.Status)
 297            {
 298                case 200:
 299                case 204:
 0300                    return message.Response;
 301                default:
 0302                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 303            }
 0304        }
 305
 306        /// <summary> Deletes a pipeline. </summary>
 307        /// <param name="pipelineName"> The pipeline name. </param>
 308        /// <param name="cancellationToken"> The cancellation token to use. </param>
 309        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> is null. </exception>
 310        public Response DeletePipeline(string pipelineName, CancellationToken cancellationToken = default)
 311        {
 0312            if (pipelineName == null)
 313            {
 0314                throw new ArgumentNullException(nameof(pipelineName));
 315            }
 316
 0317            using var message = CreateDeletePipelineRequest(pipelineName);
 0318            _pipeline.Send(message, cancellationToken);
 0319            switch (message.Response.Status)
 320            {
 321                case 200:
 322                case 204:
 0323                    return message.Response;
 324                default:
 0325                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 326            }
 0327        }
 328
 329        internal HttpMessage CreateCreatePipelineRunRequest(string pipelineName, string referencePipelineRunId, bool? is
 330        {
 0331            var message = _pipeline.CreateMessage();
 0332            var request = message.Request;
 0333            request.Method = RequestMethod.Post;
 0334            var uri = new RawRequestUriBuilder();
 0335            uri.AppendRaw(endpoint, false);
 0336            uri.AppendPath("/pipelines/", false);
 0337            uri.AppendPath(pipelineName, true);
 0338            uri.AppendPath("/createRun", false);
 0339            uri.AppendQuery("api-version", apiVersion, true);
 0340            if (referencePipelineRunId != null)
 341            {
 0342                uri.AppendQuery("referencePipelineRunId", referencePipelineRunId, true);
 343            }
 0344            if (isRecovery != null)
 345            {
 0346                uri.AppendQuery("isRecovery", isRecovery.Value, true);
 347            }
 0348            if (startActivityName != null)
 349            {
 0350                uri.AppendQuery("startActivityName", startActivityName, true);
 351            }
 0352            request.Uri = uri;
 0353            request.Headers.Add("Content-Type", "application/json");
 0354            if (parameters != null)
 355            {
 0356                var content = new Utf8JsonRequestContent();
 0357                content.JsonWriter.WriteStartObject();
 0358                foreach (var item in parameters)
 359                {
 0360                    content.JsonWriter.WritePropertyName(item.Key);
 0361                    content.JsonWriter.WriteObjectValue(item.Value);
 362                }
 0363                content.JsonWriter.WriteEndObject();
 0364                request.Content = content;
 365            }
 0366            return message;
 367        }
 368
 369        /// <summary> Creates a run of a pipeline. </summary>
 370        /// <param name="pipelineName"> The pipeline name. </param>
 371        /// <param name="referencePipelineRunId"> The pipeline run identifier. If run ID is specified the parameters of 
 372        /// <param name="isRecovery"> Recovery mode flag. If recovery mode is set to true, the specified referenced pipe
 373        /// <param name="startActivityName"> In recovery mode, the rerun will start from this activity. If not specified
 374        /// <param name="parameters"> Parameters of the pipeline run. These parameters will be used only if the runId is
 375        /// <param name="cancellationToken"> The cancellation token to use. </param>
 376        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> is null. </exception>
 377        public async Task<Response<CreateRunResponse>> CreatePipelineRunAsync(string pipelineName, string referencePipel
 378        {
 0379            if (pipelineName == null)
 380            {
 0381                throw new ArgumentNullException(nameof(pipelineName));
 382            }
 383
 0384            using var message = CreateCreatePipelineRunRequest(pipelineName, referencePipelineRunId, isRecovery, startAc
 0385            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0386            switch (message.Response.Status)
 387            {
 388                case 200:
 389                    {
 390                        CreateRunResponse value = default;
 0391                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0392                        value = CreateRunResponse.DeserializeCreateRunResponse(document.RootElement);
 0393                        return Response.FromValue(value, message.Response);
 394                    }
 395                default:
 0396                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 397            }
 0398        }
 399
 400        /// <summary> Creates a run of a pipeline. </summary>
 401        /// <param name="pipelineName"> The pipeline name. </param>
 402        /// <param name="referencePipelineRunId"> The pipeline run identifier. If run ID is specified the parameters of 
 403        /// <param name="isRecovery"> Recovery mode flag. If recovery mode is set to true, the specified referenced pipe
 404        /// <param name="startActivityName"> In recovery mode, the rerun will start from this activity. If not specified
 405        /// <param name="parameters"> Parameters of the pipeline run. These parameters will be used only if the runId is
 406        /// <param name="cancellationToken"> The cancellation token to use. </param>
 407        /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/> is null. </exception>
 408        public Response<CreateRunResponse> CreatePipelineRun(string pipelineName, string referencePipelineRunId = null, 
 409        {
 0410            if (pipelineName == null)
 411            {
 0412                throw new ArgumentNullException(nameof(pipelineName));
 413            }
 414
 0415            using var message = CreateCreatePipelineRunRequest(pipelineName, referencePipelineRunId, isRecovery, startAc
 0416            _pipeline.Send(message, cancellationToken);
 0417            switch (message.Response.Status)
 418            {
 419                case 200:
 420                    {
 421                        CreateRunResponse value = default;
 0422                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0423                        value = CreateRunResponse.DeserializeCreateRunResponse(document.RootElement);
 0424                        return Response.FromValue(value, message.Response);
 425                    }
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 0429        }
 430
 431        internal HttpMessage CreateGetPipelinesByWorkspaceNextPageRequest(string nextLink)
 432        {
 0433            var message = _pipeline.CreateMessage();
 0434            var request = message.Request;
 0435            request.Method = RequestMethod.Get;
 0436            var uri = new RawRequestUriBuilder();
 0437            uri.AppendRaw(endpoint, false);
 0438            uri.AppendRawNextLink(nextLink, false);
 0439            request.Uri = uri;
 0440            return message;
 441        }
 442
 443        /// <summary> Lists pipelines. </summary>
 444        /// <param name="nextLink"> The URL to the next page of results. </param>
 445        /// <param name="cancellationToken"> The cancellation token to use. </param>
 446        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 447        public async Task<Response<PipelineListResponse>> GetPipelinesByWorkspaceNextPageAsync(string nextLink, Cancella
 448        {
 0449            if (nextLink == null)
 450            {
 0451                throw new ArgumentNullException(nameof(nextLink));
 452            }
 453
 0454            using var message = CreateGetPipelinesByWorkspaceNextPageRequest(nextLink);
 0455            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0456            switch (message.Response.Status)
 457            {
 458                case 200:
 459                    {
 460                        PipelineListResponse value = default;
 0461                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0462                        value = PipelineListResponse.DeserializePipelineListResponse(document.RootElement);
 0463                        return Response.FromValue(value, message.Response);
 464                    }
 465                default:
 0466                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 467            }
 0468        }
 469
 470        /// <summary> Lists pipelines. </summary>
 471        /// <param name="nextLink"> The URL to the next page of results. </param>
 472        /// <param name="cancellationToken"> The cancellation token to use. </param>
 473        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 474        public Response<PipelineListResponse> GetPipelinesByWorkspaceNextPage(string nextLink, CancellationToken cancell
 475        {
 0476            if (nextLink == null)
 477            {
 0478                throw new ArgumentNullException(nameof(nextLink));
 479            }
 480
 0481            using var message = CreateGetPipelinesByWorkspaceNextPageRequest(nextLink);
 0482            _pipeline.Send(message, cancellationToken);
 0483            switch (message.Response.Status)
 484            {
 485                case 200:
 486                    {
 487                        PipelineListResponse value = default;
 0488                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0489                        value = PipelineListResponse.DeserializePipelineListResponse(document.RootElement);
 0490                        return Response.FromValue(value, message.Response);
 491                    }
 492                default:
 0493                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 494            }
 0495        }
 496    }
 497}