< Summary

Class:Azure.ResourceManager.Compute.DisksRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\DisksRestOperations.cs
Covered lines:270
Uncovered lines:123
Coverable lines:393
Total lines:864
Line coverage:68.7% (270 of 393)
Covered branches:80
Total branches:164
Branch coverage:48.7% (80 of 164)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-75%70%
CreateOrUpdate(...)-75%70%
CreateUpdateRequest(...)-100%100%
UpdateAsync()-66.67%60%
Update(...)-66.67%60%
CreateGetRequest(...)-100%100%
GetAsync()-80%62.5%
Get(...)-80%62.5%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateListByResourceGroupRequest(...)-100%100%
ListByResourceGroupAsync()-76.92%50%
ListByResourceGroup(...)-76.92%50%
CreateListRequest()-100%100%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateGrantAccessRequest(...)-100%100%
GrantAccessAsync()-66.67%60%
GrantAccess(...)-66.67%60%
CreateRevokeAccessRequest(...)-100%100%
RevokeAccessAsync()-70%62.5%
RevokeAccess(...)-70%62.5%
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\DisksRestOperations.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 DisksRestOperations
 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 DisksRestOperations. </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 DisksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Ur
 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 diskName, Disk disk)
 47        {
 18048            var message = _pipeline.CreateMessage();
 18049            var request = message.Request;
 18050            request.Method = RequestMethod.Put;
 18051            var uri = new RawRequestUriBuilder();
 18052            uri.Reset(endpoint);
 18053            uri.AppendPath("/subscriptions/", false);
 18054            uri.AppendPath(subscriptionId, true);
 18055            uri.AppendPath("/resourceGroups/", false);
 18056            uri.AppendPath(resourceGroupName, true);
 18057            uri.AppendPath("/providers/Microsoft.Compute/disks/", false);
 18058            uri.AppendPath(diskName, true);
 18059            uri.AppendQuery("api-version", "2019-11-01", true);
 18060            request.Uri = uri;
 18061            request.Headers.Add("Content-Type", "application/json");
 18062            var content = new Utf8JsonRequestContent();
 18063            content.JsonWriter.WriteObjectValue(disk);
 18064            request.Content = content;
 18065            return message;
 66        }
 67
 68        /// <summary> Creates or updates a disk. </summary>
 69        /// <param name="resourceGroupName"> The name of the resource group. </param>
 70        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 71        /// <param name="disk"> Disk object supplied in the body of the Put disk operation. </param>
 72        /// <param name="cancellationToken"> The cancellation token to use. </param>
 73        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string diskName, Disk disk, Cancellati
 74        {
 4675            if (resourceGroupName == null)
 76            {
 077                throw new ArgumentNullException(nameof(resourceGroupName));
 78            }
 4679            if (diskName == null)
 80            {
 081                throw new ArgumentNullException(nameof(diskName));
 82            }
 4683            if (disk == null)
 84            {
 085                throw new ArgumentNullException(nameof(disk));
 86            }
 87
 4688            using var message = CreateCreateOrUpdateRequest(resourceGroupName, diskName, disk);
 4689            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4690            switch (message.Response.Status)
 91            {
 92                case 200:
 93                case 202:
 4494                    return message.Response;
 95                default:
 296                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 97            }
 4498        }
 99
 100        /// <summary> Creates or updates a disk. </summary>
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 103        /// <param name="disk"> Disk object supplied in the body of the Put disk operation. </param>
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public Response CreateOrUpdate(string resourceGroupName, string diskName, Disk disk, CancellationToken cancellat
 106        {
 46107            if (resourceGroupName == null)
 108            {
 0109                throw new ArgumentNullException(nameof(resourceGroupName));
 110            }
 46111            if (diskName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(diskName));
 114            }
 46115            if (disk == null)
 116            {
 0117                throw new ArgumentNullException(nameof(disk));
 118            }
 119
 46120            using var message = CreateCreateOrUpdateRequest(resourceGroupName, diskName, disk);
 46121            _pipeline.Send(message, cancellationToken);
 46122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                case 202:
 44126                    return message.Response;
 127                default:
 2128                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 129            }
 44130        }
 131
 132        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string diskName, DiskUpdate disk)
 133        {
 24134            var message = _pipeline.CreateMessage();
 24135            var request = message.Request;
 24136            request.Method = RequestMethod.Patch;
 24137            var uri = new RawRequestUriBuilder();
 24138            uri.Reset(endpoint);
 24139            uri.AppendPath("/subscriptions/", false);
 24140            uri.AppendPath(subscriptionId, true);
 24141            uri.AppendPath("/resourceGroups/", false);
 24142            uri.AppendPath(resourceGroupName, true);
 24143            uri.AppendPath("/providers/Microsoft.Compute/disks/", false);
 24144            uri.AppendPath(diskName, true);
 24145            uri.AppendQuery("api-version", "2019-11-01", true);
 24146            request.Uri = uri;
 24147            request.Headers.Add("Content-Type", "application/json");
 24148            var content = new Utf8JsonRequestContent();
 24149            content.JsonWriter.WriteObjectValue(disk);
 24150            request.Content = content;
 24151            return message;
 152        }
 153
 154        /// <summary> Updates (patches) a disk. </summary>
 155        /// <param name="resourceGroupName"> The name of the resource group. </param>
 156        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 157        /// <param name="disk"> Disk object supplied in the body of the Patch disk operation. </param>
 158        /// <param name="cancellationToken"> The cancellation token to use. </param>
 159        public async Task<Response> UpdateAsync(string resourceGroupName, string diskName, DiskUpdate disk, Cancellation
 160        {
 6161            if (resourceGroupName == null)
 162            {
 0163                throw new ArgumentNullException(nameof(resourceGroupName));
 164            }
 6165            if (diskName == null)
 166            {
 0167                throw new ArgumentNullException(nameof(diskName));
 168            }
 6169            if (disk == null)
 170            {
 0171                throw new ArgumentNullException(nameof(disk));
 172            }
 173
 6174            using var message = CreateUpdateRequest(resourceGroupName, diskName, disk);
 6175            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6176            switch (message.Response.Status)
 177            {
 178                case 200:
 179                case 202:
 6180                    return message.Response;
 181                default:
 0182                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 183            }
 6184        }
 185
 186        /// <summary> Updates (patches) a disk. </summary>
 187        /// <param name="resourceGroupName"> The name of the resource group. </param>
 188        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 189        /// <param name="disk"> Disk object supplied in the body of the Patch disk operation. </param>
 190        /// <param name="cancellationToken"> The cancellation token to use. </param>
 191        public Response Update(string resourceGroupName, string diskName, DiskUpdate disk, CancellationToken cancellatio
 192        {
 6193            if (resourceGroupName == null)
 194            {
 0195                throw new ArgumentNullException(nameof(resourceGroupName));
 196            }
 6197            if (diskName == null)
 198            {
 0199                throw new ArgumentNullException(nameof(diskName));
 200            }
 6201            if (disk == null)
 202            {
 0203                throw new ArgumentNullException(nameof(disk));
 204            }
 205
 6206            using var message = CreateUpdateRequest(resourceGroupName, diskName, disk);
 6207            _pipeline.Send(message, cancellationToken);
 6208            switch (message.Response.Status)
 209            {
 210                case 200:
 211                case 202:
 6212                    return message.Response;
 213                default:
 0214                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 215            }
 6216        }
 217
 218        internal HttpMessage CreateGetRequest(string resourceGroupName, string diskName)
 219        {
 80220            var message = _pipeline.CreateMessage();
 80221            var request = message.Request;
 80222            request.Method = RequestMethod.Get;
 80223            var uri = new RawRequestUriBuilder();
 80224            uri.Reset(endpoint);
 80225            uri.AppendPath("/subscriptions/", false);
 80226            uri.AppendPath(subscriptionId, true);
 80227            uri.AppendPath("/resourceGroups/", false);
 80228            uri.AppendPath(resourceGroupName, true);
 80229            uri.AppendPath("/providers/Microsoft.Compute/disks/", false);
 80230            uri.AppendPath(diskName, true);
 80231            uri.AppendQuery("api-version", "2019-11-01", true);
 80232            request.Uri = uri;
 80233            return message;
 234        }
 235
 236        /// <summary> Gets information about a disk. </summary>
 237        /// <param name="resourceGroupName"> The name of the resource group. </param>
 238        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 239        /// <param name="cancellationToken"> The cancellation token to use. </param>
 240        public async Task<Response<Disk>> GetAsync(string resourceGroupName, string diskName, CancellationToken cancella
 241        {
 40242            if (resourceGroupName == null)
 243            {
 0244                throw new ArgumentNullException(nameof(resourceGroupName));
 245            }
 40246            if (diskName == null)
 247            {
 0248                throw new ArgumentNullException(nameof(diskName));
 249            }
 250
 40251            using var message = CreateGetRequest(resourceGroupName, diskName);
 40252            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 40253            switch (message.Response.Status)
 254            {
 255                case 200:
 256                    {
 32257                        Disk value = default;
 32258                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 32259                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 260                        {
 0261                            value = null;
 262                        }
 263                        else
 264                        {
 32265                            value = Disk.DeserializeDisk(document.RootElement);
 266                        }
 32267                        return Response.FromValue(value, message.Response);
 268                    }
 269                default:
 8270                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 271            }
 32272        }
 273
 274        /// <summary> Gets information about a disk. </summary>
 275        /// <param name="resourceGroupName"> The name of the resource group. </param>
 276        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 277        /// <param name="cancellationToken"> The cancellation token to use. </param>
 278        public Response<Disk> Get(string resourceGroupName, string diskName, CancellationToken cancellationToken = defau
 279        {
 40280            if (resourceGroupName == null)
 281            {
 0282                throw new ArgumentNullException(nameof(resourceGroupName));
 283            }
 40284            if (diskName == null)
 285            {
 0286                throw new ArgumentNullException(nameof(diskName));
 287            }
 288
 40289            using var message = CreateGetRequest(resourceGroupName, diskName);
 40290            _pipeline.Send(message, cancellationToken);
 40291            switch (message.Response.Status)
 292            {
 293                case 200:
 294                    {
 32295                        Disk value = default;
 32296                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 32297                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 298                        {
 0299                            value = null;
 300                        }
 301                        else
 302                        {
 32303                            value = Disk.DeserializeDisk(document.RootElement);
 304                        }
 32305                        return Response.FromValue(value, message.Response);
 306                    }
 307                default:
 8308                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 309            }
 32310        }
 311
 312        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string diskName)
 313        {
 72314            var message = _pipeline.CreateMessage();
 72315            var request = message.Request;
 72316            request.Method = RequestMethod.Delete;
 72317            var uri = new RawRequestUriBuilder();
 72318            uri.Reset(endpoint);
 72319            uri.AppendPath("/subscriptions/", false);
 72320            uri.AppendPath(subscriptionId, true);
 72321            uri.AppendPath("/resourceGroups/", false);
 72322            uri.AppendPath(resourceGroupName, true);
 72323            uri.AppendPath("/providers/Microsoft.Compute/disks/", false);
 72324            uri.AppendPath(diskName, true);
 72325            uri.AppendQuery("api-version", "2019-11-01", true);
 72326            request.Uri = uri;
 72327            return message;
 328        }
 329
 330        /// <summary> Deletes a disk. </summary>
 331        /// <param name="resourceGroupName"> The name of the resource group. </param>
 332        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 333        /// <param name="cancellationToken"> The cancellation token to use. </param>
 334        public async Task<Response> DeleteAsync(string resourceGroupName, string diskName, CancellationToken cancellatio
 335        {
 18336            if (resourceGroupName == null)
 337            {
 0338                throw new ArgumentNullException(nameof(resourceGroupName));
 339            }
 18340            if (diskName == null)
 341            {
 0342                throw new ArgumentNullException(nameof(diskName));
 343            }
 344
 18345            using var message = CreateDeleteRequest(resourceGroupName, diskName);
 18346            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 18347            switch (message.Response.Status)
 348            {
 349                case 200:
 350                case 202:
 351                case 204:
 18352                    return message.Response;
 353                default:
 0354                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 355            }
 18356        }
 357
 358        /// <summary> Deletes a disk. </summary>
 359        /// <param name="resourceGroupName"> The name of the resource group. </param>
 360        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 361        /// <param name="cancellationToken"> The cancellation token to use. </param>
 362        public Response Delete(string resourceGroupName, string diskName, CancellationToken cancellationToken = default)
 363        {
 18364            if (resourceGroupName == null)
 365            {
 0366                throw new ArgumentNullException(nameof(resourceGroupName));
 367            }
 18368            if (diskName == null)
 369            {
 0370                throw new ArgumentNullException(nameof(diskName));
 371            }
 372
 18373            using var message = CreateDeleteRequest(resourceGroupName, diskName);
 18374            _pipeline.Send(message, cancellationToken);
 18375            switch (message.Response.Status)
 376            {
 377                case 200:
 378                case 202:
 379                case 204:
 18380                    return message.Response;
 381                default:
 0382                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 383            }
 18384        }
 385
 386        internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName)
 387        {
 16388            var message = _pipeline.CreateMessage();
 16389            var request = message.Request;
 16390            request.Method = RequestMethod.Get;
 16391            var uri = new RawRequestUriBuilder();
 16392            uri.Reset(endpoint);
 16393            uri.AppendPath("/subscriptions/", false);
 16394            uri.AppendPath(subscriptionId, true);
 16395            uri.AppendPath("/resourceGroups/", false);
 16396            uri.AppendPath(resourceGroupName, true);
 16397            uri.AppendPath("/providers/Microsoft.Compute/disks", false);
 16398            uri.AppendQuery("api-version", "2019-11-01", true);
 16399            request.Uri = uri;
 16400            return message;
 401        }
 402
 403        /// <summary> Lists all the disks under a resource group. </summary>
 404        /// <param name="resourceGroupName"> The name of the resource group. </param>
 405        /// <param name="cancellationToken"> The cancellation token to use. </param>
 406        public async Task<Response<DiskList>> ListByResourceGroupAsync(string resourceGroupName, CancellationToken cance
 407        {
 8408            if (resourceGroupName == null)
 409            {
 0410                throw new ArgumentNullException(nameof(resourceGroupName));
 411            }
 412
 8413            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 8414            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8415            switch (message.Response.Status)
 416            {
 417                case 200:
 418                    {
 8419                        DiskList value = default;
 8420                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8421                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 422                        {
 0423                            value = null;
 424                        }
 425                        else
 426                        {
 8427                            value = DiskList.DeserializeDiskList(document.RootElement);
 428                        }
 8429                        return Response.FromValue(value, message.Response);
 430                    }
 431                default:
 0432                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 433            }
 8434        }
 435
 436        /// <summary> Lists all the disks under a resource group. </summary>
 437        /// <param name="resourceGroupName"> The name of the resource group. </param>
 438        /// <param name="cancellationToken"> The cancellation token to use. </param>
 439        public Response<DiskList> ListByResourceGroup(string resourceGroupName, CancellationToken cancellationToken = de
 440        {
 8441            if (resourceGroupName == null)
 442            {
 0443                throw new ArgumentNullException(nameof(resourceGroupName));
 444            }
 445
 8446            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 8447            _pipeline.Send(message, cancellationToken);
 8448            switch (message.Response.Status)
 449            {
 450                case 200:
 451                    {
 8452                        DiskList value = default;
 8453                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8454                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 455                        {
 0456                            value = null;
 457                        }
 458                        else
 459                        {
 8460                            value = DiskList.DeserializeDiskList(document.RootElement);
 461                        }
 8462                        return Response.FromValue(value, message.Response);
 463                    }
 464                default:
 0465                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 466            }
 8467        }
 468
 469        internal HttpMessage CreateListRequest()
 470        {
 8471            var message = _pipeline.CreateMessage();
 8472            var request = message.Request;
 8473            request.Method = RequestMethod.Get;
 8474            var uri = new RawRequestUriBuilder();
 8475            uri.Reset(endpoint);
 8476            uri.AppendPath("/subscriptions/", false);
 8477            uri.AppendPath(subscriptionId, true);
 8478            uri.AppendPath("/providers/Microsoft.Compute/disks", false);
 8479            uri.AppendQuery("api-version", "2019-11-01", true);
 8480            request.Uri = uri;
 8481            return message;
 482        }
 483
 484        /// <summary> Lists all the disks under a subscription. </summary>
 485        /// <param name="cancellationToken"> The cancellation token to use. </param>
 486        public async Task<Response<DiskList>> ListAsync(CancellationToken cancellationToken = default)
 487        {
 4488            using var message = CreateListRequest();
 4489            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4490            switch (message.Response.Status)
 491            {
 492                case 200:
 493                    {
 4494                        DiskList value = default;
 4495                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4496                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 497                        {
 0498                            value = null;
 499                        }
 500                        else
 501                        {
 4502                            value = DiskList.DeserializeDiskList(document.RootElement);
 503                        }
 4504                        return Response.FromValue(value, message.Response);
 505                    }
 506                default:
 0507                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 508            }
 4509        }
 510
 511        /// <summary> Lists all the disks under a subscription. </summary>
 512        /// <param name="cancellationToken"> The cancellation token to use. </param>
 513        public Response<DiskList> List(CancellationToken cancellationToken = default)
 514        {
 4515            using var message = CreateListRequest();
 4516            _pipeline.Send(message, cancellationToken);
 4517            switch (message.Response.Status)
 518            {
 519                case 200:
 520                    {
 4521                        DiskList value = default;
 4522                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4523                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 524                        {
 0525                            value = null;
 526                        }
 527                        else
 528                        {
 4529                            value = DiskList.DeserializeDiskList(document.RootElement);
 530                        }
 4531                        return Response.FromValue(value, message.Response);
 532                    }
 533                default:
 0534                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 535            }
 4536        }
 537
 538        internal HttpMessage CreateGrantAccessRequest(string resourceGroupName, string diskName, GrantAccessData grantAc
 539        {
 24540            var message = _pipeline.CreateMessage();
 24541            var request = message.Request;
 24542            request.Method = RequestMethod.Post;
 24543            var uri = new RawRequestUriBuilder();
 24544            uri.Reset(endpoint);
 24545            uri.AppendPath("/subscriptions/", false);
 24546            uri.AppendPath(subscriptionId, true);
 24547            uri.AppendPath("/resourceGroups/", false);
 24548            uri.AppendPath(resourceGroupName, true);
 24549            uri.AppendPath("/providers/Microsoft.Compute/disks/", false);
 24550            uri.AppendPath(diskName, true);
 24551            uri.AppendPath("/beginGetAccess", false);
 24552            uri.AppendQuery("api-version", "2019-11-01", true);
 24553            request.Uri = uri;
 24554            request.Headers.Add("Content-Type", "application/json");
 24555            var content = new Utf8JsonRequestContent();
 24556            content.JsonWriter.WriteObjectValue(grantAccessData);
 24557            request.Content = content;
 24558            return message;
 559        }
 560
 561        /// <summary> Grants access to a disk. </summary>
 562        /// <param name="resourceGroupName"> The name of the resource group. </param>
 563        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 564        /// <param name="grantAccessData"> Access data object supplied in the body of the get disk access operation. </p
 565        /// <param name="cancellationToken"> The cancellation token to use. </param>
 566        public async Task<Response> GrantAccessAsync(string resourceGroupName, string diskName, GrantAccessData grantAcc
 567        {
 6568            if (resourceGroupName == null)
 569            {
 0570                throw new ArgumentNullException(nameof(resourceGroupName));
 571            }
 6572            if (diskName == null)
 573            {
 0574                throw new ArgumentNullException(nameof(diskName));
 575            }
 6576            if (grantAccessData == null)
 577            {
 0578                throw new ArgumentNullException(nameof(grantAccessData));
 579            }
 580
 6581            using var message = CreateGrantAccessRequest(resourceGroupName, diskName, grantAccessData);
 6582            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6583            switch (message.Response.Status)
 584            {
 585                case 200:
 586                case 202:
 6587                    return message.Response;
 588                default:
 0589                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 590            }
 6591        }
 592
 593        /// <summary> Grants access to a disk. </summary>
 594        /// <param name="resourceGroupName"> The name of the resource group. </param>
 595        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 596        /// <param name="grantAccessData"> Access data object supplied in the body of the get disk access operation. </p
 597        /// <param name="cancellationToken"> The cancellation token to use. </param>
 598        public Response GrantAccess(string resourceGroupName, string diskName, GrantAccessData grantAccessData, Cancella
 599        {
 6600            if (resourceGroupName == null)
 601            {
 0602                throw new ArgumentNullException(nameof(resourceGroupName));
 603            }
 6604            if (diskName == null)
 605            {
 0606                throw new ArgumentNullException(nameof(diskName));
 607            }
 6608            if (grantAccessData == null)
 609            {
 0610                throw new ArgumentNullException(nameof(grantAccessData));
 611            }
 612
 6613            using var message = CreateGrantAccessRequest(resourceGroupName, diskName, grantAccessData);
 6614            _pipeline.Send(message, cancellationToken);
 6615            switch (message.Response.Status)
 616            {
 617                case 200:
 618                case 202:
 6619                    return message.Response;
 620                default:
 0621                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 622            }
 6623        }
 624
 625        internal HttpMessage CreateRevokeAccessRequest(string resourceGroupName, string diskName)
 626        {
 24627            var message = _pipeline.CreateMessage();
 24628            var request = message.Request;
 24629            request.Method = RequestMethod.Post;
 24630            var uri = new RawRequestUriBuilder();
 24631            uri.Reset(endpoint);
 24632            uri.AppendPath("/subscriptions/", false);
 24633            uri.AppendPath(subscriptionId, true);
 24634            uri.AppendPath("/resourceGroups/", false);
 24635            uri.AppendPath(resourceGroupName, true);
 24636            uri.AppendPath("/providers/Microsoft.Compute/disks/", false);
 24637            uri.AppendPath(diskName, true);
 24638            uri.AppendPath("/endGetAccess", false);
 24639            uri.AppendQuery("api-version", "2019-11-01", true);
 24640            request.Uri = uri;
 24641            return message;
 642        }
 643
 644        /// <summary> Revokes access to a disk. </summary>
 645        /// <param name="resourceGroupName"> The name of the resource group. </param>
 646        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 647        /// <param name="cancellationToken"> The cancellation token to use. </param>
 648        public async Task<Response> RevokeAccessAsync(string resourceGroupName, string diskName, CancellationToken cance
 649        {
 6650            if (resourceGroupName == null)
 651            {
 0652                throw new ArgumentNullException(nameof(resourceGroupName));
 653            }
 6654            if (diskName == null)
 655            {
 0656                throw new ArgumentNullException(nameof(diskName));
 657            }
 658
 6659            using var message = CreateRevokeAccessRequest(resourceGroupName, diskName);
 6660            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6661            switch (message.Response.Status)
 662            {
 663                case 200:
 664                case 202:
 6665                    return message.Response;
 666                default:
 0667                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 668            }
 6669        }
 670
 671        /// <summary> Revokes access to a disk. </summary>
 672        /// <param name="resourceGroupName"> The name of the resource group. </param>
 673        /// <param name="diskName"> The name of the managed disk that is being created. The name can&apos;t be changed a
 674        /// <param name="cancellationToken"> The cancellation token to use. </param>
 675        public Response RevokeAccess(string resourceGroupName, string diskName, CancellationToken cancellationToken = de
 676        {
 6677            if (resourceGroupName == null)
 678            {
 0679                throw new ArgumentNullException(nameof(resourceGroupName));
 680            }
 6681            if (diskName == null)
 682            {
 0683                throw new ArgumentNullException(nameof(diskName));
 684            }
 685
 6686            using var message = CreateRevokeAccessRequest(resourceGroupName, diskName);
 6687            _pipeline.Send(message, cancellationToken);
 6688            switch (message.Response.Status)
 689            {
 690                case 200:
 691                case 202:
 6692                    return message.Response;
 693                default:
 0694                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 695            }
 6696        }
 697
 698        internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName)
 699        {
 0700            var message = _pipeline.CreateMessage();
 0701            var request = message.Request;
 0702            request.Method = RequestMethod.Get;
 0703            var uri = new RawRequestUriBuilder();
 0704            uri.Reset(endpoint);
 0705            uri.AppendRawNextLink(nextLink, false);
 0706            request.Uri = uri;
 0707            return message;
 708        }
 709
 710        /// <summary> Lists all the disks under a resource group. </summary>
 711        /// <param name="nextLink"> The URL to the next page of results. </param>
 712        /// <param name="resourceGroupName"> The name of the resource group. </param>
 713        /// <param name="cancellationToken"> The cancellation token to use. </param>
 714        public async Task<Response<DiskList>> ListByResourceGroupNextPageAsync(string nextLink, string resourceGroupName
 715        {
 0716            if (nextLink == null)
 717            {
 0718                throw new ArgumentNullException(nameof(nextLink));
 719            }
 0720            if (resourceGroupName == null)
 721            {
 0722                throw new ArgumentNullException(nameof(resourceGroupName));
 723            }
 724
 0725            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0726            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0727            switch (message.Response.Status)
 728            {
 729                case 200:
 730                    {
 0731                        DiskList value = default;
 0732                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0733                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 734                        {
 0735                            value = null;
 736                        }
 737                        else
 738                        {
 0739                            value = DiskList.DeserializeDiskList(document.RootElement);
 740                        }
 0741                        return Response.FromValue(value, message.Response);
 742                    }
 743                default:
 0744                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 745            }
 0746        }
 747
 748        /// <summary> Lists all the disks under a resource group. </summary>
 749        /// <param name="nextLink"> The URL to the next page of results. </param>
 750        /// <param name="resourceGroupName"> The name of the resource group. </param>
 751        /// <param name="cancellationToken"> The cancellation token to use. </param>
 752        public Response<DiskList> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, CancellationTok
 753        {
 0754            if (nextLink == null)
 755            {
 0756                throw new ArgumentNullException(nameof(nextLink));
 757            }
 0758            if (resourceGroupName == null)
 759            {
 0760                throw new ArgumentNullException(nameof(resourceGroupName));
 761            }
 762
 0763            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0764            _pipeline.Send(message, cancellationToken);
 0765            switch (message.Response.Status)
 766            {
 767                case 200:
 768                    {
 0769                        DiskList value = default;
 0770                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0771                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 772                        {
 0773                            value = null;
 774                        }
 775                        else
 776                        {
 0777                            value = DiskList.DeserializeDiskList(document.RootElement);
 778                        }
 0779                        return Response.FromValue(value, message.Response);
 780                    }
 781                default:
 0782                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 783            }
 0784        }
 785
 786        internal HttpMessage CreateListNextPageRequest(string nextLink)
 787        {
 0788            var message = _pipeline.CreateMessage();
 0789            var request = message.Request;
 0790            request.Method = RequestMethod.Get;
 0791            var uri = new RawRequestUriBuilder();
 0792            uri.Reset(endpoint);
 0793            uri.AppendRawNextLink(nextLink, false);
 0794            request.Uri = uri;
 0795            return message;
 796        }
 797
 798        /// <summary> Lists all the disks under a subscription. </summary>
 799        /// <param name="nextLink"> The URL to the next page of results. </param>
 800        /// <param name="cancellationToken"> The cancellation token to use. </param>
 801        public async Task<Response<DiskList>> ListNextPageAsync(string nextLink, CancellationToken cancellationToken = d
 802        {
 0803            if (nextLink == null)
 804            {
 0805                throw new ArgumentNullException(nameof(nextLink));
 806            }
 807
 0808            using var message = CreateListNextPageRequest(nextLink);
 0809            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0810            switch (message.Response.Status)
 811            {
 812                case 200:
 813                    {
 0814                        DiskList value = default;
 0815                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0816                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 817                        {
 0818                            value = null;
 819                        }
 820                        else
 821                        {
 0822                            value = DiskList.DeserializeDiskList(document.RootElement);
 823                        }
 0824                        return Response.FromValue(value, message.Response);
 825                    }
 826                default:
 0827                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 828            }
 0829        }
 830
 831        /// <summary> Lists all the disks under a subscription. </summary>
 832        /// <param name="nextLink"> The URL to the next page of results. </param>
 833        /// <param name="cancellationToken"> The cancellation token to use. </param>
 834        public Response<DiskList> ListNextPage(string nextLink, CancellationToken cancellationToken = default)
 835        {
 0836            if (nextLink == null)
 837            {
 0838                throw new ArgumentNullException(nameof(nextLink));
 839            }
 840
 0841            using var message = CreateListNextPageRequest(nextLink);
 0842            _pipeline.Send(message, cancellationToken);
 0843            switch (message.Response.Status)
 844            {
 845                case 200:
 846                    {
 0847                        DiskList value = default;
 0848                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0849                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 850                        {
 0851                            value = null;
 852                        }
 853                        else
 854                        {
 0855                            value = DiskList.DeserializeDiskList(document.RootElement);
 856                        }
 0857                        return Response.FromValue(value, message.Response);
 858                    }
 859                default:
 0860                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 861            }
 0862        }
 863    }
 864}