< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateGetRequest(...)-0%0%
GetAsync()-0%0%
Get(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateUpdateTagsRequest(...)-0%100%
UpdateTagsAsync()-0%0%
UpdateTags(...)-0%0%
CreateListAllRequest()-0%100%
ListAllAsync()-0%0%
ListAll(...)-0%0%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateListAllNextPageRequest(...)-0%100%
ListAllNextPageAsync()-0%0%
ListAllNextPage(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\NatGatewaysRestOperations.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 NatGatewaysRestOperations
 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 NatGatewaysRestOperations. </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 NatGatewaysRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription
 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 CreateDeleteRequest(string resourceGroupName, string natGatewayName)
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Delete;
 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/natGateways/", false);
 058            uri.AppendPath(natGatewayName, true);
 059            uri.AppendQuery("api-version", "2020-04-01", true);
 060            request.Uri = uri;
 061            return message;
 62        }
 63
 64        /// <summary> Deletes the specified nat gateway. </summary>
 65        /// <param name="resourceGroupName"> The name of the resource group. </param>
 66        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 67        /// <param name="cancellationToken"> The cancellation token to use. </param>
 68        public async Task<Response> DeleteAsync(string resourceGroupName, string natGatewayName, CancellationToken cance
 69        {
 070            if (resourceGroupName == null)
 71            {
 072                throw new ArgumentNullException(nameof(resourceGroupName));
 73            }
 074            if (natGatewayName == null)
 75            {
 076                throw new ArgumentNullException(nameof(natGatewayName));
 77            }
 78
 079            using var message = CreateDeleteRequest(resourceGroupName, natGatewayName);
 080            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 081            switch (message.Response.Status)
 82            {
 83                case 200:
 84                case 202:
 85                case 204:
 086                    return message.Response;
 87                default:
 088                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 89            }
 090        }
 91
 92        /// <summary> Deletes the specified nat gateway. </summary>
 93        /// <param name="resourceGroupName"> The name of the resource group. </param>
 94        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 95        /// <param name="cancellationToken"> The cancellation token to use. </param>
 96        public Response Delete(string resourceGroupName, string natGatewayName, CancellationToken cancellationToken = de
 97        {
 098            if (resourceGroupName == null)
 99            {
 0100                throw new ArgumentNullException(nameof(resourceGroupName));
 101            }
 0102            if (natGatewayName == null)
 103            {
 0104                throw new ArgumentNullException(nameof(natGatewayName));
 105            }
 106
 0107            using var message = CreateDeleteRequest(resourceGroupName, natGatewayName);
 0108            _pipeline.Send(message, cancellationToken);
 0109            switch (message.Response.Status)
 110            {
 111                case 200:
 112                case 202:
 113                case 204:
 0114                    return message.Response;
 115                default:
 0116                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 117            }
 0118        }
 119
 120        internal HttpMessage CreateGetRequest(string resourceGroupName, string natGatewayName, string expand)
 121        {
 0122            var message = _pipeline.CreateMessage();
 0123            var request = message.Request;
 0124            request.Method = RequestMethod.Get;
 0125            var uri = new RawRequestUriBuilder();
 0126            uri.Reset(endpoint);
 0127            uri.AppendPath("/subscriptions/", false);
 0128            uri.AppendPath(subscriptionId, true);
 0129            uri.AppendPath("/resourceGroups/", false);
 0130            uri.AppendPath(resourceGroupName, true);
 0131            uri.AppendPath("/providers/Microsoft.Network/natGateways/", false);
 0132            uri.AppendPath(natGatewayName, true);
 0133            uri.AppendQuery("api-version", "2020-04-01", true);
 0134            if (expand != null)
 135            {
 0136                uri.AppendQuery("$expand", expand, true);
 137            }
 0138            request.Uri = uri;
 0139            return message;
 140        }
 141
 142        /// <summary> Gets the specified nat gateway in a specified resource group. </summary>
 143        /// <param name="resourceGroupName"> The name of the resource group. </param>
 144        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 145        /// <param name="expand"> Expands referenced resources. </param>
 146        /// <param name="cancellationToken"> The cancellation token to use. </param>
 147        public async Task<Response<NatGateway>> GetAsync(string resourceGroupName, string natGatewayName, string expand 
 148        {
 0149            if (resourceGroupName == null)
 150            {
 0151                throw new ArgumentNullException(nameof(resourceGroupName));
 152            }
 0153            if (natGatewayName == null)
 154            {
 0155                throw new ArgumentNullException(nameof(natGatewayName));
 156            }
 157
 0158            using var message = CreateGetRequest(resourceGroupName, natGatewayName, expand);
 0159            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0160            switch (message.Response.Status)
 161            {
 162                case 200:
 163                    {
 0164                        NatGateway value = default;
 0165                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0166                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 167                        {
 0168                            value = null;
 169                        }
 170                        else
 171                        {
 0172                            value = NatGateway.DeserializeNatGateway(document.RootElement);
 173                        }
 0174                        return Response.FromValue(value, message.Response);
 175                    }
 176                default:
 0177                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 178            }
 0179        }
 180
 181        /// <summary> Gets the specified nat gateway in a specified resource group. </summary>
 182        /// <param name="resourceGroupName"> The name of the resource group. </param>
 183        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 184        /// <param name="expand"> Expands referenced resources. </param>
 185        /// <param name="cancellationToken"> The cancellation token to use. </param>
 186        public Response<NatGateway> Get(string resourceGroupName, string natGatewayName, string expand = null, Cancellat
 187        {
 0188            if (resourceGroupName == null)
 189            {
 0190                throw new ArgumentNullException(nameof(resourceGroupName));
 191            }
 0192            if (natGatewayName == null)
 193            {
 0194                throw new ArgumentNullException(nameof(natGatewayName));
 195            }
 196
 0197            using var message = CreateGetRequest(resourceGroupName, natGatewayName, expand);
 0198            _pipeline.Send(message, cancellationToken);
 0199            switch (message.Response.Status)
 200            {
 201                case 200:
 202                    {
 0203                        NatGateway value = default;
 0204                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0205                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 206                        {
 0207                            value = null;
 208                        }
 209                        else
 210                        {
 0211                            value = NatGateway.DeserializeNatGateway(document.RootElement);
 212                        }
 0213                        return Response.FromValue(value, message.Response);
 214                    }
 215                default:
 0216                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 217            }
 0218        }
 219
 220        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string natGatewayName, NatGateway par
 221        {
 0222            var message = _pipeline.CreateMessage();
 0223            var request = message.Request;
 0224            request.Method = RequestMethod.Put;
 0225            var uri = new RawRequestUriBuilder();
 0226            uri.Reset(endpoint);
 0227            uri.AppendPath("/subscriptions/", false);
 0228            uri.AppendPath(subscriptionId, true);
 0229            uri.AppendPath("/resourceGroups/", false);
 0230            uri.AppendPath(resourceGroupName, true);
 0231            uri.AppendPath("/providers/Microsoft.Network/natGateways/", false);
 0232            uri.AppendPath(natGatewayName, true);
 0233            uri.AppendQuery("api-version", "2020-04-01", true);
 0234            request.Uri = uri;
 0235            request.Headers.Add("Content-Type", "application/json");
 0236            var content = new Utf8JsonRequestContent();
 0237            content.JsonWriter.WriteObjectValue(parameters);
 0238            request.Content = content;
 0239            return message;
 240        }
 241
 242        /// <summary> Creates or updates a nat gateway. </summary>
 243        /// <param name="resourceGroupName"> The name of the resource group. </param>
 244        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 245        /// <param name="parameters"> Parameters supplied to the create or update nat gateway operation. </param>
 246        /// <param name="cancellationToken"> The cancellation token to use. </param>
 247        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string natGatewayName, NatGateway para
 248        {
 0249            if (resourceGroupName == null)
 250            {
 0251                throw new ArgumentNullException(nameof(resourceGroupName));
 252            }
 0253            if (natGatewayName == null)
 254            {
 0255                throw new ArgumentNullException(nameof(natGatewayName));
 256            }
 0257            if (parameters == null)
 258            {
 0259                throw new ArgumentNullException(nameof(parameters));
 260            }
 261
 0262            using var message = CreateCreateOrUpdateRequest(resourceGroupName, natGatewayName, parameters);
 0263            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0264            switch (message.Response.Status)
 265            {
 266                case 200:
 267                case 201:
 268                case 202:
 0269                    return message.Response;
 270                default:
 0271                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 272            }
 0273        }
 274
 275        /// <summary> Creates or updates a nat gateway. </summary>
 276        /// <param name="resourceGroupName"> The name of the resource group. </param>
 277        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 278        /// <param name="parameters"> Parameters supplied to the create or update nat gateway operation. </param>
 279        /// <param name="cancellationToken"> The cancellation token to use. </param>
 280        public Response CreateOrUpdate(string resourceGroupName, string natGatewayName, NatGateway parameters, Cancellat
 281        {
 0282            if (resourceGroupName == null)
 283            {
 0284                throw new ArgumentNullException(nameof(resourceGroupName));
 285            }
 0286            if (natGatewayName == null)
 287            {
 0288                throw new ArgumentNullException(nameof(natGatewayName));
 289            }
 0290            if (parameters == null)
 291            {
 0292                throw new ArgumentNullException(nameof(parameters));
 293            }
 294
 0295            using var message = CreateCreateOrUpdateRequest(resourceGroupName, natGatewayName, parameters);
 0296            _pipeline.Send(message, cancellationToken);
 0297            switch (message.Response.Status)
 298            {
 299                case 200:
 300                case 201:
 301                case 202:
 0302                    return message.Response;
 303                default:
 0304                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 305            }
 0306        }
 307
 308        internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string natGatewayName, TagsObject paramet
 309        {
 0310            var message = _pipeline.CreateMessage();
 0311            var request = message.Request;
 0312            request.Method = RequestMethod.Patch;
 0313            var uri = new RawRequestUriBuilder();
 0314            uri.Reset(endpoint);
 0315            uri.AppendPath("/subscriptions/", false);
 0316            uri.AppendPath(subscriptionId, true);
 0317            uri.AppendPath("/resourceGroups/", false);
 0318            uri.AppendPath(resourceGroupName, true);
 0319            uri.AppendPath("/providers/Microsoft.Network/natGateways/", false);
 0320            uri.AppendPath(natGatewayName, true);
 0321            uri.AppendQuery("api-version", "2020-04-01", true);
 0322            request.Uri = uri;
 0323            request.Headers.Add("Content-Type", "application/json");
 0324            var content = new Utf8JsonRequestContent();
 0325            content.JsonWriter.WriteObjectValue(parameters);
 0326            request.Content = content;
 0327            return message;
 328        }
 329
 330        /// <summary> Updates nat gateway tags. </summary>
 331        /// <param name="resourceGroupName"> The name of the resource group. </param>
 332        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 333        /// <param name="parameters"> Parameters supplied to update nat gateway tags. </param>
 334        /// <param name="cancellationToken"> The cancellation token to use. </param>
 335        public async Task<Response<NatGateway>> UpdateTagsAsync(string resourceGroupName, string natGatewayName, TagsObj
 336        {
 0337            if (resourceGroupName == null)
 338            {
 0339                throw new ArgumentNullException(nameof(resourceGroupName));
 340            }
 0341            if (natGatewayName == null)
 342            {
 0343                throw new ArgumentNullException(nameof(natGatewayName));
 344            }
 0345            if (parameters == null)
 346            {
 0347                throw new ArgumentNullException(nameof(parameters));
 348            }
 349
 0350            using var message = CreateUpdateTagsRequest(resourceGroupName, natGatewayName, parameters);
 0351            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0352            switch (message.Response.Status)
 353            {
 354                case 200:
 355                    {
 0356                        NatGateway value = default;
 0357                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0358                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 359                        {
 0360                            value = null;
 361                        }
 362                        else
 363                        {
 0364                            value = NatGateway.DeserializeNatGateway(document.RootElement);
 365                        }
 0366                        return Response.FromValue(value, message.Response);
 367                    }
 368                default:
 0369                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 370            }
 0371        }
 372
 373        /// <summary> Updates nat gateway tags. </summary>
 374        /// <param name="resourceGroupName"> The name of the resource group. </param>
 375        /// <param name="natGatewayName"> The name of the nat gateway. </param>
 376        /// <param name="parameters"> Parameters supplied to update nat gateway tags. </param>
 377        /// <param name="cancellationToken"> The cancellation token to use. </param>
 378        public Response<NatGateway> UpdateTags(string resourceGroupName, string natGatewayName, TagsObject parameters, C
 379        {
 0380            if (resourceGroupName == null)
 381            {
 0382                throw new ArgumentNullException(nameof(resourceGroupName));
 383            }
 0384            if (natGatewayName == null)
 385            {
 0386                throw new ArgumentNullException(nameof(natGatewayName));
 387            }
 0388            if (parameters == null)
 389            {
 0390                throw new ArgumentNullException(nameof(parameters));
 391            }
 392
 0393            using var message = CreateUpdateTagsRequest(resourceGroupName, natGatewayName, parameters);
 0394            _pipeline.Send(message, cancellationToken);
 0395            switch (message.Response.Status)
 396            {
 397                case 200:
 398                    {
 0399                        NatGateway value = default;
 0400                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0401                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 402                        {
 0403                            value = null;
 404                        }
 405                        else
 406                        {
 0407                            value = NatGateway.DeserializeNatGateway(document.RootElement);
 408                        }
 0409                        return Response.FromValue(value, message.Response);
 410                    }
 411                default:
 0412                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 413            }
 0414        }
 415
 416        internal HttpMessage CreateListAllRequest()
 417        {
 0418            var message = _pipeline.CreateMessage();
 0419            var request = message.Request;
 0420            request.Method = RequestMethod.Get;
 0421            var uri = new RawRequestUriBuilder();
 0422            uri.Reset(endpoint);
 0423            uri.AppendPath("/subscriptions/", false);
 0424            uri.AppendPath(subscriptionId, true);
 0425            uri.AppendPath("/providers/Microsoft.Network/natGateways", false);
 0426            uri.AppendQuery("api-version", "2020-04-01", true);
 0427            request.Uri = uri;
 0428            return message;
 429        }
 430
 431        /// <summary> Gets all the Nat Gateways in a subscription. </summary>
 432        /// <param name="cancellationToken"> The cancellation token to use. </param>
 433        public async Task<Response<NatGatewayListResult>> ListAllAsync(CancellationToken cancellationToken = default)
 434        {
 0435            using var message = CreateListAllRequest();
 0436            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0437            switch (message.Response.Status)
 438            {
 439                case 200:
 440                    {
 0441                        NatGatewayListResult value = default;
 0442                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0443                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 444                        {
 0445                            value = null;
 446                        }
 447                        else
 448                        {
 0449                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 450                        }
 0451                        return Response.FromValue(value, message.Response);
 452                    }
 453                default:
 0454                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 455            }
 0456        }
 457
 458        /// <summary> Gets all the Nat Gateways in a subscription. </summary>
 459        /// <param name="cancellationToken"> The cancellation token to use. </param>
 460        public Response<NatGatewayListResult> ListAll(CancellationToken cancellationToken = default)
 461        {
 0462            using var message = CreateListAllRequest();
 0463            _pipeline.Send(message, cancellationToken);
 0464            switch (message.Response.Status)
 465            {
 466                case 200:
 467                    {
 0468                        NatGatewayListResult value = default;
 0469                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0470                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 471                        {
 0472                            value = null;
 473                        }
 474                        else
 475                        {
 0476                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 477                        }
 0478                        return Response.FromValue(value, message.Response);
 479                    }
 480                default:
 0481                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 482            }
 0483        }
 484
 485        internal HttpMessage CreateListRequest(string resourceGroupName)
 486        {
 0487            var message = _pipeline.CreateMessage();
 0488            var request = message.Request;
 0489            request.Method = RequestMethod.Get;
 0490            var uri = new RawRequestUriBuilder();
 0491            uri.Reset(endpoint);
 0492            uri.AppendPath("/subscriptions/", false);
 0493            uri.AppendPath(subscriptionId, true);
 0494            uri.AppendPath("/resourceGroups/", false);
 0495            uri.AppendPath(resourceGroupName, true);
 0496            uri.AppendPath("/providers/Microsoft.Network/natGateways", false);
 0497            uri.AppendQuery("api-version", "2020-04-01", true);
 0498            request.Uri = uri;
 0499            return message;
 500        }
 501
 502        /// <summary> Gets all nat gateways in a resource group. </summary>
 503        /// <param name="resourceGroupName"> The name of the resource group. </param>
 504        /// <param name="cancellationToken"> The cancellation token to use. </param>
 505        public async Task<Response<NatGatewayListResult>> ListAsync(string resourceGroupName, CancellationToken cancella
 506        {
 0507            if (resourceGroupName == null)
 508            {
 0509                throw new ArgumentNullException(nameof(resourceGroupName));
 510            }
 511
 0512            using var message = CreateListRequest(resourceGroupName);
 0513            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0514            switch (message.Response.Status)
 515            {
 516                case 200:
 517                    {
 0518                        NatGatewayListResult value = default;
 0519                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0520                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 521                        {
 0522                            value = null;
 523                        }
 524                        else
 525                        {
 0526                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 527                        }
 0528                        return Response.FromValue(value, message.Response);
 529                    }
 530                default:
 0531                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 532            }
 0533        }
 534
 535        /// <summary> Gets all nat gateways in a resource group. </summary>
 536        /// <param name="resourceGroupName"> The name of the resource group. </param>
 537        /// <param name="cancellationToken"> The cancellation token to use. </param>
 538        public Response<NatGatewayListResult> List(string resourceGroupName, CancellationToken cancellationToken = defau
 539        {
 0540            if (resourceGroupName == null)
 541            {
 0542                throw new ArgumentNullException(nameof(resourceGroupName));
 543            }
 544
 0545            using var message = CreateListRequest(resourceGroupName);
 0546            _pipeline.Send(message, cancellationToken);
 0547            switch (message.Response.Status)
 548            {
 549                case 200:
 550                    {
 0551                        NatGatewayListResult value = default;
 0552                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0553                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 554                        {
 0555                            value = null;
 556                        }
 557                        else
 558                        {
 0559                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 560                        }
 0561                        return Response.FromValue(value, message.Response);
 562                    }
 563                default:
 0564                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 565            }
 0566        }
 567
 568        internal HttpMessage CreateListAllNextPageRequest(string nextLink)
 569        {
 0570            var message = _pipeline.CreateMessage();
 0571            var request = message.Request;
 0572            request.Method = RequestMethod.Get;
 0573            var uri = new RawRequestUriBuilder();
 0574            uri.Reset(endpoint);
 0575            uri.AppendRawNextLink(nextLink, false);
 0576            request.Uri = uri;
 0577            return message;
 578        }
 579
 580        /// <summary> Gets all the Nat Gateways in a subscription. </summary>
 581        /// <param name="nextLink"> The URL to the next page of results. </param>
 582        /// <param name="cancellationToken"> The cancellation token to use. </param>
 583        public async Task<Response<NatGatewayListResult>> ListAllNextPageAsync(string nextLink, CancellationToken cancel
 584        {
 0585            if (nextLink == null)
 586            {
 0587                throw new ArgumentNullException(nameof(nextLink));
 588            }
 589
 0590            using var message = CreateListAllNextPageRequest(nextLink);
 0591            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0592            switch (message.Response.Status)
 593            {
 594                case 200:
 595                    {
 0596                        NatGatewayListResult value = default;
 0597                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0598                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 599                        {
 0600                            value = null;
 601                        }
 602                        else
 603                        {
 0604                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 605                        }
 0606                        return Response.FromValue(value, message.Response);
 607                    }
 608                default:
 0609                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 610            }
 0611        }
 612
 613        /// <summary> Gets all the Nat Gateways in a subscription. </summary>
 614        /// <param name="nextLink"> The URL to the next page of results. </param>
 615        /// <param name="cancellationToken"> The cancellation token to use. </param>
 616        public Response<NatGatewayListResult> ListAllNextPage(string nextLink, CancellationToken cancellationToken = def
 617        {
 0618            if (nextLink == null)
 619            {
 0620                throw new ArgumentNullException(nameof(nextLink));
 621            }
 622
 0623            using var message = CreateListAllNextPageRequest(nextLink);
 0624            _pipeline.Send(message, cancellationToken);
 0625            switch (message.Response.Status)
 626            {
 627                case 200:
 628                    {
 0629                        NatGatewayListResult value = default;
 0630                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0631                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 632                        {
 0633                            value = null;
 634                        }
 635                        else
 636                        {
 0637                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 638                        }
 0639                        return Response.FromValue(value, message.Response);
 640                    }
 641                default:
 0642                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 643            }
 0644        }
 645
 646        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName)
 647        {
 0648            var message = _pipeline.CreateMessage();
 0649            var request = message.Request;
 0650            request.Method = RequestMethod.Get;
 0651            var uri = new RawRequestUriBuilder();
 0652            uri.Reset(endpoint);
 0653            uri.AppendRawNextLink(nextLink, false);
 0654            request.Uri = uri;
 0655            return message;
 656        }
 657
 658        /// <summary> Gets all nat gateways in a resource group. </summary>
 659        /// <param name="nextLink"> The URL to the next page of results. </param>
 660        /// <param name="resourceGroupName"> The name of the resource group. </param>
 661        /// <param name="cancellationToken"> The cancellation token to use. </param>
 662        public async Task<Response<NatGatewayListResult>> ListNextPageAsync(string nextLink, string resourceGroupName, C
 663        {
 0664            if (nextLink == null)
 665            {
 0666                throw new ArgumentNullException(nameof(nextLink));
 667            }
 0668            if (resourceGroupName == null)
 669            {
 0670                throw new ArgumentNullException(nameof(resourceGroupName));
 671            }
 672
 0673            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0674            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0675            switch (message.Response.Status)
 676            {
 677                case 200:
 678                    {
 0679                        NatGatewayListResult value = default;
 0680                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0681                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 682                        {
 0683                            value = null;
 684                        }
 685                        else
 686                        {
 0687                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 688                        }
 0689                        return Response.FromValue(value, message.Response);
 690                    }
 691                default:
 0692                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 693            }
 0694        }
 695
 696        /// <summary> Gets all nat gateways in a resource group. </summary>
 697        /// <param name="nextLink"> The URL to the next page of results. </param>
 698        /// <param name="resourceGroupName"> The name of the resource group. </param>
 699        /// <param name="cancellationToken"> The cancellation token to use. </param>
 700        public Response<NatGatewayListResult> ListNextPage(string nextLink, string resourceGroupName, CancellationToken 
 701        {
 0702            if (nextLink == null)
 703            {
 0704                throw new ArgumentNullException(nameof(nextLink));
 705            }
 0706            if (resourceGroupName == null)
 707            {
 0708                throw new ArgumentNullException(nameof(resourceGroupName));
 709            }
 710
 0711            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0712            _pipeline.Send(message, cancellationToken);
 0713            switch (message.Response.Status)
 714            {
 715                case 200:
 716                    {
 0717                        NatGatewayListResult value = default;
 0718                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0719                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 720                        {
 0721                            value = null;
 722                        }
 723                        else
 724                        {
 0725                            value = NatGatewayListResult.DeserializeNatGatewayListResult(document.RootElement);
 726                        }
 0727                        return Response.FromValue(value, message.Response);
 728                    }
 729                default:
 0730                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 731            }
 0732        }
 733    }
 734}