< Summary

Class:Azure.ResourceManager.Resources.ResourceGroupsRestOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourceGroupsRestOperations.cs
Covered lines:202
Uncovered lines:101
Coverable lines:303
Total lines:680
Line coverage:66.6% (202 of 303)
Covered branches:53
Total branches:112
Branch coverage:47.3% (53 of 112)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCheckExistenceRequest(...)-100%100%
CheckExistenceAsync()-87.5%83.33%
CheckExistence(...)-87.5%83.33%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-86.67%75%
CreateOrUpdate(...)-86.67%75%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-75%66.67%
Delete(...)-75%66.67%
CreateGetRequest(...)-100%100%
GetAsync()-76.92%50%
Get(...)-76.92%50%
CreateUpdateRequest(...)-100%100%
UpdateAsync()-73.33%50%
Update(...)-73.33%50%
CreateExportTemplateRequest(...)-0%100%
ExportTemplateAsync()-0%0%
ExportTemplate(...)-0%0%
CreateListRequest(...)-93.33%75%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourceGroupsRestOperations.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.Resources.Models;
 16
 17namespace Azure.ResourceManager.Resources
 18{
 19    internal partial class ResourceGroupsRestOperations
 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 ResourceGroupsRestOperations. </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 ID of the target subscription. </param>
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 31232        public ResourceGroupsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript
 33        {
 31234            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 31238            endpoint ??= new Uri("https://management.azure.com");
 39
 31240            this.subscriptionId = subscriptionId;
 31241            this.endpoint = endpoint;
 31242            _clientDiagnostics = clientDiagnostics;
 31243            _pipeline = pipeline;
 31244        }
 45
 46        internal Core.HttpMessage CreateCheckExistenceRequest(string resourceGroupName)
 47        {
 2048            var message = _pipeline.CreateMessage();
 2049            var request = message.Request;
 2050            request.Method = RequestMethod.Head;
 2051            var uri = new RawRequestUriBuilder();
 2052            uri.Reset(endpoint);
 2053            uri.AppendPath("/subscriptions/", false);
 2054            uri.AppendPath(subscriptionId, true);
 2055            uri.AppendPath("/resourcegroups/", false);
 2056            uri.AppendPath(resourceGroupName, true);
 2057            uri.AppendQuery("api-version", "2019-10-01", true);
 2058            request.Uri = uri;
 2059            return message;
 60        }
 61
 62        /// <summary> Checks whether a resource group exists. </summary>
 63        /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public async Task<Response> CheckExistenceAsync(string resourceGroupName, CancellationToken cancellationToken = 
 66        {
 1067            if (resourceGroupName == null)
 68            {
 069                throw new ArgumentNullException(nameof(resourceGroupName));
 70            }
 71
 1072            using var message = CreateCheckExistenceRequest(resourceGroupName);
 1073            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 1074            switch (message.Response.Status)
 75            {
 76                case 204:
 77                case 404:
 878                    return message.Response;
 79                default:
 280                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 81            }
 882        }
 83
 84        /// <summary> Checks whether a resource group exists. </summary>
 85        /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa
 86        /// <param name="cancellationToken"> The cancellation token to use. </param>
 87        public Response CheckExistence(string resourceGroupName, CancellationToken cancellationToken = default)
 88        {
 1089            if (resourceGroupName == null)
 90            {
 091                throw new ArgumentNullException(nameof(resourceGroupName));
 92            }
 93
 1094            using var message = CreateCheckExistenceRequest(resourceGroupName);
 1095            _pipeline.Send(message, cancellationToken);
 1096            switch (message.Response.Status)
 97            {
 98                case 204:
 99                case 404:
 8100                    return message.Response;
 101                default:
 2102                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 103            }
 8104        }
 105
 106        internal Core.HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, ResourceGroup parameters)
 107        {
 112108            var message = _pipeline.CreateMessage();
 112109            var request = message.Request;
 112110            request.Method = RequestMethod.Put;
 112111            var uri = new RawRequestUriBuilder();
 112112            uri.Reset(endpoint);
 112113            uri.AppendPath("/subscriptions/", false);
 112114            uri.AppendPath(subscriptionId, true);
 112115            uri.AppendPath("/resourcegroups/", false);
 112116            uri.AppendPath(resourceGroupName, true);
 112117            uri.AppendQuery("api-version", "2019-10-01", true);
 112118            request.Uri = uri;
 112119            request.Headers.Add("Content-Type", "application/json");
 112120            var content = new Utf8JsonRequestContent();
 112121            content.JsonWriter.WriteObjectValue(parameters);
 112122            request.Content = content;
 112123            return message;
 124        }
 125
 126        /// <summary> Creates or updates a resource group. </summary>
 127        /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri
 128        /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param>
 129        /// <param name="cancellationToken"> The cancellation token to use. </param>
 130        public async Task<Response<ResourceGroup>> CreateOrUpdateAsync(string resourceGroupName, ResourceGroup parameter
 131        {
 60132            if (resourceGroupName == null)
 133            {
 2134                throw new ArgumentNullException(nameof(resourceGroupName));
 135            }
 58136            if (parameters == null)
 137            {
 2138                throw new ArgumentNullException(nameof(parameters));
 139            }
 140
 56141            using var message = CreateCreateOrUpdateRequest(resourceGroupName, parameters);
 56142            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 56143            switch (message.Response.Status)
 144            {
 145                case 200:
 146                case 201:
 147                    {
 56148                        ResourceGroup value = default;
 56149                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 56150                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 151                        {
 0152                            value = null;
 153                        }
 154                        else
 155                        {
 56156                            value = ResourceGroup.DeserializeResourceGroup(document.RootElement);
 157                        }
 56158                        return Response.FromValue(value, message.Response);
 159                    }
 160                default:
 0161                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 162            }
 56163        }
 164
 165        /// <summary> Creates or updates a resource group. </summary>
 166        /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri
 167        /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param>
 168        /// <param name="cancellationToken"> The cancellation token to use. </param>
 169        public Response<ResourceGroup> CreateOrUpdate(string resourceGroupName, ResourceGroup parameters, CancellationTo
 170        {
 60171            if (resourceGroupName == null)
 172            {
 2173                throw new ArgumentNullException(nameof(resourceGroupName));
 174            }
 58175            if (parameters == null)
 176            {
 2177                throw new ArgumentNullException(nameof(parameters));
 178            }
 179
 56180            using var message = CreateCreateOrUpdateRequest(resourceGroupName, parameters);
 56181            _pipeline.Send(message, cancellationToken);
 56182            switch (message.Response.Status)
 183            {
 184                case 200:
 185                case 201:
 186                    {
 56187                        ResourceGroup value = default;
 56188                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 56189                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 190                        {
 0191                            value = null;
 192                        }
 193                        else
 194                        {
 56195                            value = ResourceGroup.DeserializeResourceGroup(document.RootElement);
 196                        }
 56197                        return Response.FromValue(value, message.Response);
 198                    }
 199                default:
 0200                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 201            }
 56202        }
 203
 204        internal Core.HttpMessage CreateDeleteRequest(string resourceGroupName)
 205        {
 32206            var message = _pipeline.CreateMessage();
 32207            var request = message.Request;
 32208            request.Method = RequestMethod.Delete;
 32209            var uri = new RawRequestUriBuilder();
 32210            uri.Reset(endpoint);
 32211            uri.AppendPath("/subscriptions/", false);
 32212            uri.AppendPath(subscriptionId, true);
 32213            uri.AppendPath("/resourcegroups/", false);
 32214            uri.AppendPath(resourceGroupName, true);
 32215            uri.AppendQuery("api-version", "2019-10-01", true);
 32216            request.Uri = uri;
 32217            return message;
 218        }
 219
 220        /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group
 221        /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p
 222        /// <param name="cancellationToken"> The cancellation token to use. </param>
 223        public async Task<Response> DeleteAsync(string resourceGroupName, CancellationToken cancellationToken = default)
 224        {
 8225            if (resourceGroupName == null)
 226            {
 0227                throw new ArgumentNullException(nameof(resourceGroupName));
 228            }
 229
 8230            using var message = CreateDeleteRequest(resourceGroupName);
 8231            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8232            switch (message.Response.Status)
 233            {
 234                case 200:
 235                case 202:
 8236                    return message.Response;
 237                default:
 0238                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 239            }
 8240        }
 241
 242        /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group
 243        /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p
 244        /// <param name="cancellationToken"> The cancellation token to use. </param>
 245        public Response Delete(string resourceGroupName, CancellationToken cancellationToken = default)
 246        {
 8247            if (resourceGroupName == null)
 248            {
 0249                throw new ArgumentNullException(nameof(resourceGroupName));
 250            }
 251
 8252            using var message = CreateDeleteRequest(resourceGroupName);
 8253            _pipeline.Send(message, cancellationToken);
 8254            switch (message.Response.Status)
 255            {
 256                case 200:
 257                case 202:
 8258                    return message.Response;
 259                default:
 0260                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 261            }
 8262        }
 263
 264        internal Core.HttpMessage CreateGetRequest(string resourceGroupName)
 265        {
 16266            var message = _pipeline.CreateMessage();
 16267            var request = message.Request;
 16268            request.Method = RequestMethod.Get;
 16269            var uri = new RawRequestUriBuilder();
 16270            uri.Reset(endpoint);
 16271            uri.AppendPath("/subscriptions/", false);
 16272            uri.AppendPath(subscriptionId, true);
 16273            uri.AppendPath("/resourcegroups/", false);
 16274            uri.AppendPath(resourceGroupName, true);
 16275            uri.AppendQuery("api-version", "2019-10-01", true);
 16276            request.Uri = uri;
 16277            return message;
 278        }
 279
 280        /// <summary> Gets a resource group. </summary>
 281        /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para
 282        /// <param name="cancellationToken"> The cancellation token to use. </param>
 283        public async Task<Response<ResourceGroup>> GetAsync(string resourceGroupName, CancellationToken cancellationToke
 284        {
 8285            if (resourceGroupName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(resourceGroupName));
 288            }
 289
 8290            using var message = CreateGetRequest(resourceGroupName);
 8291            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8292            switch (message.Response.Status)
 293            {
 294                case 200:
 295                    {
 8296                        ResourceGroup value = default;
 8297                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8298                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 299                        {
 0300                            value = null;
 301                        }
 302                        else
 303                        {
 8304                            value = ResourceGroup.DeserializeResourceGroup(document.RootElement);
 305                        }
 8306                        return Response.FromValue(value, message.Response);
 307                    }
 308                default:
 0309                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 310            }
 8311        }
 312
 313        /// <summary> Gets a resource group. </summary>
 314        /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para
 315        /// <param name="cancellationToken"> The cancellation token to use. </param>
 316        public Response<ResourceGroup> Get(string resourceGroupName, CancellationToken cancellationToken = default)
 317        {
 8318            if (resourceGroupName == null)
 319            {
 0320                throw new ArgumentNullException(nameof(resourceGroupName));
 321            }
 322
 8323            using var message = CreateGetRequest(resourceGroupName);
 8324            _pipeline.Send(message, cancellationToken);
 8325            switch (message.Response.Status)
 326            {
 327                case 200:
 328                    {
 8329                        ResourceGroup value = default;
 8330                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8331                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 332                        {
 0333                            value = null;
 334                        }
 335                        else
 336                        {
 8337                            value = ResourceGroup.DeserializeResourceGroup(document.RootElement);
 338                        }
 8339                        return Response.FromValue(value, message.Response);
 340                    }
 341                default:
 0342                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 343            }
 8344        }
 345
 346        internal Core.HttpMessage CreateUpdateRequest(string resourceGroupName, ResourceGroupPatchable parameters)
 347        {
 4348            var message = _pipeline.CreateMessage();
 4349            var request = message.Request;
 4350            request.Method = RequestMethod.Patch;
 4351            var uri = new RawRequestUriBuilder();
 4352            uri.Reset(endpoint);
 4353            uri.AppendPath("/subscriptions/", false);
 4354            uri.AppendPath(subscriptionId, true);
 4355            uri.AppendPath("/resourcegroups/", false);
 4356            uri.AppendPath(resourceGroupName, true);
 4357            uri.AppendQuery("api-version", "2019-10-01", true);
 4358            request.Uri = uri;
 4359            request.Headers.Add("Content-Type", "application/json");
 4360            var content = new Utf8JsonRequestContent();
 4361            content.JsonWriter.WriteObjectValue(parameters);
 4362            request.Content = content;
 4363            return message;
 364        }
 365
 366        /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of 
 367        /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p
 368        /// <param name="parameters"> Parameters supplied to update a resource group. </param>
 369        /// <param name="cancellationToken"> The cancellation token to use. </param>
 370        public async Task<Response<ResourceGroup>> UpdateAsync(string resourceGroupName, ResourceGroupPatchable paramete
 371        {
 2372            if (resourceGroupName == null)
 373            {
 0374                throw new ArgumentNullException(nameof(resourceGroupName));
 375            }
 2376            if (parameters == null)
 377            {
 0378                throw new ArgumentNullException(nameof(parameters));
 379            }
 380
 2381            using var message = CreateUpdateRequest(resourceGroupName, parameters);
 2382            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2383            switch (message.Response.Status)
 384            {
 385                case 200:
 386                    {
 2387                        ResourceGroup value = default;
 2388                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2389                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 390                        {
 0391                            value = null;
 392                        }
 393                        else
 394                        {
 2395                            value = ResourceGroup.DeserializeResourceGroup(document.RootElement);
 396                        }
 2397                        return Response.FromValue(value, message.Response);
 398                    }
 399                default:
 0400                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 401            }
 2402        }
 403
 404        /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of 
 405        /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p
 406        /// <param name="parameters"> Parameters supplied to update a resource group. </param>
 407        /// <param name="cancellationToken"> The cancellation token to use. </param>
 408        public Response<ResourceGroup> Update(string resourceGroupName, ResourceGroupPatchable parameters, CancellationT
 409        {
 2410            if (resourceGroupName == null)
 411            {
 0412                throw new ArgumentNullException(nameof(resourceGroupName));
 413            }
 2414            if (parameters == null)
 415            {
 0416                throw new ArgumentNullException(nameof(parameters));
 417            }
 418
 2419            using var message = CreateUpdateRequest(resourceGroupName, parameters);
 2420            _pipeline.Send(message, cancellationToken);
 2421            switch (message.Response.Status)
 422            {
 423                case 200:
 424                    {
 2425                        ResourceGroup value = default;
 2426                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2427                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 428                        {
 0429                            value = null;
 430                        }
 431                        else
 432                        {
 2433                            value = ResourceGroup.DeserializeResourceGroup(document.RootElement);
 434                        }
 2435                        return Response.FromValue(value, message.Response);
 436                    }
 437                default:
 0438                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 439            }
 2440        }
 441
 442        internal Core.HttpMessage CreateExportTemplateRequest(string resourceGroupName, ExportTemplateRequest parameters
 443        {
 0444            var message = _pipeline.CreateMessage();
 0445            var request = message.Request;
 0446            request.Method = RequestMethod.Post;
 0447            var uri = new RawRequestUriBuilder();
 0448            uri.Reset(endpoint);
 0449            uri.AppendPath("/subscriptions/", false);
 0450            uri.AppendPath(subscriptionId, true);
 0451            uri.AppendPath("/resourcegroups/", false);
 0452            uri.AppendPath(resourceGroupName, true);
 0453            uri.AppendPath("/exportTemplate", false);
 0454            uri.AppendQuery("api-version", "2019-10-01", true);
 0455            request.Uri = uri;
 0456            request.Headers.Add("Content-Type", "application/json");
 0457            var content = new Utf8JsonRequestContent();
 0458            content.JsonWriter.WriteObjectValue(parameters);
 0459            request.Content = content;
 0460            return message;
 461        }
 462
 463        /// <summary> Captures the specified resource group as a template. </summary>
 464        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 465        /// <param name="parameters"> Parameters for exporting the template. </param>
 466        /// <param name="cancellationToken"> The cancellation token to use. </param>
 467        public async Task<Response> ExportTemplateAsync(string resourceGroupName, ExportTemplateRequest parameters, Canc
 468        {
 0469            if (resourceGroupName == null)
 470            {
 0471                throw new ArgumentNullException(nameof(resourceGroupName));
 472            }
 0473            if (parameters == null)
 474            {
 0475                throw new ArgumentNullException(nameof(parameters));
 476            }
 477
 0478            using var message = CreateExportTemplateRequest(resourceGroupName, parameters);
 0479            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0480            switch (message.Response.Status)
 481            {
 482                case 200:
 483                case 202:
 0484                    return message.Response;
 485                default:
 0486                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 487            }
 0488        }
 489
 490        /// <summary> Captures the specified resource group as a template. </summary>
 491        /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param>
 492        /// <param name="parameters"> Parameters for exporting the template. </param>
 493        /// <param name="cancellationToken"> The cancellation token to use. </param>
 494        public Response ExportTemplate(string resourceGroupName, ExportTemplateRequest parameters, CancellationToken can
 495        {
 0496            if (resourceGroupName == null)
 497            {
 0498                throw new ArgumentNullException(nameof(resourceGroupName));
 499            }
 0500            if (parameters == null)
 501            {
 0502                throw new ArgumentNullException(nameof(parameters));
 503            }
 504
 0505            using var message = CreateExportTemplateRequest(resourceGroupName, parameters);
 0506            _pipeline.Send(message, cancellationToken);
 0507            switch (message.Response.Status)
 508            {
 509                case 200:
 510                case 202:
 0511                    return message.Response;
 512                default:
 0513                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 514            }
 0515        }
 516
 517        internal Core.HttpMessage CreateListRequest(string filter, int? top)
 518        {
 20519            var message = _pipeline.CreateMessage();
 20520            var request = message.Request;
 20521            request.Method = RequestMethod.Get;
 20522            var uri = new RawRequestUriBuilder();
 20523            uri.Reset(endpoint);
 20524            uri.AppendPath("/subscriptions/", false);
 20525            uri.AppendPath(subscriptionId, true);
 20526            uri.AppendPath("/resourcegroups", false);
 20527            if (filter != null)
 528            {
 0529                uri.AppendQuery("$filter", filter, true);
 530            }
 20531            if (top != null)
 532            {
 4533                uri.AppendQuery("$top", top.Value, true);
 534            }
 20535            uri.AppendQuery("api-version", "2019-10-01", true);
 20536            request.Uri = uri;
 20537            return message;
 538        }
 539
 540        /// <summary> Gets all the resource groups for a subscription. </summary>
 541        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;You can filter by tag names a
 542        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 543        /// <param name="cancellationToken"> The cancellation token to use. </param>
 544        public async Task<Response<ResourceGroupListResult>> ListAsync(string filter = null, int? top = null, Cancellati
 545        {
 10546            using var message = CreateListRequest(filter, top);
 10547            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 10548            switch (message.Response.Status)
 549            {
 550                case 200:
 551                    {
 10552                        ResourceGroupListResult value = default;
 10553                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 10554                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 555                        {
 0556                            value = null;
 557                        }
 558                        else
 559                        {
 10560                            value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement);
 561                        }
 10562                        return Response.FromValue(value, message.Response);
 563                    }
 564                default:
 0565                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 566            }
 10567        }
 568
 569        /// <summary> Gets all the resource groups for a subscription. </summary>
 570        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;You can filter by tag names a
 571        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 572        /// <param name="cancellationToken"> The cancellation token to use. </param>
 573        public Response<ResourceGroupListResult> List(string filter = null, int? top = null, CancellationToken cancellat
 574        {
 10575            using var message = CreateListRequest(filter, top);
 10576            _pipeline.Send(message, cancellationToken);
 10577            switch (message.Response.Status)
 578            {
 579                case 200:
 580                    {
 10581                        ResourceGroupListResult value = default;
 10582                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 10583                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 584                        {
 0585                            value = null;
 586                        }
 587                        else
 588                        {
 10589                            value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement);
 590                        }
 10591                        return Response.FromValue(value, message.Response);
 592                    }
 593                default:
 0594                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 595            }
 10596        }
 597
 598        internal Core.HttpMessage CreateListNextPageRequest(string nextLink, string filter, int? top)
 599        {
 0600            var message = _pipeline.CreateMessage();
 0601            var request = message.Request;
 0602            request.Method = RequestMethod.Get;
 0603            var uri = new RawRequestUriBuilder();
 0604            uri.Reset(endpoint);
 0605            uri.AppendRawNextLink(nextLink, false);
 0606            request.Uri = uri;
 0607            return message;
 608        }
 609
 610        /// <summary> Gets all the resource groups for a subscription. </summary>
 611        /// <param name="nextLink"> The URL to the next page of results. </param>
 612        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;You can filter by tag names a
 613        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 614        /// <param name="cancellationToken"> The cancellation token to use. </param>
 615        public async Task<Response<ResourceGroupListResult>> ListNextPageAsync(string nextLink, string filter = null, in
 616        {
 0617            if (nextLink == null)
 618            {
 0619                throw new ArgumentNullException(nameof(nextLink));
 620            }
 621
 0622            using var message = CreateListNextPageRequest(nextLink, filter, top);
 0623            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0624            switch (message.Response.Status)
 625            {
 626                case 200:
 627                    {
 0628                        ResourceGroupListResult value = default;
 0629                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0630                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 631                        {
 0632                            value = null;
 633                        }
 634                        else
 635                        {
 0636                            value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement);
 637                        }
 0638                        return Response.FromValue(value, message.Response);
 639                    }
 640                default:
 0641                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 642            }
 0643        }
 644
 645        /// <summary> Gets all the resource groups for a subscription. </summary>
 646        /// <param name="nextLink"> The URL to the next page of results. </param>
 647        /// <param name="filter"> The filter to apply on the operation.&lt;br&gt;&lt;br&gt;You can filter by tag names a
 648        /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param>
 649        /// <param name="cancellationToken"> The cancellation token to use. </param>
 650        public Response<ResourceGroupListResult> ListNextPage(string nextLink, string filter = null, int? top = null, Ca
 651        {
 0652            if (nextLink == null)
 653            {
 0654                throw new ArgumentNullException(nameof(nextLink));
 655            }
 656
 0657            using var message = CreateListNextPageRequest(nextLink, filter, top);
 0658            _pipeline.Send(message, cancellationToken);
 0659            switch (message.Response.Status)
 660            {
 661                case 200:
 662                    {
 0663                        ResourceGroupListResult value = default;
 0664                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0665                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 666                        {
 0667                            value = null;
 668                        }
 669                        else
 670                        {
 0671                            value = ResourceGroupListResult.DeserializeResourceGroupListResult(document.RootElement);
 672                        }
 0673                        return Response.FromValue(value, message.Response);
 674                    }
 675                default:
 0676                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 677            }
 0678        }
 679    }
 680}