< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateListBySubscriptionRequest()-0%100%
ListBySubscriptionAsync()-0%0%
ListBySubscription(...)-0%0%
CreateListByResourceGroupRequest(...)-0%100%
ListByResourceGroupAsync()-0%0%
ListByResourceGroup(...)-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%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteGatewaysRestOperations.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 ExpressRouteGatewaysRestOperations
 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 ExpressRouteGatewaysRestOperations. </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 ExpressRouteGatewaysRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub
 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 CreateListBySubscriptionRequest()
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Get;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways", false);
 056            uri.AppendQuery("api-version", "2020-04-01", true);
 057            request.Uri = uri;
 058            return message;
 59        }
 60
 61        /// <summary> Lists ExpressRoute gateways under a given subscription. </summary>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public async Task<Response<ExpressRouteGatewayList>> ListBySubscriptionAsync(CancellationToken cancellationToken
 64        {
 065            using var message = CreateListBySubscriptionRequest();
 066            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 067            switch (message.Response.Status)
 68            {
 69                case 200:
 70                    {
 071                        ExpressRouteGatewayList value = default;
 072                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 073                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 74                        {
 075                            value = null;
 76                        }
 77                        else
 78                        {
 079                            value = ExpressRouteGatewayList.DeserializeExpressRouteGatewayList(document.RootElement);
 80                        }
 081                        return Response.FromValue(value, message.Response);
 82                    }
 83                default:
 084                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 85            }
 086        }
 87
 88        /// <summary> Lists ExpressRoute gateways under a given subscription. </summary>
 89        /// <param name="cancellationToken"> The cancellation token to use. </param>
 90        public Response<ExpressRouteGatewayList> ListBySubscription(CancellationToken cancellationToken = default)
 91        {
 092            using var message = CreateListBySubscriptionRequest();
 093            _pipeline.Send(message, cancellationToken);
 094            switch (message.Response.Status)
 95            {
 96                case 200:
 97                    {
 098                        ExpressRouteGatewayList value = default;
 099                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0100                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 101                        {
 0102                            value = null;
 103                        }
 104                        else
 105                        {
 0106                            value = ExpressRouteGatewayList.DeserializeExpressRouteGatewayList(document.RootElement);
 107                        }
 0108                        return Response.FromValue(value, message.Response);
 109                    }
 110                default:
 0111                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 112            }
 0113        }
 114
 115        internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName)
 116        {
 0117            var message = _pipeline.CreateMessage();
 0118            var request = message.Request;
 0119            request.Method = RequestMethod.Get;
 0120            var uri = new RawRequestUriBuilder();
 0121            uri.Reset(endpoint);
 0122            uri.AppendPath("/subscriptions/", false);
 0123            uri.AppendPath(subscriptionId, true);
 0124            uri.AppendPath("/resourceGroups/", false);
 0125            uri.AppendPath(resourceGroupName, true);
 0126            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways", false);
 0127            uri.AppendQuery("api-version", "2020-04-01", true);
 0128            request.Uri = uri;
 0129            return message;
 130        }
 131
 132        /// <summary> Lists ExpressRoute gateways in a given resource group. </summary>
 133        /// <param name="resourceGroupName"> The name of the resource group. </param>
 134        /// <param name="cancellationToken"> The cancellation token to use. </param>
 135        public async Task<Response<ExpressRouteGatewayList>> ListByResourceGroupAsync(string resourceGroupName, Cancella
 136        {
 0137            if (resourceGroupName == null)
 138            {
 0139                throw new ArgumentNullException(nameof(resourceGroupName));
 140            }
 141
 0142            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 0143            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0144            switch (message.Response.Status)
 145            {
 146                case 200:
 147                    {
 0148                        ExpressRouteGatewayList value = default;
 0149                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0150                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 151                        {
 0152                            value = null;
 153                        }
 154                        else
 155                        {
 0156                            value = ExpressRouteGatewayList.DeserializeExpressRouteGatewayList(document.RootElement);
 157                        }
 0158                        return Response.FromValue(value, message.Response);
 159                    }
 160                default:
 0161                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 162            }
 0163        }
 164
 165        /// <summary> Lists ExpressRoute gateways in a given resource group. </summary>
 166        /// <param name="resourceGroupName"> The name of the resource group. </param>
 167        /// <param name="cancellationToken"> The cancellation token to use. </param>
 168        public Response<ExpressRouteGatewayList> ListByResourceGroup(string resourceGroupName, CancellationToken cancell
 169        {
 0170            if (resourceGroupName == null)
 171            {
 0172                throw new ArgumentNullException(nameof(resourceGroupName));
 173            }
 174
 0175            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 0176            _pipeline.Send(message, cancellationToken);
 0177            switch (message.Response.Status)
 178            {
 179                case 200:
 180                    {
 0181                        ExpressRouteGatewayList value = default;
 0182                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0183                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 184                        {
 0185                            value = null;
 186                        }
 187                        else
 188                        {
 0189                            value = ExpressRouteGatewayList.DeserializeExpressRouteGatewayList(document.RootElement);
 190                        }
 0191                        return Response.FromValue(value, message.Response);
 192                    }
 193                default:
 0194                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 195            }
 0196        }
 197
 198        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string expressRouteGatewayName, Expre
 199        {
 0200            var message = _pipeline.CreateMessage();
 0201            var request = message.Request;
 0202            request.Method = RequestMethod.Put;
 0203            var uri = new RawRequestUriBuilder();
 0204            uri.Reset(endpoint);
 0205            uri.AppendPath("/subscriptions/", false);
 0206            uri.AppendPath(subscriptionId, true);
 0207            uri.AppendPath("/resourceGroups/", false);
 0208            uri.AppendPath(resourceGroupName, true);
 0209            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways/", false);
 0210            uri.AppendPath(expressRouteGatewayName, true);
 0211            uri.AppendQuery("api-version", "2020-04-01", true);
 0212            request.Uri = uri;
 0213            request.Headers.Add("Content-Type", "application/json");
 0214            var content = new Utf8JsonRequestContent();
 0215            content.JsonWriter.WriteObjectValue(putExpressRouteGatewayParameters);
 0216            request.Content = content;
 0217            return message;
 218        }
 219
 220        /// <summary> Creates or updates a ExpressRoute gateway in a specified resource group. </summary>
 221        /// <param name="resourceGroupName"> The name of the resource group. </param>
 222        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 223        /// <param name="putExpressRouteGatewayParameters"> Parameters required in an ExpressRoute gateway PUT operation
 224        /// <param name="cancellationToken"> The cancellation token to use. </param>
 225        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string expressRouteGatewayName, Expres
 226        {
 0227            if (resourceGroupName == null)
 228            {
 0229                throw new ArgumentNullException(nameof(resourceGroupName));
 230            }
 0231            if (expressRouteGatewayName == null)
 232            {
 0233                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 234            }
 0235            if (putExpressRouteGatewayParameters == null)
 236            {
 0237                throw new ArgumentNullException(nameof(putExpressRouteGatewayParameters));
 238            }
 239
 0240            using var message = CreateCreateOrUpdateRequest(resourceGroupName, expressRouteGatewayName, putExpressRouteG
 0241            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0242            switch (message.Response.Status)
 243            {
 244                case 200:
 245                case 201:
 0246                    return message.Response;
 247                default:
 0248                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 249            }
 0250        }
 251
 252        /// <summary> Creates or updates a ExpressRoute gateway in a specified resource group. </summary>
 253        /// <param name="resourceGroupName"> The name of the resource group. </param>
 254        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 255        /// <param name="putExpressRouteGatewayParameters"> Parameters required in an ExpressRoute gateway PUT operation
 256        /// <param name="cancellationToken"> The cancellation token to use. </param>
 257        public Response CreateOrUpdate(string resourceGroupName, string expressRouteGatewayName, ExpressRouteGateway put
 258        {
 0259            if (resourceGroupName == null)
 260            {
 0261                throw new ArgumentNullException(nameof(resourceGroupName));
 262            }
 0263            if (expressRouteGatewayName == null)
 264            {
 0265                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 266            }
 0267            if (putExpressRouteGatewayParameters == null)
 268            {
 0269                throw new ArgumentNullException(nameof(putExpressRouteGatewayParameters));
 270            }
 271
 0272            using var message = CreateCreateOrUpdateRequest(resourceGroupName, expressRouteGatewayName, putExpressRouteG
 0273            _pipeline.Send(message, cancellationToken);
 0274            switch (message.Response.Status)
 275            {
 276                case 200:
 277                case 201:
 0278                    return message.Response;
 279                default:
 0280                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 281            }
 0282        }
 283
 284        internal HttpMessage CreateGetRequest(string resourceGroupName, string expressRouteGatewayName)
 285        {
 0286            var message = _pipeline.CreateMessage();
 0287            var request = message.Request;
 0288            request.Method = RequestMethod.Get;
 0289            var uri = new RawRequestUriBuilder();
 0290            uri.Reset(endpoint);
 0291            uri.AppendPath("/subscriptions/", false);
 0292            uri.AppendPath(subscriptionId, true);
 0293            uri.AppendPath("/resourceGroups/", false);
 0294            uri.AppendPath(resourceGroupName, true);
 0295            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways/", false);
 0296            uri.AppendPath(expressRouteGatewayName, true);
 0297            uri.AppendQuery("api-version", "2020-04-01", true);
 0298            request.Uri = uri;
 0299            return message;
 300        }
 301
 302        /// <summary> Fetches the details of a ExpressRoute gateway in a resource group. </summary>
 303        /// <param name="resourceGroupName"> The name of the resource group. </param>
 304        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 305        /// <param name="cancellationToken"> The cancellation token to use. </param>
 306        public async Task<Response<ExpressRouteGateway>> GetAsync(string resourceGroupName, string expressRouteGatewayNa
 307        {
 0308            if (resourceGroupName == null)
 309            {
 0310                throw new ArgumentNullException(nameof(resourceGroupName));
 311            }
 0312            if (expressRouteGatewayName == null)
 313            {
 0314                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 315            }
 316
 0317            using var message = CreateGetRequest(resourceGroupName, expressRouteGatewayName);
 0318            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0319            switch (message.Response.Status)
 320            {
 321                case 200:
 322                    {
 0323                        ExpressRouteGateway value = default;
 0324                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0325                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 326                        {
 0327                            value = null;
 328                        }
 329                        else
 330                        {
 0331                            value = ExpressRouteGateway.DeserializeExpressRouteGateway(document.RootElement);
 332                        }
 0333                        return Response.FromValue(value, message.Response);
 334                    }
 335                default:
 0336                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 337            }
 0338        }
 339
 340        /// <summary> Fetches the details of a ExpressRoute gateway in a resource group. </summary>
 341        /// <param name="resourceGroupName"> The name of the resource group. </param>
 342        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 343        /// <param name="cancellationToken"> The cancellation token to use. </param>
 344        public Response<ExpressRouteGateway> Get(string resourceGroupName, string expressRouteGatewayName, CancellationT
 345        {
 0346            if (resourceGroupName == null)
 347            {
 0348                throw new ArgumentNullException(nameof(resourceGroupName));
 349            }
 0350            if (expressRouteGatewayName == null)
 351            {
 0352                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 353            }
 354
 0355            using var message = CreateGetRequest(resourceGroupName, expressRouteGatewayName);
 0356            _pipeline.Send(message, cancellationToken);
 0357            switch (message.Response.Status)
 358            {
 359                case 200:
 360                    {
 0361                        ExpressRouteGateway value = default;
 0362                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0363                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 364                        {
 0365                            value = null;
 366                        }
 367                        else
 368                        {
 0369                            value = ExpressRouteGateway.DeserializeExpressRouteGateway(document.RootElement);
 370                        }
 0371                        return Response.FromValue(value, message.Response);
 372                    }
 373                default:
 0374                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 375            }
 0376        }
 377
 378        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string expressRouteGatewayName)
 379        {
 0380            var message = _pipeline.CreateMessage();
 0381            var request = message.Request;
 0382            request.Method = RequestMethod.Delete;
 0383            var uri = new RawRequestUriBuilder();
 0384            uri.Reset(endpoint);
 0385            uri.AppendPath("/subscriptions/", false);
 0386            uri.AppendPath(subscriptionId, true);
 0387            uri.AppendPath("/resourceGroups/", false);
 0388            uri.AppendPath(resourceGroupName, true);
 0389            uri.AppendPath("/providers/Microsoft.Network/expressRouteGateways/", false);
 0390            uri.AppendPath(expressRouteGatewayName, true);
 0391            uri.AppendQuery("api-version", "2020-04-01", true);
 0392            request.Uri = uri;
 0393            return message;
 394        }
 395
 396        /// <summary> Deletes the specified ExpressRoute gateway in a resource group. An ExpressRoute gateway resource c
 397        /// <param name="resourceGroupName"> The name of the resource group. </param>
 398        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 399        /// <param name="cancellationToken"> The cancellation token to use. </param>
 400        public async Task<Response> DeleteAsync(string resourceGroupName, string expressRouteGatewayName, CancellationTo
 401        {
 0402            if (resourceGroupName == null)
 403            {
 0404                throw new ArgumentNullException(nameof(resourceGroupName));
 405            }
 0406            if (expressRouteGatewayName == null)
 407            {
 0408                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 409            }
 410
 0411            using var message = CreateDeleteRequest(resourceGroupName, expressRouteGatewayName);
 0412            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0413            switch (message.Response.Status)
 414            {
 415                case 200:
 416                case 202:
 417                case 204:
 0418                    return message.Response;
 419                default:
 0420                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 421            }
 0422        }
 423
 424        /// <summary> Deletes the specified ExpressRoute gateway in a resource group. An ExpressRoute gateway resource c
 425        /// <param name="resourceGroupName"> The name of the resource group. </param>
 426        /// <param name="expressRouteGatewayName"> The name of the ExpressRoute gateway. </param>
 427        /// <param name="cancellationToken"> The cancellation token to use. </param>
 428        public Response Delete(string resourceGroupName, string expressRouteGatewayName, CancellationToken cancellationT
 429        {
 0430            if (resourceGroupName == null)
 431            {
 0432                throw new ArgumentNullException(nameof(resourceGroupName));
 433            }
 0434            if (expressRouteGatewayName == null)
 435            {
 0436                throw new ArgumentNullException(nameof(expressRouteGatewayName));
 437            }
 438
 0439            using var message = CreateDeleteRequest(resourceGroupName, expressRouteGatewayName);
 0440            _pipeline.Send(message, cancellationToken);
 0441            switch (message.Response.Status)
 442            {
 443                case 200:
 444                case 202:
 445                case 204:
 0446                    return message.Response;
 447                default:
 0448                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 449            }
 0450        }
 451    }
 452}