< Summary

Class:Azure.ResourceManager.Compute.VirtualMachineScaleSetVMsRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineScaleSetVMsRestOperations.cs
Covered lines:468
Uncovered lines:249
Coverable lines:717
Total lines:1538
Line coverage:65.2% (468 of 717)
Covered branches:157
Total branches:338
Branch coverage:46.4% (157 of 338)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateReimageRequest(...)-86.36%50%
ReimageAsync()-66.67%60%
Reimage(...)-66.67%60%
CreateReimageAllRequest(...)-100%100%
ReimageAllAsync()-66.67%60%
ReimageAll(...)-66.67%60%
CreateDeallocateRequest(...)-100%100%
DeallocateAsync()-66.67%60%
Deallocate(...)-66.67%60%
CreateUpdateRequest(...)-0%100%
UpdateAsync()-0%0%
Update(...)-0%0%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-66.67%50%
Delete(...)-66.67%50%
CreateGetRequest(...)-100%100%
GetAsync()-70.59%50%
Get(...)-70.59%50%
CreateGetInstanceViewRequest(...)-100%100%
GetInstanceViewAsync()-70.59%50%
GetInstanceView(...)-70.59%50%
CreateListRequest(...)-95.24%83.33%
ListAsync()-73.33%50%
List(...)-73.33%50%
CreatePowerOffRequest(...)-94.74%50%
PowerOffAsync()-66.67%60%
PowerOff(...)-66.67%60%
CreateRestartRequest(...)-100%100%
RestartAsync()-66.67%60%
Restart(...)-66.67%60%
CreateStartRequest(...)-100%100%
StartAsync()-66.67%60%
Start(...)-66.67%60%
CreateRedeployRequest(...)-100%100%
RedeployAsync()-66.67%60%
Redeploy(...)-66.67%60%
CreatePerformMaintenanceRequest(...)-100%100%
PerformMaintenanceAsync()-58.33%50%
PerformMaintenance(...)-58.33%50%
CreateSimulateEvictionRequest(...)-0%100%
SimulateEvictionAsync()-0%0%
SimulateEviction(...)-0%0%
CreateRunCommandRequest(...)-100%100%
RunCommandAsync()-64.29%58.33%
RunCommand(...)-64.29%58.33%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineScaleSetVMsRestOperations.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 VirtualMachineScaleSetVMsRestOperations
 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 VirtualMachineScaleSetVMsRestOperations. </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 VirtualMachineScaleSetVMsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, strin
 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 CreateReimageRequest(string resourceGroupName, string vmScaleSetName, string instanceId, Vi
 47        {
 1648            var message = _pipeline.CreateMessage();
 1649            var request = message.Request;
 1650            request.Method = RequestMethod.Post;
 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/virtualMachineScaleSets/", false);
 1658            uri.AppendPath(vmScaleSetName, true);
 1659            uri.AppendPath("/virtualmachines/", false);
 1660            uri.AppendPath(instanceId, true);
 1661            uri.AppendPath("/reimage", false);
 1662            uri.AppendQuery("api-version", "2019-12-01", true);
 1663            request.Uri = uri;
 1664            request.Headers.Add("Content-Type", "application/json");
 1665            if (vmScaleSetVMReimageInput != null)
 66            {
 067                var content = new Utf8JsonRequestContent();
 068                content.JsonWriter.WriteObjectValue(vmScaleSetVMReimageInput);
 069                request.Content = content;
 70            }
 1671            return message;
 72        }
 73
 74        /// <summary> Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. </summary>
 75        /// <param name="resourceGroupName"> The name of the resource group. </param>
 76        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 77        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 78        /// <param name="vmScaleSetVMReimageInput"> Parameters for the Reimaging Virtual machine in ScaleSet. </param>
 79        /// <param name="cancellationToken"> The cancellation token to use. </param>
 80        public async Task<Response> ReimageAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Vir
 81        {
 482            if (resourceGroupName == null)
 83            {
 084                throw new ArgumentNullException(nameof(resourceGroupName));
 85            }
 486            if (vmScaleSetName == null)
 87            {
 088                throw new ArgumentNullException(nameof(vmScaleSetName));
 89            }
 490            if (instanceId == null)
 91            {
 092                throw new ArgumentNullException(nameof(instanceId));
 93            }
 94
 495            using var message = CreateReimageRequest(resourceGroupName, vmScaleSetName, instanceId, vmScaleSetVMReimageI
 496            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 497            switch (message.Response.Status)
 98            {
 99                case 200:
 100                case 202:
 4101                    return message.Response;
 102                default:
 0103                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 104            }
 4105        }
 106
 107        /// <summary> Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. </summary>
 108        /// <param name="resourceGroupName"> The name of the resource group. </param>
 109        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 110        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 111        /// <param name="vmScaleSetVMReimageInput"> Parameters for the Reimaging Virtual machine in ScaleSet. </param>
 112        /// <param name="cancellationToken"> The cancellation token to use. </param>
 113        public Response Reimage(string resourceGroupName, string vmScaleSetName, string instanceId, VirtualMachineReimag
 114        {
 4115            if (resourceGroupName == null)
 116            {
 0117                throw new ArgumentNullException(nameof(resourceGroupName));
 118            }
 4119            if (vmScaleSetName == null)
 120            {
 0121                throw new ArgumentNullException(nameof(vmScaleSetName));
 122            }
 4123            if (instanceId == null)
 124            {
 0125                throw new ArgumentNullException(nameof(instanceId));
 126            }
 127
 4128            using var message = CreateReimageRequest(resourceGroupName, vmScaleSetName, instanceId, vmScaleSetVMReimageI
 4129            _pipeline.Send(message, cancellationToken);
 4130            switch (message.Response.Status)
 131            {
 132                case 200:
 133                case 202:
 4134                    return message.Response;
 135                default:
 0136                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 137            }
 4138        }
 139
 140        internal HttpMessage CreateReimageAllRequest(string resourceGroupName, string vmScaleSetName, string instanceId)
 141        {
 8142            var message = _pipeline.CreateMessage();
 8143            var request = message.Request;
 8144            request.Method = RequestMethod.Post;
 8145            var uri = new RawRequestUriBuilder();
 8146            uri.Reset(endpoint);
 8147            uri.AppendPath("/subscriptions/", false);
 8148            uri.AppendPath(subscriptionId, true);
 8149            uri.AppendPath("/resourceGroups/", false);
 8150            uri.AppendPath(resourceGroupName, true);
 8151            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 8152            uri.AppendPath(vmScaleSetName, true);
 8153            uri.AppendPath("/virtualmachines/", false);
 8154            uri.AppendPath(instanceId, true);
 8155            uri.AppendPath("/reimageall", false);
 8156            uri.AppendQuery("api-version", "2019-12-01", true);
 8157            request.Uri = uri;
 8158            return message;
 159        }
 160
 161        /// <summary> Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This
 162        /// <param name="resourceGroupName"> The name of the resource group. </param>
 163        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 164        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 165        /// <param name="cancellationToken"> The cancellation token to use. </param>
 166        public async Task<Response> ReimageAllAsync(string resourceGroupName, string vmScaleSetName, string instanceId, 
 167        {
 2168            if (resourceGroupName == null)
 169            {
 0170                throw new ArgumentNullException(nameof(resourceGroupName));
 171            }
 2172            if (vmScaleSetName == null)
 173            {
 0174                throw new ArgumentNullException(nameof(vmScaleSetName));
 175            }
 2176            if (instanceId == null)
 177            {
 0178                throw new ArgumentNullException(nameof(instanceId));
 179            }
 180
 2181            using var message = CreateReimageAllRequest(resourceGroupName, vmScaleSetName, instanceId);
 2182            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2183            switch (message.Response.Status)
 184            {
 185                case 200:
 186                case 202:
 2187                    return message.Response;
 188                default:
 0189                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 190            }
 2191        }
 192
 193        /// <summary> Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This
 194        /// <param name="resourceGroupName"> The name of the resource group. </param>
 195        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 196        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 197        /// <param name="cancellationToken"> The cancellation token to use. </param>
 198        public Response ReimageAll(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken
 199        {
 2200            if (resourceGroupName == null)
 201            {
 0202                throw new ArgumentNullException(nameof(resourceGroupName));
 203            }
 2204            if (vmScaleSetName == null)
 205            {
 0206                throw new ArgumentNullException(nameof(vmScaleSetName));
 207            }
 2208            if (instanceId == null)
 209            {
 0210                throw new ArgumentNullException(nameof(instanceId));
 211            }
 212
 2213            using var message = CreateReimageAllRequest(resourceGroupName, vmScaleSetName, instanceId);
 2214            _pipeline.Send(message, cancellationToken);
 2215            switch (message.Response.Status)
 216            {
 217                case 200:
 218                case 202:
 2219                    return message.Response;
 220                default:
 0221                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 222            }
 2223        }
 224
 225        internal HttpMessage CreateDeallocateRequest(string resourceGroupName, string vmScaleSetName, string instanceId)
 226        {
 16227            var message = _pipeline.CreateMessage();
 16228            var request = message.Request;
 16229            request.Method = RequestMethod.Post;
 16230            var uri = new RawRequestUriBuilder();
 16231            uri.Reset(endpoint);
 16232            uri.AppendPath("/subscriptions/", false);
 16233            uri.AppendPath(subscriptionId, true);
 16234            uri.AppendPath("/resourceGroups/", false);
 16235            uri.AppendPath(resourceGroupName, true);
 16236            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 16237            uri.AppendPath(vmScaleSetName, true);
 16238            uri.AppendPath("/virtualmachines/", false);
 16239            uri.AppendPath(instanceId, true);
 16240            uri.AppendPath("/deallocate", false);
 16241            uri.AppendQuery("api-version", "2019-12-01", true);
 16242            request.Uri = uri;
 16243            return message;
 244        }
 245
 246        /// <summary> Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and relea
 247        /// <param name="resourceGroupName"> The name of the resource group. </param>
 248        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 249        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 250        /// <param name="cancellationToken"> The cancellation token to use. </param>
 251        public async Task<Response> DeallocateAsync(string resourceGroupName, string vmScaleSetName, string instanceId, 
 252        {
 4253            if (resourceGroupName == null)
 254            {
 0255                throw new ArgumentNullException(nameof(resourceGroupName));
 256            }
 4257            if (vmScaleSetName == null)
 258            {
 0259                throw new ArgumentNullException(nameof(vmScaleSetName));
 260            }
 4261            if (instanceId == null)
 262            {
 0263                throw new ArgumentNullException(nameof(instanceId));
 264            }
 265
 4266            using var message = CreateDeallocateRequest(resourceGroupName, vmScaleSetName, instanceId);
 4267            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4268            switch (message.Response.Status)
 269            {
 270                case 200:
 271                case 202:
 4272                    return message.Response;
 273                default:
 0274                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 275            }
 4276        }
 277
 278        /// <summary> Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and relea
 279        /// <param name="resourceGroupName"> The name of the resource group. </param>
 280        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 281        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 282        /// <param name="cancellationToken"> The cancellation token to use. </param>
 283        public Response Deallocate(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken
 284        {
 4285            if (resourceGroupName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(resourceGroupName));
 288            }
 4289            if (vmScaleSetName == null)
 290            {
 0291                throw new ArgumentNullException(nameof(vmScaleSetName));
 292            }
 4293            if (instanceId == null)
 294            {
 0295                throw new ArgumentNullException(nameof(instanceId));
 296            }
 297
 4298            using var message = CreateDeallocateRequest(resourceGroupName, vmScaleSetName, instanceId);
 4299            _pipeline.Send(message, cancellationToken);
 4300            switch (message.Response.Status)
 301            {
 302                case 200:
 303                case 202:
 4304                    return message.Response;
 305                default:
 0306                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 307            }
 4308        }
 309
 310        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string vmScaleSetName, string instanceId, Vir
 311        {
 0312            var message = _pipeline.CreateMessage();
 0313            var request = message.Request;
 0314            request.Method = RequestMethod.Put;
 0315            var uri = new RawRequestUriBuilder();
 0316            uri.Reset(endpoint);
 0317            uri.AppendPath("/subscriptions/", false);
 0318            uri.AppendPath(subscriptionId, true);
 0319            uri.AppendPath("/resourceGroups/", false);
 0320            uri.AppendPath(resourceGroupName, true);
 0321            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 0322            uri.AppendPath(vmScaleSetName, true);
 0323            uri.AppendPath("/virtualmachines/", false);
 0324            uri.AppendPath(instanceId, true);
 0325            uri.AppendQuery("api-version", "2019-12-01", true);
 0326            request.Uri = uri;
 0327            request.Headers.Add("Content-Type", "application/json");
 0328            var content = new Utf8JsonRequestContent();
 0329            content.JsonWriter.WriteObjectValue(parameters);
 0330            request.Content = content;
 0331            return message;
 332        }
 333
 334        /// <summary> Updates a virtual machine of a VM scale set. </summary>
 335        /// <param name="resourceGroupName"> The name of the resource group. </param>
 336        /// <param name="vmScaleSetName"> The name of the VM scale set where the extension should be create or updated. 
 337        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 338        /// <param name="parameters"> Parameters supplied to the Update Virtual Machine Scale Sets VM operation. </param
 339        /// <param name="cancellationToken"> The cancellation token to use. </param>
 340        public async Task<Response> UpdateAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Virt
 341        {
 0342            if (resourceGroupName == null)
 343            {
 0344                throw new ArgumentNullException(nameof(resourceGroupName));
 345            }
 0346            if (vmScaleSetName == null)
 347            {
 0348                throw new ArgumentNullException(nameof(vmScaleSetName));
 349            }
 0350            if (instanceId == null)
 351            {
 0352                throw new ArgumentNullException(nameof(instanceId));
 353            }
 0354            if (parameters == null)
 355            {
 0356                throw new ArgumentNullException(nameof(parameters));
 357            }
 358
 0359            using var message = CreateUpdateRequest(resourceGroupName, vmScaleSetName, instanceId, parameters);
 0360            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0361            switch (message.Response.Status)
 362            {
 363                case 200:
 364                case 202:
 0365                    return message.Response;
 366                default:
 0367                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 368            }
 0369        }
 370
 371        /// <summary> Updates a virtual machine of a VM scale set. </summary>
 372        /// <param name="resourceGroupName"> The name of the resource group. </param>
 373        /// <param name="vmScaleSetName"> The name of the VM scale set where the extension should be create or updated. 
 374        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 375        /// <param name="parameters"> Parameters supplied to the Update Virtual Machine Scale Sets VM operation. </param
 376        /// <param name="cancellationToken"> The cancellation token to use. </param>
 377        public Response Update(string resourceGroupName, string vmScaleSetName, string instanceId, VirtualMachineScaleSe
 378        {
 0379            if (resourceGroupName == null)
 380            {
 0381                throw new ArgumentNullException(nameof(resourceGroupName));
 382            }
 0383            if (vmScaleSetName == null)
 384            {
 0385                throw new ArgumentNullException(nameof(vmScaleSetName));
 386            }
 0387            if (instanceId == null)
 388            {
 0389                throw new ArgumentNullException(nameof(instanceId));
 390            }
 0391            if (parameters == null)
 392            {
 0393                throw new ArgumentNullException(nameof(parameters));
 394            }
 395
 0396            using var message = CreateUpdateRequest(resourceGroupName, vmScaleSetName, instanceId, parameters);
 0397            _pipeline.Send(message, cancellationToken);
 0398            switch (message.Response.Status)
 399            {
 400                case 200:
 401                case 202:
 0402                    return message.Response;
 403                default:
 0404                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 405            }
 0406        }
 407
 408        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string vmScaleSetName, string instanceId)
 409        {
 16410            var message = _pipeline.CreateMessage();
 16411            var request = message.Request;
 16412            request.Method = RequestMethod.Delete;
 16413            var uri = new RawRequestUriBuilder();
 16414            uri.Reset(endpoint);
 16415            uri.AppendPath("/subscriptions/", false);
 16416            uri.AppendPath(subscriptionId, true);
 16417            uri.AppendPath("/resourceGroups/", false);
 16418            uri.AppendPath(resourceGroupName, true);
 16419            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 16420            uri.AppendPath(vmScaleSetName, true);
 16421            uri.AppendPath("/virtualmachines/", false);
 16422            uri.AppendPath(instanceId, true);
 16423            uri.AppendQuery("api-version", "2019-12-01", true);
 16424            request.Uri = uri;
 16425            return message;
 426        }
 427
 428        /// <summary> Deletes a virtual machine from a VM scale set. </summary>
 429        /// <param name="resourceGroupName"> The name of the resource group. </param>
 430        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 431        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 432        /// <param name="cancellationToken"> The cancellation token to use. </param>
 433        public async Task<Response> DeleteAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Canc
 434        {
 4435            if (resourceGroupName == null)
 436            {
 0437                throw new ArgumentNullException(nameof(resourceGroupName));
 438            }
 4439            if (vmScaleSetName == null)
 440            {
 0441                throw new ArgumentNullException(nameof(vmScaleSetName));
 442            }
 4443            if (instanceId == null)
 444            {
 0445                throw new ArgumentNullException(nameof(instanceId));
 446            }
 447
 4448            using var message = CreateDeleteRequest(resourceGroupName, vmScaleSetName, instanceId);
 4449            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4450            switch (message.Response.Status)
 451            {
 452                case 200:
 453                case 202:
 454                case 204:
 4455                    return message.Response;
 456                default:
 0457                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 458            }
 4459        }
 460
 461        /// <summary> Deletes a virtual machine from a VM scale set. </summary>
 462        /// <param name="resourceGroupName"> The name of the resource group. </param>
 463        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 464        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 465        /// <param name="cancellationToken"> The cancellation token to use. </param>
 466        public Response Delete(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken can
 467        {
 4468            if (resourceGroupName == null)
 469            {
 0470                throw new ArgumentNullException(nameof(resourceGroupName));
 471            }
 4472            if (vmScaleSetName == null)
 473            {
 0474                throw new ArgumentNullException(nameof(vmScaleSetName));
 475            }
 4476            if (instanceId == null)
 477            {
 0478                throw new ArgumentNullException(nameof(instanceId));
 479            }
 480
 4481            using var message = CreateDeleteRequest(resourceGroupName, vmScaleSetName, instanceId);
 4482            _pipeline.Send(message, cancellationToken);
 4483            switch (message.Response.Status)
 484            {
 485                case 200:
 486                case 202:
 487                case 204:
 4488                    return message.Response;
 489                default:
 0490                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 491            }
 4492        }
 493
 494        internal HttpMessage CreateGetRequest(string resourceGroupName, string vmScaleSetName, string instanceId)
 495        {
 32496            var message = _pipeline.CreateMessage();
 32497            var request = message.Request;
 32498            request.Method = RequestMethod.Get;
 32499            var uri = new RawRequestUriBuilder();
 32500            uri.Reset(endpoint);
 32501            uri.AppendPath("/subscriptions/", false);
 32502            uri.AppendPath(subscriptionId, true);
 32503            uri.AppendPath("/resourceGroups/", false);
 32504            uri.AppendPath(resourceGroupName, true);
 32505            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 32506            uri.AppendPath(vmScaleSetName, true);
 32507            uri.AppendPath("/virtualmachines/", false);
 32508            uri.AppendPath(instanceId, true);
 32509            uri.AppendQuery("$expand", "instanceView", true);
 32510            uri.AppendQuery("api-version", "2019-12-01", true);
 32511            request.Uri = uri;
 32512            return message;
 513        }
 514
 515        /// <summary> Gets a virtual machine from a VM scale set. </summary>
 516        /// <param name="resourceGroupName"> The name of the resource group. </param>
 517        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 518        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 519        /// <param name="cancellationToken"> The cancellation token to use. </param>
 520        public async Task<Response<VirtualMachineScaleSetVM>> GetAsync(string resourceGroupName, string vmScaleSetName, 
 521        {
 16522            if (resourceGroupName == null)
 523            {
 0524                throw new ArgumentNullException(nameof(resourceGroupName));
 525            }
 16526            if (vmScaleSetName == null)
 527            {
 0528                throw new ArgumentNullException(nameof(vmScaleSetName));
 529            }
 16530            if (instanceId == null)
 531            {
 0532                throw new ArgumentNullException(nameof(instanceId));
 533            }
 534
 16535            using var message = CreateGetRequest(resourceGroupName, vmScaleSetName, instanceId);
 16536            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16537            switch (message.Response.Status)
 538            {
 539                case 200:
 540                    {
 16541                        VirtualMachineScaleSetVM value = default;
 16542                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 16543                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 544                        {
 0545                            value = null;
 546                        }
 547                        else
 548                        {
 16549                            value = VirtualMachineScaleSetVM.DeserializeVirtualMachineScaleSetVM(document.RootElement);
 550                        }
 16551                        return Response.FromValue(value, message.Response);
 552                    }
 553                default:
 0554                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 555            }
 16556        }
 557
 558        /// <summary> Gets a virtual machine from a VM scale set. </summary>
 559        /// <param name="resourceGroupName"> The name of the resource group. </param>
 560        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 561        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 562        /// <param name="cancellationToken"> The cancellation token to use. </param>
 563        public Response<VirtualMachineScaleSetVM> Get(string resourceGroupName, string vmScaleSetName, string instanceId
 564        {
 16565            if (resourceGroupName == null)
 566            {
 0567                throw new ArgumentNullException(nameof(resourceGroupName));
 568            }
 16569            if (vmScaleSetName == null)
 570            {
 0571                throw new ArgumentNullException(nameof(vmScaleSetName));
 572            }
 16573            if (instanceId == null)
 574            {
 0575                throw new ArgumentNullException(nameof(instanceId));
 576            }
 577
 16578            using var message = CreateGetRequest(resourceGroupName, vmScaleSetName, instanceId);
 16579            _pipeline.Send(message, cancellationToken);
 16580            switch (message.Response.Status)
 581            {
 582                case 200:
 583                    {
 16584                        VirtualMachineScaleSetVM value = default;
 16585                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 16586                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 587                        {
 0588                            value = null;
 589                        }
 590                        else
 591                        {
 16592                            value = VirtualMachineScaleSetVM.DeserializeVirtualMachineScaleSetVM(document.RootElement);
 593                        }
 16594                        return Response.FromValue(value, message.Response);
 595                    }
 596                default:
 0597                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 598            }
 16599        }
 600
 601        internal HttpMessage CreateGetInstanceViewRequest(string resourceGroupName, string vmScaleSetName, string instan
 602        {
 8603            var message = _pipeline.CreateMessage();
 8604            var request = message.Request;
 8605            request.Method = RequestMethod.Get;
 8606            var uri = new RawRequestUriBuilder();
 8607            uri.Reset(endpoint);
 8608            uri.AppendPath("/subscriptions/", false);
 8609            uri.AppendPath(subscriptionId, true);
 8610            uri.AppendPath("/resourceGroups/", false);
 8611            uri.AppendPath(resourceGroupName, true);
 8612            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 8613            uri.AppendPath(vmScaleSetName, true);
 8614            uri.AppendPath("/virtualmachines/", false);
 8615            uri.AppendPath(instanceId, true);
 8616            uri.AppendPath("/instanceView", false);
 8617            uri.AppendQuery("api-version", "2019-12-01", true);
 8618            request.Uri = uri;
 8619            return message;
 620        }
 621
 622        /// <summary> Gets the status of a virtual machine from a VM scale set. </summary>
 623        /// <param name="resourceGroupName"> The name of the resource group. </param>
 624        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 625        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 626        /// <param name="cancellationToken"> The cancellation token to use. </param>
 627        public async Task<Response<VirtualMachineScaleSetVMInstanceView>> GetInstanceViewAsync(string resourceGroupName,
 628        {
 4629            if (resourceGroupName == null)
 630            {
 0631                throw new ArgumentNullException(nameof(resourceGroupName));
 632            }
 4633            if (vmScaleSetName == null)
 634            {
 0635                throw new ArgumentNullException(nameof(vmScaleSetName));
 636            }
 4637            if (instanceId == null)
 638            {
 0639                throw new ArgumentNullException(nameof(instanceId));
 640            }
 641
 4642            using var message = CreateGetInstanceViewRequest(resourceGroupName, vmScaleSetName, instanceId);
 4643            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4644            switch (message.Response.Status)
 645            {
 646                case 200:
 647                    {
 4648                        VirtualMachineScaleSetVMInstanceView value = default;
 4649                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4650                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 651                        {
 0652                            value = null;
 653                        }
 654                        else
 655                        {
 4656                            value = VirtualMachineScaleSetVMInstanceView.DeserializeVirtualMachineScaleSetVMInstanceView
 657                        }
 4658                        return Response.FromValue(value, message.Response);
 659                    }
 660                default:
 0661                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 662            }
 4663        }
 664
 665        /// <summary> Gets the status of a virtual machine from a VM scale set. </summary>
 666        /// <param name="resourceGroupName"> The name of the resource group. </param>
 667        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 668        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 669        /// <param name="cancellationToken"> The cancellation token to use. </param>
 670        public Response<VirtualMachineScaleSetVMInstanceView> GetInstanceView(string resourceGroupName, string vmScaleSe
 671        {
 4672            if (resourceGroupName == null)
 673            {
 0674                throw new ArgumentNullException(nameof(resourceGroupName));
 675            }
 4676            if (vmScaleSetName == null)
 677            {
 0678                throw new ArgumentNullException(nameof(vmScaleSetName));
 679            }
 4680            if (instanceId == null)
 681            {
 0682                throw new ArgumentNullException(nameof(instanceId));
 683            }
 684
 4685            using var message = CreateGetInstanceViewRequest(resourceGroupName, vmScaleSetName, instanceId);
 4686            _pipeline.Send(message, cancellationToken);
 4687            switch (message.Response.Status)
 688            {
 689                case 200:
 690                    {
 4691                        VirtualMachineScaleSetVMInstanceView value = default;
 4692                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4693                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 694                        {
 0695                            value = null;
 696                        }
 697                        else
 698                        {
 4699                            value = VirtualMachineScaleSetVMInstanceView.DeserializeVirtualMachineScaleSetVMInstanceView
 700                        }
 4701                        return Response.FromValue(value, message.Response);
 702                    }
 703                default:
 0704                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 705            }
 4706        }
 707
 708        internal HttpMessage CreateListRequest(string resourceGroupName, string virtualMachineScaleSetName, string filte
 709        {
 28710            var message = _pipeline.CreateMessage();
 28711            var request = message.Request;
 28712            request.Method = RequestMethod.Get;
 28713            var uri = new RawRequestUriBuilder();
 28714            uri.Reset(endpoint);
 28715            uri.AppendPath("/subscriptions/", false);
 28716            uri.AppendPath(subscriptionId, true);
 28717            uri.AppendPath("/resourceGroups/", false);
 28718            uri.AppendPath(resourceGroupName, true);
 28719            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 28720            uri.AppendPath(virtualMachineScaleSetName, true);
 28721            uri.AppendPath("/virtualMachines", false);
 28722            if (filter != null)
 723            {
 20724                uri.AppendQuery("$filter", filter, true);
 725            }
 28726            if (select != null)
 727            {
 0728                uri.AppendQuery("$select", select, true);
 729            }
 28730            if (expand != null)
 731            {
 8732                uri.AppendQuery("$expand", expand, true);
 733            }
 28734            uri.AppendQuery("api-version", "2019-12-01", true);
 28735            request.Uri = uri;
 28736            return message;
 737        }
 738
 739        /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary>
 740        /// <param name="resourceGroupName"> The name of the resource group. </param>
 741        /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param>
 742        /// <param name="filter"> The filter to apply to the operation. </param>
 743        /// <param name="select"> The list parameters. </param>
 744        /// <param name="expand"> The expand expression to apply to the operation. </param>
 745        /// <param name="cancellationToken"> The cancellation token to use. </param>
 746        public async Task<Response<VirtualMachineScaleSetVMListResult>> ListAsync(string resourceGroupName, string virtu
 747        {
 14748            if (resourceGroupName == null)
 749            {
 0750                throw new ArgumentNullException(nameof(resourceGroupName));
 751            }
 14752            if (virtualMachineScaleSetName == null)
 753            {
 0754                throw new ArgumentNullException(nameof(virtualMachineScaleSetName));
 755            }
 756
 14757            using var message = CreateListRequest(resourceGroupName, virtualMachineScaleSetName, filter, select, expand)
 14758            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 14759            switch (message.Response.Status)
 760            {
 761                case 200:
 762                    {
 14763                        VirtualMachineScaleSetVMListResult value = default;
 14764                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 14765                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 766                        {
 0767                            value = null;
 768                        }
 769                        else
 770                        {
 14771                            value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc
 772                        }
 14773                        return Response.FromValue(value, message.Response);
 774                    }
 775                default:
 0776                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 777            }
 14778        }
 779
 780        /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary>
 781        /// <param name="resourceGroupName"> The name of the resource group. </param>
 782        /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param>
 783        /// <param name="filter"> The filter to apply to the operation. </param>
 784        /// <param name="select"> The list parameters. </param>
 785        /// <param name="expand"> The expand expression to apply to the operation. </param>
 786        /// <param name="cancellationToken"> The cancellation token to use. </param>
 787        public Response<VirtualMachineScaleSetVMListResult> List(string resourceGroupName, string virtualMachineScaleSet
 788        {
 14789            if (resourceGroupName == null)
 790            {
 0791                throw new ArgumentNullException(nameof(resourceGroupName));
 792            }
 14793            if (virtualMachineScaleSetName == null)
 794            {
 0795                throw new ArgumentNullException(nameof(virtualMachineScaleSetName));
 796            }
 797
 14798            using var message = CreateListRequest(resourceGroupName, virtualMachineScaleSetName, filter, select, expand)
 14799            _pipeline.Send(message, cancellationToken);
 14800            switch (message.Response.Status)
 801            {
 802                case 200:
 803                    {
 14804                        VirtualMachineScaleSetVMListResult value = default;
 14805                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 14806                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 807                        {
 0808                            value = null;
 809                        }
 810                        else
 811                        {
 14812                            value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc
 813                        }
 14814                        return Response.FromValue(value, message.Response);
 815                    }
 816                default:
 0817                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 818            }
 14819        }
 820
 821        internal HttpMessage CreatePowerOffRequest(string resourceGroupName, string vmScaleSetName, string instanceId, b
 822        {
 16823            var message = _pipeline.CreateMessage();
 16824            var request = message.Request;
 16825            request.Method = RequestMethod.Post;
 16826            var uri = new RawRequestUriBuilder();
 16827            uri.Reset(endpoint);
 16828            uri.AppendPath("/subscriptions/", false);
 16829            uri.AppendPath(subscriptionId, true);
 16830            uri.AppendPath("/resourceGroups/", false);
 16831            uri.AppendPath(resourceGroupName, true);
 16832            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 16833            uri.AppendPath(vmScaleSetName, true);
 16834            uri.AppendPath("/virtualmachines/", false);
 16835            uri.AppendPath(instanceId, true);
 16836            uri.AppendPath("/poweroff", false);
 16837            if (skipShutdown != null)
 838            {
 0839                uri.AppendQuery("skipShutdown", skipShutdown.Value, true);
 840            }
 16841            uri.AppendQuery("api-version", "2019-12-01", true);
 16842            request.Uri = uri;
 16843            return message;
 844        }
 845
 846        /// <summary> Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and y
 847        /// <param name="resourceGroupName"> The name of the resource group. </param>
 848        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 849        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 850        /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi
 851        /// <param name="cancellationToken"> The cancellation token to use. </param>
 852        public async Task<Response> PowerOffAsync(string resourceGroupName, string vmScaleSetName, string instanceId, bo
 853        {
 4854            if (resourceGroupName == null)
 855            {
 0856                throw new ArgumentNullException(nameof(resourceGroupName));
 857            }
 4858            if (vmScaleSetName == null)
 859            {
 0860                throw new ArgumentNullException(nameof(vmScaleSetName));
 861            }
 4862            if (instanceId == null)
 863            {
 0864                throw new ArgumentNullException(nameof(instanceId));
 865            }
 866
 4867            using var message = CreatePowerOffRequest(resourceGroupName, vmScaleSetName, instanceId, skipShutdown);
 4868            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4869            switch (message.Response.Status)
 870            {
 871                case 200:
 872                case 202:
 4873                    return message.Response;
 874                default:
 0875                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 876            }
 4877        }
 878
 879        /// <summary> Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and y
 880        /// <param name="resourceGroupName"> The name of the resource group. </param>
 881        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 882        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 883        /// <param name="skipShutdown"> The parameter to request non-graceful VM shutdown. True value for this flag indi
 884        /// <param name="cancellationToken"> The cancellation token to use. </param>
 885        public Response PowerOff(string resourceGroupName, string vmScaleSetName, string instanceId, bool? skipShutdown 
 886        {
 4887            if (resourceGroupName == null)
 888            {
 0889                throw new ArgumentNullException(nameof(resourceGroupName));
 890            }
 4891            if (vmScaleSetName == null)
 892            {
 0893                throw new ArgumentNullException(nameof(vmScaleSetName));
 894            }
 4895            if (instanceId == null)
 896            {
 0897                throw new ArgumentNullException(nameof(instanceId));
 898            }
 899
 4900            using var message = CreatePowerOffRequest(resourceGroupName, vmScaleSetName, instanceId, skipShutdown);
 4901            _pipeline.Send(message, cancellationToken);
 4902            switch (message.Response.Status)
 903            {
 904                case 200:
 905                case 202:
 4906                    return message.Response;
 907                default:
 0908                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 909            }
 4910        }
 911
 912        internal HttpMessage CreateRestartRequest(string resourceGroupName, string vmScaleSetName, string instanceId)
 913        {
 16914            var message = _pipeline.CreateMessage();
 16915            var request = message.Request;
 16916            request.Method = RequestMethod.Post;
 16917            var uri = new RawRequestUriBuilder();
 16918            uri.Reset(endpoint);
 16919            uri.AppendPath("/subscriptions/", false);
 16920            uri.AppendPath(subscriptionId, true);
 16921            uri.AppendPath("/resourceGroups/", false);
 16922            uri.AppendPath(resourceGroupName, true);
 16923            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 16924            uri.AppendPath(vmScaleSetName, true);
 16925            uri.AppendPath("/virtualmachines/", false);
 16926            uri.AppendPath(instanceId, true);
 16927            uri.AppendPath("/restart", false);
 16928            uri.AppendQuery("api-version", "2019-12-01", true);
 16929            request.Uri = uri;
 16930            return message;
 931        }
 932
 933        /// <summary> Restarts a virtual machine in a VM scale set. </summary>
 934        /// <param name="resourceGroupName"> The name of the resource group. </param>
 935        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 936        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 937        /// <param name="cancellationToken"> The cancellation token to use. </param>
 938        public async Task<Response> RestartAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Can
 939        {
 4940            if (resourceGroupName == null)
 941            {
 0942                throw new ArgumentNullException(nameof(resourceGroupName));
 943            }
 4944            if (vmScaleSetName == null)
 945            {
 0946                throw new ArgumentNullException(nameof(vmScaleSetName));
 947            }
 4948            if (instanceId == null)
 949            {
 0950                throw new ArgumentNullException(nameof(instanceId));
 951            }
 952
 4953            using var message = CreateRestartRequest(resourceGroupName, vmScaleSetName, instanceId);
 4954            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4955            switch (message.Response.Status)
 956            {
 957                case 200:
 958                case 202:
 4959                    return message.Response;
 960                default:
 0961                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 962            }
 4963        }
 964
 965        /// <summary> Restarts a virtual machine in a VM scale set. </summary>
 966        /// <param name="resourceGroupName"> The name of the resource group. </param>
 967        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 968        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 969        /// <param name="cancellationToken"> The cancellation token to use. </param>
 970        public Response Restart(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken ca
 971        {
 4972            if (resourceGroupName == null)
 973            {
 0974                throw new ArgumentNullException(nameof(resourceGroupName));
 975            }
 4976            if (vmScaleSetName == null)
 977            {
 0978                throw new ArgumentNullException(nameof(vmScaleSetName));
 979            }
 4980            if (instanceId == null)
 981            {
 0982                throw new ArgumentNullException(nameof(instanceId));
 983            }
 984
 4985            using var message = CreateRestartRequest(resourceGroupName, vmScaleSetName, instanceId);
 4986            _pipeline.Send(message, cancellationToken);
 4987            switch (message.Response.Status)
 988            {
 989                case 200:
 990                case 202:
 4991                    return message.Response;
 992                default:
 0993                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 994            }
 4995        }
 996
 997        internal HttpMessage CreateStartRequest(string resourceGroupName, string vmScaleSetName, string instanceId)
 998        {
 24999            var message = _pipeline.CreateMessage();
 241000            var request = message.Request;
 241001            request.Method = RequestMethod.Post;
 241002            var uri = new RawRequestUriBuilder();
 241003            uri.Reset(endpoint);
 241004            uri.AppendPath("/subscriptions/", false);
 241005            uri.AppendPath(subscriptionId, true);
 241006            uri.AppendPath("/resourceGroups/", false);
 241007            uri.AppendPath(resourceGroupName, true);
 241008            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 241009            uri.AppendPath(vmScaleSetName, true);
 241010            uri.AppendPath("/virtualmachines/", false);
 241011            uri.AppendPath(instanceId, true);
 241012            uri.AppendPath("/start", false);
 241013            uri.AppendQuery("api-version", "2019-12-01", true);
 241014            request.Uri = uri;
 241015            return message;
 1016        }
 1017
 1018        /// <summary> Starts a virtual machine in a VM scale set. </summary>
 1019        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1020        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1021        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1022        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1023        public async Task<Response> StartAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Cance
 1024        {
 61025            if (resourceGroupName == null)
 1026            {
 01027                throw new ArgumentNullException(nameof(resourceGroupName));
 1028            }
 61029            if (vmScaleSetName == null)
 1030            {
 01031                throw new ArgumentNullException(nameof(vmScaleSetName));
 1032            }
 61033            if (instanceId == null)
 1034            {
 01035                throw new ArgumentNullException(nameof(instanceId));
 1036            }
 1037
 61038            using var message = CreateStartRequest(resourceGroupName, vmScaleSetName, instanceId);
 61039            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 61040            switch (message.Response.Status)
 1041            {
 1042                case 200:
 1043                case 202:
 61044                    return message.Response;
 1045                default:
 01046                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1047            }
 61048        }
 1049
 1050        /// <summary> Starts a virtual machine in a VM scale set. </summary>
 1051        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1052        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1053        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1054        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1055        public Response Start(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken canc
 1056        {
 61057            if (resourceGroupName == null)
 1058            {
 01059                throw new ArgumentNullException(nameof(resourceGroupName));
 1060            }
 61061            if (vmScaleSetName == null)
 1062            {
 01063                throw new ArgumentNullException(nameof(vmScaleSetName));
 1064            }
 61065            if (instanceId == null)
 1066            {
 01067                throw new ArgumentNullException(nameof(instanceId));
 1068            }
 1069
 61070            using var message = CreateStartRequest(resourceGroupName, vmScaleSetName, instanceId);
 61071            _pipeline.Send(message, cancellationToken);
 61072            switch (message.Response.Status)
 1073            {
 1074                case 200:
 1075                case 202:
 61076                    return message.Response;
 1077                default:
 01078                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1079            }
 61080        }
 1081
 1082        internal HttpMessage CreateRedeployRequest(string resourceGroupName, string vmScaleSetName, string instanceId)
 1083        {
 81084            var message = _pipeline.CreateMessage();
 81085            var request = message.Request;
 81086            request.Method = RequestMethod.Post;
 81087            var uri = new RawRequestUriBuilder();
 81088            uri.Reset(endpoint);
 81089            uri.AppendPath("/subscriptions/", false);
 81090            uri.AppendPath(subscriptionId, true);
 81091            uri.AppendPath("/resourceGroups/", false);
 81092            uri.AppendPath(resourceGroupName, true);
 81093            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 81094            uri.AppendPath(vmScaleSetName, true);
 81095            uri.AppendPath("/virtualmachines/", false);
 81096            uri.AppendPath(instanceId, true);
 81097            uri.AppendPath("/redeploy", false);
 81098            uri.AppendQuery("api-version", "2019-12-01", true);
 81099            request.Uri = uri;
 81100            return message;
 1101        }
 1102
 1103        /// <summary> Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and power
 1104        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1105        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1106        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1107        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1108        public async Task<Response> RedeployAsync(string resourceGroupName, string vmScaleSetName, string instanceId, Ca
 1109        {
 21110            if (resourceGroupName == null)
 1111            {
 01112                throw new ArgumentNullException(nameof(resourceGroupName));
 1113            }
 21114            if (vmScaleSetName == null)
 1115            {
 01116                throw new ArgumentNullException(nameof(vmScaleSetName));
 1117            }
 21118            if (instanceId == null)
 1119            {
 01120                throw new ArgumentNullException(nameof(instanceId));
 1121            }
 1122
 21123            using var message = CreateRedeployRequest(resourceGroupName, vmScaleSetName, instanceId);
 21124            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21125            switch (message.Response.Status)
 1126            {
 1127                case 200:
 1128                case 202:
 21129                    return message.Response;
 1130                default:
 01131                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1132            }
 21133        }
 1134
 1135        /// <summary> Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and power
 1136        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1137        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1138        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1139        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1140        public Response Redeploy(string resourceGroupName, string vmScaleSetName, string instanceId, CancellationToken c
 1141        {
 21142            if (resourceGroupName == null)
 1143            {
 01144                throw new ArgumentNullException(nameof(resourceGroupName));
 1145            }
 21146            if (vmScaleSetName == null)
 1147            {
 01148                throw new ArgumentNullException(nameof(vmScaleSetName));
 1149            }
 21150            if (instanceId == null)
 1151            {
 01152                throw new ArgumentNullException(nameof(instanceId));
 1153            }
 1154
 21155            using var message = CreateRedeployRequest(resourceGroupName, vmScaleSetName, instanceId);
 21156            _pipeline.Send(message, cancellationToken);
 21157            switch (message.Response.Status)
 1158            {
 1159                case 200:
 1160                case 202:
 21161                    return message.Response;
 1162                default:
 01163                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1164            }
 21165        }
 1166
 1167        internal HttpMessage CreatePerformMaintenanceRequest(string resourceGroupName, string vmScaleSetName, string ins
 1168        {
 41169            var message = _pipeline.CreateMessage();
 41170            var request = message.Request;
 41171            request.Method = RequestMethod.Post;
 41172            var uri = new RawRequestUriBuilder();
 41173            uri.Reset(endpoint);
 41174            uri.AppendPath("/subscriptions/", false);
 41175            uri.AppendPath(subscriptionId, true);
 41176            uri.AppendPath("/resourceGroups/", false);
 41177            uri.AppendPath(resourceGroupName, true);
 41178            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 41179            uri.AppendPath(vmScaleSetName, true);
 41180            uri.AppendPath("/virtualmachines/", false);
 41181            uri.AppendPath(instanceId, true);
 41182            uri.AppendPath("/performMaintenance", false);
 41183            uri.AppendQuery("api-version", "2019-12-01", true);
 41184            request.Uri = uri;
 41185            return message;
 1186        }
 1187
 1188        /// <summary> Performs maintenance on a virtual machine in a VM scale set. </summary>
 1189        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1190        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1191        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1192        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1193        public async Task<Response> PerformMaintenanceAsync(string resourceGroupName, string vmScaleSetName, string inst
 1194        {
 21195            if (resourceGroupName == null)
 1196            {
 01197                throw new ArgumentNullException(nameof(resourceGroupName));
 1198            }
 21199            if (vmScaleSetName == null)
 1200            {
 01201                throw new ArgumentNullException(nameof(vmScaleSetName));
 1202            }
 21203            if (instanceId == null)
 1204            {
 01205                throw new ArgumentNullException(nameof(instanceId));
 1206            }
 1207
 21208            using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmScaleSetName, instanceId);
 21209            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21210            switch (message.Response.Status)
 1211            {
 1212                case 200:
 1213                case 202:
 01214                    return message.Response;
 1215                default:
 21216                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1217            }
 01218        }
 1219
 1220        /// <summary> Performs maintenance on a virtual machine in a VM scale set. </summary>
 1221        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1222        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1223        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1224        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1225        public Response PerformMaintenance(string resourceGroupName, string vmScaleSetName, string instanceId, Cancellat
 1226        {
 21227            if (resourceGroupName == null)
 1228            {
 01229                throw new ArgumentNullException(nameof(resourceGroupName));
 1230            }
 21231            if (vmScaleSetName == null)
 1232            {
 01233                throw new ArgumentNullException(nameof(vmScaleSetName));
 1234            }
 21235            if (instanceId == null)
 1236            {
 01237                throw new ArgumentNullException(nameof(instanceId));
 1238            }
 1239
 21240            using var message = CreatePerformMaintenanceRequest(resourceGroupName, vmScaleSetName, instanceId);
 21241            _pipeline.Send(message, cancellationToken);
 21242            switch (message.Response.Status)
 1243            {
 1244                case 200:
 1245                case 202:
 01246                    return message.Response;
 1247                default:
 21248                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1249            }
 01250        }
 1251
 1252        internal HttpMessage CreateSimulateEvictionRequest(string resourceGroupName, string vmScaleSetName, string insta
 1253        {
 01254            var message = _pipeline.CreateMessage();
 01255            var request = message.Request;
 01256            request.Method = RequestMethod.Post;
 01257            var uri = new RawRequestUriBuilder();
 01258            uri.Reset(endpoint);
 01259            uri.AppendPath("/subscriptions/", false);
 01260            uri.AppendPath(subscriptionId, true);
 01261            uri.AppendPath("/resourceGroups/", false);
 01262            uri.AppendPath(resourceGroupName, true);
 01263            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 01264            uri.AppendPath(vmScaleSetName, true);
 01265            uri.AppendPath("/virtualMachines/", false);
 01266            uri.AppendPath(instanceId, true);
 01267            uri.AppendPath("/simulateEviction", false);
 01268            uri.AppendQuery("api-version", "2019-12-01", true);
 01269            request.Uri = uri;
 01270            return message;
 1271        }
 1272
 1273        /// <summary> The operation to simulate the eviction of spot virtual machine in a VM scale set. The eviction wil
 1274        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1275        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1276        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1277        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1278        public async Task<Response> SimulateEvictionAsync(string resourceGroupName, string vmScaleSetName, string instan
 1279        {
 01280            if (resourceGroupName == null)
 1281            {
 01282                throw new ArgumentNullException(nameof(resourceGroupName));
 1283            }
 01284            if (vmScaleSetName == null)
 1285            {
 01286                throw new ArgumentNullException(nameof(vmScaleSetName));
 1287            }
 01288            if (instanceId == null)
 1289            {
 01290                throw new ArgumentNullException(nameof(instanceId));
 1291            }
 1292
 01293            using var message = CreateSimulateEvictionRequest(resourceGroupName, vmScaleSetName, instanceId);
 01294            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01295            switch (message.Response.Status)
 1296            {
 1297                case 204:
 01298                    return message.Response;
 1299                default:
 01300                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1301            }
 01302        }
 1303
 1304        /// <summary> The operation to simulate the eviction of spot virtual machine in a VM scale set. The eviction wil
 1305        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1306        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1307        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1308        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1309        public Response SimulateEviction(string resourceGroupName, string vmScaleSetName, string instanceId, Cancellatio
 1310        {
 01311            if (resourceGroupName == null)
 1312            {
 01313                throw new ArgumentNullException(nameof(resourceGroupName));
 1314            }
 01315            if (vmScaleSetName == null)
 1316            {
 01317                throw new ArgumentNullException(nameof(vmScaleSetName));
 1318            }
 01319            if (instanceId == null)
 1320            {
 01321                throw new ArgumentNullException(nameof(instanceId));
 1322            }
 1323
 01324            using var message = CreateSimulateEvictionRequest(resourceGroupName, vmScaleSetName, instanceId);
 01325            _pipeline.Send(message, cancellationToken);
 01326            switch (message.Response.Status)
 1327            {
 1328                case 204:
 01329                    return message.Response;
 1330                default:
 01331                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1332            }
 01333        }
 1334
 1335        internal HttpMessage CreateRunCommandRequest(string resourceGroupName, string vmScaleSetName, string instanceId,
 1336        {
 81337            var message = _pipeline.CreateMessage();
 81338            var request = message.Request;
 81339            request.Method = RequestMethod.Post;
 81340            var uri = new RawRequestUriBuilder();
 81341            uri.Reset(endpoint);
 81342            uri.AppendPath("/subscriptions/", false);
 81343            uri.AppendPath(subscriptionId, true);
 81344            uri.AppendPath("/resourceGroups/", false);
 81345            uri.AppendPath(resourceGroupName, true);
 81346            uri.AppendPath("/providers/Microsoft.Compute/virtualMachineScaleSets/", false);
 81347            uri.AppendPath(vmScaleSetName, true);
 81348            uri.AppendPath("/virtualmachines/", false);
 81349            uri.AppendPath(instanceId, true);
 81350            uri.AppendPath("/runCommand", false);
 81351            uri.AppendQuery("api-version", "2019-12-01", true);
 81352            request.Uri = uri;
 81353            request.Headers.Add("Content-Type", "application/json");
 81354            var content = new Utf8JsonRequestContent();
 81355            content.JsonWriter.WriteObjectValue(parameters);
 81356            request.Content = content;
 81357            return message;
 1358        }
 1359
 1360        /// <summary> Run command on a virtual machine in a VM scale set. </summary>
 1361        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1362        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1363        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1364        /// <param name="parameters"> Parameters supplied to the Run command operation. </param>
 1365        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1366        public async Task<Response> RunCommandAsync(string resourceGroupName, string vmScaleSetName, string instanceId, 
 1367        {
 21368            if (resourceGroupName == null)
 1369            {
 01370                throw new ArgumentNullException(nameof(resourceGroupName));
 1371            }
 21372            if (vmScaleSetName == null)
 1373            {
 01374                throw new ArgumentNullException(nameof(vmScaleSetName));
 1375            }
 21376            if (instanceId == null)
 1377            {
 01378                throw new ArgumentNullException(nameof(instanceId));
 1379            }
 21380            if (parameters == null)
 1381            {
 01382                throw new ArgumentNullException(nameof(parameters));
 1383            }
 1384
 21385            using var message = CreateRunCommandRequest(resourceGroupName, vmScaleSetName, instanceId, parameters);
 21386            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 21387            switch (message.Response.Status)
 1388            {
 1389                case 200:
 1390                case 202:
 21391                    return message.Response;
 1392                default:
 01393                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1394            }
 21395        }
 1396
 1397        /// <summary> Run command on a virtual machine in a VM scale set. </summary>
 1398        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1399        /// <param name="vmScaleSetName"> The name of the VM scale set. </param>
 1400        /// <param name="instanceId"> The instance ID of the virtual machine. </param>
 1401        /// <param name="parameters"> Parameters supplied to the Run command operation. </param>
 1402        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1403        public Response RunCommand(string resourceGroupName, string vmScaleSetName, string instanceId, RunCommandInput p
 1404        {
 21405            if (resourceGroupName == null)
 1406            {
 01407                throw new ArgumentNullException(nameof(resourceGroupName));
 1408            }
 21409            if (vmScaleSetName == null)
 1410            {
 01411                throw new ArgumentNullException(nameof(vmScaleSetName));
 1412            }
 21413            if (instanceId == null)
 1414            {
 01415                throw new ArgumentNullException(nameof(instanceId));
 1416            }
 21417            if (parameters == null)
 1418            {
 01419                throw new ArgumentNullException(nameof(parameters));
 1420            }
 1421
 21422            using var message = CreateRunCommandRequest(resourceGroupName, vmScaleSetName, instanceId, parameters);
 21423            _pipeline.Send(message, cancellationToken);
 21424            switch (message.Response.Status)
 1425            {
 1426                case 200:
 1427                case 202:
 21428                    return message.Response;
 1429                default:
 01430                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1431            }
 21432        }
 1433
 1434        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string virtualMachineS
 1435        {
 01436            var message = _pipeline.CreateMessage();
 01437            var request = message.Request;
 01438            request.Method = RequestMethod.Get;
 01439            var uri = new RawRequestUriBuilder();
 01440            uri.Reset(endpoint);
 01441            uri.AppendRawNextLink(nextLink, false);
 01442            request.Uri = uri;
 01443            return message;
 1444        }
 1445
 1446        /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary>
 1447        /// <param name="nextLink"> The URL to the next page of results. </param>
 1448        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1449        /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param>
 1450        /// <param name="filter"> The filter to apply to the operation. </param>
 1451        /// <param name="select"> The list parameters. </param>
 1452        /// <param name="expand"> The expand expression to apply to the operation. </param>
 1453        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1454        public async Task<Response<VirtualMachineScaleSetVMListResult>> ListNextPageAsync(string nextLink, string resour
 1455        {
 01456            if (nextLink == null)
 1457            {
 01458                throw new ArgumentNullException(nameof(nextLink));
 1459            }
 01460            if (resourceGroupName == null)
 1461            {
 01462                throw new ArgumentNullException(nameof(resourceGroupName));
 1463            }
 01464            if (virtualMachineScaleSetName == null)
 1465            {
 01466                throw new ArgumentNullException(nameof(virtualMachineScaleSetName));
 1467            }
 1468
 01469            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualMachineScaleSetName, filte
 01470            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 01471            switch (message.Response.Status)
 1472            {
 1473                case 200:
 1474                    {
 01475                        VirtualMachineScaleSetVMListResult value = default;
 01476                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 01477                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1478                        {
 01479                            value = null;
 1480                        }
 1481                        else
 1482                        {
 01483                            value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc
 1484                        }
 01485                        return Response.FromValue(value, message.Response);
 1486                    }
 1487                default:
 01488                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 1489            }
 01490        }
 1491
 1492        /// <summary> Gets a list of all virtual machines in a VM scale sets. </summary>
 1493        /// <param name="nextLink"> The URL to the next page of results. </param>
 1494        /// <param name="resourceGroupName"> The name of the resource group. </param>
 1495        /// <param name="virtualMachineScaleSetName"> The name of the VM scale set. </param>
 1496        /// <param name="filter"> The filter to apply to the operation. </param>
 1497        /// <param name="select"> The list parameters. </param>
 1498        /// <param name="expand"> The expand expression to apply to the operation. </param>
 1499        /// <param name="cancellationToken"> The cancellation token to use. </param>
 1500        public Response<VirtualMachineScaleSetVMListResult> ListNextPage(string nextLink, string resourceGroupName, stri
 1501        {
 01502            if (nextLink == null)
 1503            {
 01504                throw new ArgumentNullException(nameof(nextLink));
 1505            }
 01506            if (resourceGroupName == null)
 1507            {
 01508                throw new ArgumentNullException(nameof(resourceGroupName));
 1509            }
 01510            if (virtualMachineScaleSetName == null)
 1511            {
 01512                throw new ArgumentNullException(nameof(virtualMachineScaleSetName));
 1513            }
 1514
 01515            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualMachineScaleSetName, filte
 01516            _pipeline.Send(message, cancellationToken);
 01517            switch (message.Response.Status)
 1518            {
 1519                case 200:
 1520                    {
 01521                        VirtualMachineScaleSetVMListResult value = default;
 01522                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01523                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1524                        {
 01525                            value = null;
 1526                        }
 1527                        else
 1528                        {
 01529                            value = VirtualMachineScaleSetVMListResult.DeserializeVirtualMachineScaleSetVMListResult(doc
 1530                        }
 01531                        return Response.FromValue(value, message.Response);
 1532                    }
 1533                default:
 01534                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1535            }
 01536        }
 1537    }
 1538}