< Summary

Class:Azure.ResourceManager.Network.ExpressRouteConnectionsRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteConnectionsRestOperations.cs
Covered lines:0
Uncovered lines:192
Coverable lines:192
Total lines:431
Line coverage:0% (0 of 192)
Covered branches:0
Total branches:84
Branch coverage:0% (0 of 84)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteConnectionsRestOperations.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.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.Network.Models;
 16
 17namespace Azure.ResourceManager.Network
 18{
 19    internal partial class ExpressRouteConnectionsRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of ExpressRouteConnectionsRestOperations. </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="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 032        public ExpressRouteConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string 
 33        {
 034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 038            endpoint ??= new Uri("https://management.azure.com");
 39
 040            this.subscriptionId = subscriptionId;
 041            this.endpoint = endpoint;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string expressRouteGatewayName, strin
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Put;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/resourceGroups/", false);
 056            uri.AppendPath(resourceGroupName, true);
 057            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways/", false);
 058            uri.AppendPath(expressRouteGatewayName, true);
 059            uri.AppendPath("/expressRouteConnections/", false);
 060            uri.AppendPath(connectionName, true);
 061            uri.AppendQuery("api-version", "2020-04-01", true);
 062            request.Uri = uri;
 063            request.Headers.Add("Content-Type", "application/json");
 064            var content = new Utf8JsonRequestContent();
 065            content.JsonWriter.WriteObjectValue(putExpressRouteConnectionParameters);
 066            request.Content = content;
 067            return message;
 68        }
 69
 70        /// <summary> Creates a connection between an ExpressRoute gateway and an ExpressRoute circuit. </summary>
 71        /// <param name="resourceGroupName"> The name of the resource group. </param>
 72        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 73        /// <param name="connectionName"> The name of the connection subresource. </param>
 74        /// <param name="putExpressRouteConnectionParameters"> Parameters required in an ExpressRouteConnection PUT oper
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string expressRouteGatewayName, string
 77        {
 078            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 082            if (expressRouteGatewayName == null)
 83            {
 084                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 85            }
 086            if (connectionName == null)
 87            {
 088                throw new ArgumentNullException(nameof(connectionName));
 89            }
 090            if (putExpressRouteConnectionParameters == null)
 91            {
 092                throw new ArgumentNullException(nameof(putExpressRouteConnectionParameters));
 93            }
 94
 095            using var message = CreateCreateOrUpdateRequest(resourceGroupName, expressRouteGatewayName, connectionName, 
 096            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 097            switch (message.Response.Status)
 98            {
 99                case 200:
 100                case 201:
 0101                    return message.Response;
 102                default:
 0103                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 104            }
 0105        }
 106
 107        /// <summary> Creates a connection between an ExpressRoute gateway and an ExpressRoute circuit. </summary>
 108        /// <param name="resourceGroupName"> The name of the resource group. </param>
 109        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 110        /// <param name="connectionName"> The name of the connection subresource. </param>
 111        /// <param name="putExpressRouteConnectionParameters"> Parameters required in an ExpressRouteConnection PUT oper
 112        /// <param name="cancellationToken"> The cancellation token to use. </param>
 113        public Response CreateOrUpdate(string resourceGroupName, string expressRouteGatewayName, string connectionName, 
 114        {
 0115            if (resourceGroupName == null)
 116            {
 0117                throw new ArgumentNullException(nameof(resourceGroupName));
 118            }
 0119            if (expressRouteGatewayName == null)
 120            {
 0121                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 122            }
 0123            if (connectionName == null)
 124            {
 0125                throw new ArgumentNullException(nameof(connectionName));
 126            }
 0127            if (putExpressRouteConnectionParameters == null)
 128            {
 0129                throw new ArgumentNullException(nameof(putExpressRouteConnectionParameters));
 130            }
 131
 0132            using var message = CreateCreateOrUpdateRequest(resourceGroupName, expressRouteGatewayName, connectionName, 
 0133            _pipeline.Send(message, cancellationToken);
 0134            switch (message.Response.Status)
 135            {
 136                case 200:
 137                case 201:
 0138                    return message.Response;
 139                default:
 0140                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 141            }
 0142        }
 143
 144        internal HttpMessage CreateGetRequest(string resourceGroupName, string expressRouteGatewayName, string connectio
 145        {
 0146            var message = _pipeline.CreateMessage();
 0147            var request = message.Request;
 0148            request.Method = RequestMethod.Get;
 0149            var uri = new RawRequestUriBuilder();
 0150            uri.Reset(endpoint);
 0151            uri.AppendPath("/subscriptions/", false);
 0152            uri.AppendPath(subscriptionId, true);
 0153            uri.AppendPath("/resourceGroups/", false);
 0154            uri.AppendPath(resourceGroupName, true);
 0155            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways/", false);
 0156            uri.AppendPath(expressRouteGatewayName, true);
 0157            uri.AppendPath("/expressRouteConnections/", false);
 0158            uri.AppendPath(connectionName, true);
 0159            uri.AppendQuery("api-version", "2020-04-01", true);
 0160            request.Uri = uri;
 0161            return message;
 162        }
 163
 164        /// <summary> Gets the specified ExpressRouteConnection. </summary>
 165        /// <param name="resourceGroupName"> The name of the resource group. </param>
 166        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 167        /// <param name="connectionName"> The name of the ExpressRoute connection. </param>
 168        /// <param name="cancellationToken"> The cancellation token to use. </param>
 169        public async Task<Response<ExpressRouteConnection>> GetAsync(string resourceGroupName, string expressRouteGatewa
 170        {
 0171            if (resourceGroupName == null)
 172            {
 0173                throw new ArgumentNullException(nameof(resourceGroupName));
 174            }
 0175            if (expressRouteGatewayName == null)
 176            {
 0177                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 178            }
 0179            if (connectionName == null)
 180            {
 0181                throw new ArgumentNullException(nameof(connectionName));
 182            }
 183
 0184            using var message = CreateGetRequest(resourceGroupName, expressRouteGatewayName, connectionName);
 0185            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0186            switch (message.Response.Status)
 187            {
 188                case 200:
 189                    {
 0190                        ExpressRouteConnection value = default;
 0191                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0192                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 193                        {
 0194                            value = null;
 195                        }
 196                        else
 197                        {
 0198                            value = ExpressRouteConnection.DeserializeExpressRouteConnection(document.RootElement);
 199                        }
 0200                        return Response.FromValue(value, message.Response);
 201                    }
 202                default:
 0203                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 204            }
 0205        }
 206
 207        /// <summary> Gets the specified ExpressRouteConnection. </summary>
 208        /// <param name="resourceGroupName"> The name of the resource group. </param>
 209        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 210        /// <param name="connectionName"> The name of the ExpressRoute connection. </param>
 211        /// <param name="cancellationToken"> The cancellation token to use. </param>
 212        public Response<ExpressRouteConnection> Get(string resourceGroupName, string expressRouteGatewayName, string con
 213        {
 0214            if (resourceGroupName == null)
 215            {
 0216                throw new ArgumentNullException(nameof(resourceGroupName));
 217            }
 0218            if (expressRouteGatewayName == null)
 219            {
 0220                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 221            }
 0222            if (connectionName == null)
 223            {
 0224                throw new ArgumentNullException(nameof(connectionName));
 225            }
 226
 0227            using var message = CreateGetRequest(resourceGroupName, expressRouteGatewayName, connectionName);
 0228            _pipeline.Send(message, cancellationToken);
 0229            switch (message.Response.Status)
 230            {
 231                case 200:
 232                    {
 0233                        ExpressRouteConnection value = default;
 0234                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0235                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 236                        {
 0237                            value = null;
 238                        }
 239                        else
 240                        {
 0241                            value = ExpressRouteConnection.DeserializeExpressRouteConnection(document.RootElement);
 242                        }
 0243                        return Response.FromValue(value, message.Response);
 244                    }
 245                default:
 0246                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 247            }
 0248        }
 249
 250        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string expressRouteGatewayName, string connec
 251        {
 0252            var message = _pipeline.CreateMessage();
 0253            var request = message.Request;
 0254            request.Method = RequestMethod.Delete;
 0255            var uri = new RawRequestUriBuilder();
 0256            uri.Reset(endpoint);
 0257            uri.AppendPath("/subscriptions/", false);
 0258            uri.AppendPath(subscriptionId, true);
 0259            uri.AppendPath("/resourceGroups/", false);
 0260            uri.AppendPath(resourceGroupName, true);
 0261            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways/", false);
 0262            uri.AppendPath(expressRouteGatewayName, true);
 0263            uri.AppendPath("/expressRouteConnections/", false);
 0264            uri.AppendPath(connectionName, true);
 0265            uri.AppendQuery("api-version", "2020-04-01", true);
 0266            request.Uri = uri;
 0267            return message;
 268        }
 269
 270        /// <summary> Deletes a connection to a ExpressRoute circuit. </summary>
 271        /// <param name="resourceGroupName"> The name of the resource group. </param>
 272        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 273        /// <param name="connectionName"> The name of the connection subresource. </param>
 274        /// <param name="cancellationToken"> The cancellation token to use. </param>
 275        public async Task<Response> DeleteAsync(string resourceGroupName, string expressRouteGatewayName, string connect
 276        {
 0277            if (resourceGroupName == null)
 278            {
 0279                throw new ArgumentNullException(nameof(resourceGroupName));
 280            }
 0281            if (expressRouteGatewayName == null)
 282            {
 0283                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 284            }
 0285            if (connectionName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(connectionName));
 288            }
 289
 0290            using var message = CreateDeleteRequest(resourceGroupName, expressRouteGatewayName, connectionName);
 0291            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0292            switch (message.Response.Status)
 293            {
 294                case 200:
 295                case 202:
 296                case 204:
 0297                    return message.Response;
 298                default:
 0299                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 300            }
 0301        }
 302
 303        /// <summary> Deletes a connection to a ExpressRoute circuit. </summary>
 304        /// <param name="resourceGroupName"> The name of the resource group. </param>
 305        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 306        /// <param name="connectionName"> The name of the connection subresource. </param>
 307        /// <param name="cancellationToken"> The cancellation token to use. </param>
 308        public Response Delete(string resourceGroupName, string expressRouteGatewayName, string connectionName, Cancella
 309        {
 0310            if (resourceGroupName == null)
 311            {
 0312                throw new ArgumentNullException(nameof(resourceGroupName));
 313            }
 0314            if (expressRouteGatewayName == null)
 315            {
 0316                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 317            }
 0318            if (connectionName == null)
 319            {
 0320                throw new ArgumentNullException(nameof(connectionName));
 321            }
 322
 0323            using var message = CreateDeleteRequest(resourceGroupName, expressRouteGatewayName, connectionName);
 0324            _pipeline.Send(message, cancellationToken);
 0325            switch (message.Response.Status)
 326            {
 327                case 200:
 328                case 202:
 329                case 204:
 0330                    return message.Response;
 331                default:
 0332                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 333            }
 0334        }
 335
 336        internal HttpMessage CreateListRequest(string resourceGroupName, string expressRouteGatewayName)
 337        {
 0338            var message = _pipeline.CreateMessage();
 0339            var request = message.Request;
 0340            request.Method = RequestMethod.Get;
 0341            var uri = new RawRequestUriBuilder();
 0342            uri.Reset(endpoint);
 0343            uri.AppendPath("/subscriptions/", false);
 0344            uri.AppendPath(subscriptionId, true);
 0345            uri.AppendPath("/resourceGroups/", false);
 0346            uri.AppendPath(resourceGroupName, true);
 0347            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways/", false);
 0348            uri.AppendPath(expressRouteGatewayName, true);
 0349            uri.AppendPath("/expressRouteConnections", false);
 0350            uri.AppendQuery("api-version", "2020-04-01", true);
 0351            request.Uri = uri;
 0352            return message;
 353        }
 354
 355        /// <summary> Lists ExpressRouteConnections. </summary>
 356        /// <param name="resourceGroupName"> The name of the resource group. </param>
 357        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 359        public async Task<Response<ExpressRouteConnectionList>> ListAsync(string resourceGroupName, string expressRouteG
 360        {
 0361            if (resourceGroupName == null)
 362            {
 0363                throw new ArgumentNullException(nameof(resourceGroupName));
 364            }
 0365            if (expressRouteGatewayName == null)
 366            {
 0367                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 368            }
 369
 0370            using var message = CreateListRequest(resourceGroupName, expressRouteGatewayName);
 0371            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0372            switch (message.Response.Status)
 373            {
 374                case 200:
 375                    {
 0376                        ExpressRouteConnectionList value = default;
 0377                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0378                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 379                        {
 0380                            value = null;
 381                        }
 382                        else
 383                        {
 0384                            value = ExpressRouteConnectionList.DeserializeExpressRouteConnectionList(document.RootElemen
 385                        }
 0386                        return Response.FromValue(value, message.Response);
 387                    }
 388                default:
 0389                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 390            }
 0391        }
 392
 393        /// <summary> Lists ExpressRouteConnections. </summary>
 394        /// <param name="resourceGroupName"> The name of the resource group. </param>
 395        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 396        /// <param name="cancellationToken"> The cancellation token to use. </param>
 397        public Response<ExpressRouteConnectionList> List(string resourceGroupName, string expressRouteGatewayName, Cance
 398        {
 0399            if (resourceGroupName == null)
 400            {
 0401                throw new ArgumentNullException(nameof(resourceGroupName));
 402            }
 0403            if (expressRouteGatewayName == null)
 404            {
 0405                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 406            }
 407
 0408            using var message = CreateListRequest(resourceGroupName, expressRouteGatewayName);
 0409            _pipeline.Send(message, cancellationToken);
 0410            switch (message.Response.Status)
 411            {
 412                case 200:
 413                    {
 0414                        ExpressRouteConnectionList value = default;
 0415                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0416                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 417                        {
 0418                            value = null;
 419                        }
 420                        else
 421                        {
 0422                            value = ExpressRouteConnectionList.DeserializeExpressRouteConnectionList(document.RootElemen
 423                        }
 0424                        return Response.FromValue(value, message.Response);
 425                    }
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 0429        }
 430    }
 431}