< Summary

Class:Azure.ResourceManager.Compute.ImagesRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\ImagesRestOperations.cs
Covered lines:174
Uncovered lines:143
Coverable lines:317
Total lines:710
Line coverage:54.8% (174 of 317)
Covered branches:43
Total branches:122
Branch coverage:35.2% (43 of 122)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-66.67%50%
CreateOrUpdate(...)-66.67%50%
CreateUpdateRequest(...)-100%100%
UpdateAsync()-66.67%50%
Update(...)-66.67%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateGetRequest(...)-93.75%50%
GetAsync()-73.33%50%
Get(...)-73.33%50%
CreateListByResourceGroupRequest(...)-100%100%
ListByResourceGroupAsync()-76.92%50%
ListByResourceGroup(...)-76.92%50%
CreateListRequest()-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateListByResourceGroupNextPageRequest(...)-0%100%
ListByResourceGroupNextPageAsync()-0%0%
ListByResourceGroupNextPage(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\ImagesRestOperations.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.Compute.Models;
 16
 17namespace Azure.ResourceManager.Compute
 18{
 19    internal partial class ImagesRestOperations
 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 ImagesRestOperations. </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"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 39632        public ImagesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, U
 33        {
 39634            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 39638            endpoint ??= new Uri("https://management.azure.com");
 39
 39640            this.subscriptionId = subscriptionId;
 39641            this.endpoint = endpoint;
 39642            _clientDiagnostics = clientDiagnostics;
 39643            _pipeline = pipeline;
 39644        }
 45
 46        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string imageName, Image parameters)
 47        {
 1648            var message = _pipeline.CreateMessage();
 1649            var request = message.Request;
 1650            request.Method = RequestMethod.Put;
 1651            var uri = new RawRequestUriBuilder();
 1652            uri.Reset(endpoint);
 1653            uri.AppendPath("/subscriptions/", false);
 1654            uri.AppendPath(subscriptionId, true);
 1655            uri.AppendPath("/resourceGroups/", false);
 1656            uri.AppendPath(resourceGroupName, true);
 1657            uri.AppendPath("/providers/Microsoft.Compute/images/", false);
 1658            uri.AppendPath(imageName, true);
 1659            uri.AppendQuery("api-version", "2019-12-01", true);
 1660            request.Uri = uri;
 1661            request.Headers.Add("Content-Type", "application/json");
 1662            var content = new Utf8JsonRequestContent();
 1663            content.JsonWriter.WriteObjectValue(parameters);
 1664            request.Content = content;
 1665            return message;
 66        }
 67
 68        /// <summary> Create or update an image. </summary>
 69        /// <param name="resourceGroupName"> The name of the resource group. </param>
 70        /// <param name="imageName"> The name of the image. </param>
 71        /// <param name="parameters"> Parameters supplied to the Create Image operation. </param>
 72        /// <param name="cancellationToken"> The cancellation token to use. </param>
 73        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string imageName, Image parameters, Ca
 74        {
 475            if (resourceGroupName == null)
 76            {
 077                throw new ArgumentNullException(nameof(resourceGroupName));
 78            }
 479            if (imageName == null)
 80            {
 081                throw new ArgumentNullException(nameof(imageName));
 82            }
 483            if (parameters == null)
 84            {
 085                throw new ArgumentNullException(nameof(parameters));
 86            }
 87
 488            using var message = CreateCreateOrUpdateRequest(resourceGroupName, imageName, parameters);
 489            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 490            switch (message.Response.Status)
 91            {
 92                case 200:
 93                case 201:
 494                    return message.Response;
 95                default:
 096                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 97            }
 498        }
 99
 100        /// <summary> Create or update an image. </summary>
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="imageName"> The name of the image. </param>
 103        /// <param name="parameters"> Parameters supplied to the Create Image operation. </param>
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public Response CreateOrUpdate(string resourceGroupName, string imageName, Image parameters, CancellationToken c
 106        {
 4107            if (resourceGroupName == null)
 108            {
 0109                throw new ArgumentNullException(nameof(resourceGroupName));
 110            }
 4111            if (imageName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(imageName));
 114            }
 4115            if (parameters == null)
 116            {
 0117                throw new ArgumentNullException(nameof(parameters));
 118            }
 119
 4120            using var message = CreateCreateOrUpdateRequest(resourceGroupName, imageName, parameters);
 4121            _pipeline.Send(message, cancellationToken);
 4122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                case 201:
 4126                    return message.Response;
 127                default:
 0128                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 129            }
 4130        }
 131
 132        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string imageName, ImageUpdate parameters)
 133        {
 8134            var message = _pipeline.CreateMessage();
 8135            var request = message.Request;
 8136            request.Method = RequestMethod.Patch;
 8137            var uri = new RawRequestUriBuilder();
 8138            uri.Reset(endpoint);
 8139            uri.AppendPath("/subscriptions/", false);
 8140            uri.AppendPath(subscriptionId, true);
 8141            uri.AppendPath("/resourceGroups/", false);
 8142            uri.AppendPath(resourceGroupName, true);
 8143            uri.AppendPath("/providers/Microsoft.Compute/images/", false);
 8144            uri.AppendPath(imageName, true);
 8145            uri.AppendQuery("api-version", "2019-12-01", true);
 8146            request.Uri = uri;
 8147            request.Headers.Add("Content-Type", "application/json");
 8148            var content = new Utf8JsonRequestContent();
 8149            content.JsonWriter.WriteObjectValue(parameters);
 8150            request.Content = content;
 8151            return message;
 152        }
 153
 154        /// <summary> Update an image. </summary>
 155        /// <param name="resourceGroupName"> The name of the resource group. </param>
 156        /// <param name="imageName"> The name of the image. </param>
 157        /// <param name="parameters"> Parameters supplied to the Update Image operation. </param>
 158        /// <param name="cancellationToken"> The cancellation token to use. </param>
 159        public async Task<Response> UpdateAsync(string resourceGroupName, string imageName, ImageUpdate parameters, Canc
 160        {
 2161            if (resourceGroupName == null)
 162            {
 0163                throw new ArgumentNullException(nameof(resourceGroupName));
 164            }
 2165            if (imageName == null)
 166            {
 0167                throw new ArgumentNullException(nameof(imageName));
 168            }
 2169            if (parameters == null)
 170            {
 0171                throw new ArgumentNullException(nameof(parameters));
 172            }
 173
 2174            using var message = CreateUpdateRequest(resourceGroupName, imageName, parameters);
 2175            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2176            switch (message.Response.Status)
 177            {
 178                case 200:
 179                case 201:
 2180                    return message.Response;
 181                default:
 0182                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 183            }
 2184        }
 185
 186        /// <summary> Update an image. </summary>
 187        /// <param name="resourceGroupName"> The name of the resource group. </param>
 188        /// <param name="imageName"> The name of the image. </param>
 189        /// <param name="parameters"> Parameters supplied to the Update Image operation. </param>
 190        /// <param name="cancellationToken"> The cancellation token to use. </param>
 191        public Response Update(string resourceGroupName, string imageName, ImageUpdate parameters, CancellationToken can
 192        {
 2193            if (resourceGroupName == null)
 194            {
 0195                throw new ArgumentNullException(nameof(resourceGroupName));
 196            }
 2197            if (imageName == null)
 198            {
 0199                throw new ArgumentNullException(nameof(imageName));
 200            }
 2201            if (parameters == null)
 202            {
 0203                throw new ArgumentNullException(nameof(parameters));
 204            }
 205
 2206            using var message = CreateUpdateRequest(resourceGroupName, imageName, parameters);
 2207            _pipeline.Send(message, cancellationToken);
 2208            switch (message.Response.Status)
 209            {
 210                case 200:
 211                case 201:
 2212                    return message.Response;
 213                default:
 0214                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 215            }
 2216        }
 217
 218        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string imageName)
 219        {
 16220            var message = _pipeline.CreateMessage();
 16221            var request = message.Request;
 16222            request.Method = RequestMethod.Delete;
 16223            var uri = new RawRequestUriBuilder();
 16224            uri.Reset(endpoint);
 16225            uri.AppendPath("/subscriptions/", false);
 16226            uri.AppendPath(subscriptionId, true);
 16227            uri.AppendPath("/resourceGroups/", false);
 16228            uri.AppendPath(resourceGroupName, true);
 16229            uri.AppendPath("/providers/Microsoft.Compute/images/", false);
 16230            uri.AppendPath(imageName, true);
 16231            uri.AppendQuery("api-version", "2019-12-01", true);
 16232            request.Uri = uri;
 16233            return message;
 234        }
 235
 236        /// <summary> Deletes an Image. </summary>
 237        /// <param name="resourceGroupName"> The name of the resource group. </param>
 238        /// <param name="imageName"> The name of the image. </param>
 239        /// <param name="cancellationToken"> The cancellation token to use. </param>
 240        public async Task<Response> DeleteAsync(string resourceGroupName, string imageName, CancellationToken cancellati
 241        {
 4242            if (resourceGroupName == null)
 243            {
 0244                throw new ArgumentNullException(nameof(resourceGroupName));
 245            }
 4246            if (imageName == null)
 247            {
 0248                throw new ArgumentNullException(nameof(imageName));
 249            }
 250
 4251            using var message = CreateDeleteRequest(resourceGroupName, imageName);
 4252            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4253            switch (message.Response.Status)
 254            {
 255                case 200:
 256                case 202:
 257                case 204:
 4258                    return message.Response;
 259                default:
 0260                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 261            }
 4262        }
 263
 264        /// <summary> Deletes an Image. </summary>
 265        /// <param name="resourceGroupName"> The name of the resource group. </param>
 266        /// <param name="imageName"> The name of the image. </param>
 267        /// <param name="cancellationToken"> The cancellation token to use. </param>
 268        public Response Delete(string resourceGroupName, string imageName, CancellationToken cancellationToken = default
 269        {
 4270            if (resourceGroupName == null)
 271            {
 0272                throw new ArgumentNullException(nameof(resourceGroupName));
 273            }
 4274            if (imageName == null)
 275            {
 0276                throw new ArgumentNullException(nameof(imageName));
 277            }
 278
 4279            using var message = CreateDeleteRequest(resourceGroupName, imageName);
 4280            _pipeline.Send(message, cancellationToken);
 4281            switch (message.Response.Status)
 282            {
 283                case 200:
 284                case 202:
 285                case 204:
 4286                    return message.Response;
 287                default:
 0288                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 289            }
 4290        }
 291
 292        internal HttpMessage CreateGetRequest(string resourceGroupName, string imageName, string expand)
 293        {
 12294            var message = _pipeline.CreateMessage();
 12295            var request = message.Request;
 12296            request.Method = RequestMethod.Get;
 12297            var uri = new RawRequestUriBuilder();
 12298            uri.Reset(endpoint);
 12299            uri.AppendPath("/subscriptions/", false);
 12300            uri.AppendPath(subscriptionId, true);
 12301            uri.AppendPath("/resourceGroups/", false);
 12302            uri.AppendPath(resourceGroupName, true);
 12303            uri.AppendPath("/providers/Microsoft.Compute/images/", false);
 12304            uri.AppendPath(imageName, true);
 12305            if (expand != null)
 306            {
 0307                uri.AppendQuery("$expand", expand, true);
 308            }
 12309            uri.AppendQuery("api-version", "2019-12-01", true);
 12310            request.Uri = uri;
 12311            return message;
 312        }
 313
 314        /// <summary> Gets an image. </summary>
 315        /// <param name="resourceGroupName"> The name of the resource group. </param>
 316        /// <param name="imageName"> The name of the image. </param>
 317        /// <param name="expand"> The expand expression to apply on the operation. </param>
 318        /// <param name="cancellationToken"> The cancellation token to use. </param>
 319        public async Task<Response<Image>> GetAsync(string resourceGroupName, string imageName, string expand = null, Ca
 320        {
 6321            if (resourceGroupName == null)
 322            {
 0323                throw new ArgumentNullException(nameof(resourceGroupName));
 324            }
 6325            if (imageName == null)
 326            {
 0327                throw new ArgumentNullException(nameof(imageName));
 328            }
 329
 6330            using var message = CreateGetRequest(resourceGroupName, imageName, expand);
 6331            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6332            switch (message.Response.Status)
 333            {
 334                case 200:
 335                    {
 6336                        Image value = default;
 6337                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 6338                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 339                        {
 0340                            value = null;
 341                        }
 342                        else
 343                        {
 6344                            value = Image.DeserializeImage(document.RootElement);
 345                        }
 6346                        return Response.FromValue(value, message.Response);
 347                    }
 348                default:
 0349                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 350            }
 6351        }
 352
 353        /// <summary> Gets an image. </summary>
 354        /// <param name="resourceGroupName"> The name of the resource group. </param>
 355        /// <param name="imageName"> The name of the image. </param>
 356        /// <param name="expand"> The expand expression to apply on the operation. </param>
 357        /// <param name="cancellationToken"> The cancellation token to use. </param>
 358        public Response<Image> Get(string resourceGroupName, string imageName, string expand = null, CancellationToken c
 359        {
 6360            if (resourceGroupName == null)
 361            {
 0362                throw new ArgumentNullException(nameof(resourceGroupName));
 363            }
 6364            if (imageName == null)
 365            {
 0366                throw new ArgumentNullException(nameof(imageName));
 367            }
 368
 6369            using var message = CreateGetRequest(resourceGroupName, imageName, expand);
 6370            _pipeline.Send(message, cancellationToken);
 6371            switch (message.Response.Status)
 372            {
 373                case 200:
 374                    {
 6375                        Image value = default;
 6376                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 6377                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 378                        {
 0379                            value = null;
 380                        }
 381                        else
 382                        {
 6383                            value = Image.DeserializeImage(document.RootElement);
 384                        }
 6385                        return Response.FromValue(value, message.Response);
 386                    }
 387                default:
 0388                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 389            }
 6390        }
 391
 392        internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName)
 393        {
 4394            var message = _pipeline.CreateMessage();
 4395            var request = message.Request;
 4396            request.Method = RequestMethod.Get;
 4397            var uri = new RawRequestUriBuilder();
 4398            uri.Reset(endpoint);
 4399            uri.AppendPath("/subscriptions/", false);
 4400            uri.AppendPath(subscriptionId, true);
 4401            uri.AppendPath("/resourceGroups/", false);
 4402            uri.AppendPath(resourceGroupName, true);
 4403            uri.AppendPath("/providers/Microsoft.Compute/images", false);
 4404            uri.AppendQuery("api-version", "2019-12-01", true);
 4405            request.Uri = uri;
 4406            return message;
 407        }
 408
 409        /// <summary> Gets the list of images under a resource group. </summary>
 410        /// <param name="resourceGroupName"> The name of the resource group. </param>
 411        /// <param name="cancellationToken"> The cancellation token to use. </param>
 412        public async Task<Response<ImageListResult>> ListByResourceGroupAsync(string resourceGroupName, CancellationToke
 413        {
 2414            if (resourceGroupName == null)
 415            {
 0416                throw new ArgumentNullException(nameof(resourceGroupName));
 417            }
 418
 2419            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 2420            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2421            switch (message.Response.Status)
 422            {
 423                case 200:
 424                    {
 2425                        ImageListResult value = default;
 2426                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2427                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 428                        {
 0429                            value = null;
 430                        }
 431                        else
 432                        {
 2433                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 434                        }
 2435                        return Response.FromValue(value, message.Response);
 436                    }
 437                default:
 0438                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 439            }
 2440        }
 441
 442        /// <summary> Gets the list of images under a resource group. </summary>
 443        /// <param name="resourceGroupName"> The name of the resource group. </param>
 444        /// <param name="cancellationToken"> The cancellation token to use. </param>
 445        public Response<ImageListResult> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationTok
 446        {
 2447            if (resourceGroupName == null)
 448            {
 0449                throw new ArgumentNullException(nameof(resourceGroupName));
 450            }
 451
 2452            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 2453            _pipeline.Send(message, cancellationToken);
 2454            switch (message.Response.Status)
 455            {
 456                case 200:
 457                    {
 2458                        ImageListResult value = default;
 2459                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2460                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 461                        {
 0462                            value = null;
 463                        }
 464                        else
 465                        {
 2466                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 467                        }
 2468                        return Response.FromValue(value, message.Response);
 469                    }
 470                default:
 0471                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 472            }
 2473        }
 474
 475        internal HttpMessage CreateListRequest()
 476        {
 0477            var message = _pipeline.CreateMessage();
 0478            var request = message.Request;
 0479            request.Method = RequestMethod.Get;
 0480            var uri = new RawRequestUriBuilder();
 0481            uri.Reset(endpoint);
 0482            uri.AppendPath("/subscriptions/", false);
 0483            uri.AppendPath(subscriptionId, true);
 0484            uri.AppendPath("/providers/Microsoft.Compute/images", false);
 0485            uri.AppendQuery("api-version", "2019-12-01", true);
 0486            request.Uri = uri;
 0487            return message;
 488        }
 489
 490        /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next
 491        /// <param name="cancellationToken"> The cancellation token to use. </param>
 492        public async Task<Response<ImageListResult>> ListAsync(CancellationToken cancellationToken = default)
 493        {
 0494            using var message = CreateListRequest();
 0495            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0496            switch (message.Response.Status)
 497            {
 498                case 200:
 499                    {
 0500                        ImageListResult value = default;
 0501                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0502                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 503                        {
 0504                            value = null;
 505                        }
 506                        else
 507                        {
 0508                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 509                        }
 0510                        return Response.FromValue(value, message.Response);
 511                    }
 512                default:
 0513                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 514            }
 0515        }
 516
 517        /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next
 518        /// <param name="cancellationToken"> The cancellation token to use. </param>
 519        public Response<ImageListResult> List(CancellationToken cancellationToken = default)
 520        {
 0521            using var message = CreateListRequest();
 0522            _pipeline.Send(message, cancellationToken);
 0523            switch (message.Response.Status)
 524            {
 525                case 200:
 526                    {
 0527                        ImageListResult value = default;
 0528                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0529                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 530                        {
 0531                            value = null;
 532                        }
 533                        else
 534                        {
 0535                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 536                        }
 0537                        return Response.FromValue(value, message.Response);
 538                    }
 539                default:
 0540                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 541            }
 0542        }
 543
 544        internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName)
 545        {
 0546            var message = _pipeline.CreateMessage();
 0547            var request = message.Request;
 0548            request.Method = RequestMethod.Get;
 0549            var uri = new RawRequestUriBuilder();
 0550            uri.Reset(endpoint);
 0551            uri.AppendRawNextLink(nextLink, false);
 0552            request.Uri = uri;
 0553            return message;
 554        }
 555
 556        /// <summary> Gets the list of images under a resource group. </summary>
 557        /// <param name="nextLink"> The URL to the next page of results. </param>
 558        /// <param name="resourceGroupName"> The name of the resource group. </param>
 559        /// <param name="cancellationToken"> The cancellation token to use. </param>
 560        public async Task<Response<ImageListResult>> ListByResourceGroupNextPageAsync(string nextLink, string resourceGr
 561        {
 0562            if (nextLink == null)
 563            {
 0564                throw new ArgumentNullException(nameof(nextLink));
 565            }
 0566            if (resourceGroupName == null)
 567            {
 0568                throw new ArgumentNullException(nameof(resourceGroupName));
 569            }
 570
 0571            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0572            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0573            switch (message.Response.Status)
 574            {
 575                case 200:
 576                    {
 0577                        ImageListResult value = default;
 0578                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0579                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 580                        {
 0581                            value = null;
 582                        }
 583                        else
 584                        {
 0585                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 586                        }
 0587                        return Response.FromValue(value, message.Response);
 588                    }
 589                default:
 0590                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 591            }
 0592        }
 593
 594        /// <summary> Gets the list of images under a resource group. </summary>
 595        /// <param name="nextLink"> The URL to the next page of results. </param>
 596        /// <param name="resourceGroupName"> The name of the resource group. </param>
 597        /// <param name="cancellationToken"> The cancellation token to use. </param>
 598        public Response<ImageListResult> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, Cancella
 599        {
 0600            if (nextLink == null)
 601            {
 0602                throw new ArgumentNullException(nameof(nextLink));
 603            }
 0604            if (resourceGroupName == null)
 605            {
 0606                throw new ArgumentNullException(nameof(resourceGroupName));
 607            }
 608
 0609            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0610            _pipeline.Send(message, cancellationToken);
 0611            switch (message.Response.Status)
 612            {
 613                case 200:
 614                    {
 0615                        ImageListResult value = default;
 0616                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0617                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 618                        {
 0619                            value = null;
 620                        }
 621                        else
 622                        {
 0623                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 624                        }
 0625                        return Response.FromValue(value, message.Response);
 626                    }
 627                default:
 0628                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 629            }
 0630        }
 631
 632        internal HttpMessage CreateListNextPageRequest(string nextLink)
 633        {
 0634            var message = _pipeline.CreateMessage();
 0635            var request = message.Request;
 0636            request.Method = RequestMethod.Get;
 0637            var uri = new RawRequestUriBuilder();
 0638            uri.Reset(endpoint);
 0639            uri.AppendRawNextLink(nextLink, false);
 0640            request.Uri = uri;
 0641            return message;
 642        }
 643
 644        /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next
 645        /// <param name="nextLink"> The URL to the next page of results. </param>
 646        /// <param name="cancellationToken"> The cancellation token to use. </param>
 647        public async Task<Response<ImageListResult>> ListNextPageAsync(string nextLink, CancellationToken cancellationTo
 648        {
 0649            if (nextLink == null)
 650            {
 0651                throw new ArgumentNullException(nameof(nextLink));
 652            }
 653
 0654            using var message = CreateListNextPageRequest(nextLink);
 0655            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0656            switch (message.Response.Status)
 657            {
 658                case 200:
 659                    {
 0660                        ImageListResult value = default;
 0661                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0662                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 663                        {
 0664                            value = null;
 665                        }
 666                        else
 667                        {
 0668                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 669                        }
 0670                        return Response.FromValue(value, message.Response);
 671                    }
 672                default:
 0673                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 674            }
 0675        }
 676
 677        /// <summary> Gets the list of Images in the subscription. Use nextLink property in the response to get the next
 678        /// <param name="nextLink"> The URL to the next page of results. </param>
 679        /// <param name="cancellationToken"> The cancellation token to use. </param>
 680        public Response<ImageListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = default)
 681        {
 0682            if (nextLink == null)
 683            {
 0684                throw new ArgumentNullException(nameof(nextLink));
 685            }
 686
 0687            using var message = CreateListNextPageRequest(nextLink);
 0688            _pipeline.Send(message, cancellationToken);
 0689            switch (message.Response.Status)
 690            {
 691                case 200:
 692                    {
 0693                        ImageListResult value = default;
 0694                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0695                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 696                        {
 0697                            value = null;
 698                        }
 699                        else
 700                        {
 0701                            value = ImageListResult.DeserializeImageListResult(document.RootElement);
 702                        }
 0703                        return Response.FromValue(value, message.Response);
 704                    }
 705                default:
 0706                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 707            }
 0708        }
 709    }
 710}