< Summary

Class:Azure.ResourceManager.Compute.AvailabilitySetsRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\AvailabilitySetsRestOperations.cs
Covered lines:259
Uncovered lines:123
Coverable lines:382
Total lines:849
Line coverage:67.8% (259 of 382)
Covered branches:60
Total branches:142
Branch coverage:42.2% (60 of 142)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-76.47%60%
CreateOrUpdate(...)-76.47%60%
CreateUpdateRequest(...)-100%100%
UpdateAsync()-70.59%50%
Update(...)-70.59%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateGetRequest(...)-100%100%
GetAsync()-73.33%50%
Get(...)-73.33%50%
CreateListBySubscriptionRequest(...)-100%100%
ListBySubscriptionAsync()-81.82%50%
ListBySubscription(...)-81.82%50%
CreateListRequest(...)-100%100%
ListAsync()-76.92%50%
List(...)-76.92%50%
CreateListAvailableSizesRequest(...)-100%100%
ListAvailableSizesAsync()-73.33%50%
ListAvailableSizes(...)-73.33%50%
CreateListBySubscriptionNextPageRequest(...)-0%100%
ListBySubscriptionNextPageAsync()-0%0%
ListBySubscriptionNextPage(...)-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\AvailabilitySetsRestOperations.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 AvailabilitySetsRestOperations
 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 AvailabilitySetsRestOperations. </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 AvailabilitySetsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscri
 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 availabilitySetName, Availabil
 47        {
 14848            var message = _pipeline.CreateMessage();
 14849            var request = message.Request;
 14850            request.Method = RequestMethod.Put;
 14851            var uri = new RawRequestUriBuilder();
 14852            uri.Reset(endpoint);
 14853            uri.AppendPath("/subscriptions/", false);
 14854            uri.AppendPath(subscriptionId, true);
 14855            uri.AppendPath("/resourceGroups/", false);
 14856            uri.AppendPath(resourceGroupName, true);
 14857            uri.AppendPath("/providers/Microsoft.Compute/availabilitySets/", false);
 14858            uri.AppendPath(availabilitySetName, true);
 14859            uri.AppendQuery("api-version", "2019-12-01", true);
 14860            request.Uri = uri;
 14861            request.Headers.Add("Content-Type", "application/json");
 14862            var content = new Utf8JsonRequestContent();
 14863            content.JsonWriter.WriteObjectValue(parameters);
 14864            request.Content = content;
 14865            return message;
 66        }
 67
 68        /// <summary> Create or update an availability set. </summary>
 69        /// <param name="resourceGroupName"> The name of the resource group. </param>
 70        /// <param name="availabilitySetName"> The name of the availability set. </param>
 71        /// <param name="parameters"> Parameters supplied to the Create Availability Set operation. </param>
 72        /// <param name="cancellationToken"> The cancellation token to use. </param>
 73        public async Task<Response<AvailabilitySet>> CreateOrUpdateAsync(string resourceGroupName, string availabilitySe
 74        {
 7475            if (resourceGroupName == null)
 76            {
 077                throw new ArgumentNullException(nameof(resourceGroupName));
 78            }
 7479            if (availabilitySetName == null)
 80            {
 081                throw new ArgumentNullException(nameof(availabilitySetName));
 82            }
 7483            if (parameters == null)
 84            {
 085                throw new ArgumentNullException(nameof(parameters));
 86            }
 87
 7488            using var message = CreateCreateOrUpdateRequest(resourceGroupName, availabilitySetName, parameters);
 7489            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 7490            switch (message.Response.Status)
 91            {
 92                case 200:
 93                    {
 6694                        AvailabilitySet value = default;
 6695                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 6696                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 97                        {
 098                            value = null;
 99                        }
 100                        else
 101                        {
 66102                            value = AvailabilitySet.DeserializeAvailabilitySet(document.RootElement);
 103                        }
 66104                        return Response.FromValue(value, message.Response);
 105                    }
 106                default:
 8107                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 108            }
 66109        }
 110
 111        /// <summary> Create or update an availability set. </summary>
 112        /// <param name="resourceGroupName"> The name of the resource group. </param>
 113        /// <param name="availabilitySetName"> The name of the availability set. </param>
 114        /// <param name="parameters"> Parameters supplied to the Create Availability Set operation. </param>
 115        /// <param name="cancellationToken"> The cancellation token to use. </param>
 116        public Response<AvailabilitySet> CreateOrUpdate(string resourceGroupName, string availabilitySetName, Availabili
 117        {
 74118            if (resourceGroupName == null)
 119            {
 0120                throw new ArgumentNullException(nameof(resourceGroupName));
 121            }
 74122            if (availabilitySetName == null)
 123            {
 0124                throw new ArgumentNullException(nameof(availabilitySetName));
 125            }
 74126            if (parameters == null)
 127            {
 0128                throw new ArgumentNullException(nameof(parameters));
 129            }
 130
 74131            using var message = CreateCreateOrUpdateRequest(resourceGroupName, availabilitySetName, parameters);
 74132            _pipeline.Send(message, cancellationToken);
 74133            switch (message.Response.Status)
 134            {
 135                case 200:
 136                    {
 66137                        AvailabilitySet value = default;
 66138                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 66139                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 140                        {
 0141                            value = null;
 142                        }
 143                        else
 144                        {
 66145                            value = AvailabilitySet.DeserializeAvailabilitySet(document.RootElement);
 146                        }
 66147                        return Response.FromValue(value, message.Response);
 148                    }
 149                default:
 8150                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 151            }
 66152        }
 153
 154        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string availabilitySetName, AvailabilitySetUp
 155        {
 4156            var message = _pipeline.CreateMessage();
 4157            var request = message.Request;
 4158            request.Method = RequestMethod.Patch;
 4159            var uri = new RawRequestUriBuilder();
 4160            uri.Reset(endpoint);
 4161            uri.AppendPath("/subscriptions/", false);
 4162            uri.AppendPath(subscriptionId, true);
 4163            uri.AppendPath("/resourceGroups/", false);
 4164            uri.AppendPath(resourceGroupName, true);
 4165            uri.AppendPath("/providers/Microsoft.Compute/availabilitySets/", false);
 4166            uri.AppendPath(availabilitySetName, true);
 4167            uri.AppendQuery("api-version", "2019-12-01", true);
 4168            request.Uri = uri;
 4169            request.Headers.Add("Content-Type", "application/json");
 4170            var content = new Utf8JsonRequestContent();
 4171            content.JsonWriter.WriteObjectValue(parameters);
 4172            request.Content = content;
 4173            return message;
 174        }
 175
 176        /// <summary> Update an availability set. </summary>
 177        /// <param name="resourceGroupName"> The name of the resource group. </param>
 178        /// <param name="availabilitySetName"> The name of the availability set. </param>
 179        /// <param name="parameters"> Parameters supplied to the Update Availability Set operation. </param>
 180        /// <param name="cancellationToken"> The cancellation token to use. </param>
 181        public async Task<Response<AvailabilitySet>> UpdateAsync(string resourceGroupName, string availabilitySetName, A
 182        {
 2183            if (resourceGroupName == null)
 184            {
 0185                throw new ArgumentNullException(nameof(resourceGroupName));
 186            }
 2187            if (availabilitySetName == null)
 188            {
 0189                throw new ArgumentNullException(nameof(availabilitySetName));
 190            }
 2191            if (parameters == null)
 192            {
 0193                throw new ArgumentNullException(nameof(parameters));
 194            }
 195
 2196            using var message = CreateUpdateRequest(resourceGroupName, availabilitySetName, parameters);
 2197            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2198            switch (message.Response.Status)
 199            {
 200                case 200:
 201                    {
 2202                        AvailabilitySet value = default;
 2203                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2204                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 205                        {
 0206                            value = null;
 207                        }
 208                        else
 209                        {
 2210                            value = AvailabilitySet.DeserializeAvailabilitySet(document.RootElement);
 211                        }
 2212                        return Response.FromValue(value, message.Response);
 213                    }
 214                default:
 0215                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 216            }
 2217        }
 218
 219        /// <summary> Update an availability set. </summary>
 220        /// <param name="resourceGroupName"> The name of the resource group. </param>
 221        /// <param name="availabilitySetName"> The name of the availability set. </param>
 222        /// <param name="parameters"> Parameters supplied to the Update Availability Set operation. </param>
 223        /// <param name="cancellationToken"> The cancellation token to use. </param>
 224        public Response<AvailabilitySet> Update(string resourceGroupName, string availabilitySetName, AvailabilitySetUpd
 225        {
 2226            if (resourceGroupName == null)
 227            {
 0228                throw new ArgumentNullException(nameof(resourceGroupName));
 229            }
 2230            if (availabilitySetName == null)
 231            {
 0232                throw new ArgumentNullException(nameof(availabilitySetName));
 233            }
 2234            if (parameters == null)
 235            {
 0236                throw new ArgumentNullException(nameof(parameters));
 237            }
 238
 2239            using var message = CreateUpdateRequest(resourceGroupName, availabilitySetName, parameters);
 2240            _pipeline.Send(message, cancellationToken);
 2241            switch (message.Response.Status)
 242            {
 243                case 200:
 244                    {
 2245                        AvailabilitySet value = default;
 2246                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2247                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 248                        {
 0249                            value = null;
 250                        }
 251                        else
 252                        {
 2253                            value = AvailabilitySet.DeserializeAvailabilitySet(document.RootElement);
 254                        }
 2255                        return Response.FromValue(value, message.Response);
 256                    }
 257                default:
 0258                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 259            }
 2260        }
 261
 262        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string availabilitySetName)
 263        {
 16264            var message = _pipeline.CreateMessage();
 16265            var request = message.Request;
 16266            request.Method = RequestMethod.Delete;
 16267            var uri = new RawRequestUriBuilder();
 16268            uri.Reset(endpoint);
 16269            uri.AppendPath("/subscriptions/", false);
 16270            uri.AppendPath(subscriptionId, true);
 16271            uri.AppendPath("/resourceGroups/", false);
 16272            uri.AppendPath(resourceGroupName, true);
 16273            uri.AppendPath("/providers/Microsoft.Compute/availabilitySets/", false);
 16274            uri.AppendPath(availabilitySetName, true);
 16275            uri.AppendQuery("api-version", "2019-12-01", true);
 16276            request.Uri = uri;
 16277            return message;
 278        }
 279
 280        /// <summary> Delete an availability set. </summary>
 281        /// <param name="resourceGroupName"> The name of the resource group. </param>
 282        /// <param name="availabilitySetName"> The name of the availability set. </param>
 283        /// <param name="cancellationToken"> The cancellation token to use. </param>
 284        public async Task<Response> DeleteAsync(string resourceGroupName, string availabilitySetName, CancellationToken 
 285        {
 8286            if (resourceGroupName == null)
 287            {
 0288                throw new ArgumentNullException(nameof(resourceGroupName));
 289            }
 8290            if (availabilitySetName == null)
 291            {
 0292                throw new ArgumentNullException(nameof(availabilitySetName));
 293            }
 294
 8295            using var message = CreateDeleteRequest(resourceGroupName, availabilitySetName);
 8296            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8297            switch (message.Response.Status)
 298            {
 299                case 200:
 300                case 204:
 8301                    return message.Response;
 302                default:
 0303                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 304            }
 8305        }
 306
 307        /// <summary> Delete an availability set. </summary>
 308        /// <param name="resourceGroupName"> The name of the resource group. </param>
 309        /// <param name="availabilitySetName"> The name of the availability set. </param>
 310        /// <param name="cancellationToken"> The cancellation token to use. </param>
 311        public Response Delete(string resourceGroupName, string availabilitySetName, CancellationToken cancellationToken
 312        {
 8313            if (resourceGroupName == null)
 314            {
 0315                throw new ArgumentNullException(nameof(resourceGroupName));
 316            }
 8317            if (availabilitySetName == null)
 318            {
 0319                throw new ArgumentNullException(nameof(availabilitySetName));
 320            }
 321
 8322            using var message = CreateDeleteRequest(resourceGroupName, availabilitySetName);
 8323            _pipeline.Send(message, cancellationToken);
 8324            switch (message.Response.Status)
 325            {
 326                case 200:
 327                case 204:
 8328                    return message.Response;
 329                default:
 0330                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 331            }
 8332        }
 333
 334        internal HttpMessage CreateGetRequest(string resourceGroupName, string availabilitySetName)
 335        {
 16336            var message = _pipeline.CreateMessage();
 16337            var request = message.Request;
 16338            request.Method = RequestMethod.Get;
 16339            var uri = new RawRequestUriBuilder();
 16340            uri.Reset(endpoint);
 16341            uri.AppendPath("/subscriptions/", false);
 16342            uri.AppendPath(subscriptionId, true);
 16343            uri.AppendPath("/resourceGroups/", false);
 16344            uri.AppendPath(resourceGroupName, true);
 16345            uri.AppendPath("/providers/Microsoft.Compute/availabilitySets/", false);
 16346            uri.AppendPath(availabilitySetName, true);
 16347            uri.AppendQuery("api-version", "2019-12-01", true);
 16348            request.Uri = uri;
 16349            return message;
 350        }
 351
 352        /// <summary> Retrieves information about an availability set. </summary>
 353        /// <param name="resourceGroupName"> The name of the resource group. </param>
 354        /// <param name="availabilitySetName"> The name of the availability set. </param>
 355        /// <param name="cancellationToken"> The cancellation token to use. </param>
 356        public async Task<Response<AvailabilitySet>> GetAsync(string resourceGroupName, string availabilitySetName, Canc
 357        {
 8358            if (resourceGroupName == null)
 359            {
 0360                throw new ArgumentNullException(nameof(resourceGroupName));
 361            }
 8362            if (availabilitySetName == null)
 363            {
 0364                throw new ArgumentNullException(nameof(availabilitySetName));
 365            }
 366
 8367            using var message = CreateGetRequest(resourceGroupName, availabilitySetName);
 8368            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8369            switch (message.Response.Status)
 370            {
 371                case 200:
 372                    {
 8373                        AvailabilitySet value = default;
 8374                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8375                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 376                        {
 0377                            value = null;
 378                        }
 379                        else
 380                        {
 8381                            value = AvailabilitySet.DeserializeAvailabilitySet(document.RootElement);
 382                        }
 8383                        return Response.FromValue(value, message.Response);
 384                    }
 385                default:
 0386                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 387            }
 8388        }
 389
 390        /// <summary> Retrieves information about an availability set. </summary>
 391        /// <param name="resourceGroupName"> The name of the resource group. </param>
 392        /// <param name="availabilitySetName"> The name of the availability set. </param>
 393        /// <param name="cancellationToken"> The cancellation token to use. </param>
 394        public Response<AvailabilitySet> Get(string resourceGroupName, string availabilitySetName, CancellationToken can
 395        {
 8396            if (resourceGroupName == null)
 397            {
 0398                throw new ArgumentNullException(nameof(resourceGroupName));
 399            }
 8400            if (availabilitySetName == null)
 401            {
 0402                throw new ArgumentNullException(nameof(availabilitySetName));
 403            }
 404
 8405            using var message = CreateGetRequest(resourceGroupName, availabilitySetName);
 8406            _pipeline.Send(message, cancellationToken);
 8407            switch (message.Response.Status)
 408            {
 409                case 200:
 410                    {
 8411                        AvailabilitySet value = default;
 8412                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8413                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 414                        {
 0415                            value = null;
 416                        }
 417                        else
 418                        {
 8419                            value = AvailabilitySet.DeserializeAvailabilitySet(document.RootElement);
 420                        }
 8421                        return Response.FromValue(value, message.Response);
 422                    }
 423                default:
 0424                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 425            }
 8426        }
 427
 428        internal HttpMessage CreateListBySubscriptionRequest(string expand)
 429        {
 8430            var message = _pipeline.CreateMessage();
 8431            var request = message.Request;
 8432            request.Method = RequestMethod.Get;
 8433            var uri = new RawRequestUriBuilder();
 8434            uri.Reset(endpoint);
 8435            uri.AppendPath("/subscriptions/", false);
 8436            uri.AppendPath(subscriptionId, true);
 8437            uri.AppendPath("/providers/Microsoft.Compute/availabilitySets", false);
 8438            uri.AppendQuery("api-version", "2019-12-01", true);
 8439            if (expand != null)
 440            {
 4441                uri.AppendQuery("$expand", expand, true);
 442            }
 8443            request.Uri = uri;
 8444            return message;
 445        }
 446
 447        /// <summary> Lists all availability sets in a subscription. </summary>
 448        /// <param name="expand"> The expand expression to apply to the operation. </param>
 449        /// <param name="cancellationToken"> The cancellation token to use. </param>
 450        public async Task<Response<AvailabilitySetListResult>> ListBySubscriptionAsync(string expand = null, Cancellatio
 451        {
 4452            using var message = CreateListBySubscriptionRequest(expand);
 4453            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4454            switch (message.Response.Status)
 455            {
 456                case 200:
 457                    {
 4458                        AvailabilitySetListResult value = default;
 4459                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4460                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 461                        {
 0462                            value = null;
 463                        }
 464                        else
 465                        {
 4466                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 467                        }
 4468                        return Response.FromValue(value, message.Response);
 469                    }
 470                default:
 0471                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 472            }
 4473        }
 474
 475        /// <summary> Lists all availability sets in a subscription. </summary>
 476        /// <param name="expand"> The expand expression to apply to the operation. </param>
 477        /// <param name="cancellationToken"> The cancellation token to use. </param>
 478        public Response<AvailabilitySetListResult> ListBySubscription(string expand = null, CancellationToken cancellati
 479        {
 4480            using var message = CreateListBySubscriptionRequest(expand);
 4481            _pipeline.Send(message, cancellationToken);
 4482            switch (message.Response.Status)
 483            {
 484                case 200:
 485                    {
 4486                        AvailabilitySetListResult value = default;
 4487                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4488                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 489                        {
 0490                            value = null;
 491                        }
 492                        else
 493                        {
 4494                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 495                        }
 4496                        return Response.FromValue(value, message.Response);
 497                    }
 498                default:
 0499                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 500            }
 4501        }
 502
 503        internal HttpMessage CreateListRequest(string resourceGroupName)
 504        {
 4505            var message = _pipeline.CreateMessage();
 4506            var request = message.Request;
 4507            request.Method = RequestMethod.Get;
 4508            var uri = new RawRequestUriBuilder();
 4509            uri.Reset(endpoint);
 4510            uri.AppendPath("/subscriptions/", false);
 4511            uri.AppendPath(subscriptionId, true);
 4512            uri.AppendPath("/resourceGroups/", false);
 4513            uri.AppendPath(resourceGroupName, true);
 4514            uri.AppendPath("/providers/Microsoft.Compute/availabilitySets", false);
 4515            uri.AppendQuery("api-version", "2019-12-01", true);
 4516            request.Uri = uri;
 4517            return message;
 518        }
 519
 520        /// <summary> Lists all availability sets in a resource group. </summary>
 521        /// <param name="resourceGroupName"> The name of the resource group. </param>
 522        /// <param name="cancellationToken"> The cancellation token to use. </param>
 523        public async Task<Response<AvailabilitySetListResult>> ListAsync(string resourceGroupName, CancellationToken can
 524        {
 2525            if (resourceGroupName == null)
 526            {
 0527                throw new ArgumentNullException(nameof(resourceGroupName));
 528            }
 529
 2530            using var message = CreateListRequest(resourceGroupName);
 2531            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2532            switch (message.Response.Status)
 533            {
 534                case 200:
 535                    {
 2536                        AvailabilitySetListResult value = default;
 2537                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2538                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 539                        {
 0540                            value = null;
 541                        }
 542                        else
 543                        {
 2544                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 545                        }
 2546                        return Response.FromValue(value, message.Response);
 547                    }
 548                default:
 0549                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 550            }
 2551        }
 552
 553        /// <summary> Lists all availability sets in a resource group. </summary>
 554        /// <param name="resourceGroupName"> The name of the resource group. </param>
 555        /// <param name="cancellationToken"> The cancellation token to use. </param>
 556        public Response<AvailabilitySetListResult> List(string resourceGroupName, CancellationToken cancellationToken = 
 557        {
 2558            if (resourceGroupName == null)
 559            {
 0560                throw new ArgumentNullException(nameof(resourceGroupName));
 561            }
 562
 2563            using var message = CreateListRequest(resourceGroupName);
 2564            _pipeline.Send(message, cancellationToken);
 2565            switch (message.Response.Status)
 566            {
 567                case 200:
 568                    {
 2569                        AvailabilitySetListResult value = default;
 2570                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2571                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 572                        {
 0573                            value = null;
 574                        }
 575                        else
 576                        {
 2577                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 578                        }
 2579                        return Response.FromValue(value, message.Response);
 580                    }
 581                default:
 0582                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 583            }
 2584        }
 585
 586        internal HttpMessage CreateListAvailableSizesRequest(string resourceGroupName, string availabilitySetName)
 587        {
 32588            var message = _pipeline.CreateMessage();
 32589            var request = message.Request;
 32590            request.Method = RequestMethod.Get;
 32591            var uri = new RawRequestUriBuilder();
 32592            uri.Reset(endpoint);
 32593            uri.AppendPath("/subscriptions/", false);
 32594            uri.AppendPath(subscriptionId, true);
 32595            uri.AppendPath("/resourceGroups/", false);
 32596            uri.AppendPath(resourceGroupName, true);
 32597            uri.AppendPath("/providers/Microsoft.Compute/availabilitySets/", false);
 32598            uri.AppendPath(availabilitySetName, true);
 32599            uri.AppendPath("/vmSizes", false);
 32600            uri.AppendQuery("api-version", "2019-12-01", true);
 32601            request.Uri = uri;
 32602            return message;
 603        }
 604
 605        /// <summary> Lists all available virtual machine sizes that can be used to create a new virtual machine in an e
 606        /// <param name="resourceGroupName"> The name of the resource group. </param>
 607        /// <param name="availabilitySetName"> The name of the availability set. </param>
 608        /// <param name="cancellationToken"> The cancellation token to use. </param>
 609        public async Task<Response<VirtualMachineSizeListResult>> ListAvailableSizesAsync(string resourceGroupName, stri
 610        {
 16611            if (resourceGroupName == null)
 612            {
 0613                throw new ArgumentNullException(nameof(resourceGroupName));
 614            }
 16615            if (availabilitySetName == null)
 616            {
 0617                throw new ArgumentNullException(nameof(availabilitySetName));
 618            }
 619
 16620            using var message = CreateListAvailableSizesRequest(resourceGroupName, availabilitySetName);
 16621            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16622            switch (message.Response.Status)
 623            {
 624                case 200:
 625                    {
 16626                        VirtualMachineSizeListResult value = default;
 16627                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 16628                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 629                        {
 0630                            value = null;
 631                        }
 632                        else
 633                        {
 16634                            value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl
 635                        }
 16636                        return Response.FromValue(value, message.Response);
 637                    }
 638                default:
 0639                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 640            }
 16641        }
 642
 643        /// <summary> Lists all available virtual machine sizes that can be used to create a new virtual machine in an e
 644        /// <param name="resourceGroupName"> The name of the resource group. </param>
 645        /// <param name="availabilitySetName"> The name of the availability set. </param>
 646        /// <param name="cancellationToken"> The cancellation token to use. </param>
 647        public Response<VirtualMachineSizeListResult> ListAvailableSizes(string resourceGroupName, string availabilitySe
 648        {
 16649            if (resourceGroupName == null)
 650            {
 0651                throw new ArgumentNullException(nameof(resourceGroupName));
 652            }
 16653            if (availabilitySetName == null)
 654            {
 0655                throw new ArgumentNullException(nameof(availabilitySetName));
 656            }
 657
 16658            using var message = CreateListAvailableSizesRequest(resourceGroupName, availabilitySetName);
 16659            _pipeline.Send(message, cancellationToken);
 16660            switch (message.Response.Status)
 661            {
 662                case 200:
 663                    {
 16664                        VirtualMachineSizeListResult value = default;
 16665                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 16666                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 667                        {
 0668                            value = null;
 669                        }
 670                        else
 671                        {
 16672                            value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl
 673                        }
 16674                        return Response.FromValue(value, message.Response);
 675                    }
 676                default:
 0677                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 678            }
 16679        }
 680
 681        internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string expand)
 682        {
 0683            var message = _pipeline.CreateMessage();
 0684            var request = message.Request;
 0685            request.Method = RequestMethod.Get;
 0686            var uri = new RawRequestUriBuilder();
 0687            uri.Reset(endpoint);
 0688            uri.AppendRawNextLink(nextLink, false);
 0689            request.Uri = uri;
 0690            return message;
 691        }
 692
 693        /// <summary> Lists all availability sets in a subscription. </summary>
 694        /// <param name="nextLink"> The URL to the next page of results. </param>
 695        /// <param name="expand"> The expand expression to apply to the operation. </param>
 696        /// <param name="cancellationToken"> The cancellation token to use. </param>
 697        public async Task<Response<AvailabilitySetListResult>> ListBySubscriptionNextPageAsync(string nextLink, string e
 698        {
 0699            if (nextLink == null)
 700            {
 0701                throw new ArgumentNullException(nameof(nextLink));
 702            }
 703
 0704            using var message = CreateListBySubscriptionNextPageRequest(nextLink, expand);
 0705            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0706            switch (message.Response.Status)
 707            {
 708                case 200:
 709                    {
 0710                        AvailabilitySetListResult value = default;
 0711                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0712                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 713                        {
 0714                            value = null;
 715                        }
 716                        else
 717                        {
 0718                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 719                        }
 0720                        return Response.FromValue(value, message.Response);
 721                    }
 722                default:
 0723                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 724            }
 0725        }
 726
 727        /// <summary> Lists all availability sets in a subscription. </summary>
 728        /// <param name="nextLink"> The URL to the next page of results. </param>
 729        /// <param name="expand"> The expand expression to apply to the operation. </param>
 730        /// <param name="cancellationToken"> The cancellation token to use. </param>
 731        public Response<AvailabilitySetListResult> ListBySubscriptionNextPage(string nextLink, string expand = null, Can
 732        {
 0733            if (nextLink == null)
 734            {
 0735                throw new ArgumentNullException(nameof(nextLink));
 736            }
 737
 0738            using var message = CreateListBySubscriptionNextPageRequest(nextLink, expand);
 0739            _pipeline.Send(message, cancellationToken);
 0740            switch (message.Response.Status)
 741            {
 742                case 200:
 743                    {
 0744                        AvailabilitySetListResult value = default;
 0745                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0746                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 747                        {
 0748                            value = null;
 749                        }
 750                        else
 751                        {
 0752                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 753                        }
 0754                        return Response.FromValue(value, message.Response);
 755                    }
 756                default:
 0757                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 758            }
 0759        }
 760
 761        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName)
 762        {
 0763            var message = _pipeline.CreateMessage();
 0764            var request = message.Request;
 0765            request.Method = RequestMethod.Get;
 0766            var uri = new RawRequestUriBuilder();
 0767            uri.Reset(endpoint);
 0768            uri.AppendRawNextLink(nextLink, false);
 0769            request.Uri = uri;
 0770            return message;
 771        }
 772
 773        /// <summary> Lists all availability sets in a resource group. </summary>
 774        /// <param name="nextLink"> The URL to the next page of results. </param>
 775        /// <param name="resourceGroupName"> The name of the resource group. </param>
 776        /// <param name="cancellationToken"> The cancellation token to use. </param>
 777        public async Task<Response<AvailabilitySetListResult>> ListNextPageAsync(string nextLink, string resourceGroupNa
 778        {
 0779            if (nextLink == null)
 780            {
 0781                throw new ArgumentNullException(nameof(nextLink));
 782            }
 0783            if (resourceGroupName == null)
 784            {
 0785                throw new ArgumentNullException(nameof(resourceGroupName));
 786            }
 787
 0788            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0789            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0790            switch (message.Response.Status)
 791            {
 792                case 200:
 793                    {
 0794                        AvailabilitySetListResult value = default;
 0795                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0796                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 797                        {
 0798                            value = null;
 799                        }
 800                        else
 801                        {
 0802                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 803                        }
 0804                        return Response.FromValue(value, message.Response);
 805                    }
 806                default:
 0807                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 808            }
 0809        }
 810
 811        /// <summary> Lists all availability sets in a resource group. </summary>
 812        /// <param name="nextLink"> The URL to the next page of results. </param>
 813        /// <param name="resourceGroupName"> The name of the resource group. </param>
 814        /// <param name="cancellationToken"> The cancellation token to use. </param>
 815        public Response<AvailabilitySetListResult> ListNextPage(string nextLink, string resourceGroupName, CancellationT
 816        {
 0817            if (nextLink == null)
 818            {
 0819                throw new ArgumentNullException(nameof(nextLink));
 820            }
 0821            if (resourceGroupName == null)
 822            {
 0823                throw new ArgumentNullException(nameof(resourceGroupName));
 824            }
 825
 0826            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0827            _pipeline.Send(message, cancellationToken);
 0828            switch (message.Response.Status)
 829            {
 830                case 200:
 831                    {
 0832                        AvailabilitySetListResult value = default;
 0833                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0834                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 835                        {
 0836                            value = null;
 837                        }
 838                        else
 839                        {
 0840                            value = AvailabilitySetListResult.DeserializeAvailabilitySetListResult(document.RootElement)
 841                        }
 0842                        return Response.FromValue(value, message.Response);
 843                    }
 844                default:
 0845                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 846            }
 0847        }
 848    }
 849}